ER Diagram
ER Diagram
BADRI NARAYAN. B
1
ER modeling
ER modeling: A graphical technique for understanding and organizing
which we intend to collect data. Also known as Entity type. E.g.: Student
Relationships: Associations between entities. E.g.: Student belongs to
a CBS
Attributes
The set of possible values for an attribute is called the domain of the
attribute Example: The domain of attribute marital status is having four values: single, married, divorced or widowed.
The domain of the attribute month is having twelve values ranging
unique for every entity instance E.g.: the account number of an account, the employee id of an employee etc.
4
Attribute Type
Types of Attributes
Simple attribute
Definition
Cannot be divided into simpler components Can be split into components
Example
Composite attribute
Single valued Multi-valued Stored Attribute
Gender of the employee Date of joining of the employee Can take on only a single value for Age of the employee each entity instance Can take up many values Attribute that need to be stored permanently Attribute that can be calculated based on other attributes.
5
Skill set of the employee Date of joining of the employee Years of service of the employee
Derived Attribute
Entity Types
Regular Entity: Entity that has its own key attribute (s).
name
E#
Strong entity
Id ----
Weak entity
Employee
has
dependent
Degree of a Relationship
Degree: The number of entity types involved
E.g.: employee manager-of employee is unary employee works-for department is binary customer purchase item, shop keeper is a ternary relationship
Unary Relationship
Employee Manages
Ternary Relationship
Medicine
Doctor
Prescription
Patient
Cardinality
Relationships can have different connectivity
one-to-one one-to-many many-to- One many-to-many
E.g.: Employee head-of department (1:1) Lecturer offers course (1:N) assuming a course is taught by a single lecturer Student enrolls course (M:N)
10
ER Modeling -Notations
An Entity is an object or concept about which business user wants to store information. A weak Entity is dependent on another Entity to exist. Example Order Item depends upon Order Number for its existence. Without Order Number it is impossible to identify Order Item uniquely.
11
ER Modeling Notations(Contd..)
A derived attribute is based on another attribute. For example, an employee's monthly salary is based on the employee's basic salary and House rent allowance.
Relationships illustrate how two entities share information in the database structure.
To connect a weak Entity with others, you should use a weak relationship notation.
12
Steps in ER Modeling
Identify the Entities
Find relationships
Primary Key
Department Name
Location
Department
Pre Requisite
1 Offers
1 Headed by
1 Has
Course Name
Room#
Enrolled by
Student#
Student Name
14
15
16