Data integrity preserves correctness and consistency across object relationships and relational schemas. In a bidirectional Item–Bid association, both object references must agree; in an inheritance mapping, table design affects constraints, normalization, and schema evolution. section 3.2.4 section 7.9
Maintain association integrity explicitly:
- Add the Bid to the Item’s collection and set the Bid’s item property. section 3.2.4
- Use a convenience method or constructor to perform both updates and reject null or already-assigned bids. section 3.2.4
- Store bid amount and creation time rather than display order; sort when querying or presenting data. section 3.2.4
Keeping both sides consistent
public void addBid(Bid bid) { if (bid == null) throw new NullPointerException("Can't add null Bid"); if (bid.getItem() != null) throw new IllegalStateException("Bid is already assigned to an Item"); bids.add(bid); bid.setItem(this); } section 3.2.4
Inheritance mapping introduces a different integrity tradeoff. A single table simplifies queries and performs well but requires nullable columns and can violate third normal form. Joined subclass tables normalize the schema and simplify integrity constraints, at the cost of more complex implementation and potentially slower queries. section 7.9
Inspect the Item–Bid association diagram to see the two references that must remain synchronized. section 3.2.4

















