问题
I'm really trying to understand CakePHP's naming conventions and the following isn't entirely intuitive to me.
Let's say I have two pieces of information:
videos - specific information about video
category - list of categories with id, title, description
How would I structure my tables? My first instinct is:
videos
categories
video_categories
Is this right?
回答1:
It should be:
videos
categories
categories_videos
(plural model names in alphabetical order for HABTM)
If your videos can only belong to one category, forgo the categories_videos
table and just put a category_id
field into the videos
table.
http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html#model-and-database-conventions
来源:https://stackoverflow.com/questions/6327249/cakephp-table-naming-convention