You are on page 1of 6

academy.oracle.

com

Database Design
9-4: Subtype Mapping Practice
Activities
Objectives
• State and apply the table, column, identifiers, relationship, and integrity constraint rules
for mapping: o supertype implementations o subtype implementations o supertype and
subtype arc implementations

Try It / Solve It
1. Transform the PARTNER supertype in the following model for a DJ business, using
SingleTable/Supertype Implementation.

PARTNER
#id
*first name
*last name
EVENT PLANNER
*expertise

DJ
*specialty

supervise MANAGER
°authorized expense limit

OTHER

supervised by

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their
respective owners.
EventPlaners
Key Type Optionality (“*” or “o”) Column Name
( pk, uk, fk)

PK * ID
* FNE
* LNE
* EPS

DJ
Key Type Optionality (“*” or “o”) Column Name
( pk, uk, fk)

PK * ID
* FNE
* LNE
* Specialty

Managers
Key Type Optionality (“*” or “o”) Column Name
( pk, uk, fk)

PK * ID
* FNE
* LNE
* AEL

Other
Key Type Optionality (“*” or “o”) Column Name
( pk, uk, fk)

PK * ID
* FNE
* LNE

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their
respective owners.
2. Transform the STAFF supertype in the following restaurant model, using Single-Table/Supertype
Implementation or Two-Table/Subtype Implementation.

STAFF
#id
*first name
*last name
*date of birth
ORDER TAKER
*salary
*overtime rate

COOK
*training

supervise
MANAGER
*budget
*target revenue

OTHER

supervised by

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their
respective owners.
Managers
Key Type Optionality (“*” or “o”) Column Name
( pk, uk, fk)

PK * ID
* FNE
* LNE
* DOB
* Salary
* Budget
TRV

OrderTakers
Key Type Optionality (“*” or “o”) Column Name
( pk, uk, fk)

PK * ID
* FNE
* LNE
* DOB
* Salary
* ORE

Cooks
Key Type Optionality (“*” or “o”) Column Name
( pk, uk, fk)

PK * ID
* FNE
* LNE
* DOB
* Salary
* Training

Other
Key Type Optionality (“*” or “o”) Column Name
( pk, uk, fk)

PK * ID
* FNE
* LNE
* DOB
* Salary

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their
respective owners.
3. Identify the database rules for each part of the database implementations below.

Supertype implementations
• Table
o Single table for super type and all subtype entities, no matter how many
subtypes I have.

• Column
o Supertype columns accommodated as is, no change in optionality.
o Subtype columns accommodated as optional

• Identifiers
o Unique identifiers transform to primary and unique keys

• Relationship
o Relationships at supertype level mapped as usual, but the sub type level
relationship is mapped as optional foreign key, even if it was meant to be
mandatory in ERD for that subtype

• Integrity constraint rules


o A check constraint is needed to ensure that for each particular subtype, all
columns that come from mandatory attributes are not null. Check constraint
is needed to ensure business rules present in ERD .

Subtype implementations
• Table
o One table per first level subtype

• Column
o  All the attributes from supertype and current subtype are accommodated
without losing optionality.

• Identifiers
o Primary UID as primary key and secondary UIDs as unique keys come from
supertype

• Relationship
o Foreign key to represent relationship at super type level are accommodated
as is without losing optionality. For the relations at sub type level, foreign key
is implemented only in the table of that sub class with original optionality

• Integrity constraint rules


o  Check constraint as in Supertype implementation is not needed here.

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their
respective owners.
Arc implementations
• Table
o Supertype and subtype entities generate one table for each entity.

• Column
o Supertype and subtype entities generate one table for each entity.

• Identifiers
o Primary UID of the supertype level creates a primary key for each of the
tables
o All other unique identifiers mapped as unique keys in respective tables.

• Relationship
o Relationships mentioned at respective level are maintained as foreign keys
without losing optionality.

• Integrity constraint rules


o These are optional foreign key columns pointing to each subtype level table.
These foreign key columns are optional because these 1:1 relationship b/w
super type and subtypes is present in arc.

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their
respective owners.

You might also like