SlideShare a Scribd company logo
Unit-2
DataModels

Outline
• Basic concept of E-R diagram
• Types of Attributes
• Mapping Cardinality
• Weak Entity Sets
• Extended E-R features
• Generalization and Specialization
• Constraints on Specialization and
Generalization
• Aggregation
• E-R diagram of Hospital Management
System
• Reduction to E-R Database Schema
• Database Models
• Integrity Constraints
Section -
1
Basicconcepts
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
4
What is Database Design?
Database Design is a collection of processes that facilitate the designing, development,
implementation and
maintenanceof enterprise database management systems.
What is E-R diagram?
E-R diagram: (Entity-Relationship diagram)
It is graphical (pictorial) representationofdatabase.
It uses different types of symbols to represent different objects ofdatabase.
Entity
#310703 (DBMS) UNIT 2 – DATA
MODELS
An entity is a person,a place or anobject.
An entity is represented by a rectangle which contains the name of
an entity.
Entities of a college database are:
Student
Professor/Faculty
Course
Department
Result
Class
Subject
Entity Name
Symb
ol
Student Faculty Course
Exercise Write down the different entities of bank
database.
Exercise Write down the different entities of hospital
database.
5
EntitySet
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
It is a set (group) of entities of same
type.
Examples:
All persons having an account in a bank
All the students studying in a college
All the professors working in a college
Set of all accounts in a bank
6
Attributes
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
Attribute is propertiesor details about an entity.
An attribute is represented by an oval containing name of an
attribute.
Attributes of Student are:
Roll No
Student
Name
Branch
Semester
Address
Mobile No
Age
SPI
Backlogs
Symb
ol
Attribut
e
Name
Student
RollN
o
Nam
e
Exercise Write down the different attributes of Faculty
entity.
Exercise Write down the different attributes of Account
entity.
7
Relationship
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
Relationship is an association (connection) between several entities.
It should be placed between two entities and a line connecting it to
an entity.
A relationship is represented by a diamondcontaining relationship's
name.
Relationsh
ip Name
Symbol
Student Book
Issu
e
8
E-RDiagramofaLibrarySystem
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
Student Book
Issu
e
RollN
o
Nam
e
Branc
h
Se
m
BookN
o
Nam
e
Autho
r
Pric
e
Primary
Key
Primary
Key
Entitie
s
Attributes
Relationsh
ip
Each and every entity must have one primary key
attribute. Relationship between 2 entities is called
binary relationship.
9
TernaryRelationship
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
Faculty Student
Guid
e
FacI
D
Nam
e
Branc
h
Technolog
y
RollN
o
Nam
e
Branc
h
Se
m
Project
P
rojectID
Project
Name
Relationship between 3 entities is called ternary
relationship.
10
Exercise
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
11
Draw an E-R diagram of following pair of entities
Customer &Account
Customer & Loan
Doctor & Patient
Student & Project
Student & Teacher
Note: Take four attributes per entity with one primary key
attribute.
Keep proper relationship between two entities.
Section -
2
TypesofAttributes
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 13
SimpleAttribute CompositeAttribute
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
Roll No
Symbo
l
First
name
Name
Middle
name
Last name
TypesofAttributes
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 14
Single-valuedAttribute Multi-valuedAttribute
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
Roll No
Symbol
Phone No
TypesofAttributes
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 15
StoredAttribute DerivedAttribute
It’s value is stored manually in
database
It’s value is derived or calculated
from other attributes
E.g. Birthdate E.g. Age
(can be calculated using current date
and birthdate)
Symbol
Birthdate
Symbol
Age
EntitywithalltypesofAttributes
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 16
Stude
nt
RollN
o
Nam
e
Phone
No
Birth
Date
First
Name
Last
Name
Middl
e
Nam
e
Addres
s
Ag
e
Apartme
nt
Are
a
Stree
t
Composite
Composit
e
Singl
e
SVima
lp
u
l
e
e
Multipl
e
Value
Store
d
Derive
d
Exercise
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 17
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 twoentities
Use all types of attributes
DescriptiveAttribute
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 18
Student Book
Issu
e
RollN
o
Nam
e
Branc
h
Se
m
BookN
o
Nam
e
Autho
r
Pric
e
Issu
e
Dat
e
Attributes of therelationship is called descriptive
attribute.
Descriptiv
e
Attribute
Role
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 19
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.
EmpI
D
Nam
e
Branc
h
Experien
ce
Faculty
Coordinat
o
Head
r
Reports_
To
RecursiveRelationshipSet
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
The same entityparticipatesin a relationship set morethanoncethen it is called recursive
relationship set.
Facult
y
Departme
nt
Work
s
Pos
t
FacID
DeptI
D
FName
DNam
e
Recursive
Relationsh
ip Set
Prof.
FName Post
Ajay Professor
Haresh Professor
Ramesh HOD
DName
Computer
Civil
Mechanical
20
Section -
3
MappingCardinality(CardinalityConstraints)
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 22
It represents the numberof entities of anotherentityset which are connectedtoan entity
using a relationship set.
It is most useful in describing binaryrelationshipsets.
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
One-to-Onerelationship(1– 1)
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 23
An entity in A is associated withonly oneentityin B and an entity in B is associated with
only oneentityinA.
Example: A customer is connected with only one loan using the relationship borrower
and a
loan is connected withonly onecustomerusing borrower.
A
1
A
2
B
1
B
2
A B
loan
customer
borro
w
C1
C
2
L
1
L
2
C
3
L
3
One-to-Manyrelationship(1– N)
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 24
An entity in A is associated withmorethanoneentities in B and an entity in B is associated
withonly oneentityin A.
A
1
A
2
B
1
B
2
A B
loan
customer
borro
w
C1
C
2
L
1
L
2
C
3
L
3
L4
Example: A loan is connected withonly onecustomerusing borrower and a customeris
connected withmorethanoneloans using borrower.
Many-to-Onerelationship(N– 1)
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 25
An entity in A is associated withonlyoneentityin B and an entity in B is associated with
more thanoneentities inA.
A
1
A
2
B
1
B
2
A B
loan
customer
borro
w
C1
C
2
L
1
L
2
C
3
L
3
C4
Example: A loan is connected withmorethanonecustomerusing borrower and a customer
is connected withonly oneloan using borrower.
Many-to-Manyrelationship(N– N)
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 26
An entity in A is associated withmorethanoneentities in B and an entity in B is associated
withmorethanoneentities in A.
Example: A customer is connected withmorethanoneloan using borrower and a loan is
connected withmorethanonecustomerusing borrower.
A
1
A
2
B
1
B
2
A B
loan
customer
borro
w
C1
C
2
L
1
L
2
C
3
L
3
C
4
L
4
MappingCardinality(CardinalityConstraints)[Exercise]
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 27
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 onestudent.
A student can issue more than one book but a book is issued to only onestudent.
A subject is taught by more than one faculty and a faculty can teach more than one subject.
Section -
4
• every entity in the entity set participates in at
least one relationship in the relationship set.
• indicated by double line
• some entities in the entity set may not
participate in any relationship in the
relationship set.
• indicated by single line
It specifies the participation of an entityset in a relationship
set.
There are two types participation constraints
Total participation
Partial participation
Partial participation Total participation
ParticipationConstraints
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
customer loan
borro
w
C
1
C
2
L
1
L
2
C
3
Each customer
has maximum
one loan
29
Section -
5
WeakEntitySet
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
loan payment
loan-
no
amoun
t
payment-
no
An entityset thatdoes nothavea primarykeyis called weak entity
set.
Payment-date
L_
P
Payment-
amount
Strong
Entity
Set
Weak
Entity
Set
Weak
Entity
Relationsh
ip
• Weak entity set is indicated by double rectangle.
• Weak entity relationship set is indicated by double
diamond.
31
WeakEntitySet
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
32
The existence of a weakentityset depends on the existence of a strong entityset.
The discriminator (partial key) of a weak entity set is the set of attributes that
distinguishes all theentities 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).
Section -
6
Superclassv/sSubclass
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
Super Class Sub Class
A superclass is an entity from which
another entities can bederived.
A subclass is an entity that is derived
from anotherentity.
E.g,
an entity account has two
subsets saving_account and
current_account So an account
is superclass.
E.g,
saving_account and current_account
entities are derived from entity
account.
So saving_account andcurrent_accountare
subclass.
Account
Saving_Account
Current_Accou
nt
Super
Class
Sub
Class
34
Section -
7
Generalizationv/sSpecialization
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 36
Bottom-up
approach
Generalization Specialization
It extracts thecommonfeatures of multiple
entities to forma newentity.
It splits anentitytoform multiple newentities
that inheritsome featureof thesplitting entity.
Name Address
Person
Name Name
Address
ISA
Address
Student Faculty
SPI Salary
Name Address
SPI Salary
Person
ISA
Student Faculty
SPI Salary
Generalizationv/sSpecialization
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 37
Generalization Specialization
The process of creationof group from
various entities is called generalization.
The process of creationof sub-groups
within anentityis called specialization.
It is Bottom-upapproach. It is T
op-downapproach.
The process of taking the union of two or
more lower level entity sets to produce a
higher level entity set.
The process of taking a sub set of higher
level entityset to form a lower level entity
set.
It starts from the number of entity sets
and creates high level entity set using
some common features.
It starts from a single entity set and
creates different low level entity sets
using some different features.
Generalization&Specializationexample
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 38
Employee Customer
Person
Nam
e
Addres
s
PI
D
Cit
y
Salar
y
Balanc
e
IS
A
Full Time Part Time
Days
Worked
Hour
Worked
IS
A
Exercise
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 39
Give the examples of Generalization/Specialization in the following E-R
diagram:
Hospital Management System.
College Management System.
Bank Management System.
Insurance Company.
Section -
8
ConstraintsonSpecializationandGeneralization
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
Constraint
s
Disjoin
t
Participatio
n
Disjoin
t
Non-
disjoint
(Overlappin
g)
Total
(Mandator
y)
Partial
(Optiona
l)
41
DisjointConstraint
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 42
It describes relationship betweenmembers of thesuperclass andsubclass 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
DisjointConstraint
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 43
It specifies that the entityof a super class can belong to onlyonelower-levelentityset (sub
class).
Specified by ‘d’ or by writing disjoint near to the ISA
triangle. Cricketer
(Super
class)
Batsman
(Sub
class)
Bowler
(Sub
class)
All the players are associated with only one sub class either (Batsman or
Bowler).
Employee
(Super class)
Full-time
(Sub class)
Part-time
(Sub class)
IS
A
Disjoin
t
Non-disjoint(Overlapping)Constraint
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 44
It specifies that an entityof a super class can belong to morethanonelower-levelentityset
(sub class).
Specified by ‘o’ or by writing overlapping near to the ISA
triangle. Cricketer
(Super
class)
Batsman
(Sub
class)
Bowler
(Sub
class)
One player (Yuvraj singh) is associated with more than one sub
class.
Employee
(Super class)
Faculty
(Sub class)
Head
(Sub class)
IS
A
Non-
disjoint
ConstraintsonSpecializationandGeneralization
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 45
Constraint
s
Disjoin
t
Participatio
n
Disjoin
t
Non-
disjoint
(Overlappin
g)
Total
(Mandator
y)
Partial
(Optiona
l)
Participation(Completeness)Constraint
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 46
It determines whethereverymemberof super class must participateas a memberof
subclass ornot.
Types of participation (Completeness) Constraint
Total (Mandatory) participation
Partial (Optional) participation
Total(Mandatory)Participation
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 47
Total participation specifies that everyentityin thesuperclass must bea memberof some
subclass in the specialization.
Specified by a double line in E-R
diagram.
Cricketer
(Super
class)
Batsman
(Sub
class)
Bowler
(Sub
class)
All the players are associated with minimum one sub class either (Batsman or
Bowler).
Employee
(Super class)
Professor
(Sub class)
Head
(Sub class)
IS
A
Partial(Optional)Participation
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 48
Partial participation specifies that everyentityin thesuper class does notbelong to anyof
the subclass of specialization.
Specified by a single line in E-R
diagram.
Cricketer
(Super
class)
Batsman
(Sub
class)
Bowler
(Sub
class)
Employee
(Super class)
Professor
(Sub class)
Head
(Sub class)
IS
A
Not associated
with any sub
class
Section -
9
LimitationofE-Rdiagram
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
In E-R model we cannotexpress relationships betweentwo
relationships.
Relatio
n
Relatio
n
Relatio
n
Relatio
n
Entity 1 Entity 2
50
LimitationofE-Rdiagram
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
Employee Department
Work
s
Borro
w
Loan
Can not connect two
relationship
Borro
w
Loan
Customer
Custom
er
Company
Process of creating an entity by combining various
components of E-R diagram is called
aggregation.
51
Section -
10
E-RdiagramofHospitalManagementSystem
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
Patien
t
53
Hospit
al
Admitte
d
PatI
D
Nam
e
HosI
D
Nam
e
Ha
s
Medical
Record
MRI
D
Ha
s
Docto
r
DrI
D
Dr
Name
Report
Name
IS
A
Indoo
r
Outdo
or
IPDI
D
OPDI
D
RoomN
o
Charg
e
Section -
11
ReducetheE-Rdiagramtodatabaseschema
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 55
An entityof an ER diagram is turnedinto a table.
Each attribute(except multi-valued attribute) turns
into
a column(attribute) in the table.
Table namecan be same as entity name.
Key attribute of the entity is the primary key of the
table which is usually underlined.
It is highly recommended that every table should
start with its primary key attribute conventionally
named as TablenameID.
Person
PersonI
D
Nam
e
Addres
s
Cit
y
PhoneN
o
Person (PersonID, Name, Address,
City)
Step 1: Reduce Entities and SimpleAttributes:
ReducetheE-Rdiagramtodatabaseschema
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 56
Multi-value attribute is turned into a newtable.
Add the primary key column into multi-value
attribute’stable.
Add the primary key column of the parent entity’s
table as a foreign key within the new (multi-value
attribute’s)table.
Then make a 1:N relationship between the Person
table and PhoneNo table.
Step 2: Reduce Multi-valuedAttributes:
Person
P
ersonID
PhoneN
o
Havin
g
PhoneNo (T2)
Person
(T1)
PhoneNo (PhoneID, PersonID,
PhoneNo)
Foreign Key
ReducetheE-Rdiagramtodatabaseschema
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 57
Convert bothentities in to tablewith proper
attribute.
Placethe primary key of any one table in to
the
anothertable as a foreign key.
Place the primary key of the Wife table WifeID in
the table Persons as Foreign key.
OR
Place the primary key of the Person table
PersonID in the table Wife as Foreign key.
Step 3: Reduce 1:1Mapping Cardinality:
Wife
WifeI
D
WNam
e
Person
PersonID
PNam
e
Havin
g
Person (PersonID,
PName)
Wife (WifeID, Wname,
PersonID)
Wife (WifeID, Wname)
Person (
P ersonID, Pname,
WifeID)
ReducetheE-Rdiagramtodatabaseschema
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 58
Convert bothentities in to tablewith proper
attribute.
Place the primary key of table having 1 mapping in
to the another table having many cardinality as a
Foreign key.
Place the primary key of the Person table
PersonID in the table House as Foreign key.
Step 4: Reduce 1:NMapping Cardinality:
House
HouseI
D
HNam
e
Person
Havin
g
PersonID PName
Person (PersonID, PName)
House (HouseID, Hname,
PersonID)
ReducetheE-Rdiagramtodatabaseschema
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 59
Convert both entities in to tablewith proper
attribute.
Create a separate tableforrelationship.
Place the primarykeyof bothentities table into the
relationship’s tableas foreignkey.
Place the primary key of the Customer table CID
and Account table Ano in the table Has_Acct as
Foreign key.
Step 5: Reduce N:N MappingCardinality:
Account
ActN
o
Balanc
e
Customer
Has_Ac
ct
CID CName
Customer ( CID,
CName) Account (
A
ctNo, Balance)
Has_Acct (HasAcctID, CID, ActNo)
SummeryofSymbolsusedinE-Rdiagram
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
Customer
Entit
y
EmpID
Primary
Key
Attribute
Payment
Weak
Entity
Total
Participatio
n
Name
Attribut
e
Age
Derived
Attribut
e
Hold
Relationsh
ip
PhoneN
o
Multi
Valued
Attribute
Issue
Weak
Entity
Relationsh
ip
IS
A
Specializatio
n/
Generalizati
on
R
E
Role
Indicato
r
R
E
PymtID
Discriminatin
g Attribute
Role
Nam
e
60
SummeryofSymbolsusedinE-Rdiagram
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
R
One to
One
E E
One to
Many
R
E E
Many to
One
R
E E
Many to
Many
R
E E
ISA
Total
Specializatio
n/
Generalizatio
n
Disjoint
ISA
Disjoint
Specializatio
n/
Generalizatio
n
Overlappin
g
ISA
Overlapping
Specializatio
n/
Generalizatio
n
ISA
Partial
Specializatio
n/
Generalizatio
n
61
Section -
12
Whatis aDatabaseModels?
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 63
A database model is a type of data model that defines thelogical structure of a
database.
It determine how datacan bestored, accessed andupdatedin a database management
system.
The most popular example of a database model is the relational model, which uses a
table- based format.
TypeofDatabaseModels
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 64
Hierarchical Model
Network Model
Entity-relationship
Model Relational
Model
Object-oriented database
Model
HierarchicalModel
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 65
The hierarchical model organizes data into a tree-like structure,where each record has a
single parentorroot.
Department
Student Professor
The hierarchy starts from the Root data, and expands like a tree, adding child nodes to the
parentnodes.
In hierarchical model, data is organized into tree-like structure with one-to-many
relationship between two different types of data, for example, one department can have
manyprofessors and manystudents.
NetworkModel
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 66
This is an extensionof thehierarchical model,allowing many-to-manyrelationships in a
tree- like structure that allows multipleparents.
A
B C
D E F
Entity-relationshipModel
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 67
In this database model, relationships are created by dividing object of interest into entity
and
its characteristics intoattributes.
Student Book
Issu
e
RollN
o
Nam
e
Branc
h
Se
m
B
ookNo
Nam
e
Autho
r
Pric
e
Entitie
s
Attributes
Relationsh
ip
RelationalModel
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 68
In this model, data is organized in two-dimensionaltables and the relationship is
maintained bystoring a commonattribute.
ResID Rno SubID Marks
1 101 1 80
2 101 2 85
3 102 1 75
4 102 2 80
SubID Subject_Name Teacher
1 DBMS Doshi
2 DS Vyash
Foreign
Key
Rno Student_Name Age
101 Raj Patel 20
102 Meet Shah 21
Foreign Key
Object-orienteddatabaseModel
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 69
This data model is another method of representing real world objects.
It considers each objectin theworldas objects and isolates it from each other.
It groups its relatedfunctionalities togetherand allows inheriting its functionality to other
related sub-groups.
Section -
13
IntegrityConstraints
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS
71
Integrity constraints are a set of rules. It is used to maintain thequalityof information.
Integrity constraints ensure that the data insertion, updating, and other processes
have to be performed in such a way that data integrity is not affected.
Thus, integrity constraint is used to guard against accidental damage to the database.
Various Integrity Constraints are:
Check
Not null
Unique
Primary key
Foreign key
IntegrityConstraints
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 72
Check
This constraint defines a business rule on a column. All the rows in that column must satisfy this
rule.
Limits the data values of variables to a specific set, range,orlist ofvalues.
The constraint can be applied for a single column or a group ofcolumns.
E.g. value of SPI should be between 0 to10.
Not null
This constraint ensures all rows in the table contain a definite value for the column which is
specified as not null. Which means a null valueis not allowed.
E.g. name column should have some value.
Unique
This constraint ensures that a column or a group of columns in each row have a distinct (unique)
value.
A column(s) can have a null value but the values cannot beduplicated.
E.g. enrollmentno column should have uniquevalue.
IntegrityConstraints
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 73
Primary key
This constraint defines a column or combination of columns which uniquely identifies each row in
the table.
Primary key = Uniquekey+Not null
E.g. enrollmentno column should have unique value as well as can’t benull.
Foreign key (referential integrity constraint)
A referential integrity constraint (foreign key) is specified between twotables.
In the referential integrity constraints, if a foreign key column in table 1 refers to the primary key
column of table 2, then every value of the foreign key column in table 1 must be null or be
available in primary key column of table 2.
RollNo Student_Name DeptID
101 Raj Patel 1
102 Meet Shah 2
Foreign Key
DeptID Dept_Name HOD
1 Computer Doshi
2 IT Vyash
iQuestions
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 74
1. Write a note on mapping cardinality in E-R diagram.
2. Explain the difference between a weak and a strong entity set.
3. Explain the difference between generalization and specialization. OR Explain
specialization and generalization concept in E-R diagram with suitable example.
4. Write a note on constraints on specialization and generalization.
5. Explain aggregation in E-R diagram with example.
6. What do you mean by integrity constraints? Discuss various integrity constraints.
Questionsasked[E-Rdiagrams]
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 75
7. Draw E-R diagram for Bank Management System.
8. Define E-R diagram. Draw an E-R diagram for Library Management System.
Assume relevant entities and attributes for the given system.
9. Construct an E-R diagram for a car-insurance company whose customers own one
or more cars each. Each car has associated with it zero to any number of recorded
accidents.
10.Design a generalization–specialization hierarchy for a motor-vehicle sales company.
The company sells motorcycles, passenger cars, vans, and buses. Justify your
placement of attributes at each level of the hierarchy. Explain why they should not
be placed at a higher or lower level.
Questions[E-RdiagramsandDatabase]
Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 76
11.Design a database for an airline. The database must keep track of customers and
their reservations, flights and their status, seat assignments on individual flights,
and the schedule and routing of future flights. Your design should include an E-R
diagram, a set of relational schemas, and a list of constraints, including primary-key
and foreign-key constraints.
12.Design a database for a hospital with a set of patients and a set of medical doctors.
Associate with each patient a log of the various tests and examinations conducted.
Your design should include an E-R diagram, a set of relational schemas, and a list
of constraints, including primary-key and foreign-key constraints.
Than
k
You
DatabaseManagementSystems(DBMS)
GTU # 3130703

More Related Content

What's hot

3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) modelKumar
 
chapter 3-Data Modelling using Entity Relationship .pdf
chapter 3-Data Modelling using Entity Relationship .pdfchapter 3-Data Modelling using Entity Relationship .pdf
chapter 3-Data Modelling using Entity Relationship .pdf
MisganawAbeje1
 
Extended ER Model and other Modelling Languages - Lecture 2 - Introduction to...
Extended ER Model and other Modelling Languages - Lecture 2 - Introduction to...Extended ER Model and other Modelling Languages - Lecture 2 - Introduction to...
Extended ER Model and other Modelling Languages - Lecture 2 - Introduction to...
Beat Signer
 
Relationship Types of degree higher than 2
Relationship Types of degree higher than 2Relationship Types of degree higher than 2
Relationship Types of degree higher than 2
Aadesh Shrestha
 
object oriented methodologies
object oriented methodologiesobject oriented methodologies
object oriented methodologies
Amith Tiwari
 
Mapping Cardinalities
Mapping CardinalitiesMapping Cardinalities
Mapping Cardinalities
Megha Sharma
 
Entity (types, attibute types)
Entity (types, attibute types)Entity (types, attibute types)
Entity (types, attibute types)
Zaheer Soomro
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
madhav bansal
 
Uml Presentation
Uml PresentationUml Presentation
Uml Presentation
anasz3z3
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
adeel hamid
 
Object diagram
Object diagramObject diagram
Object diagram
Preeti Mishra
 
Chapter-4 Enhanced ER Model
Chapter-4 Enhanced ER ModelChapter-4 Enhanced ER Model
Chapter-4 Enhanced ER Model
Kunal Anand
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship ModelSlideshare
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
Dashani Rajapaksha
 
Uml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot netUml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot net
mekhap
 
Class diagram presentation
Class diagram presentationClass diagram presentation
Class diagram presentation
SayedFarhan110
 
Unified modelling language (UML)
Unified modelling language (UML)Unified modelling language (UML)
Unified modelling language (UML)
Hirra Sultan
 
Dbms anomalies
Dbms anomaliesDbms anomalies
Dbms anomalies
Zaheer Soomro
 
Deployment Diagram
Deployment DiagramDeployment Diagram
Deployment Diagram
University of Texas at Dallas
 

What's hot (20)

3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model
 
chapter 3-Data Modelling using Entity Relationship .pdf
chapter 3-Data Modelling using Entity Relationship .pdfchapter 3-Data Modelling using Entity Relationship .pdf
chapter 3-Data Modelling using Entity Relationship .pdf
 
Extended ER Model and other Modelling Languages - Lecture 2 - Introduction to...
Extended ER Model and other Modelling Languages - Lecture 2 - Introduction to...Extended ER Model and other Modelling Languages - Lecture 2 - Introduction to...
Extended ER Model and other Modelling Languages - Lecture 2 - Introduction to...
 
Relationship Types of degree higher than 2
Relationship Types of degree higher than 2Relationship Types of degree higher than 2
Relationship Types of degree higher than 2
 
object oriented methodologies
object oriented methodologiesobject oriented methodologies
object oriented methodologies
 
Mapping Cardinalities
Mapping CardinalitiesMapping Cardinalities
Mapping Cardinalities
 
Entity (types, attibute types)
Entity (types, attibute types)Entity (types, attibute types)
Entity (types, attibute types)
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Uml Presentation
Uml PresentationUml Presentation
Uml Presentation
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Object diagram
Object diagramObject diagram
Object diagram
 
Chapter-4 Enhanced ER Model
Chapter-4 Enhanced ER ModelChapter-4 Enhanced ER Model
Chapter-4 Enhanced ER Model
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Uml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot netUml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot net
 
Class diagram presentation
Class diagram presentationClass diagram presentation
Class diagram presentation
 
Unified modelling language (UML)
Unified modelling language (UML)Unified modelling language (UML)
Unified modelling language (UML)
 
Dbms anomalies
Dbms anomaliesDbms anomalies
Dbms anomalies
 
Deployment Diagram
Deployment DiagramDeployment Diagram
Deployment Diagram
 

Similar to Datamodels.pptx

Er diagrams
Er diagramsEr diagrams
Er diagrams
VisnuDharsini
 
Unit-1-DBMS-SUN-4 everything you need to know.pptx
Unit-1-DBMS-SUN-4 everything you need to know.pptxUnit-1-DBMS-SUN-4 everything you need to know.pptx
Unit-1-DBMS-SUN-4 everything you need to know.pptx
nirajsharmapuneiat
 
Data Models
Data ModelsData Models
Data Models
RIAH ENCARNACION
 
Data Models & Introduction to UML
Data Models & Introduction to UML Data Models & Introduction to UML
Data Models & Introduction to UML
نبيله نواز
 
Db lec 01
Db lec 01Db lec 01
ER model
ER modelER model
ER model
ShilpaDe
 
Database Design and the ER Model, Indexing and Hashing
Database Design and the ER Model, Indexing and HashingDatabase Design and the ER Model, Indexing and Hashing
Database Design and the ER Model, Indexing and Hashing
Prabu U
 
Unit1 rdbms study_materials
Unit1 rdbms study_materialsUnit1 rdbms study_materials
Unit1 rdbms study_materials
gayaramesh
 
Unit1 rdbms study_materials-converted (1) (1)
Unit1 rdbms study_materials-converted (1) (1)Unit1 rdbms study_materials-converted (1) (1)
Unit1 rdbms study_materials-converted (1) (1)
gayaramesh
 
ER MODEL
ER MODELER MODEL
ER MODEL
Rupali Rana
 
DBMS Part-2.pptx
DBMS Part-2.pptxDBMS Part-2.pptx
DBMS Part-2.pptx
Prof. Dr. K. Adisesha
 
Conceptual Data Modelling Using ER-models
Conceptual Data Modelling Using ER-modelsConceptual Data Modelling Using ER-models
Conceptual Data Modelling Using ER-models
Shailaja Jayaprakash
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
Kabindra Koirala
 
U2_ER_modeling.pptx
U2_ER_modeling.pptxU2_ER_modeling.pptx
U2_ER_modeling.pptx
ssusera7b660
 
Special lecture er diagram
Special lecture er diagramSpecial lecture er diagram
Special lecture er diagram
Niaz Ali
 
DBMS_Data Model,Keys,Attributes,Relationship.pptx
DBMS_Data Model,Keys,Attributes,Relationship.pptxDBMS_Data Model,Keys,Attributes,Relationship.pptx
DBMS_Data Model,Keys,Attributes,Relationship.pptx
DrThenmozhiKarunanit
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
Rakhi Mukherji
 
Chapter 2. Concepctual design -.pptx
Chapter 2. Concepctual design -.pptxChapter 2. Concepctual design -.pptx
Chapter 2. Concepctual design -.pptx
santosh96234
 

Similar to Datamodels.pptx (20)

Database model
Database modelDatabase model
Database model
 
Er diagrams
Er diagramsEr diagrams
Er diagrams
 
Unit-1-DBMS-SUN-4 everything you need to know.pptx
Unit-1-DBMS-SUN-4 everything you need to know.pptxUnit-1-DBMS-SUN-4 everything you need to know.pptx
Unit-1-DBMS-SUN-4 everything you need to know.pptx
 
Data Models
Data ModelsData Models
Data Models
 
Data Models & Introduction to UML
Data Models & Introduction to UML Data Models & Introduction to UML
Data Models & Introduction to UML
 
Db lec 01
Db lec 01Db lec 01
Db lec 01
 
ER model
ER modelER model
ER model
 
Database Design and the ER Model, Indexing and Hashing
Database Design and the ER Model, Indexing and HashingDatabase Design and the ER Model, Indexing and Hashing
Database Design and the ER Model, Indexing and Hashing
 
Unit1 rdbms study_materials
Unit1 rdbms study_materialsUnit1 rdbms study_materials
Unit1 rdbms study_materials
 
Unit1 rdbms study_materials-converted (1) (1)
Unit1 rdbms study_materials-converted (1) (1)Unit1 rdbms study_materials-converted (1) (1)
Unit1 rdbms study_materials-converted (1) (1)
 
ER MODEL
ER MODELER MODEL
ER MODEL
 
DBMS Part-2.pptx
DBMS Part-2.pptxDBMS Part-2.pptx
DBMS Part-2.pptx
 
Conceptual Data Modelling Using ER-models
Conceptual Data Modelling Using ER-modelsConceptual Data Modelling Using ER-models
Conceptual Data Modelling Using ER-models
 
Unit02 dbms
Unit02 dbmsUnit02 dbms
Unit02 dbms
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
U2_ER_modeling.pptx
U2_ER_modeling.pptxU2_ER_modeling.pptx
U2_ER_modeling.pptx
 
Special lecture er diagram
Special lecture er diagramSpecial lecture er diagram
Special lecture er diagram
 
DBMS_Data Model,Keys,Attributes,Relationship.pptx
DBMS_Data Model,Keys,Attributes,Relationship.pptxDBMS_Data Model,Keys,Attributes,Relationship.pptx
DBMS_Data Model,Keys,Attributes,Relationship.pptx
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Chapter 2. Concepctual design -.pptx
Chapter 2. Concepctual design -.pptxChapter 2. Concepctual design -.pptx
Chapter 2. Concepctual design -.pptx
 

More from Ramya Nellutla

artificial Intelligence unit1 ppt (1).ppt
artificial Intelligence unit1 ppt (1).pptartificial Intelligence unit1 ppt (1).ppt
artificial Intelligence unit1 ppt (1).ppt
Ramya Nellutla
 
Deep network notes.pdf
Deep network notes.pdfDeep network notes.pdf
Deep network notes.pdf
Ramya Nellutla
 
pentration testing.pdf
pentration testing.pdfpentration testing.pdf
pentration testing.pdf
Ramya Nellutla
 
Deep Learning.pptx
Deep Learning.pptxDeep Learning.pptx
Deep Learning.pptx
Ramya Nellutla
 
Unit-I PPT.pdf
Unit-I PPT.pdfUnit-I PPT.pdf
Unit-I PPT.pdf
Ramya Nellutla
 
- Social Engineering Unit- II Part- I.pdf
- Social Engineering Unit- II Part- I.pdf- Social Engineering Unit- II Part- I.pdf
- Social Engineering Unit- II Part- I.pdf
Ramya Nellutla
 
Unit-3-Part-1 [Autosaved].ppt
Unit-3-Part-1 [Autosaved].pptUnit-3-Part-1 [Autosaved].ppt
Unit-3-Part-1 [Autosaved].ppt
Ramya Nellutla
 
E5-roughsets unit-V.pdf
E5-roughsets unit-V.pdfE5-roughsets unit-V.pdf
E5-roughsets unit-V.pdf
Ramya Nellutla
 
Unit-3.pptx
Unit-3.pptxUnit-3.pptx
Unit-3.pptx
Ramya Nellutla
 
Unit-II -Soft Computing.pdf
Unit-II -Soft Computing.pdfUnit-II -Soft Computing.pdf
Unit-II -Soft Computing.pdf
Ramya Nellutla
 
SC01_IntroductionSC-Unit-I.ppt
SC01_IntroductionSC-Unit-I.pptSC01_IntroductionSC-Unit-I.ppt
SC01_IntroductionSC-Unit-I.ppt
Ramya Nellutla
 
- Fuzzy Systems -II.pptx
- Fuzzy Systems -II.pptx- Fuzzy Systems -II.pptx
- Fuzzy Systems -II.pptx
Ramya Nellutla
 

More from Ramya Nellutla (12)

artificial Intelligence unit1 ppt (1).ppt
artificial Intelligence unit1 ppt (1).pptartificial Intelligence unit1 ppt (1).ppt
artificial Intelligence unit1 ppt (1).ppt
 
Deep network notes.pdf
Deep network notes.pdfDeep network notes.pdf
Deep network notes.pdf
 
pentration testing.pdf
pentration testing.pdfpentration testing.pdf
pentration testing.pdf
 
Deep Learning.pptx
Deep Learning.pptxDeep Learning.pptx
Deep Learning.pptx
 
Unit-I PPT.pdf
Unit-I PPT.pdfUnit-I PPT.pdf
Unit-I PPT.pdf
 
- Social Engineering Unit- II Part- I.pdf
- Social Engineering Unit- II Part- I.pdf- Social Engineering Unit- II Part- I.pdf
- Social Engineering Unit- II Part- I.pdf
 
Unit-3-Part-1 [Autosaved].ppt
Unit-3-Part-1 [Autosaved].pptUnit-3-Part-1 [Autosaved].ppt
Unit-3-Part-1 [Autosaved].ppt
 
E5-roughsets unit-V.pdf
E5-roughsets unit-V.pdfE5-roughsets unit-V.pdf
E5-roughsets unit-V.pdf
 
Unit-3.pptx
Unit-3.pptxUnit-3.pptx
Unit-3.pptx
 
Unit-II -Soft Computing.pdf
Unit-II -Soft Computing.pdfUnit-II -Soft Computing.pdf
Unit-II -Soft Computing.pdf
 
SC01_IntroductionSC-Unit-I.ppt
SC01_IntroductionSC-Unit-I.pptSC01_IntroductionSC-Unit-I.ppt
SC01_IntroductionSC-Unit-I.ppt
 
- Fuzzy Systems -II.pptx
- Fuzzy Systems -II.pptx- Fuzzy Systems -II.pptx
- Fuzzy Systems -II.pptx
 

Recently uploaded

KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
zwunae
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
itech2017
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 

Recently uploaded (20)

KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 

Datamodels.pptx

  • 2.  Outline • Basic concept of E-R diagram • Types of Attributes • Mapping Cardinality • Weak Entity Sets • Extended E-R features • Generalization and Specialization • Constraints on Specialization and Generalization • Aggregation • E-R diagram of Hospital Management System • Reduction to E-R Database Schema • Database Models • Integrity Constraints
  • 4. Basicconcepts Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 4 What is Database Design? Database Design is a collection of processes that facilitate the designing, development, implementation and maintenanceof enterprise database management systems. What is E-R diagram? E-R diagram: (Entity-Relationship diagram) It is graphical (pictorial) representationofdatabase. It uses different types of symbols to represent different objects ofdatabase.
  • 5. Entity #310703 (DBMS) UNIT 2 – DATA MODELS An entity is a person,a place or anobject. An entity is represented by a rectangle which contains the name of an entity. Entities of a college database are: Student Professor/Faculty Course Department Result Class Subject Entity Name Symb ol Student Faculty Course Exercise Write down the different entities of bank database. Exercise Write down the different entities of hospital database. 5
  • 6. EntitySet Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS It is a set (group) of entities of same type. Examples: All persons having an account in a bank All the students studying in a college All the professors working in a college Set of all accounts in a bank 6
  • 7. Attributes Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS Attribute is propertiesor details about an entity. An attribute is represented by an oval containing name of an attribute. Attributes of Student are: Roll No Student Name Branch Semester Address Mobile No Age SPI Backlogs Symb ol Attribut e Name Student RollN o Nam e Exercise Write down the different attributes of Faculty entity. Exercise Write down the different attributes of Account entity. 7
  • 8. Relationship Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS Relationship is an association (connection) between several entities. It should be placed between two entities and a line connecting it to an entity. A relationship is represented by a diamondcontaining relationship's name. Relationsh ip Name Symbol Student Book Issu e 8
  • 9. E-RDiagramofaLibrarySystem Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS Student Book Issu e RollN o Nam e Branc h Se m BookN o Nam e Autho r Pric e Primary Key Primary Key Entitie s Attributes Relationsh ip Each and every entity must have one primary key attribute. Relationship between 2 entities is called binary relationship. 9
  • 10. TernaryRelationship Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS Faculty Student Guid e FacI D Nam e Branc h Technolog y RollN o Nam e Branc h Se m Project P rojectID Project Name Relationship between 3 entities is called ternary relationship. 10
  • 11. Exercise Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 11 Draw an E-R diagram of following pair of entities Customer &Account Customer & Loan Doctor & Patient Student & Project Student & Teacher Note: Take four attributes per entity with one primary key attribute. Keep proper relationship between two entities.
  • 13. TypesofAttributes Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 13 SimpleAttribute CompositeAttribute 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 Roll No Symbo l First name Name Middle name Last name
  • 14. TypesofAttributes Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 14 Single-valuedAttribute Multi-valuedAttribute 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 Roll No Symbol Phone No
  • 15. TypesofAttributes Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 15 StoredAttribute DerivedAttribute It’s value is stored manually in database It’s value is derived or calculated from other attributes E.g. Birthdate E.g. Age (can be calculated using current date and birthdate) Symbol Birthdate Symbol Age
  • 16. EntitywithalltypesofAttributes Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 16 Stude nt RollN o Nam e Phone No Birth Date First Name Last Name Middl e Nam e Addres s Ag e Apartme nt Are a Stree t Composite Composit e Singl e SVima lp u l e e Multipl e Value Store d Derive d
  • 17. Exercise Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 17 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 twoentities Use all types of attributes
  • 18. DescriptiveAttribute Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 18 Student Book Issu e RollN o Nam e Branc h Se m BookN o Nam e Autho r Pric e Issu e Dat e Attributes of therelationship is called descriptive attribute. Descriptiv e Attribute
  • 19. Role Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 19 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. EmpI D Nam e Branc h Experien ce Faculty Coordinat o Head r Reports_ To
  • 20. RecursiveRelationshipSet Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS The same entityparticipatesin a relationship set morethanoncethen it is called recursive relationship set. Facult y Departme nt Work s Pos t FacID DeptI D FName DNam e Recursive Relationsh ip Set Prof. FName Post Ajay Professor Haresh Professor Ramesh HOD DName Computer Civil Mechanical 20
  • 22. MappingCardinality(CardinalityConstraints) Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 22 It represents the numberof entities of anotherentityset which are connectedtoan entity using a relationship set. It is most useful in describing binaryrelationshipsets. 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
  • 23. One-to-Onerelationship(1– 1) Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 23 An entity in A is associated withonly oneentityin B and an entity in B is associated with only oneentityinA. Example: A customer is connected with only one loan using the relationship borrower and a loan is connected withonly onecustomerusing borrower. A 1 A 2 B 1 B 2 A B loan customer borro w C1 C 2 L 1 L 2 C 3 L 3
  • 24. One-to-Manyrelationship(1– N) Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 24 An entity in A is associated withmorethanoneentities in B and an entity in B is associated withonly oneentityin A. A 1 A 2 B 1 B 2 A B loan customer borro w C1 C 2 L 1 L 2 C 3 L 3 L4 Example: A loan is connected withonly onecustomerusing borrower and a customeris connected withmorethanoneloans using borrower.
  • 25. Many-to-Onerelationship(N– 1) Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 25 An entity in A is associated withonlyoneentityin B and an entity in B is associated with more thanoneentities inA. A 1 A 2 B 1 B 2 A B loan customer borro w C1 C 2 L 1 L 2 C 3 L 3 C4 Example: A loan is connected withmorethanonecustomerusing borrower and a customer is connected withonly oneloan using borrower.
  • 26. Many-to-Manyrelationship(N– N) Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 26 An entity in A is associated withmorethanoneentities in B and an entity in B is associated withmorethanoneentities in A. Example: A customer is connected withmorethanoneloan using borrower and a loan is connected withmorethanonecustomerusing borrower. A 1 A 2 B 1 B 2 A B loan customer borro w C1 C 2 L 1 L 2 C 3 L 3 C 4 L 4
  • 27. MappingCardinality(CardinalityConstraints)[Exercise] Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 27 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 onestudent. A student can issue more than one book but a book is issued to only onestudent. A subject is taught by more than one faculty and a faculty can teach more than one subject.
  • 29. • every entity in the entity set participates in at least one relationship in the relationship set. • indicated by double line • some entities in the entity set may not participate in any relationship in the relationship set. • indicated by single line It specifies the participation of an entityset in a relationship set. There are two types participation constraints Total participation Partial participation Partial participation Total participation ParticipationConstraints Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS customer loan borro w C 1 C 2 L 1 L 2 C 3 Each customer has maximum one loan 29
  • 31. WeakEntitySet Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS loan payment loan- no amoun t payment- no An entityset thatdoes nothavea primarykeyis called weak entity set. Payment-date L_ P Payment- amount Strong Entity Set Weak Entity Set Weak Entity Relationsh ip • Weak entity set is indicated by double rectangle. • Weak entity relationship set is indicated by double diamond. 31
  • 32. WeakEntitySet Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 32 The existence of a weakentityset depends on the existence of a strong entityset. The discriminator (partial key) of a weak entity set is the set of attributes that distinguishes all theentities 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).
  • 34. Superclassv/sSubclass Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS Super Class Sub Class A superclass is an entity from which another entities can bederived. A subclass is an entity that is derived from anotherentity. E.g, an entity account has two subsets saving_account and current_account So an account is superclass. E.g, saving_account and current_account entities are derived from entity account. So saving_account andcurrent_accountare subclass. Account Saving_Account Current_Accou nt Super Class Sub Class 34
  • 36. Generalizationv/sSpecialization Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 36 Bottom-up approach Generalization Specialization It extracts thecommonfeatures of multiple entities to forma newentity. It splits anentitytoform multiple newentities that inheritsome featureof thesplitting entity. Name Address Person Name Name Address ISA Address Student Faculty SPI Salary Name Address SPI Salary Person ISA Student Faculty SPI Salary
  • 37. Generalizationv/sSpecialization Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 37 Generalization Specialization The process of creationof group from various entities is called generalization. The process of creationof sub-groups within anentityis called specialization. It is Bottom-upapproach. It is T op-downapproach. The process of taking the union of two or more lower level entity sets to produce a higher level entity set. The process of taking a sub set of higher level entityset to form a lower level entity set. It starts from the number of entity sets and creates high level entity set using some common features. It starts from a single entity set and creates different low level entity sets using some different features.
  • 38. Generalization&Specializationexample Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 38 Employee Customer Person Nam e Addres s PI D Cit y Salar y Balanc e IS A Full Time Part Time Days Worked Hour Worked IS A
  • 39. Exercise Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 39 Give the examples of Generalization/Specialization in the following E-R diagram: Hospital Management System. College Management System. Bank Management System. Insurance Company.
  • 41. ConstraintsonSpecializationandGeneralization Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS Constraint s Disjoin t Participatio n Disjoin t Non- disjoint (Overlappin g) Total (Mandator y) Partial (Optiona l) 41
  • 42. DisjointConstraint Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 42 It describes relationship betweenmembers of thesuperclass andsubclass 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
  • 43. DisjointConstraint Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 43 It specifies that the entityof a super class can belong to onlyonelower-levelentityset (sub class). Specified by ‘d’ or by writing disjoint near to the ISA triangle. Cricketer (Super class) Batsman (Sub class) Bowler (Sub class) All the players are associated with only one sub class either (Batsman or Bowler). Employee (Super class) Full-time (Sub class) Part-time (Sub class) IS A Disjoin t
  • 44. Non-disjoint(Overlapping)Constraint Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 44 It specifies that an entityof a super class can belong to morethanonelower-levelentityset (sub class). Specified by ‘o’ or by writing overlapping near to the ISA triangle. Cricketer (Super class) Batsman (Sub class) Bowler (Sub class) One player (Yuvraj singh) is associated with more than one sub class. Employee (Super class) Faculty (Sub class) Head (Sub class) IS A Non- disjoint
  • 45. ConstraintsonSpecializationandGeneralization Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 45 Constraint s Disjoin t Participatio n Disjoin t Non- disjoint (Overlappin g) Total (Mandator y) Partial (Optiona l)
  • 46. Participation(Completeness)Constraint Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 46 It determines whethereverymemberof super class must participateas a memberof subclass ornot. Types of participation (Completeness) Constraint Total (Mandatory) participation Partial (Optional) participation
  • 47. Total(Mandatory)Participation Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 47 Total participation specifies that everyentityin thesuperclass must bea memberof some subclass in the specialization. Specified by a double line in E-R diagram. Cricketer (Super class) Batsman (Sub class) Bowler (Sub class) All the players are associated with minimum one sub class either (Batsman or Bowler). Employee (Super class) Professor (Sub class) Head (Sub class) IS A
  • 48. Partial(Optional)Participation Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 48 Partial participation specifies that everyentityin thesuper class does notbelong to anyof the subclass of specialization. Specified by a single line in E-R diagram. Cricketer (Super class) Batsman (Sub class) Bowler (Sub class) Employee (Super class) Professor (Sub class) Head (Sub class) IS A Not associated with any sub class
  • 50. LimitationofE-Rdiagram Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS In E-R model we cannotexpress relationships betweentwo relationships. Relatio n Relatio n Relatio n Relatio n Entity 1 Entity 2 50
  • 51. LimitationofE-Rdiagram Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS Employee Department Work s Borro w Loan Can not connect two relationship Borro w Loan Customer Custom er Company Process of creating an entity by combining various components of E-R diagram is called aggregation. 51
  • 53. E-RdiagramofHospitalManagementSystem Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS Patien t 53 Hospit al Admitte d PatI D Nam e HosI D Nam e Ha s Medical Record MRI D Ha s Docto r DrI D Dr Name Report Name IS A Indoo r Outdo or IPDI D OPDI D RoomN o Charg e
  • 55. ReducetheE-Rdiagramtodatabaseschema Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 55 An entityof an ER diagram is turnedinto a table. Each attribute(except multi-valued attribute) turns into a column(attribute) in the table. Table namecan be same as entity name. Key attribute of the entity is the primary key of the table which is usually underlined. It is highly recommended that every table should start with its primary key attribute conventionally named as TablenameID. Person PersonI D Nam e Addres s Cit y PhoneN o Person (PersonID, Name, Address, City) Step 1: Reduce Entities and SimpleAttributes:
  • 56. ReducetheE-Rdiagramtodatabaseschema Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 56 Multi-value attribute is turned into a newtable. Add the primary key column into multi-value attribute’stable. Add the primary key column of the parent entity’s table as a foreign key within the new (multi-value attribute’s)table. Then make a 1:N relationship between the Person table and PhoneNo table. Step 2: Reduce Multi-valuedAttributes: Person P ersonID PhoneN o Havin g PhoneNo (T2) Person (T1) PhoneNo (PhoneID, PersonID, PhoneNo) Foreign Key
  • 57. ReducetheE-Rdiagramtodatabaseschema Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 57 Convert bothentities in to tablewith proper attribute. Placethe primary key of any one table in to the anothertable as a foreign key. Place the primary key of the Wife table WifeID in the table Persons as Foreign key. OR Place the primary key of the Person table PersonID in the table Wife as Foreign key. Step 3: Reduce 1:1Mapping Cardinality: Wife WifeI D WNam e Person PersonID PNam e Havin g Person (PersonID, PName) Wife (WifeID, Wname, PersonID) Wife (WifeID, Wname) Person ( P ersonID, Pname, WifeID)
  • 58. ReducetheE-Rdiagramtodatabaseschema Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 58 Convert bothentities in to tablewith proper attribute. Place the primary key of table having 1 mapping in to the another table having many cardinality as a Foreign key. Place the primary key of the Person table PersonID in the table House as Foreign key. Step 4: Reduce 1:NMapping Cardinality: House HouseI D HNam e Person Havin g PersonID PName Person (PersonID, PName) House (HouseID, Hname, PersonID)
  • 59. ReducetheE-Rdiagramtodatabaseschema Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 59 Convert both entities in to tablewith proper attribute. Create a separate tableforrelationship. Place the primarykeyof bothentities table into the relationship’s tableas foreignkey. Place the primary key of the Customer table CID and Account table Ano in the table Has_Acct as Foreign key. Step 5: Reduce N:N MappingCardinality: Account ActN o Balanc e Customer Has_Ac ct CID CName Customer ( CID, CName) Account ( A ctNo, Balance) Has_Acct (HasAcctID, CID, ActNo)
  • 60. SummeryofSymbolsusedinE-Rdiagram Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS Customer Entit y EmpID Primary Key Attribute Payment Weak Entity Total Participatio n Name Attribut e Age Derived Attribut e Hold Relationsh ip PhoneN o Multi Valued Attribute Issue Weak Entity Relationsh ip IS A Specializatio n/ Generalizati on R E Role Indicato r R E PymtID Discriminatin g Attribute Role Nam e 60
  • 61. SummeryofSymbolsusedinE-Rdiagram Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS R One to One E E One to Many R E E Many to One R E E Many to Many R E E ISA Total Specializatio n/ Generalizatio n Disjoint ISA Disjoint Specializatio n/ Generalizatio n Overlappin g ISA Overlapping Specializatio n/ Generalizatio n ISA Partial Specializatio n/ Generalizatio n 61
  • 63. Whatis aDatabaseModels? Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 63 A database model is a type of data model that defines thelogical structure of a database. It determine how datacan bestored, accessed andupdatedin a database management system. The most popular example of a database model is the relational model, which uses a table- based format.
  • 64. TypeofDatabaseModels Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 64 Hierarchical Model Network Model Entity-relationship Model Relational Model Object-oriented database Model
  • 65. HierarchicalModel Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 65 The hierarchical model organizes data into a tree-like structure,where each record has a single parentorroot. Department Student Professor The hierarchy starts from the Root data, and expands like a tree, adding child nodes to the parentnodes. In hierarchical model, data is organized into tree-like structure with one-to-many relationship between two different types of data, for example, one department can have manyprofessors and manystudents.
  • 66. NetworkModel Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 66 This is an extensionof thehierarchical model,allowing many-to-manyrelationships in a tree- like structure that allows multipleparents. A B C D E F
  • 67. Entity-relationshipModel Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 67 In this database model, relationships are created by dividing object of interest into entity and its characteristics intoattributes. Student Book Issu e RollN o Nam e Branc h Se m B ookNo Nam e Autho r Pric e Entitie s Attributes Relationsh ip
  • 68. RelationalModel Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 68 In this model, data is organized in two-dimensionaltables and the relationship is maintained bystoring a commonattribute. ResID Rno SubID Marks 1 101 1 80 2 101 2 85 3 102 1 75 4 102 2 80 SubID Subject_Name Teacher 1 DBMS Doshi 2 DS Vyash Foreign Key Rno Student_Name Age 101 Raj Patel 20 102 Meet Shah 21 Foreign Key
  • 69. Object-orienteddatabaseModel Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 69 This data model is another method of representing real world objects. It considers each objectin theworldas objects and isolates it from each other. It groups its relatedfunctionalities togetherand allows inheriting its functionality to other related sub-groups.
  • 71. IntegrityConstraints Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 71 Integrity constraints are a set of rules. It is used to maintain thequalityof information. Integrity constraints ensure that the data insertion, updating, and other processes have to be performed in such a way that data integrity is not affected. Thus, integrity constraint is used to guard against accidental damage to the database. Various Integrity Constraints are: Check Not null Unique Primary key Foreign key
  • 72. IntegrityConstraints Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 72 Check This constraint defines a business rule on a column. All the rows in that column must satisfy this rule. Limits the data values of variables to a specific set, range,orlist ofvalues. The constraint can be applied for a single column or a group ofcolumns. E.g. value of SPI should be between 0 to10. Not null This constraint ensures all rows in the table contain a definite value for the column which is specified as not null. Which means a null valueis not allowed. E.g. name column should have some value. Unique This constraint ensures that a column or a group of columns in each row have a distinct (unique) value. A column(s) can have a null value but the values cannot beduplicated. E.g. enrollmentno column should have uniquevalue.
  • 73. IntegrityConstraints Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 73 Primary key This constraint defines a column or combination of columns which uniquely identifies each row in the table. Primary key = Uniquekey+Not null E.g. enrollmentno column should have unique value as well as can’t benull. Foreign key (referential integrity constraint) A referential integrity constraint (foreign key) is specified between twotables. In the referential integrity constraints, if a foreign key column in table 1 refers to the primary key column of table 2, then every value of the foreign key column in table 1 must be null or be available in primary key column of table 2. RollNo Student_Name DeptID 101 Raj Patel 1 102 Meet Shah 2 Foreign Key DeptID Dept_Name HOD 1 Computer Doshi 2 IT Vyash
  • 74. iQuestions Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 74 1. Write a note on mapping cardinality in E-R diagram. 2. Explain the difference between a weak and a strong entity set. 3. Explain the difference between generalization and specialization. OR Explain specialization and generalization concept in E-R diagram with suitable example. 4. Write a note on constraints on specialization and generalization. 5. Explain aggregation in E-R diagram with example. 6. What do you mean by integrity constraints? Discuss various integrity constraints.
  • 75. Questionsasked[E-Rdiagrams] Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 75 7. Draw E-R diagram for Bank Management System. 8. Define E-R diagram. Draw an E-R diagram for Library Management System. Assume relevant entities and attributes for the given system. 9. Construct an E-R diagram for a car-insurance company whose customers own one or more cars each. Each car has associated with it zero to any number of recorded accidents. 10.Design a generalization–specialization hierarchy for a motor-vehicle sales company. The company sells motorcycles, passenger cars, vans, and buses. Justify your placement of attributes at each level of the hierarchy. Explain why they should not be placed at a higher or lower level.
  • 76. Questions[E-RdiagramsandDatabase] Prof. Firoz ASherasiya #3130703 (DBMS) UNIT 2 – DATA MODELS 76 11.Design a database for an airline. The database must keep track of customers and their reservations, flights and their status, seat assignments on individual flights, and the schedule and routing of future flights. Your design should include an E-R diagram, a set of relational schemas, and a list of constraints, including primary-key and foreign-key constraints. 12.Design a database for a hospital with a set of patients and a set of medical doctors. Associate with each patient a log of the various tests and examinations conducted. Your design should include an E-R diagram, a set of relational schemas, and a list of constraints, including primary-key and foreign-key constraints.