Home

 

Relationships

Before starting our discussion of entity relationships, it is useful to refresh how the concept of relationships is defined in object-oriented and in relational database worlds (Table | 2-1).

Table 12-1

Java/JPA RDBMS
A relationship is a reference from one object to another. Relationships are defined through object references (pointers) from a source object to the target object. Relationships are defined through foreign keys.
If a relationship involves a collection of other objects, a collection or array type is used to hold the contents of the relationship. Collections are either defined by the target objects have a foreign key back to the source object's primary key, or by having an intermediate join table to store the relationships.
Relationships are always unidirectional, in that if a source object references a target object, it is not guaranteed that the target object also has a relationship to the source object. Relationships are defined through foreign keys and queries, such that the inverse query always exists.

Relationship concept in two different worlds

JPA defines the following relationships: one-to-one, many-to-one, one-to-many, and many-to-many.

ibm.com/redbooks