> I'm just getting started with CakePHP and would like to know if it can
> handle compound keys in a database.
> For example, if you were to add tags to a blog, the schema would
> roughly be
> table: article(article_id, article_text, PRIMARY_KEY(article_id));
> table: tag (tag_id, tag_word, PRIMARY_KEY(tag_id));
>
> Now if you want to associate tags with an article, there would be
> another table:
> article_tag(article_id, tag_id, PRIMARY_KEY(article_id, tag_id));
>
> This seems like valid database design to me (feel free to argue or
> present an alternative).  Since I haven't worked with CakePHP yet, I'll
> ask: "Would CakePHP be able to work with this type of schema?"
> And is it pretty straight forward?

umm, as no one seems to have read the question properly, I'll answer...

no, you can not use 'compound keys' in cakephp, cake expects each
record to have it's own unique id, so you're schema would look more
like:

article_tag(id, article_id, tag_id, PRIMARY_KEY(id));

Also, Cake expects the primary key of all tables to be 'id', not
prefixed by the table name. This helps with the 'convention over
configuration', though you can bypass it. This means your tables
should look more like this:

table: article(id, text, PRIMARY_KEY(id));
table: tag (id, word, PRIMARY_KEY(id));

other than that, the other posts are right on ;)

hth

jb

-- 


jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to