ENTITY RELATIONSHIP(E-R) DIAGRAM
BADRI NARAYAN. B
1
Database Design Techniques
Top down Approach
Top down starts by defining the data sets and then define the data elements within those sets. As a result of this method, you generally end up with redundant information in one or more tables. Some references call this Entity - Relationship modeling. Bottom Up approach Bottom up starts by defining the required attributes and then grouping them to form the entities. Another term used for this method is normalization from functional dependencies.
ER modeling
ER modeling: A graphical technique for understanding and organizing
the data independent of the actual database implementation.
Entity: Any thing that may have an independent existence and about
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: Properties/characteristics that describe entities.eg:
Student Name, Batch Name, DOB, Address, etc.
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
from January to December.
Key attribute: The attribute (or combination of attributes) that is
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).
E.g.: Employee, student ,customer, policy holder etc.
Weak entity: Entity that depends on other entity for its existence and doesnt have
key attribute (s) of its own
E.g. : Dependent of employee
name
E#
Strong entity
Id ----
Weak entity
Employee
has
dependent
Degree of a Relationship
Degree: The number of entity types involved
One Two Three
Unary Binary Ternary
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
(1:1) (1:N) (M:1) (M:N)
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.
Attributes are the properties or characteristics of an Entity
A key attribute is the unique, distinguishing characteristic of the Entity A multi-valued attribute can have more than one value. For example, an employee Entity can have multiple skill values.
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
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
13
ER Model for the University Database
Department Name
Location
Department
Pre Requisite
1 Offers
1 Headed by
1 Has
Course# N N Duration Course Is taught by 1 Instructor 1 N
Course Name
Instructor Name Telephone#
Room#
Enrolled by
Student Date of Birth
Student#
Student Name
14
15
16