In conclusion @Renan:
Composite keys are a very normal part of database design but not in
any way supported or very compatible with CakePHP.

Either you have to access that data via your own queris (no find and
save), not use the core Schema Shell to dump the schema ,and a bunch
of other things you loose.

Or, as suggested, you complicate your schema a tiny bit by adding an
extra id field and get to use all the cake stuff.


Just my 2¢
I have only once found it preferable to stick to a multi-key (or zero-
key in that case) table. That table is a WORM table for reporting data
containing only a single data field and about 10 foreign keys. Since
the object is to pull stats you will never ever "find" a single
record. You will group on the various keys in different combinations
to get graph data. Cake can be forgiven for not supporting that kind
of table.

Personally I think the classic HABTM joining table would haven been
more worthy of support, seeing as there are so many of them in any
given app. But I feel the topic has been discussed to death before. I
don't want to start another discussion about database-religion.

/Martin


On Apr 18, 12:07 pm, Jeremy Burns <jeremybu...@me.com> wrote:
> And Cake will just 'deal with it', without you having to do any work.
>
> Jeremy Burns
> jeremybu...@me.com
>
> On 18 Apr 2010, at 11:04, j0n4s.h4rtm...@googlemail.com wrote:
>
>
>
>
>
> > Hello,
>
> > for instance you could have Post, Tag, PostTag, Post HABTM Tag / Post
> > HasMany PostTag, Tag HasMany PostTag.
> > why this example? because it shows the most common place where you
> > would - outside of Active Record - use a combined primary key -
> > PostTag would have PrimaryKey(post_id, tag_id) - but as Jeremy Burns
> > pointed out: besides the very tiny data overhead, what is the issue
> > with one additional field as a primary and setting Unique(post_id,
> > tag_id)?
>
> > On Apr 17, 12:50 am, Jeremy Burns <jeremybu...@me.com> wrote:
> >> I absolutely endorse a single, incremental, non-intelligent primary key, 
> >> enriched with multi-field unique indexes and the adoption of convention. 
> >> Why make life any more difficult than it is already?
>
> >> Jeremy Burns
> >> jeremybu...@me.com
>
> >> On 16 Apr 2010, at 21:29, Renan Augusto wrote:
>
> >>> Dear,
>
> >>> Someone must have encountered a situation where a table had
> >>> with composite key.
> >>> what did you do? Since CakePHP recognizes only one field to
> >>> primaryKey!
>
> >>> In my opinion I see two possibilities:
>
> >>> 1 - not create tables with composite keys. When you need to use
> >>> composite keys to identify a record, create one more field with the
> >>> name ID and put it as primary key.
>
> >>> 2 - forget standardization. Choose one of the fields to put in
> >>> $ primaryKey attribute of the model and when you need to make a
> >>> relationship (or hasMany belongsTo), use to specify the conditions
> >>> other fields that make up the key of the table.
>
> >>> That's my opinion, please tell her!
>
> >>> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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 
> >>> athttp://groups.google.com/group/cake-php?hl=en
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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 
> >> athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
> > athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
> athttp://groups.google.com/group/cake-php?hl=en

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