Transforming ERD into Relations Flashcards
Step 1 in Transforming ERD into Relations
Formally, for each entity type E in the ERD, create a relation R that includes all the attributes of E
Step 2 in Transforming ERD into Relations
Representing a relationship in a conceptual ERD to its equivalent construct in the relational logical model depends on both the degree of the relationship and its cardinality
Give me an in-depth explanation on step 1
○ Create a 2-dimensional table whose number of columns is equal to the number of attributes in your ERD
○ Give the table the name, written in capital letters, that you gave the entity in the ERD
○ Include all the names of the attributes in the table that you created
how to use Binary 1:N
Add the primary key of the entity on the one side of the relationship as the foreign key in the relation that is on the many-side of the relationship
This is the most common type of relationship and the easiest to represent
Binary 1:N
What is Binary 1:1/ how to use Binary 1:1
If two entities are maintaining a one-to-one relationship, and they can share the same primary key, these may be resolved by combining the entities into one
This means that the attribute of one entity will be moved into the other and a common primary key will be established
two entities are maintaining a one-to-one relationship, and they can share the same primary key, these may be resolved by combining the entities into one
Binary 1:1
Explain merging in Binary 1:1
Merging the two entity types and the relationship into a single relation is only appropriate when the participation of the entity types are total (an instance of one entity type ensures the existence of an instance of the other entity type) and the entity types do not participate in any other relationships.
when to add the primary key of A as a foreign key of B
If the above technique is not permissible (i.e., when at least one of the entities participates in more than one relationship)
If the above technique is not permissible (i.e., when at least one of the entities participates in more than one relationship), the 1:1 relationship can be represented as:
○ Adding the primary key of A as a foreign key of B
○ Adding the primary of B as a foreign key of A
○ Both representations
Representing Binary 1:1 Relationships
The designer is left with the discretion as to
which of the three is most appropriate.
Representing Binary 1:1 Relationships (the relationship has an attribute)
Any attributes in the relationship will be placed in the relation or table where the foreign key is placed (which is on the optional side)
what does Binary M:N contain?
Include as a foreign key, attributes in the newly created relation the primary keys of entities A and B. This combination will form the primary key of the new relation
If the relationship has any attributes, include them in the new relation
Create a separate relation to represent the
relationship
Binary M:N
Representing Unary 1:N Relationships
Represent a recursive relationship with cardinality ratio 1:N by simply adding a rename of the primary key with reference to the relationship
Representing Unary M:N Relationships
create a new relation to represent the relationship
include as a foreign key attributes, the primary
keys of the participating entity types
the primary key of the new relation is composed of its set of foreign keys