Oracle Academy - Database Design 9 Practice Activities - Answers
Oracle Academy - Database Design 9 Practice Activities - Answers
4
Gery J. Sumual (01123574291-53)
FOOD ITEM
Key Column
Optionality
Type name
pk * number
* description
* price
fk1 o rmu_code
fk2 o pmu_code
ORDER
Key Column
Optionality
Type name
pk * number
* date
* time
fk1 * stf_id
fk2 o fdcd_id
ORDER LINE
Key Column
Optionality
Type name
pk,fk * fim_num
pk,fk * odr_num
* quantity
9.4 Subtype Mapping
Try It / Solve It:
1.
PARTNERS (PNR)
Key
Optionality Column name
type
pk * id
* first_name
* last_name
o expertise
o specialty
o authorized_expense_limit
* pnr_type
fk o pnr_id
2.
MANAGERS (MGR)
Key type Optionality Column name
pk * stf_id
* first_name
* last_name
* birth_date
* salary
* budget
target
*
revenue
fk o stf_id
3.
• Supertype implementations
o Table: Each supertype along with its subtypes will get a single table
o Column: for each attribute belongs to the supertype and its subtypes a
corresponding column will be added to the table.
o Identifiers: The primary UID, unique UIDs, and the rest of the attributes of the
supertype will retain their optionality in the table as keys and non-keys, but those
from the subtypes will have their optionality turned into optional if they aren’t
already.
o Relationship: The relationships from the supertype level will keep their optionality in
whichever table that they mapped to, as for the relationships from the subtypes, if
they’re mapped to the single table, will be treated as optional.
o Integrity constraint rules: There will be a discriminator column with not null
constraint that discriminates between subtypes for each row of the table, and a
check constraint that will be used as to ensure the original optionality of the
attributes and relationships of each subtypes using the pivotal role of the
discriminator column.
• Subtype implementations
o Table: each subtype will get a single table while their supertype won’t.
o Column: for each attribute belongs to the supertype a column will be added to every
table, and for each attribute belongs to the subtypes a column will be added only to
each corresponding subtype table.
o Identifiers: the primary and unique UIDs along with the attributes belongs the
supertype will be added to every table as keys and non-keys while retaining their
optionality. As for the unique UIDs and the attributes belongs to the subtypes will be
added only to their corresponding table as keys and non-keys with their optionality
unchanged.
o Relationship: each relationship from the supertype if they’re mapped to the
supertype then it will be mapped to every subtype table as foreign key retaining
their optionality. Each relationship from each subtype if they’re mapped to the
subtype then it will be mapped only to the corresponding subtype table as foreign
key with their optionality unmodified.
o Integrity constraint rules: if the primary keys of the subtype tables need to be
guaranteed as unique, then additional programming needs to be implemented to
the database.
• Arc implementations
o Table: for each supertype and subtype, a table will be created.
o Column: only the attributes that belong to the supertype level will be added as
columns to the supertype-based table, and only the attributes that belong to each
subtype, in addition of the primary UID of the supertype, that will be added as
columns to their corresponding table.
o Identifiers: the primary identifier of the supertype will be added to every table as
primary key, and the unique identifiers of the entity that each table is based on will
be added as unique keys.
o Relationship: the relevant relationships from the entity that a table is based on will
be added to the table as foreign keys with original optionality, and the supertype-
based table will have additional foreign keys that is optional and also unique that
refer to the table implementation of its subtypes.
o Integrity constraint rules: the additional foreign keys of the supertype-based table
are implemented as an arc relationship, so an arc check constraint is needed for
them.