DBMS Slide 9 Conversion of ER To Relational PPT

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

DATABASE

MANAGEMENT
SYSTEMS
Conversion of ER model
to Relational Model

Dr. Jay Sarraf


School of Computer Engineering
KIIT Deemed to be University
Overview

The notations may be used to represent the database, and these notations
can be condensed into a set of tables.

Database Management Systems


A group of relational schemas can be used to depict a database that
adheres to an ER diagram schema. Both the ER model and the Relational
data model are logical, abstract representations of businesses in the actual
world.
ER diagram to table conversion considerations include the following:

• Entity type becomes a table.

Conversion of ER to Relational
• All single-valued attribute becomes a column for the table.

• A key attribute of the entity type represented by the primary key.

• The multivalued attribute is represented by a separate table.

• Composite attribute represented by components.

• Derived attributes are not considered in the table.

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University


Conversion

1. Representation of Strong Entity sets

Database Management Systems


A schema with the same properties can be created from a strong entity
set. The resultant schema's main key is the entity set's primary key.

l_no
amount

Conversion of ER to Relational
LOAN

LOAN =(l_no, amount)

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University


Conversion

2. Representation of Weak Entity sets

Database Management Systems


A table with a column for the main key of the identifying strong entity
set is created from a weak entity set. The collection of foreign keys and
partial keys creates the primary key.

l_no …………...
payment_no
amount amount

Conversion of ER to Relational
Loan_
LOAN payment PAYMENT

date
LOAN =(l_no, amount)
PAYMENT =(loan_no, payment_no, payment_date, payment_amt)

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University


Conversion

3. Representation of Relationship sets

Database Management Systems


Binary M:N

The main key of the connection is formed by joining the primary key
characteristics from the participating entity sets.

c_id city l_no


amount

Conversion of ER to Relational
pin CUSTOMER
Student borrower LOAN

c_name t_date

Customer = (cid, c_name, pin, city)


Loan = (loan_no, amount)
Borrow = (cid, loan_no, t_date)
Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University
Conversion

3. Representation of Relationship sets


Binary M:1/1:M

Database Management Systems


Create two tables: one for the entity set at 1 side and the other for the entity
set at M side. Include the descriptive characteristics in both tables as well as
a reference to the primary key of 1 side in the entity set at M side.

c_id city l_no


amount

Conversion of ER to Relational
pin CUSTOMER
Student borrower LOAN

c_name t_date

Customer = (cid, c_name, pin, city)


Loan = (loan_no, amount, t_date, cid)
Or Loan = (loan_no, amount, t_date , borrowing_cid)

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University


Conversion

3. Representation of Relationship sets


Binary 1:1

Database Management Systems


Build two tables. Either side may be picked to represent the numerous
sides in this situation. So, while additional characteristics may be added to
any of the tables corresponding to the two entity sets, they cannot be
added simultaneously.

e_id city d_no


dname

Conversion of ER to Relational
pin EMPLOYEE borrower DEPARTMENT

Employee = (eid, e_name, pin, city, did)


e_name
or Employee = (eid, e_name, pin, city, department_id)
Department = (d_no, dname)

If department set considered as many side:


Employee = (eid, e_name, pin, city)
Department = (d_no, dname,eid)
Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University
Conversion

4. Representation of Recursive Relationship sets

Database Management Systems


For a recursive relationship two tables will be constructed; one for entity
set and one for relationship set.

ename
add

eid
hod
EMPLOYEE manages
teacher

Conversion of ER to Relational
Employee = (eid, ename, address)
Manages= (hodid, teacherid)

This ER diagram can also be represented by using a single


relation schema.

Employee = (eid, ename, address, hodid)


Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University
Conversion

5. Representation of Composite attributes

Database Management Systems


By generating a distinct property for each of its components, the
composite attributes are flattened down.

F_name
id STUDENT

name M_name

Conversion of ER to Relational
Student = (id, f_name, m_name, l_name) L_name

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University


Conversion

6. Representation of Multi-valued attributes

Database Management Systems


A distinct schema E M is used to express a multi-valued attribute M of
an entity set E. (primary key of E,M).

id STUDENT mobile

name add

Conversion of ER to Relational
Student = (id, name, add)
Student_mobile = (id, mobile)

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University


Conversion

7. Representation of Generalization/Specialization

Database Management Systems


One schema will be created for the generalized entity set and one for
each of the specialized entity sets in the event of an ER diagram relating
to generalization and specialization.

name street
Pid

city
PERSON

Conversion of ER to Relational
Is
A

salary EMPLOYEE
CUSTOMER ratings

Person = (pid, name, street, city)


Employee = (pid, salary)
Customer = (pid, credit_rating)
Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University
Conversion

7. Representation of Generalization/Specialization

Database Management Systems


Schemas are only built for specialized entity sets when
generalization/specialization is a disjointness scenario.

Employee = (employee_id, name, address, salary)

Conversion of ER to Relational
Customer = (customer_id, name, address, credit_rating)

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University


Conversion

8. Representation of Aggregation
Create a schema with the primary key of the aggregated connection,

Database Management Systems


primary key of the related entity set, and descriptive characteristics to
indicate aggregation (if any)

responsibility
works
jid Job
eid
add asset

Conversion of ER to Relational
Employee Works_on Branch

ename bname bid

manages

mid Manager Mname

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University


Conversion

8. Representation of Aggregation
Create a schema with the primary key of the aggregated connection,

Database Management Systems


primary key of the related entity set, and descriptive characteristics to
indicate aggregation (if any)

Employee = (eid, ename, address)

Conversion of ER to Relational
Branch = (bid, bname, asset)
Job = (jid, position, responsibility)
Works_on = (eid, bid, jid)
Manager = (mid, mgrname)
Manages = (eid, bid, jid, mid)

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be University

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy