Hi,

Please excuse the long post... I tried to give a concise question, but
also I felt the need to give an example and explain...

I need to store a history of database changes (i.e. copies of all of
the fields [with their same ids] grouped by a publish date), and I'm
having trouble designing the database to work with cake.

Here are some tables:

areas
shifts
people
people_shifts

Area hasMany Shift,
Shift HABTM People.

So, each area has shifts, and then people are scheduled for those
shifts. The user who is making changes would be working on a staging
copy and would then "publish" the changes, giving that set of data a
new publish_id). In my mind, every table would have a foreign key to
the publishes table, and when the whole thing is "published" all of
the data would be put in there with a new publish_id. In effect, it is
like copying the whole database inside of itself using a reference
table for each set of data.

This would work, but I want to be able to track shifts/areas/people
back through time so they need a consistent id. If I wasn't using
cake, I'd use a composite key (publish_id, id)
I know cake does not ever plan to support composite keys and I totally
understand why. This leaves me with the question of how to implement
this in cake?

If I just give every table an extra id for cake then there's my unique
key, but then how will I keep the model relationships? I want to be
able to say, for example:

we are on publish #42
    area #1 has shifts #1 and #2 and
    person #1 is doing shift #1 etc...
then...
let's look at publish #43
    area #1 has shifts #1 and #2, plus a new shift #3
    person #1 is now doing shift #3

If I let cake use an id that is unique, then how can I keep the
relationships between models intact?

Thanks so much for your support,
Jason

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 [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?hl=en

Reply via email to