Chapter 8 O/R Mapping Modeling


Defining primary identifier mapping

Columns of primary keys should be mapped to persistent attributes. Like primary keys for tables, you need to set these persistent attributes as primary identifiers of entity classes. The mapped primary keys should be primary keys of primary tables.

There are three types of primary identifier mapping:

Primary identifier mapping is mandatory for entity classes.

Steps To define simple primary identifier mapping:

  1. Set one persistent attribute as primary identifier.
  2. Define attribute mapping for the attribute.

Steps To define composite primary identifier mapping:

  1. Set multiple persistent attributes as primary identifier.
  2. Define attribute mapping for each of these attributes.

Column(s) of primary keys can be mapped to association. They are migrated from primary keys of other tables.

For more information, see the One-to-many association transformation section.

Steps To define component primary identifier mapping:

  1. Define one persistent attribute as primary identifier.
  2. Define the type as Value type class.
  3. Define attribute mappings for the Value type class.

Attributes of value type classes are mapped to columns, which are embedded in primary tables mapped by other entity classes. So you have to add primary tables of the containing classes as value type classes' mapping sources. If the value type class is used in more than one entity class, you should map each of its persistent attributes to multiple columns of tables of these classes.

For example, Value type class Address is used as attribute type for two classes, Product and Customer .


The attributes of the Value type class Address can be mapped to columns of two tables, Company table and Customer table.


The mapping is easier to visualize in the Mapping Editor.


 


Copyright (C) 2006. Sybase Inc. All rights reserved.