File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Mapping of E/R Diagram to Tables

Anil Kumar
Ranch Hand

Joined: Nov 16, 2008
Posts: 38

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.

Regards,
Anil
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

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: 38

Thanks for clearing my doubt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mapping of E/R Diagram to Tables