permaculture playing cards*
The moose likes JDBC and the fly likes Mapping of E/R Diagram to Tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Mapping of E/R Diagram to Tables" Watch "Mapping of E/R Diagram to Tables" New topic

Mapping of E/R Diagram to Tables

Anil Kumar
Ranch Hand

Joined: Nov 16, 2008
Posts: 34

Hello Ranchers,

While mapping one to many relation ship between entities to tables , each of the entities gets mapped to separate table. The tables are linked to each other with the help of referential foreign key constraint. This is the normal approach one follows.

My doubt is , Is it recommended to map both the entities to a single table ?. Kindly let me know the correct approach.

Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064

Each entity would map to one table. So in case of one-many mapping the entity having the many property would have a key to identify a unique row in the other entity.

Both the entities mapped to same table would be- repetition of the data which was supposed to be appearing once, but appears many times due to its relation with the other entity. This is usually a wrong approach. Moreover you are combining two different things which can lead to a unnecessarily coupled tables.

Mohamed Sanaulla | My Blog
Anil Kumar
Ranch Hand

Joined: Nov 16, 2008
Posts: 34

Thanks for clearing my doubt
I agree. Here's the link:
subject: Mapping of E/R Diagram to Tables
Similar Threads
many-to-many mapping - Hibernate mapping files ?
EJB 3: JPA versus Beginning EJB 3 App Dev
Inheritance/one table for each class
JPA - vendor specific implementation
Multiple tables or single table