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

Lecture 2 ERD

Uploaded by

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

Lecture 2 ERD

Uploaded by

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

ER Diagrm

Conceptual Design
Designing a Database
• Requirement Gathering
• Conceptual Design  Conceptual Model
• Entity Relationship Diagram (ERD)
• Logical Design  Logical Model
• Relational Schema
• Physical Design  Physical Model
• Actual implementation on a DBMS
• Indexes
• Views
• Normalize or de-Normalize
• Security
• Access rights
Conceptual design
Pictorial Form / Flow chart
• Made for client
• Easy to understand
• Inexpensive to change
We will start with Conceptual
design
ER diagram
• An entity relationship diagram (ERD) shows the relationships of entity
sets stored in a database.

• ER diagrams are used to sketch out the design of a database.


ER Concepts
• Entity (Nouns in the text )
• Attributes (Properties of the Entity)
• Relationship (Verb, relationship between the entities)

• Example:

• A student ‘Ali’ with id ‘1100’ takes a course of ‘Database Systems’.


Entity representation in ER Diagram
(Rectangle)

Student Course
Strong Entity vs Weak Entity
• An entity is strong if it can independently exist

• An entity is weak when its existence depends on


another entity.
Example of weak entity
• Child can't exist without parent
• Section can't exist without class
• Account can't exist without bank

• Representation

Section
Attributes representation in ERD
(Oval)
• Properties of an entity
id
Student

name
Types of an attribute
• Types of attributes

• Key attribute
• Composite attribute
• Derived attribute
• Simple attribute
• Multivalued attribute
Attributes

Month

date
DOB

Age year

CGPA

Hobby
Roll No Student
Complex attribute
Types of keys
Relationship representation in ERD
(Diamond)
Student Enrolls Course
in

Is taught
by

Teacher

• Please note: Readability is Left to Right & Top to bottom


Teacher Wrong structure
Is taught
by

Course Student
Enrolls

• Please note: Readability is Left to Right & Top to bottom


• Correct it.
Activity: Design an ERD
• The company is organized into departments. Each department has a unique
name, a unique number, and a particular employee who manages the
department. We keep track of the start date when that employee began
managing the department. A department may have several locations.
• A department controls a number of projects, each of which has a unique
name, a unique number, and a single location.
• We store each employee’s name, Social Security number,2 address, salary,
gender , and birth date. An employee is assigned to one department, but may
work on several projects, which are not necessarily controlled by the same
department. We keep track of the current number of hours per week that an
employee works on each project. We also keep track of the direct supervisor
of each employee (who is another employee).
• We want to keep track of the dependents of each employee for insurance
purposes. We keep each dependent’s first name, gender, birth date, and
Constraints on Relationship

Cardinality Participation
• One to many (1:N) • Total Participation
• One to one (1:1) • Partial participation
• Many to many (M:N)
Relationship: cardinality
• 1:M
1
M
Faculty Works Department
for

• M:N
N M
Faculty Courses
Teaches

• 1:1

1 1
Faculty Is head Department
of
Relationship: Particitaion
• Total or partial
Department
Faculty works

Faculty Courses
Teaches

Faculty Is head Department


of
Relationship: cardinality and
Participation
• 1:M
M 1
Department
Faculty works

• M:N
M N
Faculty Courses
Teaches

• 1:1
1
1
Faculty Is head Department
of
Attributes of relationship
• A relationship can have attributes:
• For example, grade of enrolls
• Its value for each relationship instance describes the grade a student takes
when he is enrolled in a course.
• A value of Grade depends on a particular (Student,Course) combination

Students Course
Enrolls

Grade
Recursive Relationship: Rolenames
• Employee is supervisor of other employees

supervisee
Employee

Supervisor

1 is M
supervisor
of
Identifying relationship

Employee has Dependent have Medical Reports

• Relationship between a strong and weak entity is identifying.

• Why it would be needed?


Ternary relationship
Mention cardinality & participation
Identify Weak entities
Identify relationship attributes

• The company is organized into departments. Each department has a unique name,
a unique number, and a particular employee who manages the department. We
keep track of the start date when that employee began managing the department.
A department may have several locations.
• A department controls a number of projects, each of which has a unique name, a
unique number, and a single location.
• We store each employee’s name, Social Security number,2 address, salary, gender ,
and birth date. An employee is assigned to one department, but may work on
several projects, which are not necessarily controlled by the same department. We
keep track of the current number of hours per week that an employee works on
each project. We also keep track of the direct supervisor of each employee (who is
another employee).
• We want to keep track of the dependents of each employee for insurance
purposes. We keep each dependent’s first name, gender, birth date, and
relationship to the employee.

You might also like