What is the first step in converting an ER diagram to a relational schema?
Identify all the entities in the ER diagram and create a separate table for each entity.
Click to reveal answer
beginner
How are attributes of an entity represented in the relational schema?
Attributes of an entity become columns (fields) in the corresponding table.
Click to reveal answer
intermediate
How is a one-to-many (1:N) relationship represented in a relational schema?
Add the primary key of the 'one' side entity as a foreign key in the table of the 'many' side entity.
Click to reveal answer
intermediate
How do you convert a many-to-many (M:N) relationship from an ER diagram to a relational schema?
Create a new table for the relationship with foreign keys referencing the primary keys of the related entities. This table may also include attributes of the relationship.
Click to reveal answer
beginner
What is the role of primary keys in the relational schema derived from an ER diagram?
Primary keys uniquely identify each record in a table and are usually derived from the entity's key attributes in the ER diagram.
Click to reveal answer
When converting an ER diagram, what does each entity become in the relational schema?
AA foreign key
BA column
CA table
DA relationship
✗ Incorrect
Each entity in an ER diagram is converted into a table in the relational schema.
How are attributes of an entity represented in the relational schema?
AAs rows in a table
BAs columns in a table
CAs separate tables
DAs foreign keys
✗ Incorrect
Attributes become columns (fields) in the table representing the entity.
In a one-to-many relationship, where is the foreign key placed?
AIn the 'many' side table
BIn a new table
CNo foreign key is needed
DIn the 'one' side table
✗ Incorrect
The foreign key is placed in the table on the 'many' side to reference the 'one' side.
What do you create to represent a many-to-many relationship in a relational schema?
AA new table with foreign keys
BA foreign key in one table
CA column with multiple values
DNo table is needed
✗ Incorrect
A new table (junction table) is created with foreign keys referencing the related entities.
What uniquely identifies each record in a relational table?
AForeign key
BRelationship
CAttribute
DPrimary key
✗ Incorrect
The primary key uniquely identifies each record in a table.
Explain the process of converting a one-to-many relationship from an ER diagram into a relational schema.
Think about where the foreign key should go to link the tables.
You got /3 concepts.
Describe how many-to-many relationships are handled when converting ER diagrams to relational schemas.
Consider how to represent connections that involve multiple records on both sides.
You got /3 concepts.
Practice
(1/5)
1. In converting an ER diagram to a relational schema, how is a one-to-many relationship typically represented?
easy
A. Add a foreign key in the table on the 'many' side referencing the 'one' side
B. Create a new table for the relationship
C. Add a foreign key in the table on the 'one' side referencing the 'many' side
D. Merge both entities into a single table
Solution
Step 1: Understand one-to-many relationship
In a one-to-many relationship, one entity instance relates to many instances of another entity.
Step 2: Represent relationship in relational schema
The foreign key is placed in the table representing the 'many' side, pointing to the 'one' side's primary key.
Final Answer:
Add a foreign key in the table on the 'many' side referencing the 'one' side -> Option A
Quick Check:
One-to-many = foreign key on many side [OK]
Hint: Foreign key goes on the 'many' side table [OK]
Common Mistakes:
Placing foreign key on the 'one' side
Creating unnecessary new tables for one-to-many
Merging entities incorrectly
2. Which of the following is the correct way to represent a many-to-many relationship in a relational schema?
easy
A. Add foreign keys in both entity tables referencing each other
B. Merge both entities into a single table
C. Create a new table with foreign keys referencing both entities
D. Add a foreign key in the 'one' side table referencing the 'many' side
Solution
Step 1: Understand many-to-many relationship
Many-to-many means multiple instances of one entity relate to multiple instances of another.
Step 2: Represent many-to-many in relational schema
Create a new table (junction table) with foreign keys referencing the primary keys of both entities.
Final Answer:
Create a new table with foreign keys referencing both entities -> Option C
Quick Check:
Many-to-many = new junction table [OK]
Hint: Use a new table for many-to-many relationships [OK]
Common Mistakes:
Adding foreign keys directly in entity tables
Merging entities incorrectly
Ignoring the need for a junction table
3. Given an ER diagram with entities Student(SID, Name) and Course(CID, Title) connected by a many-to-many relationship Enrolls, which relational schema correctly represents this?
medium
A. Student(SID, Name), Course(CID, Title, SID), Enrolls(SID, CID)
B. Student(SID, Name), Course(CID, Title), Enrolls(SID, CID)
C. Student(SID, Name, CID), Course(CID, Title)
D. Student(SID, Name), Course(CID, Title)
Solution
Step 1: Identify entities and relationship type
Student and Course are entities; Enrolls is many-to-many between them.
Step 2: Convert entities and relationship to tables
Student and Course become tables with their attributes. Enrolls becomes a new table with foreign keys SID and CID.
Final Answer:
Student(SID, Name), Course(CID, Title), Enrolls(SID, CID) -> Option B
Quick Check:
Many-to-many needs separate table [OK]
Hint: Many-to-many always needs a separate table [OK]
Common Mistakes:
Adding foreign key in Course for Student
Adding foreign key in Student for Course
Omitting the Enrolls table
4. You converted an ER diagram with a one-to-one relationship between Person and Passport by adding a foreign key PersonID in Passport. However, the database allows multiple passports for one person. What is the likely mistake?
medium
A. Foreign key in Passport lacks a UNIQUE constraint
B. Foreign key should be in Person table, not Passport
C. Passport table should be merged with Person table
D. PersonID should be primary key in Passport table
One-to-one means each person has at most one passport and vice versa.
Step 2: Check foreign key constraints
Foreign key alone allows many passports per person unless a UNIQUE constraint is added to enforce one-to-one.
Final Answer:
Foreign key in Passport lacks a UNIQUE constraint -> Option A
Quick Check:
One-to-one needs UNIQUE foreign key [OK]
Hint: Add UNIQUE to foreign key for one-to-one [OK]
Common Mistakes:
Assuming foreign key alone enforces one-to-one
Placing foreign key in wrong table
Merging tables unnecessarily
5. An ER diagram has entities Author(AID, Name), Book(BID, Title), and a many-to-many relationship Writes with an attribute RoyaltyPercentage. How should you convert this to a relational schema?
hard
A. Create Author(AID, Name), Book(BID, Title), Writes(AID, BID)
B. Create Author(AID, Name), Book(BID, Title, RoyaltyPercentage), Writes(AID, BID)
C. Create Author(AID, Name, RoyaltyPercentage), Book(BID, Title), Writes(AID, BID)
D. Create Author(AID, Name), Book(BID, Title), Writes(AID, BID, RoyaltyPercentage)
Solution
Step 1: Identify entities and relationship with attribute
Author and Book are entities; Writes is many-to-many with attribute RoyaltyPercentage.
Step 2: Convert entities and relationship with attribute
Entities become tables with their attributes. The many-to-many relationship becomes a new table including foreign keys and the attribute RoyaltyPercentage.