You have a couple options here. What's "proper" is really what works
best in your situation, so do some testing to see how the queries
perform. I had a similar situation so I'll explain what I did.

Video
- id

Episode
- video_id
- name
- date

Movie
- video_id
- name
- date
- producer

Image
- id
- name
- caption
- path
- video_id

Video hasMany Episode
Video hasMany Movie
Episode hasMany Image
Movie hasMany Image

In this design Video is the parent of Episode and Movie and generates
unique ids for them. These ids can then be added to any tables
associated to Episode or Movie. On top of that you can setup foreign
keys in MySQL so that when you delete a Video to cascades and deletes
all related data.

On Mar 31, 1:09 am, Adam M <[email protected]> wrote:
> Hi All,
>
> How can I PROPERLY set up my database so that several models have
> multiple images?  Each image belongs to a particular model, so they
> are definitely hasMany relationships.  Example:
>
> Episode
> -id
> -name
> -date
>
> Movie
> -id
> -name
> -date
> -producer
>
> Image
> -id
> -name
> -caption
> -path
>
> Episode hasMany Image
> Movie hasMany Image
>
> Does the paradigm of adding a foreign key to the Image table still
> apply if I have multiple hasMany relationships?  That is, would I add
> multiple foreign keys to the table as follows?:
> Image
> -id
> -movie_id
> -episode_id
> -name
> -caption
> -path
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
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