Welcome Guest, Not a member yet? Register   Sign In
Proper relationship definition
#1

[eluser]Mirage[/eluser]
Alright - my head hurts. Someone help me figure out how to set this up.

I have 3 tables: plants, images and plant_images

- One plant can have many (0-n) images
- Each image though, really ever has one plant

The images table is generic. It's not only bound to plants. It just hold information about the image resources and has images that have nothing to do with plants at all. So I guess plant_images is not really a n:n relationship but really 1:n relationship to plants. But it's also a 1:1 relation ship with images (if one exists).

I need some suggestion on how to set up the models for this and how to maintain the records in the plant_images table as it should change when I add/remove plants as well when I add/remove images (for a plant).

Any help would be much, much appreciated.

Regards,
m
#2

[eluser]Mirage[/eluser]
Sorry all - this was supposed to go to the DMZ thread. I'll repost there. Please ignore.




Theme © iAndrew 2016 - Forum software by © MyBB