So I'm working on my app and I am about to add a photo gallery and video gallery. I would like to keep the photos and videos seperate, but both will be using an Album to which I can add either videos, or photos. So, I will have 3 tables:
Albums
Photos
Videos
I would just like to know is, how you YOU solve this "issue"? Personally I was thinking about a polymorphic relation first, but it would be some kind of reversed relation or something, so I dropped that idea. What I am currently thinking is, I create two pivot tables, album_photo and album_video, and add photos or videos to an album that way. Like that I can also use a photo or video in multiple albums. And in the Albums table I can specify wether or not it's a photo or video album.
I would just make a polymorphic relation. It will also let you store the same photo/video in multiple albums. Perhaps the table should be called album_items.
Then give the table the entries
id - item_type - item_id - album_id - whatever you need - created_at - updated_at
Ah yes, so I was on the right track with the polymorphic relation, but I didn't think of it like that yet. Good solution, Ill see if that works for me too, thanks :)
Edit: Easy as pie, works like a charm, thanks again :)