Object To Relation Mapping
Data Structure Owner String name; String taxId; Account[] accounts; Account – is abstract String id; double balance; InterestBearingAccount extends Account double rate; int termDays; CheckingAccount extends Account double checkFee
1:1 and 1:many Mappings in the Data Model Owner – name : one to many Owner – taxId : one to one Owner – Account : one to many Account – id : one to one IntBearAcct – rate : ??? IntBearAcct – termDays: ??? intBearAcct – minBal : ??? CheckingAcct – checkFee: ???
Horizontal Partitioning Each concrete class is mapped to a table Owner String name; String taxId; Account[] accounts; Account – is abstract String id; double balance; InterestBearingAccount extends Account double rate; int termDays; CheckingAccount extends Account double checkFee
Vertical Partitioning Each class is mapped to a table Owner String name; String taxId; Account[] accounts; Account – is abstract String id; double balance; InterestBearingAccount extends Account double rate; int termDays; CheckingAccount extends Account double checkFee
Unification Each sub-class is mapped to the same table Owner String name; String taxId; Account[] accounts; Account – is abstract String id; double balance; InterestBearingAccount extends Account double rate; int termDays; CheckingAccount extends Account double checkFee
Chalk Board Exercise Assume that not only can an Owner have many Accounts, but an Account can have many Owners How does this change the data model? How Does It change database design?