
30 Mapping Your Enterprise Objects to Database Tables
Apple Computer, Inc. January 2002
CHAPTER 3
Enterprise Objects
Figure 3-2 Mapping between an enterprise object class and a single table
In actual practice, the mapping is more flexible than this. For example:
■ You can map an entity to a single table, a subset of a table, or to more than one
table. For instance, you can map a Person entity’s firstName and lastName
attributes to a PERSON table but its streetAddress, city, state and zipCode
attributes to an ADDRESS table.
■ Generally, an attribute is mapped to a single column, but the
column-to-attribute correspondence is similarly flexible. You can map an
attribute to a derived column, such as price * discount or salary * 12.
■ You can map an entity to one or more tables.
In addition to mapping tables to entities and columns to attributes, WebObjects
maps primary and foreign key columns to relationships between objects.
WebObjects defines two types of relationships—to-ones and to-manys—which are
both illustrated in Figure 3-3. The relationship a MovieRole has to its Movie is a
to-one relationship, while the relationship a Movie has to its MovieRoles is a
to-many.
1
1
3
2
F
e
l
d
m
a
n
C
o
r
e
y
1
0
2
8
F
a
r
i
n
a
D
e
n
n
i
s
T
A
L
E
N
T
_
I
D
L
A
S
T
_
N
A
M
E
F
I
R
S
T
_
N
A
M
E
T
A
L
E
N
T
Talent
lastName "Farina"
firstName "Dennis"
Comentarios a estos manuales