0% found this document useful (0 votes)
52 views

Advanced Database Management System

The document discusses entity relationship (ER) diagrams and how they are used to model databases. It defines what an ER diagram is and explains how it shows the relationships between entities and their attributes. Different types of relationships are defined such as unary, binary, and ternary relationships based on the number of entity types involved. The document also covers how to represent cardinality and modality in ER diagrams and provides examples. Finally, it discusses how to convert an ER diagram into tables in a relational database schema.

Uploaded by

Mubeen Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Advanced Database Management System

The document discusses entity relationship (ER) diagrams and how they are used to model databases. It defines what an ER diagram is and explains how it shows the relationships between entities and their attributes. Different types of relationships are defined such as unary, binary, and ternary relationships based on the number of entity types involved. The document also covers how to represent cardinality and modality in ER diagrams and provides examples. Finally, it discusses how to convert an ER diagram into tables in a relational database schema.

Uploaded by

Mubeen Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 56

Advanced Database Management

System
ER diagram
An entity relationship diagram (ERD) shows
the relationships of entity sets stored in a
database. ... By defining the entities, their
attributes, and showing the relationships
between them, an ER diagram illustrates the
logical structure of databases. ER
diagrams are used to sketch out the design of
a database.
How to Draw ER Diagrams??
Why use ER Diagrams?
ER diagram
An entity relationship diagram (ERD) shows
the relationships of entity sets stored in a
database. ... By defining the entities, their
attributes, and showing the relationships
between them, an ER diagram illustrates the
logical structure of databases. ER
diagrams are used to sketch out the design of
a database.
How to Draw ER Diagrams??
Why use ER Diagrams?
Practice of ER diagram

Create Diagram of the following entities.

•Writer
•Novel
•Consumer
Degree of Relationship
The degree of a relationship is the number of entity
types that participate(associate) in a relationship. By
seeing an E-R diagram, we can simply tell the degree
of a relationship i.e the number of an entity type that
is connected to a relationship is the degree of that
relationship.
For example, If we have two entity type ‘Customer’ and ‘Account’ and
they are linked using the primary key and foreign key. We can say that the
degree of relationship is 2 because here two entities are taking part in the
relationship.
Based on the number of entity types that are connected we
have the following degree of relationships:
•Unary
•Binary
•Ternary
•N-ary
Unary (degree 1)
A unary relationship exists when both the
participating entity type are the same. When
such a relationship is present we say that the
degree of relationship is 1.
For example, Suppose in a classroom, we have many students
who belong to a particular club-like dance club, basketball club
etc. and some of them are club leads. So, a particular group of
student is managed by their respective club lead. Here, the
group is formed from students and also, the club leads are
chosen from students. So, the ‘Student’ is the only entity
participating here. We can represent this relationship using the
E-R diagram as follows:
Binary (degree 2)

A binary relationship exists when exactly two entity


type participates. When such a relationship is
present we say that the degree is 2. This is the most
common degree of relationship. It is easy to deal
with such relationship as these can be easily
converted into relational tables.
For example, We have two entity type ‘Customer’ and
‘Account’ where each ‘Customer’ has an ‘Account’ which
stores the account details of the ‘Customer’. Since we have
two entity types participating we call it a binary relationship.
Also, one ‘Customer’ can have many ‘Account’ but each
‘Account’ should belong to only one ‘Customer’. We can say
that it is a one-to-many binary relationship.
Ternary(degree 3)
A ternary relationship exists when exactly three
entity type participates. When such a relationship
is present we say that the degree is 3. As the
number of entity increases in the relationship, it
becomes complex to convert them into relational
tables.
For example, We have three entity type ‘Employee’,
‘Department’ and ‘Location’. The relationship between
these entities are defined as an employee works in a
department, an employee works at a particular location.
So, we can see we have three entities participating in a
relationship so it is a ternary relationship. The degree of
this relation is 3.
Cardinality and Modality

Cardinality and Modality work together to define the


relationship
Cardinality indicates the maximum number of times
an instance in one entity can be associated with
instances in the related entity
Modality indicates the minimum number of times an
instance in one entity can be associated with an
instance in the related entity
Cardinality and Modality are both shown on the
relationship line by symbols
Cardinality

Cardinality → maximum
Cardinality can be 1 or Many
the symbol is placed on the
outside of the relationship line,
closest to the entity
cardinality of 1 is represented by a
straight vertical line
cardinality of Many is represented by
a “crow’s foot”
Cardinality is indicated at both
ends of the relationship line
Modality

Modality → minimum
Modality can be 1 or 0
the symbol is placed on the
inside, next to the cardinality
symbol
modality of 1 is represented by
a straight vertical line
modality of 0 is represented by
a circle
Modality is indicated at both
ends of the relationship line
from Zero to Many

from One to Many

from One to One


i.e., one and only one

from Zero to One


Consider a database used to record the marks that students get in
different exams of different course offerings.
Problem
Employees work in departments; each department is
managed by an employee; a child must be identified uniquely
by name when the parent (who is an employee; assume that
only one parent works for the company) is known. We are not
interested in information about a child once the parent leaves
the company.
Draw an ER diagram that captures this information.
Problem
Each group is identified by a name (like those just
given) that describes the group. Finally, galleries
keep information about customers. For each
customer, galleries keep that person’s unique name,
address, total amount of dollars spent in the gallery
(very important!), and the artists and groups of art
that the customer tends to like.
Draw the ER diagram for the database.
Bank ER Diagram Template
Relational database schema

A relational database schema is the tables,


columns and relationships that link together
the components into a database. ...
A relational database schema is the tables,
columns and relationships that make up
a relational database. A schema is often
depicted visually in modeling software such as
SQL dbm
Converting E-R Diagrams to Relational Model

•After designing an ER Diagram,


•ER diagram is converted into the tables in
relational model.
•This is because relational models can be easily
implemented by RDBMS like MySQL , Oracle etc.
Following rules are used for converting an ER diagram into the tables-
Rule-01: For Strong Entity Set With Only Simple Attributes-
A strong entity set with only simple attributes will require only one table in
relational model.

•Attributes of the table will be the attributes of the entity set.


•The primary key of the table will be the key attribute of the entity
set.
Rule-02: For Strong Entity Set With Composite Attributes-
 
•A strong entity set with any number of composite attributes will
require only one table in relational model.
•While conversion, simple attributes of the composite attributes
are taken into account and not the composite attribute itself.
Rule-03: Translating Relationship Set into a Table-

A relationship set will require one table in the relational model.


Attributes of the table are-
NOTE-
 
•If we consider the overall ER diagram, three tables will
be required in relational model-
•One table for the entity set “Employee”
•One table for the entity set “Department”
•One table for the relationship set “Works in”
 Rule-04: For Binary Relationships With Cardinality Ratios-
 
The following four cases are possible-
 
Case-01: Binary relationship with cardinality ratio m:n
Case-02: Binary relationship with cardinality ratio 1:n
Case-03: Binary relationship with cardinality ratio m:1
Case-04: Binary relationship with cardinality ratio 1:1

You might also like