topic covered in this video :-
ER to Relational Mapping unit -2 DATABASE DESIGN for computer science engineering in 4th sem
playlist of dbms subject :-
• Database Management system (DBMS) in ...
join to our telegram channel to download the pdf used in this video:
https://t.me/cseengineeringnotes
DATABASE MANAGEMENT SYSTEMS
unit-2
ER to Relational Mapping
2
Course Outline:-
UNIT II DATABASE DESIGN
– ER-to-Relational Mapping
ER MODEL TO RELATIONAL MODEL
ER Model can be represented using ER Diagrams which is a great way of designing and
representing the database design in more of a flow chart form.
It is very convenient to design the database using the ER Model by creating an Er diagram
and later on converting it into relational model to design your tables. Not all the ER Model
constraints and components can be directly transformed into relational model, but an
approximate schema can be derived. Few examples of ER diagrams and convert it into
relational model schema, hence creating tables in RDBMS.
Entity in ER Model is changed into tables, or we can say for every Entity in Er model, a
table is created in Relational Model. And the attributes of the Entity gets converted to
columns of the table. And the primary key specified for the entity in the Ermodel ,will
become the primary key for the table in relational model.
4
example
A table with name Student will be created in relational model, which will have 4
columns,id, name, age, address and id will be the primary key for this table.
5
Relationship Table
Relationship becomes a Relationship Table, In ER diagram, we use diamond/rhombus
to represent a relationship between two entities. In Relational model we create a
relationship table for ER Model relationships too. In the Erdiagram below, we have
two entities Teacher and Student with a relationship between them.
Entity gets mapped to table, hence we will create table for Teacher and a table for Student with all
the attributes converted into columns. Now, an additional table will be created for the relationship,
for example Student Teacher Or give it any name you like. This table will hold the primary key for
both Student and Teacher,in a tuple to describe the relationship, which teacher teaches which
student. If there are additional attributes related to this relationship, then they become the columns
for this table,like subject name. Also proper foreign key constraints must be set for all the tables.
6
Mapping Entity
An entity is a real-world object with some attributes.
Mapping Process (Algorithm)
Create table for each entity.
Entity's attributes should become fields of tables with their respective data types.
Declare primary key.
7
Mapping Relationship
A relationship is an association among entities.
Mapping Process
Create table for a relationship.
Add the primary keys of all participating Entities as fields of table with their respective data types.
If relationship has any attribute, add each attribute as field of table.
Declare a primary key composing all the primary keys of participating entities.
Declare all foreign key constraints.
8
Mapping Weak Entity Sets
A weak entity set is one which does not have any primary key associated with it.
Mapping Process
Create table for weak entity set.
Add all its attributes to table as field.
Add the primary key of identifying entity set.
Declare all foreign key constraints.
9
Mapping Hierarchical Entities
ER specialization or generalization comes in the form of hierarchical entity sets.
Mapping Process
Create tables for all higher-level entities.
Create tables for lower-level entities.
Add primary keys of higher-level entities in the table of lower-level entities.
In lower-level tables, add all other attributes of lower-level entities.
Declare primary key of higher-level table and the primary key for lower-level table.
Declare foreign key constraint.
DATABASE MANAGEMENT SYSTEMS
Thanks for watching
=Functional Dependencies