Let's say I have four completely independent models (Movie
, Book
, Game
, Album
) that control the types of things I have in my media collection. With them I can CRUD and tag individual albums, movies etc.
But I need to keep track, and do some stuff that is common to, all of them. So I figured I need an Item
model that would give me a table item
like this:
| id | item_id | item_type | status | possession | +----+---------+-----------+--------+------------+ | 01 | 01 | 1 | 3 | 2 |
Where the status
and possession
bit would let me keep track of whether the item is new or used, with me or lent (to whom, in another table), etc, and the table itself would let me know how many items I have in total. All without touching the original four models and their objects, that I think should only have information about what they are, not what I can do to them. EDIT: Note that every time a movie or book is added, it also must update the items
table with its related information.
I'm a newbie and I had some ideas on how to go about it, but none proved successful. I know it's a lot to ask but I would like to know, how can I accomplish this?
Any help will be appreciated, thanks.