beautypg.com

Figure 3-2 – Apple WebObjects 5 User Manual

Page 30

background image

30

Mapping Your Enterprise Objects to Database Tables

Apple Computer, Inc. January 2002

C H A P T E R 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.

1132

Feldman

Corey

1028

Farina

Dennis

TALENT_ID

LAST_NAME

FIRST_NA

ME

TALENT

Talent

lastName "Farina"

firstName "Dennis"