One to Many with multiple tables on One side and one table on Many side
626589Dec 4 2009 — edited Dec 9 2009Sorry for the confusion in the title. Here is my question. In my program, I have 2 different tables which store 2 different type of entities. Each one of entities has a list of attachments which I stored in a common attachment table. There is a one-to-many relationship between entity tables and attachment table.
ENTITY_ONE (
ID
NAME
)
ENTITY_TWO (
ID
NAME
)
ATTACHMENTS (
ID
ENTITY_ID
ATTACHMENT_NAME
)
ENTITY_ID in ATTACHMENTS table is used to link attachments to either entity one or entity two. All IDs are generated by one sequence. So they are always unique. My question is how I could map this relationship into EntityOne, EntityTwo and Attachment JAVA class?