Unit 2.2
Unit 2.2
Types of Attributes
Middle name
2
Types of Attributes
Roll No Phone No
3
Types of Attributes
4
Entity with all types of Attributes
Middle
Name
First Name Last Name
Single
Simple
Value
RollNo Name Composite Apartment
Derived Composite
Multiple Stored
Value
Phone No Birth Date Area
5
Exercise
Draw an E-R diagram of Banking Management System.
Draw an E-R diagram of Hospital Management System.
Draw an E-R diagram of College Management System.
Take only 2 entities
Keep proper relationship between two entities
Use all types of attributes
6
Descriptive Attribute
Attributes of the relationship is called descriptive attribute.
Descriptive
Attribute
Issue
RollNo Name Date BookNo Name
7
Role
Roles are indicated by labeling the lines that connect diamonds (relationship) to rectangles
(entity).
The labels “Coordinator” and “Head” are called roles; they specify Faculty entities interact with
whom via Reports_To relationship set.
Role labels are optional, and are used to clarify semantics (meaning) of the relationship.
EmpID Name
Coordinator
Faculty Reports_To
Head
Branch Experience
8
Recursive Relationship Set
The same entity participates in a relationship set more than once then it is called recursive
relationship set.
FacID FName DeptID DName
Post Recursive
Relationship
FName Post Set DName
Ajay Professor Prof. Computer
Haresh Professor Civil
Ramesh HOD Mechanical
9
Section - 3
Mapping Cardinality (Cardinality Constraints)
It represents the number of entities of another entity set which are connected to an entity
using a relationship set.
It is most useful in describing binary relationship sets.
For a binary relationship set the mapping cardinality must be one of the following types:
One to One
One to Many
Many to One
Many to Many
11
One-to-One relationship (1 – 1)
An entity in A is associated with only one entity in B and an entity in B is associated with only
one entity in A.
C3 L3
A B
Example: A customer is connected with only one loan using the relationship borrower and a
loan is connected with only one customer using borrower.
12
One-to-Many relationship (1 – N)
An entity in A is associated with more than one entities in B and an entity in B is associated
with only one entity in A.
C3 L3
A B
L4
Example: A loan is connected with only one customer using borrower and a customer is
connected with more than one loans using borrower.
13
Many-to-One relationship (N – 1)
An entity in A is associated with only one entity in B and an entity in B is associated with more
than one entities in A.
C3 L3
A B
C4
Example: A loan is connected with more than one customer using borrower and a customer is
connected with only one loan using borrower.
14
Many-to-Many relationship (N – N)
An entity in A is associated with more than one entities in B and an entity in B is associated
with more than one entities in A.
C3 L3
A B
C4 L4
Example: A customer is connected with more than one loan using borrower and a loan is
connected with more than one customer using borrower.
15
Mapping Cardinality (Cardinality Constraints) [Exercise]
Draw an E-R diagram and specify which type of mapping cardinality will be there in the
following examples:
Each customer has only one account in the bank and each account is held by only one customer. [single
account]
Each customer has only one account in the bank but an account can be held by more than one customer.
[joint account]
A customer may have more than one account in the bank but each account is held by only one customer.
[multiple accounts]
A customer may have more than one account in the bank and each account is held by more than one
customer. [join account as well as multiple accounts]
A student can work in more than one project and a project can be done by more than one student.
A student can issue more than one book but a book is issued to only one student.
A subject is taught by more than one faculty and a faculty can teach more than one subject.
16
Section - 4
Participation Constraints
It specifies the participation of an entity set in a relationship set.
There are two types participation constraints
Total participation
Partial participation
C1 L1
Each customer has
maximum one loan C2 L2
C3
18
Section - 5
Weak Entity Set
An entity set that does not have a primary key is called weak entity set.
Payment-date
20
Weak Entity Set
The existence of a weak entity set depends on the existence of a strong entity set.
The discriminator (partial key) of a weak entity set is the set of attributes that distinguishes all
the entities of a weak entity set.
The primary key of a weak entity set is created by combining the primary key of the strong
entity set on which the weak entity set is existence dependent and the weak entity set’s
discriminator.
We underline the discriminator attribute of a weak entity set with a dashed line.
Payment entity has payment-no which is discriminator.
Loan entity has loan-no as primary key.
So primary key for payment is (loan-no, payment-no).
21