Saturday, January 28, 2012

Re: database concentions cake bake all

I am quite new to cakePHP as well, so, if I make mistakes here, please correct me.

According to my experience,
First, the quote from the cake book, the habtm naming convention would be:

"Join tables, used in hasAndBelongsToMany (HABTM) relationships between models should be named after the model tables they will join in alphabetical order (apples_zebras rather than zebras_apples)."

means, you would want to have table name to be 

groups_users

and it will contain only three fields:

id, group_id, user_id

that way, when you bake all, hope you have configured your bake all configuration to suite your needs, the cake will create proper codes for you.

And you will want to make sure to follow proper naming convention for Foreign Keys as well.  If all of these names are properly followed, then cake will create absolutely stunningly beautiful codes for you.

and then, you could have user_groups and have user_group_id inside of that table.

But, if you are planning on using ACL, then you should make groups table independently and let the cake handle all the acl portion for you.

For example, the site I am currently working on contains tables below:
  • users
  • groups
  • organizations
  • organizations_users (habtm)
Try not to include roles to the database yet if you are not ready.

If you are using mysql, perhaps using mysql workbench to analyze your table relations would be very helpful.

-- Richard

On Fri, Jan 27, 2012 at 2:57 AM, Dennis <drf77@gmx.net> wrote:
hi,

i am thinking that i misunderstood the cake conventions. i created a
database with about 40 tables. every time i try to use cake bake all i
get the error message, that some tables are missing.

For example
Table users (FK here is user_group_id)
Table user_groups

cake bake all tell me that table users_groups ist missing. I dont want
to have a hbtm table construct here.

For my understanding: If i use users_groups instead, do i have to set
the FK as users_group_id or user_group_id?


Thanks in advance


Dennis

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php



--
Richard Joo
Director of Innovation
Telelanguage, Inc.


Support Options:
Email your problem or question to tickets@telelanguage.com
Submit a ticket to http://ticket.telelanguage.com 
Call 1.888.983.5352 and press 3

For best support please submit a ticket using the email or website method first and write down your ticket ID.  You can track the progress of the ticket by using the ticket website.   

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: