Every Mapping Class Comes Out Many-to-One
Working through ShowSeat's actual cardinality with both Show and Seat, confirming the mapping-class rule from before, then running the same test on ShowSeatType.
Work out one side of a mapping class, and the other side follows the same pattern. Here's that worked out for real.
ShowSeat to Show: Many Rows, One Show
ShowSeat holds a single Show, not a list. That alone settles one direction: one ShowSeat object relates to exactly one Show.
The reverse direction is the interesting one. For one show, how many ShowSeat objects exist? Every seat in that show's auditorium needs its own row, so one show shows up inside many different ShowSeat objects, one per seat.
That makes ShowSeat to Show many-to-one: many show-seat rows, pointing at one show.
ShowSeat to Seat: The Same Shape, a Different Reason
Run the same question on Seat. One ShowSeat object holds a single Seat, so again, one direction is settled immediately: one ShowSeat relates to exactly one Seat.
For the reverse, picture one physical seat, seat 121. That same seat shows up in the morning show, the afternoon show, the evening show, and every other show ever scheduled in that auditorium. One seat ends up inside many ShowSeat objects, one per show it's ever been part of.
So ShowSeat to Seat comes out many-to-one too, the exact same shape as ShowSeat to Show. This confirms the rule from before: for a mapping class, the cardinality with every entity it connects comes out the same.
The Same Test, Run on ShowSeatType
Apply the identical reasoning to ShowSeatType, the mapping class holding price for a Show and a SeatType. One ShowSeatType object holds a single Show, so one direction is settled the same way as before: one ShowSeatType object relates to exactly one show.
The Trap: Assuming One Show Means One ShowSeatType Object
The reverse question is where it's easy to go wrong. For one show, how many ShowSeatType objects exist? The tempting first answer is one, and it's wrong.
ShowSeatType exists to hold the price for one specific show, one specific seat type. A single show doesn't have one price, it has one price per seat type. The same show shows up inside a separate ShowSeatType object for every seat type it prices: one row for VIP at ₹100, one for Gold at ₹50, one for Silver at ₹25, and so on.
That's the same show appearing inside several different ShowSeatType objects at once. ShowSeatType to Show is many-to-one: many rows, one show, exactly the same shape ShowSeat came out as.
And ShowSeatType to SeatType Follows the Same Rule
One ShowSeatType object holds exactly one SeatType, VIP or Gold, never both at once. That settles one direction: one-to-one from that single object's point of view.
But a seat type like VIP isn't unique to one show. It shows up again in every other show's own pricing, each one getting its own ShowSeatType row. ShowSeatType to SeatType is many-to-one too — the same rule holding for the third time in a row.
Keep reading