DBMS Module1 Part2
DBMS Module1 Part2
Model
Module – 1(Part 2)
ENTITY RELATIONSHIP MODEL
2
ENTITIES & ATTRIBUTES
3
Types of Attributes
1. Composite vs Simple (Atomic) Attributes
2. Single-valued vs Multivalued Attributes
3. Stored vs Derived Attributes
4. NULL value Attributes
5. Complex Attributes – Composite Multivalued Attributes
1) Composite vs Simple (Atomic) Attributes
• Composite attributes can be divided into smaller
subparts.
• Attributes that are not divisible are called simple or
atomic attributes.
4
• Address attribute can be subdivided into StreetAddress,
City, State, and Zip. StreetAddress can be further
subdivided into three simple attributes: Number, Street,
and ApartmentNumber.
• The value of a composite attribute is the concatenation
of the values of its constituent simple attributes.
5
1) Composite vs Simple (Atomic) Attributes
6
2) Single-Valued vs Multivalued Attributes
• Most attributes have a single value for a particular entity;
such attributes are called single-valued.
• For example, Age is a single-valued attribute of a person.
• In some cases, an attribute can have a set of values for the
same entity. Such attributes are called multivalued.
• For example, one person may not have a college degree,
another person may have one, and a third person may have
two or more degrees; therefore, different persons can have
different numbers of values for the CollegeDegrees attribute.
7
2) Single-Valued vs Multivalued Attributes
8
3) Stored vs Derived Attributes
9
3) Stored vs Derived Attributes
10
4) NULL Values
11
ENTITY TYPES, ENTITY SETS, KEYS & VALUE SETS
12
13
KEY ATTRIBUTES OF AN ENTITY TYPE
14
DOMAIN OF VALUE SET OF AN ATTRIBUTE
• Grade ={A, B, C, F}
15
RELATIONSHIP
16
RELATIONSHIP
WORKS
WORKS
EMPLOYEE
EMPLOYEE PROJECT
ON
ON
MANAGES DEPARTMENT
17
RELATIONSHIP TYPE
18
WORKS
EMPLOYEE DEPARTMENT
FOR
19
Degree of a Relationship Type
20
Degree of a Relationship Type
PERSON MARRIED TO
WORKS
EMPLOYEE DEPARTMENT
FOR
COURSE
21
Degree of a Relationship Type
22
CONSTRAINTS
23
Cardinality
3. many-to-one (M-1)
4. many-to-many (M-N)
24
Cardinality
1
PERSON MARRIED TO
M 1
WORKS
EMPLOYEE DEPARTMENT
FOR
M N
TEACHER TEACHES STUDENT
25
Role Name
Husband
PERSON MARRIED TO
Wife
Worker Employer
WORKS
EMPLOYEE DEPARTMENT
FOR
Subordinate
EMPLOYEE MANAGES
Manager
Recursive Relationships - When there is a relationship between two entities
of the same type.
26
Participation Constraint
1) Total participation:
27
Participation Constraint
28
STRONG & WEAK ENTITY TYPES
29
STRONG & WEAK ENTITY TYPES
2) Weak entity types:
• Entity type that does not have any key attribute.
• A weak entity is dependent on a strong entity to ensure its
existence.
• Unlike a strong entity, a weak entity does not have any
primary key.
• It instead has a partial discriminator key.
30
STRONG & WEAK ENTITY TYPES
31
STRONG & WEAK ENTITY TYPES
32
DESIGN CHOICES
33
ER DIAGRAM NOTATIONS
34
Ternary Relationship
Three binary Relationship
Question
Construct an ER Diagram for Company having following details:
• Company organized into DEPARTMENT. Each department has unique
name and a particular employee who manages the department. Start date
for the manager is recorded. Department may have several locations.
• A department controls a number of PROJECT. Projects have a unique
name, number and a single location.
• Company’s EMPLOYEE name, ssno, address, salary, sex and birth date are
recorded. An employee is assigned to one department, but may work for
several projects (not necessarily controlled by her dept). Number of
hours/week an employee works on each project is recorded. Every
employee has an immediate supervisor. All employees should be part of
some project.
• Employee’s DEPENDENT are tracked for health insurance purposes
(dependent name, birthdate, relationship to employee).
Min-Max Notation
• (min,max)
• The numbers mean that for each entity e in E, e must
participate in at least min and at most max.
• max relationship instances in R at any point in time. In
this method, min = 0 implies partial participation,
whereas min > 0 implies total participation.