Data Models: BY: Richa Jain
Data Models: BY: Richa Jain
Mapping Cardinality:
E1:E2 =1:N=M:M
E-R Model components
• Entity: An entity in ER Model is real world entity,
which has some properties called attributes.
Every attribute is defined by its set of values,
called domain. For example, in a school database,
a student is considered as an entity. Student has
various attributes like name, age and class etc.
• An entity set is a collection of similar types of
entities. For example, Students set may contain
all the student of a school.
Attribute
•
s
Attributes describe the properties of the entity of
which they are associated.
• A particular instance of an attribute is a value. For
example, "Ram" is one value of the attribute
Name.
• We can classify attributes as following:
¨ Simple
¨ Composite
¨ Single-valued
¨ Multi-valued
¨ Derived
E-R Model: Symbols and notations
E-R Model: Symbols and notations
E-R Model
• Relationship: The association among entities
is called relationship. For example, employee
entity has relation works_at with department.
• Relationships are mapped with entities in
various ways. Mapping cardinalities define the
number of association between two entities.
Constraints
• Various types of constraints are:
1. Mapping cardinalities
2. Participation constraints
3. Keys
Mapping Cardinalities
• Mapping cardinality or cardinality ratios ,
express the number of entities to which
another entity be associated via a
relationship
canset
• Mapping cardinalities:
– one to one
– one to many
– many to one
– many to many
• One-to-one: one entity from entity set A can be
associated with at most one entity of entity set B and
vice versa.
1 1
STUDENT WORK DEPARTMENT
E1 A 20 D1 IT JAI
E1 D1
E2 B 18 D2 CSE BEN
E2 D2
E3 C 19
E3 D4 D3 ECE DEL
E4 A 18
E4 D3 D4 MEC MUM
NAME
1 Infinity
CUSTOMER GIVE ORDER
STUDENT COURSE
STUDY
on update cascade
on update set null
on update no action
Refered and Refrencing Table
1) Refrencing Table (Foregin Key)
• Instert: May cause Violation
• Delete: NO Violation
81 DBMS A1 Kalyani
81 DBMS A2 Kalyani
81 DBMS A3 Kalyani
82 Oracle C1 Kalyani
82 Oracle C2 Ka\yani
Book_Author
2 2
Representation of weak entity sets
l 3
L -14 2 8 fvl 6a y 5 oo
2oo1
9
L-15 2 23 May 300
2 2001
• L-16 5 18 ,June i 35
8 2001
L-17 5 10 May 50
Representation of relationship sets
custome Loa
r n
2. Conversion of one to many relationship to
relational model:
For one to many or many to one relationship,
there is no need to create the separate table for
the relationship. Copy the primary key of entity set
on one side of relationship into the entity set on
“many” side of relationship.
Customer and Loan relationship with 1:M type
_ !\I!#Qfill'r&i.ijfit• • tYilijfflJJfHij!ifuW/••Jl.P.t§fili#fil !
{ijfl••:iMJijtftffiijfii
Cl itY•••••:fD
f\_ja Model Tovvn Patiala UYP!#.
Ll
Ran a
·C y1
1
rzw 2 Rai
••f
Dharampura
Patiala L3,
This is not a valid database, so this solution is rejected.
n oµt L4
!ll :9:Ii nJJ!p;ppjJi r }!!iii!fi!i/i!il[III !ii!i!i!i( }i!ii
:;J /f
nie)JpfLi!l!iiI!!
l i i!i!1!!i i! ! •1!i!ii 10000
!)]!i!ii!li!&)f $Rffli rlli]il
Cl /i
L2 20000 Cl
L3 30000 C2
L4 40000 C2
3. Conversion of one to one relationship to
relational model:
• In case of 1:1 relationship, there is no need to
create a separate table for relationship and
the primary key of any entity set can be
moved to other side depending upon the
requirement. It is preferable to copy the
primary key of non-totally participated
entity set towards totally participated entity
set.
Design Issues
• There are number of different ways to define
set of entities and relationship among them.
We examine basic issues in the design of an E-
R model. These are:
– Use of entity sets vs. attributes
– Use of entity sets vs. relationship sets
– Binary versus n-ary relationship sets
– Placement of relationship attributes
Design Issues: Use of entity sets vs.
attributes
• Treating telephone as an attribute telephone-number implies that
employees have exactly one telephone number each
• Treating telephone as an entity permits employees to have several
telephone numbers associated with them.
• The distinctions to consider an object as attribute or entity
depends
on the structure of real-world enterprise being modeled.
Design Issues: Use of entity sets vs. relationship sets
• Each loan is represented by a relationship between a customer and
a branch, if every loan is associated with exactly one customer and
is associated with exactly one branch
• If several customers hold a joint loan then, loan should be
considered as an entity
The guideline in determining whether to use an entity set or
a relationship set is to designate a relationship set to
describe an action that occurs between entities
Design Issues: Binary versus n-ary
relationship sets