    ------------- 1    * -------------- *       1 --------    | Container |--------| Assignment |-----------| User |    -------------        --------------           --------          ^                     ^          |                     |      ----------            -------------      |        |            |           |---------- ----------  ---------- ---------------| Flight | | Dinner |  | Booking| | Reservation |---------- ----------  ---------- ---------------This problem is one that I've stumbled upon in several different occasions but never found an elegant solution for:In my system model (in rails), which maps to the database, I need to have Users that can be added to Containers through Assignments.Now, there can be many things that can be containers:A Flight is a Container. It can hold Users. In such a case the concrete Assignment is a Booking.A Dinner is a Container. It can hold Users. In such a case the concrete Assignment is a Reservation.And many more. You get my point.So I have Abstract notions of Container and Assignment. Containers hold Assignments and I also have concrete implementations of them, with each concrete implementation of Container matching a concrete implementation of Assignment. The straight forward design is as above. My main problem with it is that it doesn't express the relation between each concrete container and the concrete assignment.Any ideas how to better design this?
What is a good design for a container, assignment and items
design;design patterns;database design;ruby on rails;orm