Mapping From The Object-Oriented Model (UML) To The Relation Model

Classes and Attributes

1 A class C is implemented as a relation RC. Include all single-valued attributes of C as attributes of RC.

2. Select one of the candidate keys (usually the primary key) of C as the primary key of RC. If C has no candidate key, create a surrogate key for RC.

3. For each multi-valued attribute A of the class C, create a relation RCA containing the attribute A and the primary key of the relation RC (which implements C). The primary key of RCA is all-key.

Associations and attributes

4. A many-to-many binary association is implemented as a distinct relation. Include the primary keys of both relations involved in the association as foreign keys of the new relation. If the association has only single-valued attributes, then the attributes are included in the relation implementing the association. If the association contains multi-valued attributes, the association must be implemented as an association class and rule (3) applies.

5. For a one-to-many association between two classes C1 (one) and Cm (many), include the primary key of RC1 (which implements C1) as a foreign key of the relation RCm (which implements Cm).

If the association has only single-valued attributes, then the attributes are included in RCm. If the association contains multi-valued attributes, the association must be implemented as an association class and rule (3) applies.

6. For an one-to-one association involving the relations S and T:

(a) Include the primary key of S as a foreign key in T, or

(b) Include the primary key of T as a foreign key in S, or

(c) merge the relations S and T into one.

7. For each n-ary association (n>2), create a relation. Include the primary keys of all participating relations as foreign keys of the new relation. Treat attributes of the associations as in rule (4).