CakePHP - table naming convention

你。 提交于 2019-12-24 04:39:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!