An association connects two model elements and permits navigation between them. In Java, object references express the relationship; in a relational database, foreign-key columns store copied key values and enforce referential integrity. section 1.2.4
Model an association by making its navigation, multiplicity, and lifecycle semantics explicit:
- Direction matters in the object model: bidirectional navigation requires a reference or collection on both associated classes. section 1.2.4
- Multiplicity distinguishes many-to-one, one-to-many, and many-to-many relationships; relational many-to-many mappings generally require a link table. section 1.2.4 section 8.3
- Lifecycle semantics separate independent entity associations from aggregation or composition, where the part may depend on the whole. section 6.2 section 8.3
User and BillingDetails
A Java model can expose User.billingDetails as a Set<BillingDetails> and BillingDetails.user as a back-reference. A relational schema can represent the same relationship with BILLINGDETAILS.USERNAME referencing USERS.USERNAME. If the relationship becomes many-to-many, introduce USER_BILLINGDETAILS with a composite primary key and two foreign keys. section 1.2 section 1.2.4
Use the one-to-many diagram to compare the navigable Java relationship with its associated domain elements. section 1.2.4
