Monday, August 6, 2012

Re: Why is composite primary key bad?

A generalised statement: composite primary keys are bad. Each table should have a single field primary key that uniquely identifies 'this row'. If the table holds information that represents the intersection of two (or more) other tables, add them as additional fields with indexes on each with a foreign key constraint to its related table (you need to use InnoDB for this to be possible), then add a unique index that spans the fields that make up the composite key. Beside any good database driven reason why you should avoid composite primary keys, sticking to the Cake conventions makes your life so much easier, so given the opportunity to design the database with that in mind you ought to do so.


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 7 Aug 2012, at 01:40:43, Lightee <lightaiyee@gmail.com> wrote:

I notice that CakePHP does not allow composite primary key. Why is this so? Is it because composite primary keys are bad for some reason or is it simply to stick to convention? I have been using MS Access and there is no such restriction.

--
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate