@John: I gave the model relationships in the first post. The database
is already designed (it is really an existing app that I want to
rebuild in cake). In my mind I want something that will work
regardless of the table relationships.

@LunarDraco: I have looked a lot at the revision behavior. I keep
going back to it just to be sure, but it seems like it's not quite
what I am trying to do. If all of the old data can be kept in a shadow
table, then why not put it all in one place and not use a shadow
table? I think it's because the shadow table cannot be accessed in the
normal way.

What I really want is all of the data in one place so that the user
could choose any publish date and access the data (with the foreign
key to the publishes tabe) as if it was the only data there.

If I have to put the foreign key to the publishes table in my
conditions, then I have to put that in for every related model too. It
feels like I'd be bypassing to much of the beauty of what cake offers.

Other ideas?

Jason

On May 19, 9:39 am, LunarDraco <[email protected]> wrote:
> You may gleam some insight on how this could be done from the Revision
> Behavior. I'm not sure the behavior will give you exactly what you
> need, but it may at least give you some ideas of how to implement what
> you need.
>
> http://bakery.cakephp.org/articles/view/revision-behavior-revision-co...
>
> On May 18, 12:16 pm, shantamg <[email protected]> wrote:
>
>
>
>
>
> > 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 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 [email protected]
> > To unsubscribe from this group, send email to
> > [email protected] 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected] 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 [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