Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
20 views55 pages

Module-1 - ER Modeling - Presentation

Good

Uploaded by

Jay Gagan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views55 pages

Module-1 - ER Modeling - Presentation

Good

Uploaded by

Jay Gagan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Department of Information Science & Engineering

Acharya Institute of Technology

- Nurturing Aspirations & Supporting Growth

Chapter-3
Data Modeling Using the
Entity-Relationship (ER) Model

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
Outline

▪ Overview of Database Design Process


▪ Example Database Application (COMPANY)
▪ ER Model Concepts
- Entities and Attributes
- Entity Types, Value Sets, and Key Attributes
- Relationships and Relationship Types
- Weak Entity Types
- Roles and Attributes in Relationship Types
▪ ER Diagrams - Notation
Confidentiality
▪ ER Diagram for COMPANY Schema
Integrity

Availability
Main phases of
Database Design

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
Main phases of
Database Design

Integrity

Availability
Entity and
Attributes

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
Entity
▪ “Entity is defined as an object with a Physical
existence”
▪ Each Entity consists of set of attributes
Example:
In Collage database , Entities like
Student, Faculty, Department, Subject , etc

Attributes
▪ “Properties of an Entity is called Attribute”
▪ With the help of attribute we can distinguish one
entity by an another entity
Example:
Student -----> Name, USN, DOB, Contact_No ……
Faculty -----> Name, SSN, Designation, Salary ……
Different types of
Attributes

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
Different types of Attributes
Attributes are divided into 5 types they are

1. Simple v/s Composite attribute

2. Single value v/s Multivalue attribute

3. Stored v/s Derived attribute

4. Null Values

5. Complex attribute
Simple v/s Composite attribute

▪ An attribute can be divided into sub-attribute is

called Composite attribute


Example:

▪ An attribute that are not divisible is called

Simple(Atomic) attribute
Example:
Age, Fname, Gender
Single value v/s Multivalue attribute

▪ An attribute that consists of a single value is called

Single value attribute


Example:
Age of a student

▪ An attribute consists of more than one value or set

of values is called Multivalued attribute


Example:
Contact Number
Stored v/s Derived attribute

▪ In some cases two (or more) attribute values are

related each other


Example:
Date of Birth is called Stored attribute
Age is called Derived attribute
Null values

▪ In some cases a particular entity may not have an

applicable value for an attribute, Those type of

attributes are called Null value


Example:
- College Degree attribute of a employee with no
degree
- Contact_number if not available
Complex attribute

▪ Combination of Composite and Multivalued

attribute is called Complex attribute

▪ Composite attribute uses ( ) parentheses and

separating the components with , commas.

▪ Multivalued attribute uses { } braces


Example:
Employee { Local_address (Door_No, Street_Name,
City, Pincode), Permanent_address (Door_No,
Street_Name, City, Pincode) }
Entity Types and
Entity Sets

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
Entity Types and Entity Sets

Entity Type:

▪ An Entity type is defined as collection of ENTITY TYPE EMPLOYEE


NAME Name, Age, Salary
entities that have the same attributes. e1
John, 45,20000
▪ Each entity type in the database is e2
Smith, 40,30000
ENTITY SET e3
described by its name and the attributes
Ashok, 30,10000
.
Entity Set: .
.

▪ Collection of all entities of a particular

entity type in the database at any point of

time is called Entity set.


Key attribute

▪ An attribute of an entity type for which each entity


must have a unique value is called a key attribute of
the entity type
▪ One entity is distinguished from other entity using
some attribute, such an attribute is called as key
attribute
▪ Each key is underlined

Example:
Employee ( Name, SSN, Salary, DOB, Designation….)

Student ( Name, USN, DOB, email, Contact_No)


Strong Entity and Weak Entity

Strong Entity
▪ If the Key attribute is present in an entity is called
Strong Entity
Example:
Employee ( Name, SSN, Salary, DOB, Designation….)

Weak Entity
▪ If the Key attribute is absent in an entity is called
weak Entity
Example:
Dependent(Name, Relationship, Contact_No,
Address….)
Value Sets(Domain) of Attributes

▪ Each simple attribute of an Entity type is associated


with a Value Set(or Domain of values)

Example:
A: E →P(V)
Age: EMPLOYEE → P(25) to P(58)
P(V)=P(V1), P(V2), P(V3), P(V4) ………. P(Vn)
A is an Attribute
E is an Entity type
P is Power set
V1,V2,V3,V4………..Vn are values
Relationship type, Sets, Instance

▪ A relationship type ‘R’ among n entity types


E1,E2,E3…….En defines a set of association (mapping
or connection) or a relationship set among entities
from these types
Mathematically:
(e1,e2,e3……..en) are entities of E
(r1,r2,r3…………rn) are relationships of R

E R E
EMPLOYEE WORKS PROJECT
ON

John r1 ES
Ashok r2 Testing
Degree of a Relationship
▪ The degree of a relationship type is the number of
participating entity types

» One Unary
» Two Binary
» Three Ternary

Example:

1. employee manager-of employee is


unary

2. employee works-for department is


binary

3. Doctor prescription Medicine to Patient


Unary Relationship

subordinate

Manages
Employee

Manager

▪ A relationship type of degree one is called Unary


Relationship
Binary Relationship

Works
Employee for
Department

▪ A relationship type of degree two is called Binary


Relationship
Ternary Relationship

Medicine

Doctor Prescription Patient

▪ A relationship type of degree three is called Ternary


Relationship
Mapping (Cardinality Ratio)
▪ Mapping is a concept used to connect entities

Different types of mapping (Cardinality Ratio)

one-to-one (1:1)
one-to-many (1:N)
many-to- One (M:1)
many-to-many (M:N)

Example

Employee head-of department (1:1)

Lecturer offers course (1:N) assuming a course is taught


by a single lecturer

Students belongs-to department (M:1) assuming many


students belong to one department

Student enrolls course (M:N)


ER Diagram
Notations

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
ER Diagram Notations

Strong Entity

Weak Entity

Attributes

Key attribute

Multi-valued attribute
ER Diagram Notations

Derived attribute

Composite attribute
Attribute

Relationships

Identifying Relationship (To connect a weak Entity


with other entity)
Weak Entity, Partial and Total Participation

Id Name
E#
----

1 1
EMPLOYEE Has DEPENDANT
Structural Constraint (Min,Max) Notation
Role Names

subordinate

Manages
Employee
1
Manager

▪ A Role names may be added to make the


meaning more explicit
Attributes of a Relationship

Medicine

Number of days

dosage

Doctor Prescription Patient


Steps in
ER Modeling

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
Steps in ER Modeling
▪ Identify the Entities

▪ Find relationships

▪ Identify the key attributes for every Entity

▪ Identify other relevant attributes

▪ Draw complete E-R diagram with all attributes


including Key attribute

▪ Review your results with your Business users


ER Diagram
COMPANY Database

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
Entities of Company Database

▪ EMPLOYEE
▪ DEPARTMENT
▪ PROJECT
▪ DEPENDENT
Initial Design of Entity Types:
EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT
EMPLOYEE PROJECT

DEPARTMENT DEPENDENT
DOB Sex

Relationship

DEPENDENT
Name
Relationships

▪ WORKS_FOR (between EMPLOYEE, DEPARTMENT)

▪ MANAGES (between EMPLOYEE, DEPARTMENT)

▪ CONTROLS (between DEPARTMENT, PROJECT)

▪ WORKS_ON (between EMPLOYEE, PROJECT)

▪ SUPERVISION (between EMPLOYEE (as subordinate),

EMPLOYEE (as supervisor))

▪ DEPENDENTS_OF (between EMPLOYEE, DEPENDENT)


ER diagram COMPANY Database
ER Diagram
BANKING Database

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
ER diagram BANKING Database
ER Diagram
COLLEGE Database

C K Marigowda | Associate Professor & HOD | Information Science & Engineering | Acharya Institute of Technology |
[email protected]
ER diagram COLLEGE Database
Assumptions :

▪ A college contains many departments


▪ Each department can offer any number of courses
▪ Many instructors can work in a department
▪ An instructor can work only in one department
▪ For each department there is a Head
▪ An instructor can be head of only one department
▪ Each instructor can take any number of courses
▪ A course can be taken by only one instructor
▪ A student can enroll for any number of courses
▪ Each course can have any number of students
ER diagram COLLEGE Database
Steps in ER Modeling

▪ Identify the Entities

▪ Find relationships

▪ Identify the key attributes for every Entity

▪ Identify other relevant attributes

▪ Draw complete E-R diagram with all attributes


including Primary Key

▪ Review your results with your Business users


Steps in ER Modeling

Identify the Entities ?????


Step 1: Identify the Entities

DEPARTMENT
STUDENT
COURSE
INSTRUCTOR
Steps in ER Modeling

Find relationships ???


Step 2: Find the relationships

• One course is enrolled by multiple students and one student enrolls for multiple courses,
hence the cardinality between course and student is Many to Many.

COURSE M ENROLLED BY
N STUDENT
• The department offers many courses and each course belongs to only one department, hence
the cardinality between department and course is One to Many.

DEPARTMENT 1 OFFERS M COURSE

• One department has multiple instructors and one instructor belongs to one and only one
department , hence the cardinality between department and instructor is one to Many.

1 M
DEPARTMENT HAS INSTRUCTOR
Step 2: Find the relationships

• Each department there is a “Head of department” and one instructor is “Head


of department “,hence the cardinality is one to one .

1 1
DEPARTMENT HEADED BY INSTRUCTOR

• One course is taught by only one instructor, but the instructor teaches many
courses, hence the cardinality between course and instructor is many to
one.

M 1
COURSE OFFERS INSTRUCTOR
Steps in ER Modeling

▪ Identify the key attributes for every Entity

▪ Identify other relevant attributes


Steps in ER Modeling

Step 3: Identify the key attributes

▪ Deptname is the key attribute for the Entity


“Department”, as it identifies the Department uniquely.
▪ Course# (CourseId) is the key attribute for “Course”
Entity.
▪ Student# (Student Number) is the key attribute for
“Student” Entity.
▪ Instructor Name is the key attribute for “Instructor”
Entity.
Steps in ER Modeling

Step 4: Identify other relevant attributes

▪ For the department entity, the relevant attribute is

location

▪ For course entity, course name, duration, prerequisite

▪ For instructor entity, room#, telephone#

▪ For student entity, student name, date of birth


ER diagram COLLEGE Database
Department
Location
Name

Department

Pre Requisite 1 1 1
Headed
Has
Offers by
Course#

N 1 N

N 1
Duration Is taught
Course Instructor
by

N
Course Instructor
Room#
Name Name

Enrolled Telephone#
by

Student
Date of Birth

Student# Student Name


Complete the ERD

Consider the ER diagram. Assume that a Course may or may not use a
text book, A Course may not use more than five books. Instructors
teaches for two or four courses. Supply (min,max) constraint on this
diagram. State clearly any additional assumptions you make. If we add a
new relationship A D O P T S between I N S T R U C T O R and T E X T. What
structural constraints would you put on it? Why?

(A,B) (C,D)

(E,F)

(G,H)
Complete the ERD

Consider the ER diagram. Assume that a Course may or may not use a
text book, A Course may not use more than five books. Instructors
teaches for two or four courses. Supply (min,max) constraint on this
diagram. State clearly any additional assumptions you make. If we add a
new relationship A D O P T S between I N S T R U C T O R and T E X T. What
structural constraints would you put on it? Why?

(2,4) (1,N)

(0,5)
(0,20)

ADOPTS
(0,1)

(0,1)
Thank you
[email protected]
www.acharya.ac.in

You might also like