0% found this document useful (0 votes)
22 views21 pages

Unit 2.2

very useful

Uploaded by

piek446
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views21 pages

Unit 2.2

very useful

Uploaded by

piek446
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Section - 2

Types of Attributes

Simple Attribute Composite Attribute


Cannot be divided into subparts Can be divided into subparts
E.g. RollNo, CPI E.g. Name
(first name, middle name, last name)
Address
(street, road, city)
Symbol Symbol Name

Roll No First name Last name

Middle name

2
Types of Attributes

Single-valued Attribute Multi-valued Attribute


Has single value Has multiple (more than one) value
E.g. RollNo, CPI E.g. PhoneNo
(person may have multiple phone nos)
EmailID
(person may have multiple emails)
Symbol Symbol

Roll No Phone No

3
Types of Attributes

Stored Attribute Derived Attribute


It’s value is derived or calculated from
It’s value is stored manually in database
other attributes
E.g. Birthdate E.g. Age
(can be calculated using current date and
birthdate)
Symbol Symbol
Birthdate Age

4
Entity with all types of Attributes

Middle
Name
First Name Last Name
Single
Simple
Value
RollNo Name Composite Apartment
Derived Composite

Age Student Address Street

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

Student Issue Book

Branch Sem Author Price

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

Faculty Works Department

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.

customer borrow loan


A1 B1
C1 L1
A2 B2
C2 L2

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.

customer borrow loan


A1 B1
C1 L1
A2 B2
C2 L2

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.

customer borrow loan


A1 B1
C1 L1
A2 B2
C2 L2

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.

customer borrow loan


A1 B1
C1 L1
A2 B2
C2 L2

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

Partial participation Total participation


• some entities in the entity set may not participate in • every entity in the entity set participates in at least
any relationship in the relationship set. one relationship in the relationship set.
• indicated by single line • indicated by double line

customer borrow loan

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

loan-no amount payment-no Payment-amount

loan L_P payment

Strong Entity Weak Entity Weak Entity


Set Relationship Set

• Weak entity set is indicated by double rectangle.


• Weak entity relationship set is indicated by double diamond.

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

You might also like