DBMS Lab 10
DBMS Lab 10
DBMS Lab 10
OBJECTIVE:
The objective of teaching the Entity-Relationship (ER) model is to provide a foundational
understanding of data modeling concepts, enabling individuals to design efficient databases by
representing real-world entities and relationships.
Topics to Cover:
Keys:
Primary Key
Foreign Key
Composite Key
One-One Relationship
A one-to-one relationship between two entity types is established only when the foreign Key
is UNIQUE or not duplicate.
Many-to-Many Relationship
Handling a many-to-many relationship between customers and products typically involves
creating an intermediate table, often referred to as a junction table or association table.
PK is a combination of PK of both the tables.
Ternary Relations
A ternary relationship involves three entities and the relationships between them.
In a ternary relationship, you might have a table that includes foreign keys referencing the
primary keys of three related entities.
Scenario:
Consider the retail scenario of customer, product order and Vendor. A customer can make many
orders and each order can have many products.
Each product is shipped to the customer within due time by specific Vendor, One order will be delivered
to only one address provided by customer while placing order. Customer will also choose a Vendor for
each product within an order.
A Vendor can supply more than one products and each product can be supplied by more than one
Vendor.
TASKS:
Task 1 30 Minutes
Identify the ENTITITY TYPES and suggest their key attributes.
Manually CREATE a DB with your enrollment and also manually create tables for each Entity Type.
Customer
Attributes:
CustomerID (Primary Key)
Name
Email
Address
Phone Number
Product
Attributes:
ProductID (Primary Key)
Name
Description
Price
VendorID (Foreign Key)
Order
Attributes:
OrderID (Primary Key)
CustomerID (Foreign Key)
OrderDate
DeliveryAddress
Vendor
Attributes:
VendorID (Primary Key)
Name
Email
Phone Number
Task 2 30 Minutes
MANUALLY Set Primary Key and foreign key for each RELATION.
Task 3 30 Minutes
Create Database Diagram of your database and identify all RELATIONSHIPS among the entity
types and write them down in tabular form.
Task 4 30 Minutes
a) Find the ternary relationship and represent in RDBMS in an acceptable way.
b) Find many-many relationships and resolve it so that database can be implemented correctly.