Hi list!

I'm in the process of modeling my entities and before I proceed, there's something I must know:

* Should all PK of all the tables be id? If not, how can I create and association with a table that has two columns as PK?

Let me explain it better...

Ex.:

I have a pictures table

Pictures:

album_id (PK/FK)
filename (PK)
clicks
votes

album_id | filename
   20          DSC0001
   20          DSC0002
   21          DSC0001
   21          DSC0002

As you can see, I've made both album_id and filename to be the PK of this table. What I would like to know is how could I possibly is against Cake convetions / best practices.


It's really just an experiment. Actually I don't think it would be the best way as I would need both columns as FK's on a table that belongsTo pictures.

Ex.:

Comments:

comment_id
album_id -> part of Pictures FK
filename -> part of Pictures FK



And it woudn't make much sense at all...

-> The rationale here  is that when records of a given table have the property of having a field that would not duplicate, for example a name or if I can make a unique PK with two fields (like in the Pictures example, where the two columns create the unique PK) it would be better than actually creating a new picture_id column.

The album has the "album_id" PK becouse I can have two albuns with the same name, otherwise I would probally make the "album_name" column to be the PK.


What do you think?

Thanks in advance,

Marcelo.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [email protected]
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