Chapter 5. Many-to-One and One-to-One Mapping
In general, entities are related or associated to each other. For example, a Customer
is associated with an Address
. A Customer
can have one or more than one Address
(for example, Billing
and Shipping
). These relationships or associations are represented differently in a relational model and the domain/object model.
In a relational model, a foreign key column represents the dependency of one table on another. The Customer
table has an AddressId
as the foreign key column, which is the primary key of the Address
table.
From the Customer
perspective, because a Customer
can have multiple addresses, so it's a many-to-one relationship. On the other hand, from the Address
perspective, one address can belong ...
Get Hibernate Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.