In Database, I have a customer entity and a event entity. There is a MANY-TO-MANY relation between them called reserve.
reserve has three columns, CUSTOMER_ID, EVENT_ID and SEAT.
The first two columns are primary keys of each entity. The third one is a relational attribute that’s set specifically for the relation, so it is ONLY in the relation table.
What I am struggling is should I create a separate class for the reserve or should I do some trick in the two existing two classes to make this third one exist?
Thanks.
A many-to-many relation table must have only two attributes: the two primary keys of the tables that should be linked. In your case, since you store another attribute within that relation table, it’s not a pure relation table and you have to create a extra POJO for it. As far as I know.