Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP - table naming convention

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?

like image 586
David Ryder Avatar asked Feb 05 '26 08:02

David Ryder


1 Answers

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

like image 101
deceze Avatar answered Feb 07 '26 21:02

deceze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!