0% found this document useful (0 votes)
14 views29 pages

Unit 2.3

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)
14 views29 pages

Unit 2.3

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/ 29

Section - 6

Superclass v/s Subclass


Super Class Sub Class
A superclass is an entity from which another A subclass is an entity that is derived from
entities can be derived. another entity.
E.g, E.g,
an entity account has two subsets saving_account and current_account entities
saving_account and current_account are derived from entity account.
So an account is superclass. So saving_account and current_account are
subclass.
Account Super Class

Saving_Account Current_Account

Sub Class
2
Section - 7
Generalization v/s Specialization
Generalization Specialization
It extracts the common features of multiple It splits an entity to form multiple new entities
entities to form a new entity. that inherit some feature of the splitting entity.
Name Address Name Address

SPI Salary
Person Person
Name Name
ISA
Address Address

Top-down approach
Bottom-up approach

Student Faculty Student Faculty

SPI Salary SPI Salary

4
Generalization v/s Specialization
Generalization Specialization
The process of creation of group from various The process of creation of sub-groups within
entities is called generalization. an entity is called specialization.
It is Bottom-up approach. It is Top-down approach.
The process of taking the union of two or more The process of taking a sub set of higher level
lower level entity sets to produce a higher level entity set to form a lower level entity set.
entity set.
It starts from the number of entity sets and It starts from a single entity set and creates
creates high level entity set using some different low level entity sets using some
common features. different features.

5
Generalization & Specialization example

Name Address

PID City
Person

ISA

Salary Employee Customer Balance

ISA

Full Time Part Time

Days Worked Hour Worked

6
Exercise
 Give the examples of Generalization/Specialization in the following E-R diagram:
 Hospital Management System.
 College Management System.
 Bank Management System.
 Insurance Company.

7
Section - 8
Constraints on Specialization and Generalization

Constraints

Disjoint Participation

Non-disjoint Total Partial


Disjoint
(Overlapping) (Mandatory) (Optional)

9
Disjoint Constraint
 It describes relationship between members of the superclass and subclass and indicates
whether member of a superclass can be a member of one, or more than one subclass.
 Types of disjoint constraints
 Disjoint Constraint
 Non-disjoint (Overlapping) Constraint

10
Disjoint Constraint
 It specifies that the entity of a super class can belong to only one lower-level entity set (sub
class).
 Specified by ‘d’ or by writing disjoint near to the ISA triangle.
Employee
Cricketer (Super class)
(Super class)

Disjoint
Batsman Bowler ISA
(Sub class) (Sub class)

Full-time Part-time
(Sub class) (Sub class)

All the players are associated with only one sub class either (Batsman or Bowler).

11
Non-disjoint (Overlapping) Constraint
 It specifies that an entity of a super class can belong to more than one lower-level entity set
(sub class).
 Specified by ‘o’ or by writing overlapping near to the ISA triangle.
Employee
Cricketer (Super class)
(Super class)

Non-disjoint
Batsman Bowler ISA
(Sub class) (Sub class)

Faculty Head
(Sub class) (Sub class)

One player (Yuvraj singh) is associated with more than one sub class.

12
Constraints on Specialization and Generalization

Constraints

Disjoint Participation

Non-disjoint Total Partial


Disjoint
(Overlapping) (Mandatory) (Optional)

13
Participation (Completeness) Constraint
 It determines whether every member of super class must participate as a member of subclass
or not.
 Types of participation (Completeness) Constraint
 Total (Mandatory) participation
 Partial (Optional) participation

14
Total (Mandatory) Participation
 Total participation specifies that every entity in the superclass must be a member of some
subclass in the specialization.
 Specified by a double line in E-R diagram.
Employee
Cricketer (Super class)
(Super class)

Batsman Bowler ISA


(Sub class) (Sub class)

Professor Head
(Sub class) (Sub class)

All the players are associated with minimum one sub class either (Batsman or Bowler).

15
Partial (Optional) Participation
 Partial participation specifies that every entity in the super class does not belong to any of the
subclass of specialization.
 Specified by a single line in E-R diagram.
Employee
Cricketer (Super class)
(Super class)

Batsman Not associated with Bowler ISA


(Sub class) any sub class (Sub class)

Professor Head
(Sub class) (Sub class)

16
Section - 9
Limitation of E-R diagram
 In E-R model we cannot express relationships between two relationships.

Relation 1 Relation Relation 2

Entity 1 Relation Entity 2

18
Limitation of E-R diagram

Customer
Company

Employee Works Department


Customer
Can not connect two relationship

Borrow Borrow

Loan Loan

Process of creating an entity by combining various components of


E-R diagram is called aggregation.

19
Section - 10
E-R diagram of Hospital Management System

MRID
PatID Name HosID Name

Medical Record Has Patient Admitted Hospital

Report Name ISA Has

Indoor Outdoor
Doctor
RoomNo
IPDID OPDID DrID Dr Name
Charge

21
Section - 11
Reduce the E-R diagram to database schema

Step 1: Reduce Entities and Simple Attributes:

 An entity of an ER diagram is turned into a table. PersonID Name

 Each attribute (except multi-valued attribute) turns into


a column (attribute) in the table. Person
 Table name can be same as entity name.
 Key attribute of the entity is the primary key of the Address City
table which is usually underlined.
PhoneNo
 It is highly recommended that every table should start
with its primary key attribute conventionally named as
TablenameID. Person (PersonID, Name, Address, City)

23
Reduce the E-R diagram to database schema

Step 2: Reduce Multi-valued Attributes: PersonID PhoneNo

 Multi-value attribute is turned into a new table.


Person
 Add the primary key column into multi-value
attribute’s table.
PhoneNo (PhoneID, PersonID, PhoneNo)
 Add the primary key column of the parent entity’s
table as a foreign key within the new (multi-value
Person (T1)
attribute’s) table. Foreign Key

 Then make a 1:N relationship between the Person


table and PhoneNo table. Having

PhoneNo (T2)

24
Reduce the E-R diagram to database schema
WifeID WName
Step 3: Reduce 1:1 Mapping Cardinality:

 Convert both entities in to table with proper attribute. Wife

 Place the primary key of any one table in to the


another table as a foreign key. Having

 Place the primary key of the Wife table WifeID in the


Person
table Persons as Foreign key.
OR
PersonID PName
 Place the primary key of the Person table PersonID in
the table Wife as Foreign key. Person (PersonID, PName)
Wife (WifeID, Wname, PersonID)

Wife (WifeID, Wname)


Person (PersonID, Pname, WifeID)

25
Reduce the E-R diagram to database schema
HouseID HName
Step 4: Reduce 1:N Mapping Cardinality:

 Convert both entities in to table with proper attribute. House

 Place the primary key of table having 1 mapping in to


the another table having many cardinality as a Foreign Having
key.
Person
 Place the primary key of the Person table PersonID in
the table House as Foreign key.
PersonID PName

Person (PersonID, PName)


House (HouseID, Hname, PersonID)

26
Reduce the E-R diagram to database schema
ActNo Balance
Step 5: Reduce N:N Mapping Cardinality:

 Convert both entities in to table with proper attribute. Account

 Create a separate table for relationship.


Has_Acct
 Place the primary key of both entities table into the
relationship’s table as foreign key.
Customer
 Place the primary key of the Customer table CID and
Account table Ano in the table Has_Acct as Foreign
CID CName
key.
Customer (CID, CName)
Account (ActNo, Balance)
Has_Acct (HasAcctID, CID, ActNo)

27
Summery of Symbols used in E-R diagram

Customer Name Hold


Entity Attribute Relationship

EmpID Age PhoneNo


Primary Key Derived Multi Valued
Attribute Attribute Attribute

Payment PymtID Issue

Weak Entity Discriminating Weak Entity


Attribute Relationship
Role
Name
E R E R ISA

Total Role Specialization/


Participation Indicator Generalization

28
Summery of Symbols used in E-R diagram

Disjoint
E R E ISA ISA
One to One Total Disjoint
Specialization/ Specialization/
E R E Generalization Generalization
One to Many

E R E Overlapping

Many to One ISA ISA


Partial Overlapping
E R E
Specialization/ Specialization/
Many to Many Generalization Generalization

29

You might also like