On Wed, Oct 27, 2010 at 8:07 AM, Dan <dannyetdi...@gmail.com> wrote:
> Structure:
>
> Projects
> - project_id
> - project_name
>
> Contacts
> - contact_id
> - contact_name
>
> Contacts_Projects
> - project_id
> - contact_id
>
> When reading the Cookbook, in a HABTM setting, I should add an ID
> field to the Contacts_Projects table.

That's not a requirement. But, if you find that you need to store
extra information in the join table, it's recommended that you then
add a primary key.

> Wouldn't this field enable the
> possibility of having duplicates?

UNIQUE(project_id, contact_id);

This creates an index. That's why a PK isn't absolutely necessary.


> Or does the ID field only act as auto number, but the key is still
> composed of project_id/contact_id?

Sort of. The id column becomes the PK and you'd then have two indexes
on the table. If you do add a PK, you should keep the unique index as
that's what Cake will be using. However, Cake doesn't ever use
multi-column PKs..

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to