• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why or (when to) use Entity Relationship ?

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,
If tables in a db already have a relationship among them, then what is the advantage of using Entity Relationship. I am having a hard time understanding when to use this functionality. I appreciate if someone could shed some lights on this.
Thanks & Regards,
Pinal.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Entity relationships are the object equivalents of the table relationship. They allow you to traverse the relationships between the tables as object links.
So, if you have a PERSON_TABLE that contains foreign keys to an ADDRESS_TABLE you need to be able to figure out which Person EJB corresponds to which Address EJB. That's what entity relationships give you.
They allow you to say myPerson.getAddress() and get back the right Address Entity bean corresponding to the right person.
Kyle
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kyle Brown:
They allow you to say myPerson.getAddress() and get back the right Address Entity bean corresponding to the right person.


Additionally they allow you to write EJB-QL queries that navigate between objects as you would perform a SQL join without loading the intervening beans. For example, if Kyle's ADDRESS_TABLE had a relationship to a COUNTRY_TABLE, you could find all PERSONs for a particular country without dealing with ADDRESSes at all:

This would generate and execute SQL like (assuming 1:N from Person to Address)
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In enterprise solution entity EJB represents Database Data.Database data consists of multiple tables with relations.. Now if u want to modify those data in the database through ur enterprise application; we need the same relationship betn diff Entity EJB in JVM. So that any change of the object in the JVM can reflect in the Database.
[ December 09, 2003: Message edited by: Bish Ach ]
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic