Relational Database Design by ER and EER-to-Relational Mapping Flashcards

1
Q

STEP 1: Mapping of Strong Entity Types

A

For each strong (regular) entity type E:

  1. Create a relation R that includes all the atomic attributes. This can also
    be called an entity relation.
    o If there are composite attributes, include only their corresponding
    atomic attributes.
  2. Choose one of the key/s of E as the primary key for R. It will remain underlined and will be listed first in the relation.
    o If the chosen key is composite, then the set of its corresponding atomic attributes will form the primary key.
    o If multiple keys were identified for E in the ER model, the
    unselected key/s will be documented as unique key/s but they will NOT be underlined in the relation anymore.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Step 2: Mapping of Weak Entity Types

A

For each weak entity type W with owner entity type E:

  1. Create a relation R that includes all the atomic attributes (or corresponding atomic attributes of composite attributes) of W.
  2. Include the primary key of E. It and the partial key of W (if any) will form the primary key of R which is underlined and listed first in the relation.

o Note that this primary key of E that was included in R is also a
foreign key and will be documented as such.

Ex: DEPENDENT(** Ssn, Dependent name**, Sex, Birth date, Relationship )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

3 Approaches in Mapping of Binary 1:1 Relationship Types

A
  1. Foreign key approach
    <- Preferred
  2. Merged relation approach
  3. Cross-reference approach
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Step 3 (for 1:1): Foreign Key Approach

A

With R, S and T identified:

  1. Choose one of the relations (preferably one with total participation), say S,
    and include as foreign key in S the primary key of T.
  2. Include all the atomic attributes (or corresponding atomic attributes of
    composite attributes) of the 1:1 relationship type R as attributes of S.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Step 3 (for 1:1): Merged Relation Approach

A

This is only possible when both participations are total. With R, S and T identified:

  1. Merge S and T into a single relation U.
  2. Include all the atomic attributes (or corresponding atomic attributes of
    composite attributes) of the 1:1 relationship type R as attributes of U.
  3. Pick one of the primary keys from the original relations as the primary key of U. The other key will be a unique key and will be documented as such.

NOTE: This approach cannot be done if there are additional relationships between the original relations which prevent the merge into a single relation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Step 3 (for 1:1): Cross-reference Approach

A

This is also called relationship relation approach and more appropriate when both participations are partial. With R, S and T identified:

  1. Create a 3rd relation U containing both primary keys from S and T as foreign keys. This will be sort of a lookup table.
  2. Include all the atomic attributes (or corresponding atomic attributes of composite attributes) of the 1:1 relationship type R as attributes of U.
  3. Pick one of the primary keys from the original relations as the primary key of U. The other key will be a unique key and will be documented as such.

NOTE: The obvious disadvantage of this approach is the extra relation which requires extra join operation/s.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Step 4: Mapping of Binary 1:N Relationship Types

A

For each binary 1:N relationship type R:

  1. Identify the relation S that represents the participating entity type on the
    N − side of the relationship type.
  2. Include as foreign key in S the primary key of T that represents the other participating entity type (on the 1 − side).
  3. Include all the atomic attributes (or corresponding atomic attributes of
    composite attributes) of the 1:N relationship type R as attributes of S.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Step 5: Mapping of Binary M:N Relationship Types

A

For each binary M:N relationship type R:

  1. Create a new relation S to represent R.
  2. Include as foreign keys in S the primary keys of the relations that represent the participating entity types.
  3. Include all the atomic attributes (or corresponding atomic attributes of
    composite attributes) of the M:N relationship type R as attributes of S.
  4. All those added in #2 and #3 above will form the primary key of S and will need to be underlined.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Step 6: Mapping of Multivalued Attributes

A

For each multivalued attribute A:

  1. Create a new relation R.
  2. Include as foreign key in R the primary key of the relation that
    represents the entity type or relationship type that has A as attribute.
  3. Include an atomic attribute in R corresponding to single value of A. If A is composite, include its corresponding atomic attributes instead.
  4. All those added in #2 and #3 above will form the primary key of R and will need to be underlined.

ex: DEPT_LOCATION( Dnumber, Dlocation )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Step 7: Mapping of N-ary Relationship Types

A

For each n-ary relationship type R (where n > 2):

  1. Create a new relationship relation S to represent R.
  2. Include as foreign keys in S the primary keys of the relations that represent the participating entity types.
  3. Include any atomic attributes (or corresponding atomic attributes of composite attributes) of R as attributes of S.
  4. All those added in #2 and #3 above will form the primary key of S and will need to be underlined.

Ex.
SUPPLIER( Sname )
PART( Part no )
PROJECT( Proj name )
SUPPLY( Sname, Part no, Proj name, Quantity )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Mapping of Specialization / Generalization, 4 common options to convert a specialization (generalization)
into relation schemas:

A

Option 8A: Multiple relations – superclass and subclasses
Option 8B: Multiple relations – subclass relations only
Option 8C: Single relation with one type attribute
Option 8D: Single relation with multiple type attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Option 8A: Multiple Relations – Superclass and Subclasses

A

This option works for ANY specialization (Disjoint/Overlapping Disjointedness,
Total/Partial Specialization)

  1. Create a new relation for the superclass (with all its attributes).
  2. For each of subclass:
    a. Create a new relation for the subclass with the primary key of the superclass as its primary key (also a foreign key).
    b. Include the local attributes of the subclass in the new relation.

Ex.
EMPLOYEE( Ssn, Fname, Minit, Lname, Birth date, Address, Job type )
SECRETARY( Ssn, Typing speed )
TECHNICIAN( Ssn, Tgrade )
ENGINEER( Ssn, Eng type )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Option 8B:
Multiple Relations – Subclass Relations Only

A

This option works only for Total specializations and recommended for Disjoint
Disjointedness because those with Overlapping Disjointedness may have same entity duplicated in several relations.

For each subclass:
1. Create a new relation for the subclass.
2. Include all attributes of the superclass in the new relation; The primary key of the new relation is the same as that of the superclass.
3. Include the local attributes of the subclass in the new relation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Option 8C:
Single Relation with One Type Attribute

A

This option works only for Disjoint Disjointedness.

  1. Create a new relation for the superclass (with all its attributes).
  2. Include a type (or discriminating) attribute in the new relation; Its value
    will indicate the subclass the tuple belongs to (if any).
  3. For each of subclass, include its local attribute/s in the new relation.

NOTE: The drawback to this is the potential for generating many NULL values
if many local attributes exist in the subclasses.

ex. EMPLOYEE( Ssn, Fname, Minit, Lname, Birth date, Address, Job type, Typing speed, Tgrade, Eng type )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Option 8D: Single Relation with Multiple Type Attribute

A

This option works for ANY specialization but more appropriate for those with
Overlapping Disjointedness.

  1. Create a new relation for the superclass (with all its attributes).
  2. For each subclass:
    a. Include a Boolean type attribute in the new relation indicating whether
    or not the tuple belongs to the subclass
    b. Include the local attribute/s of the subclass in the new relation.

NOTE: Same drawback as the previous option.

Ex. PART( Part no, Description, Is manufactured, Drawing no, Batch no, Manufacture date, Is purchased, Supplier name, List price )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

An option in Mapping of Specialization / Generalization that works for any specialization

A

Option A Superclass and Subclasses

17
Q

An option in Mapping of Specialization / Generalization that only works for Total Specializations and recommended for Disjoin Disjointedness

A

Option B Subclass Relations Only

18
Q

This option works only for Disjoint Disjointedness.

A

Option 8C:
Single Relation with One Type Attribute

19
Q

This option works for ANY specialization but more appropriate for those with
Overlapping Disjointedness.

A

Option 8D:
Single Relation with Multiple Type Attribute

20
Q

Step 9: Mapping of Union Types (Categories)

A
  1. Create a new relation U for the Union Type with all its attributes.
  2. Include a surrogate key in U and make it the primary key of the relation.
  3. Include a type attribute to indicate the particular entity type to which the
    tuple belongs to.
  4. For each superclass:
    a. Create a new relation Si for the superclass (with its attributes).

b. Include as foreign key in Si
the surrogate key to specify the
correspondence between it and the original key of Si

Ex:

PERSON( Ssn, Driver license no, Name, Address, Owner id )
BANK( Bname, Baddress, Owner id )
COMPANY( Cname, Caddress, Owner id )
OWNER( Owner id, Owner type)

21
Q

is another term if the keys happen to be the row ids or sequential numbers.

A

Surrogate Keys