Datasheet

14
Chapter 1
cost int,
accounts int
);
create table account_security (
ID int not null primary key auto_increment,
account_id int,
security_id int,
);
Figure 1.7
For every relationship between an account and a security, there will be a unique row in the
account_security association table. If we have an account ID, we can query the account_
security table to find all the securities associated with the account. We can also go the other direction
and use a security ID to query for all the accounts using that security.
Summary
When you’re writing applications using the object-oriented methodology, real-world information is
stored in classes where the information can be encapsulated and controlled. At some point during the
execution of the application, the information in each of the objects will need to be persisted. The goal of
this chapter has been to provide you with an overview of the issues and techniques involved in object
mapping from the application to permanent storage. By far the most popular technique is mapping a
class to one or more database tables. We’ve covered many of the issues involved in object/relational
mapping; now we’ll push forward and discuss Hibernate as a tool for providing the necessary mapping.
security
ID : int
name : String
cost : int
accounts : ArrayList
account
ID : int
type : int
opendate : date
owner : Owner
addresses : ArrayList
securities : ArrayList
03_576771_c01.qxd 9/1/04 12:09 PM Page 14