DBMS Quiz
DBMS Quiz
Add a foreign key in the same table that references its own primary key.
Create a separate table with two foreign keys, both referencing the same entity.
One-to-One (1:1)
Many-to-Many (M:N)
Create a new relation (table) that includes foreign keys from all three participating
entities.
Add any relationship attributes to this table.
8. 8. Merging Relations
Project Discussion
9. Steps in Database Project Planning
1. Identify Requirements
o Understand the business rules and data needs.
o Identify entities, attributes, relationships, and constraints.
4. Normalization
o Apply normalization techniques (1NF, 2NF, 3NF, BCNF) to reduce
redundancy.
5. Database Implementation
o Choose a DBMS (e.g., MySQL, PostgreSQL, Oracle).
o Write SQL scripts to create tables, define constraints, and establish
relationships.
These detailed notes will help you prepare effectively for your DBMS quiz. Let me know if
you need more explanations or examples! 🚀📚
Final Revision
1. ER-Diagram Problems & Case Studies
10. Entity-Relationship (ER) Diagram Overview
1. Entities
o Real-world objects represented as rectangles in ER diagrams.
o Example: A university database may have entities like Student, Course, and
Professor.
2. Attributes
o Characteristics of an entity represented by ellipses.
o Example: A Student entity may have attributes: ID, Name, Age, and Email.
o Types of attributes:
Simple (Atomic): Cannot be divided further (e.g., Age, Roll Number).
Composite: Can be divided into sub-parts (e.g., Full Name → First
Name, Last Name).
Derived: Computed from another attribute (e.g., Age from DOB).
Multi-valued: An entity can have multiple values for the attribute
(e.g., Phone Numbers).
3. Primary Key
o A unique identifier for each entity instance.
o Example: A Student’s primary key can be Student_ID.
4. Relationships
o Represent associations between entities using diamonds.
o Example: A Student "Enrolls in" a Course.
5. Cardinality
o Specifies the number of entity instances in a relationship.
o Example:
1:1 - Each person has one passport.
1:M - A professor teaches multiple students.
M:N - Students can enroll in multiple courses, and each course can
have multiple students.
Entities:
Relationships:
2. Attribute Inheritance
o Subtypes inherit all attributes from the super type.
o Example:
Employee (Super type) → Manager & Engineer (Subtypes).
Attributes like Employee_ID and Name are inherited by both
subtypes.
Attributes:
Relationships:
4. Project Discussion
16. Steps to Design a Database Project
1. Identify Requirements
o Define the scope and business rules.
4. Normalization
o Remove redundancy using 1NF, 2NF, 3NF, BCNF.
5. Implementation in DBMS
o Write SQL queries to create and manage tables.
Answer:
Mapping a regular entity into a relational schema involves the following steps:
💡 Example:
Consider an entity Student (Student_ID, Name, Age, Address)
Q2. How do you map a weak entity into relations? Explain with an
example. (2 Marks)
Answer:
A weak entity does not have a primary key and depends on a strong entity. The steps to map
it into a relation are:
💡 Example:
Consider Dependent (Dependent_Name, Age, Relationship, Employee_ID), where
Employee_ID is from the strong entity Employee (Emp_ID, Name, Salary).
Relational Schema:
CREATE TABLE Employee (
Emp_ID INT PRIMARY KEY,
Name VARCHAR(50),
Salary DECIMAL(10,2)
);
CREATE TABLE Dependent (
Dependent_Name VARCHAR(50),
Age INT,
Relationship VARCHAR(30),
Employee_ID INT,
PRIMARY KEY (Dependent_Name, Employee_ID),
FOREIGN KEY (Employee_ID) REFERENCES Employee(Emp_ID)
);
The Primary Key for Dependent is a combination of Dependent_Name and
Employee_ID.
Q3. Explain the concept of super type and subtype with an example. (2
Marks)
Answer:
💡 Example:
Consider an Employee entity with two subtypes Manager and Technician.
Diagram Representation:
Answer:
💡 Example:
Answer:
💡 Example Representation:
Here, an employee may be a Manager or Technician, but some employees might not belong
to any subtype.
Answer:
There are three approaches to map a super type/subtype relationship into a relational
schema:
💡 Best Approach: Separate tables for subtypes (2nd approach) provide better normalization.
💡 Example:
Consider Student and Course entities with a many-to-many relationship through
Enrollment (associative entity).
Entities:
o Student (Student_ID, Name, Age)
o Course (Course_ID, Title, Credits)
o Enrollment (Enrollment_ID, Student_ID, Course_ID, Enrollment_Date)
Relational Schema:
In this schema:
💡 Example:
Supervisor_ID Subordinate_ID
A B
A C
Q9. How do you map a ternary relationship into relations? Explain with
an example. (2 Marks)
Answer:
💡 Example:
Consider a Supplier supplies a Product to a Warehouse.
Entities:
o Supplier (Supplier_ID, Name)
o Product (Product_ID, Name)
o Warehouse (Warehouse_ID, Location)
o Supplies (Supplier_ID, Product_ID, Warehouse_ID, Quantity,
Supply_Date)
Relational Schema:
💡 Example Data:
Answer:
Relation merging is the process of combining multiple relations (tables) into one to improve
efficiency, reduce redundancy, and simplify queries.
💡 Example:
Suppose we have:
This removes the need for joins, but denormalizes the structure.
Final Recap: