SlideShare ist ein Scribd-Unternehmen logo
1 von 65
Downloaden Sie, um offline zu lesen
Introduction to Databases
ER Model
Ajit K Nayak, Ph.D.
Siksha O Anusandhan University
AKN/IDBI.2Introduction to databases
Entity-Relationship (ER) Data Model
 The ER data model facilitates database design by
allowing specification of an enterprise schema that
represents the overall logical structure of a database.
 It is very useful in mapping the meanings and
interactions of real-world enterprises onto a
conceptual schema.
 The ER data model employs three basic concepts:
 Entity Sets,
 Relationship Sets,
 Attributes.
 The ER model also has an associated diagrammatic
representation, the ER diagram, which can express the
overall logical structure of a database graphically.
AKN/IDBI.3Introduction to databases
ER Data Model - II
 ER Model is said to be the high-end tool of database
design.
 This data model uses a collection of
 basic objects, called entities,
 and relationships among these objects.
 An entity is a ―thing‖ or ―object‖ in the real world that is
distinguishable from other objects.
 Ex: employee, student, account
 An entity has a set of properties that uniquely identifies
an entity called attributes.
 Ex: Employee (empNo, empName, …)
 Student (studNo, studName, branch, …)
AKN/IDBI.4Introduction to databases
ER Model: Entity Set
 Entity Set : is a set of entities of the same type that
share the same attributes.
 Ex: The set of all people who are instructors at a given
university, can be defined as the entity set instructor.
 Ex: The set of all students at a given university, can be defined
as the entity set student.
AKN/IDBI.5Introduction to databases
ER Diagram: Entity Set
 Entities are represented graphically as follows:
 A two part Rectangle represent an entity set.
 Part I: entity set name
 Part II: Attributes listed.
 Underline indicates primary key attributes
AKN/IDBI.6Introduction to databases
ER Model: Relationship - I
 Relationship: A relationship is an association among
several entities.
 Ex: Let‘s define a relationship advisor that associates instructor
Katz with student Shankar.
 Relationship set: is a set of relationships of same type
between two or more entity sets.
Relationship set
advisor
AKN/IDBI.7Introduction to databases
ER Model: Relationship Set - II
 The association between entity sets is referred to as
participation.
 Ex: Katz and Shankar participate in relationship instance of
advisor
 i.e. This relationship instance represents that in the university,
instructor Katz is advising student Shankar.
 Relationship may also have attributes called descriptive
attributes.. Ex. the advisor
relationship set
between entity sets
instructor and student
have the attribute date
which tracks when the
student started being
associated with the
advisor
AKN/IDBI.8Introduction to databases
ER Model: Relationship Set - III
 The function that an entity plays in a relationship is
called that entity‘s role
 Katz‘s role is „instructor‟, Shankar‘s is ‗student‟ in the relationship
of ‗advisor‟
 The same entity set participates in a relationship set
more than once, in different roles is called recursive
relationship set
 Also known as unary relationship
MTH 1001: Calculus I
MTH 2001: Calculus II
CSE1002: Discrete Maths
CSE2011: COA
MTH2002: Probability & Statistics
prerequisite
recursive relationship set
Role of MTH2001: course
Role of MTH1001: prerequisite
course
AKN/IDBI.9Introduction to databases
ER Model: Degree of Relationship
 The degree of a relationship set is the number of entity
sets participate in the relationship.
 The three most common relationship sets categorised
according to the degree in ER models are
 Binary: When two entity sets participates.
 Ex: Teacher teaches some Students
 Unary: when both participants are the same entity
 Ex: Subject prerequisite of another Subject
 Also known as recursive relation
 Ternary: when three entities participate in the
relationship.
 Ex1: Instructor becomes project_guide to students and
develops projects
 Ex2: Teacher teaching_activity with Branch and Subject
AKN/IDBI.10Introduction to databases
ER Diagram: Degree of Relationship
subject
sub_id
title
credits
prerequisite
sub_id
prereq_id
instructor
ID
name
salary
student
ID
name
tot_cred
project
. . .
proj_guid
e
teacher
ID
name
salary
branch
ID
name
tot_cred
subject
. . .
teaching
activity
Unary: The labels ―sub_id‖ and
“prereq_id” are called roles.
Ternary: 3 entity sets participate in
a relationship set
employee
ID
name
salary
department
deptNo
building
budget
belongsTo
Binary: Most of the relationships in
real world are of this type.
AKN/IDBI.11Introduction to databases
ER Model: Attributes
 Attributes are the properties of an entity set that are
relevant to the database and about which the data
values need to be stored.
 For each attribute, there is a set of permitted values,
called domain or value set
 An attribute of an entity set is a function that maps
from the entity set in to a domain.
 Each entity can be described by a set of (attribute,
value) pair.
 Ex. A particular instructor entity may be represented as
{(ID, 76766), (name, Crick), (dept, CSIT), (salary, 50000)}
 Similarly a particular student entity
{(ID, 34721),(name, Sid),(DoB, 30-12-1997),(branch, CSIT)}
AKN/IDBI.12Introduction to databases
Keys - I
 The values of the attributes of an entity must be such
that, they uniquely identify the entity.
 No two entities in an entity set are allowed to have
exactly the same value for all of its attributes.
 A Key makes one entity distinguishable from other entity
in the same entity set.
 A key for an entity set is a set of attributes, whose value
uniquely determines each and every entity in an entity
set.
 Different keys used are
 Candidate key
 Super key
 Primary Key
 Alternate key
AKN/IDBI.13Introduction to databases
Keys - II
 Ex. Consider the entity set
 Student(reg_no, name, branch, address, ph_no, DoB)
 Candidate key: is an attribute who‘s value uniquely
determine each and every entity in an entity set.
 Ex. Candidate keys {name, ph_no}, {name, address} or {reg_no}
 For a given entity set, more than one candidate keys can be
designed.
 Super Key: any superset of an candidate key is referred
as super key
 i.e. A candidate key is the minimal super key, of which no
proper subset can again act as a key.
 Ex. Super Keys: {reg_no, name}, {reg_no, name, ph_no},
{reg_no, name, branch}, {reg_no, name, address} or {reg_no,
name, DoB}, . . .
AKN/IDBI.14Introduction to databases
Keys - III
 Primary key: Out of multiple candidate keys, one of the
key is chosen by the database engineer as the primary
key.
 Primary key is used as principal means to uniquely
identify each and every entity in the entity set.
 Ex. Primary key {reg_no}
 Alternate Key: Rest of the candidate keys (excluding
primary key) are called alternate keys
 Ex. Alternate Keys {name, ph_no} and {name, address}
 Keys are represented in ER Diagram by underlining the key
attribute(s)
AKN/IDBI.15Introduction to databases
ER Model: Category of Attributes- I
 Simple and Composite
 Simple attributes are atomic and cannot be divided further.
 Ex. (regNo)
 Composite attributes are sub-divided further.
 Ex. (name{first_name, middle_name, last_name})
 Composite attributes may be represented in a hierarchy.
Composite attributes are useful when it is needed to use either
whole or part of the information of an attribute
AKN/IDBI.16Introduction to databases
ER Model: Category of Attributes- II
 Single Valued and Multivalued
 Attribute that maps to only one value in a domain are called
single valued attribute
 Ex. DoB, reg_no
 Attribute that maps to more than one values in a domain are
called multivalued attribute.
 Ex. phone_no, email_id
 Derived
 If the value for an attribute can be computed from the values
of other related attributes then is called derived attribute
 Ex. age, net_salary, can be calculated from DoB and other
salary components respectively.
AKN/IDBI.17Introduction to databases
ER Diagram: Attributes
 Composite attribute: represented in
indentation.
 Ex. name with component attributes
first_name,…, last_name
 Ex. address with , city, state, and zip.
 Ex. street with street_no, street name and
apt_number
 Multivalued attribute: represented
using curly braces.
 Ex. {phone_number} of instructor
 Derived attribute: represented
using parenthesis. Ex. age( )
AKN/IDBI.18Introduction to databases
ER Model: Constraints
 Constraints are the reflections of business rules/logic to
which the database design must comply to.
 These are the characteristics of relationship set.
 ER Model supports two types of constraints:
 Mapping Cardinalities
 How many entities in one entity set is associated with entities
of another entity set?
 Participation Constraints.
 Tells about the total or partial participation of an entity set
in a relationship set.
 i.e. Whether all entities or few of them are participating in a
relationship set.
 Ex. Participation of Student entity set in the relationship
advisor is total. But participation of Instructor may be partial
AKN/IDBI.19Introduction to databases
ER Model: Mapping Cardinalities - I
 Mapping cardinalities or
cardinality ratios tells the number
of entities to which another entity
can be associated via a
relationship set.
 One-to-One: An entity in entity set A is
associated with at most one entity in
another entity set B.
 Ex. One Student enrolls in One course
 One-to-Many: An entity in entity set A is
associated with any number of entities in
entity set B.
 Ex. One Teacher advises Multiple
students
AKN/IDBI.20Introduction to databases
ER Model: Mapping Cardinalities - II
 Many-to-One: An entity in A is
associated with at most one entity
in B. An entity in B, however, can
be associated with any number of
entities in A.
 Ex. Many Students are enrolled in One
Course
 Many-to-Many: An entity in A is
associated with any number of entities
in B and an entity in B is associated with
any number of entities in A.
 Ex. One Customer have Many bank
Accounts and One Account can have
Multiple number of Customers.
AKN/IDBI.21Introduction to databases
ER Diagram: Cardinality Constraints-I
 One: A directed line () from relationship set to entity
set
 Many: an undirected line (—)
 One-to-One relationship between an instructor and a
student :
 A student is associated with at most one instructor via the
relationship advisor
 Task: Draw ER diagram where, A student is associated with at
most one department via stud_dept
AKN/IDBI.22Introduction to databases
ER Diagram: Cardinality Constraints-II
 One-to-Many: an instructor is associated with several
(including 0) students via advisor
 Many-to-One: a student is associated with several (including
0) instructors via advisor
AKN/IDBI.23Introduction to databases
ER Diagram: Cardinality Constraints-III
 Many-to-Many:
 An instructor is associated with several (possibly 0) students via
advisor
 A student is associated with several (possibly 0) instructors via
advisor
AKN/IDBI.24Introduction to databases
ER Diagram: Total and Partial Participation
 Total participation is indicated by double line:
 i.e. every entity in the entity set participates in at least one
relationship in the relationship set
Ex. participation of student in advisor relation is total
 every student must have an associated instructor
 Partial participation: some entities may not
participate in any relationship in the relationship set
 Ex. participation of instructor in advisor is partial
AKN/IDBI.25Introduction to databases
ER Diagram: Complex Constraints
 A line may have an associated minimum and
maximum cardinality, shown in the form l..h, where
 A minimum value of 1 indicates total participation
 A maximum value of 1 indicates that the entity participates in
at most one relationship
 A maximum value of * indicates no limit.
Instructor can advise 0 or more students. A student must
have 1 advisor; cannot have multiple advisors
AKN/IDBI.26Introduction to databases
Example: Represent Entities
 Consider a retail store
 Order 1
Date: 26-8-16,
Amount:1620.00
Add: BBSR,
Item1: rice, qty: 2, Price:90.00,
Item2: trouser, qty:1, Price1200.00,
Item3:soap, qty:3, Price150.00,
Item4:biscuit, qty:3, Price:180.00
 Order 2: . . .
 Order 3: . . .
AKN/IDBI.27Introduction to databases
ER Model: Weak Entity Set - I
 An entity set that cannot be uniquely identified by its
attributes alone are called weak entity sets.
 i.e. the entity set does not have sufficient attributes to form a
primary key and are dependent on other entity sets for their
existence.
 An entity having own primary key is called a strong
entity.
 The strong entity upon which the weak entity depends
is refereed as identity entity
 The relationship set through which the weak entity is
connected to its identity (strong) entity set is called
identifying relationship set.
AKN/IDBI.28Introduction to databases
ER Diagram: Weak Entity Set
 Ex. orderItem(item_no, quantity, price, discount)
orderItem
sitem_no
quantity
price
discount
order
order_no
order_date
payment_info
shipping_add
contains
 The relationship set with its identity entity (strong) set is
represented using double line diamond
 The line from weak entity to identifying relationship set is double
lined
 A set of attributes of a weak entity set is referred as the
discriminator (or partial key) that is used as a means of
distinguishing among all those entities in the weak entity set that
depend on one particular strong entity
AKN/IDBI.29Introduction to databases
Weak Entity Set - III
 The discriminator of a weak entity is underlined with
dashed line.
 The primary key of a weak entity set is formed by
 the primary key of the identifying entity set, plus
 the weak entity set‘s discriminator.
 In the case of the entity set order, its primary key is
{order_no, item_no, quantity, price, discount}
 The participation of the weak entity set with its
identifying relationship set is always total.
 The cardinality of the identifying relationship set is
always many-to-one from the weak entity set to its
identifying entity set
AKN/IDBI.30Introduction to databases
Weak Entity Set - III
 Discriminator?
 Primary key?
 primary key of section {course_id, sec_id, year,
semester}
 The identifying relationship set is not allowed to have
any descriptive attribute
 Weak entity can participate in any other relationship
set after forming the primary key.
section
section_id
semester
year
course
course_id
title
credits
secCourse
AKN/IDBI.31Introduction to databases
Participation Constraints
account
accNum
balancedeposits
loan
loanNum
loanAmt
branch
brID
brName
brAdd
loanBranch
borrows accWith
lastAccessDate
customer
custNum
name
fName
lName
address
{phoneNum}
• Participation of entity
set account in
deposit relationship &
accWith relationship
is total
• Participation of loan
entity set in
loanBranch
relationship &
borrows relationship
is total
AKN/IDBI.32Introduction to databases
Extended ER Features
 The extended ER features are
 Specialization
 Generalization
 Aggregation
AKN/IDBI.33Introduction to databases
Specialization
 An entity set may allow further sub-grouping within it
based on the distinctive features (attributes)
 Specialization is a technique of designating sub-
grouping of entities within an entity set based upon
the distinct attributes that the entity possess
 Specialization is a refinement approach that stems
from an entity set (higher level entity set ) in order to
form multiple entity sets (lower level entity set )
 The entities in the lower level entity sets are the sub-
sets of the entities in its higher level entity set.
 This is known as „IS A‟ relationship.
 Ex. Tiger is an Animal, Cheetah is a Tiger
 Also referred as ―Superclass – subclass‖ relationship
AKN/IDBI.34Introduction to databases
Generalization
 Generalization is the approach of synthesizing multiple
entity set (lower level) in order to form a higher level
entity set based upon common features (attributes)
posses by the lower level entity sets
 Generalization stems from multiple lower level entity
sets and forms a single higher level entity set.
 In ER diagram it is represented in same way as
specialization.
 Ex. Given: Cat, Tiger, Wolf, Lion, elephant entity sets,
we extract and use all the common features available
in all entity sets to form another Animal entity set.
AKN/IDBI.35Introduction to databases
Specialization Examples
MTechStud
. . .
MCAStud
. . .
student
stud_id
name
. . .
PGStud
. . .
UGStud
. . .
employee
emp_id
name
desig
regEmp
salary
leave
partEmp
perkPerHr
hourPerWk
AKN/IDBI.36Introduction to databases
Attribute Inheritance
 All the attributes including the primary key of the
higher level entity set are inherited/derived and
associated to all lower level entity sets
 Ex. student and employee inherit the attributes of person.
 Thus, student is described by its ID, name, and address
attributes, and additionally a tot_cred attribute;
 employee is described by its ID, name, and address attributes,
and additionally a salary attribute.
AKN/IDBI.37Introduction to databases
Participation Inheritance
 A lower-level entity set also inherits participation in the
relationship sets in which its higher-level entity
participates.
 Participation inheritance applies through all tiers of lower-level
entity sets.
 Ex. suppose the person entity set participates in a relationship
person_dept with department.
 Then, the student, employee, instructor and secretary entity
sets, which are subclasses of the person entity set, also
implicitly participate in the person_dept relationship with
department.
 The above entity sets can participate in any relationships in
which the person entity set participates.
AKN/IDBI.38Introduction to databases
Overlapping and Disjoint Constraints
 Specialization is said to be overlapping if there exists at
least one entity in the higher entity set that belongs to
more than one lower level entity sets, otherwise called
disjoint.
Overlapping specialization
disjoint specialization
Overlapping Specialization
the same entity may belong to
more than one lower-level entity set
within a single generalization
Disjoint Specialization
If an entity belong to no more
than one lower-level entity set
AKN/IDBI.39Introduction to databases
Membership Constraint
 To model an enterprise more accurately, certain constraints may
be place on a particular generalization
 Condition-defined Membership
 A membership is confirmed if an entity satisfies an explicit
condition.
 Ex. student has an attribute student_type. Whose value can
be „undergraduate‟ or „graduate‟
 Then all entities that satisfy the condition student type =
“undergraduate” are included in UGStud.
 User-defined Membership
 after 3 months of employment, university employees are
assigned to one of four work teams.
 The teams are represented as four lower-level entity sets of the
higher-level employee entity set.
 A given employee is assigned to a specific team entity set
manually.
AKN/IDBI.40Introduction to databases
Completeness Constraint
 Total generalization or specialization.
 Each higher-level entity must belong to a lower-level entity set.
 Ex. The student generalization is total: All student entities must
be either post graduate or undergraduate.
 Partial generalization or specialization.
 Some higher-level entities may not belong to any lower-level
entity set.
 Partial generalization is the default.
 Ex. The employee generalization is partial. Some employees
are there who are neither an instructor nor a secretary.
AKN/IDBI.41Introduction to databases
Specialization/Generalization
• Design two sub entity sets of account as sbAcc and
currAcc.
account
accNum
balancedeposits
loan
loanNum
loanAmt
branch
brID
brName
brAdd
loanBranch
borrows accWith
lastAccessDate
customer
custNum
name
fName
lName
address
{phoneNum}
installment
instNum
instAmt
instDate
payBack
sbAcc
rateOfInt
currAcc
odAmt
• It is a disjoint
specialization!
AKN/IDBI.42Introduction to databases
Problem
 How to Modify the model s.t. an Instructor guiding a
student on a project can file a monthly evaluation
report containing instructor, student and project
information
instructor
ID
name
salary
student
ID
name
tot_cred
project
. . .
proj_guide
AKN/IDBI.43Introduction to databases
Aggregation -I
 It can express relationship among relationship sets
 Aggregation facilitates to treat a relationship set
(along with all of its associated entity sets) as a higher
level entity set and can participate in another
relationship set.
 i.e. Aggregation is an abstraction through which relationships
are treated as higher-level entities.
AKN/IDBI.44Introduction to databases
Aggregation -II
 The relationship set proj_guide is represented as a
higher-level entity set called proj guide.
 Such an entity set is treated in the same manner as is
any other entity
 We then create a binary relationship
eval_for between proj_guide and
evaluation to represent which
combination an evaluation is for.
AKN/IDBI.45Introduction to databases
Reduction to Relational Schema
 An E-R design can be Translated/mapped/reduced
into a relational design.
 Entity sets and relationship sets can be expressed
uniformly as relation schemas that represent the
contents of the database.
 A database which confirms to an E-R diagram can be
represented by a collection of schemas.
 For each entity set and relationship set there is a
unique schema that is assigned the name of the
corresponding entity set or relationship set.
 Each schema has a number of columns (generally
corresponding to attributes), which have unique
names
AKN/IDBI.46Introduction to databases
(R1) Mapping Strong Entity sets
 A strong entity set reduces to a schema with the same
attributes as in entity set.
A
a1
a2
a3
 Mapping: A(a1,a2,a3)
student
ID
name
tot_cred
 student(ID, name, tot_cred)
AKN/IDBI.47Introduction to databases
(R2) Mapping Relationship sets
 A relationship set reduces to a schema with the
primary key attributes of participating entities and
descriptive attributes.
 (R2.1) For a binary many-to-many relationship, the
union of the primary-key attributes from the
participating entity sets becomes the primary key.
A
a1
a2
a3
B
b1
b2
b3
R
r1
 A(a1, a2, a3)
 B(b1, b2, b3)
 R(a1, b1, r1)
AKN/IDBI.48Introduction to databases
(R2) Mapping Relationship sets - II
 (R2.2)For a binary one-to-one relationship set, the
primary key of either entity set can be chosen as the
primary key. The choice can be made arbitrarily
A
a1
a2
a3
B
b1
b2
b3
R
 A(a1, a2, a3)
 B(b1, b2, b3)
 R(a1, b1) or
 R(a1, b1)
AKN/IDBI.49Introduction to databases
(R2) Mapping Relationship sets - III
 (R2.3) For a binary many-to-one or one-to-many
relationship, the primary key of the entity set on the
―many‖ side of the relationship set serves as the
primary key.
A
a1
a2
a3
B
b1
b2
b3
R
 A(a1, a2, a3)
 B(b1, b2, b3)
 R(a1, b1)
AKN/IDBI.50Introduction to databases
(R2) Mapping Relationship sets - IV
 (R2.4) For an n-ary relationship set without any arrows on its
edges, the union of the primary key-attributes from the
participating entity sets becomes the primary key.
 (R2.5) For an n-ary relationship set with an arrow on one of its
edges, the primary keys of the entity sets not on the ―arrow‖
side of the relationship set serve as the primary key for the
schema.
 A(a1, a2, a3)
 B(b1, b2, b3)
 B(c1, c2, c3)
 R(a1, b1 , c1)
A
a1
a2
a3
B
b1
b2
b3
R
C
c1
c2
c3
AKN/IDBI.51Introduction to databases
(R3) Referential Integrity
 For each entity set Ei related to relationship set R, we
create a foreign-key constraint from relation schema
R, with the attributes derived from primary-key
attributes of Ei.
A
a1
a2
a3
B
b1
b2
b3
R
 Two foreign key constraints are created on relation R
 i.e. attribute r_a1 referencing primary key of A and
attribute r_b1 referencing primary key of B.
 A(a1, a2, a3)
 B(b1, b2, b3)
 R(r_a1, r_b1)
AKN/IDBI.52Introduction to databases
(R3) Mapping Composite attributes
 While mapping a composite attribute to a relation, we
form one attribute in the relation schema for each
sub-attribute in the composite attribute of ER diagram.
 Attribute is not created for the composite attribute
itself.
 A(a1, a21, a22, a3)A
a1
a2
a21
a22
a3
B
b1
b2
b21
b211
b212
b22
b3
 B(b1, b211, b212, b22,b3)
AKN/IDBI.53Introduction to databases
(R4) Mapping Multivalued attributes
 For a multivalued attribute m, we create a separate
relation schema R with an attribute a that corresponds
to m and the primary key of the entity set.
 All of the attributes of R becomes the primary key of
the relation R.
 R(a1, m)A
a1
a2
{m}
instructor
id
name
address
{phone_no}
 instructorPhone(id1, phone_no)
 We create a foreign-key constraint on the relation
schema created from the multivalued attribute.
AKN/IDBI.54Introduction to databases
(R5) Mapping Weak Entity Set
 For schemas derived from a weak entity set, the
combination of the primary key of the strong entity set
and the discriminator of the weak entity set serves as
the primary key of the schema.
 No separate relation for R is required, however, if R
contains a descriptive attribute, then it is added in A
A
a1
a2
B
b1
b2
R
 Primary key of B: b1
 Discriminator of A: a1,a2
 A foreign-key constraint is created on the relation A,
specifying that the attributes b1, b2 reference the
primary key of the relation B.
 A(a1, b1, a2) and B(b1,b2)
AKN/IDBI.55Introduction to databases
(R2.5) Referential Integrity
 For each entity set Ei related to relationship set R, we
create a foreign-key constraint from relation schema
R, with the attributes derived from primary-key
attributes of Ei.
A
a1
a2
a3
B
b1
b2
b3
R
 Two foreign key constraints are created on relation R
 i.e. attribute r_a1 referencing primary key of A and
attribute r_b1 referencing primary key of B.
 A(a1, a2, a3)
 B(b1, b2, b3)
 R(r_a1, r_b1)
AKN/IDBI.56Introduction to databases
(R3) Mapping Composite attributes
 While mapping a composite attribute to a relation, we
form one attribute in the relation schema for each
sub-attribute in the composite attribute of ER diagram.
 Attribute is not created for the composite attribute
itself.
 A(a1, a21, a22, a3)A
a1
a2
a21
a22
a3
B
b1
b2
b21
b211
b212
b22
b3
 B(b1, b211, b212, b22,b3)
AKN/IDBI.57Introduction to databases
(R4) Mapping Multivalued attributes
 For a multivalued attribute m, we create a separate
relation schema R with an attribute that corresponds
to m and the primary key of the entity set.
 All of the attributes of R becomes the primary key of
the relation R.
 A(a1,a2)
 R(a1, m)
A
a1
a2
{m}
instructor
id
name
address
{phone_no}
 Instructor(id,name,address)
 instructorPhone(id, phone_no)
 We create a foreign-key constraint on the relation
schema created from the multivalued attribute.
AKN/IDBI.58Introduction to databases
(R5) Mapping Weak Entity Set
 For schemas derived from a weak entity set, the
combination of the primary key of the strong entity set
and the discriminator of the weak entity set serves as
the primary key of the schema.
 No separate relation for R is required, however, if R
contains a descriptive attribute, then it is added in A
A
a1
a2
B
b1
b2
R
 Primary key of B: b1
 Discriminator of A: a1,a2
 A foreign-key constraint is created on the relation A,
specifying that the attributes b1 references the
primary key of the relation B.
 A(a1, b1, a2) and B(b1,b2)
AKN/IDBI.59Introduction to databases
(R6) Combination of Schemas
 If entity sets participate in a total participation with
cardinality constraint as many-to-one, then the
schema for entity set in total participation and the
relationship set may be reduced to a single schema.
 The relation schema for other entity set remain as it is.
 Now the first two schemas may further be reduced
to one schema as
 A(a1, a2, b1), where b1 is the foreign key for b1 in B
A
a1
a2
B
b1
b2
R
 A(a1, a2),
 R(a1, b1)
 B(b1, b2)
AKN/IDBI.60Introduction to databases
(R7.1) Mapping Generalization - I
 Case I: (Overlapping, disjoint and partial)
 Create a schema for higher level entity set.
 Again create a schema for each lower level entity sets with
attributes as follows
 Primary key of higher level entity set
 All attributes of lower level entity set A
a1
a2
B
b1
b2
C
c1
c2
 A(a1,a2)
 B(a1,b1,b2)
 C(a1,c1, c2);
 Foreign key constraints
 a1 of B and C refers to a1
of A
AKN/IDBI.61Introduction to databases
(R7.2) Mapping Generalization - II
 Case II: (Disjoint and complete Generalization)
 Schema for higher level entity set is created only with primary
key attribute.
 And The schema for lower level entities will have following
attributes.
 All higher level attributes.
 All attributes of lower level entity set
 A(a1)
 B(a1,a2,b1,b2)
 C(a1,a2,c1, c2);
 Foreign key constraints?
A
a1
a2
B
b1
b2
C
c1
c2
total
AKN/IDBI.62Introduction to databases
(R8) Mapping Aggregation
 The schema for the
relationship set R between
the aggregation of R and
the entity set D includes an
attribute for each attribute
in the primary keys of the
entity set D, and the
relationship set R.
C
c1
c2
A
a1
a2
B
R
R
D
d1
d2
b1
b2
 A(a1,a2), B(b1, b2), C(c1, c2), D(d1, d2)
 R(a1,b1,c1), R(a1,b1,c1,d1)
 Foreign key constraints?
AKN/IDBI.63Introduction to databases
Schema Diagram
 A database schema, along with primary key and
foreign key dependencies, can be depicted by
schema diagrams.
 Each relation appears as a box, with the relation
name at the top, and the attributes listed inside the
box.
 Primary key attributes are shown underlined.
 Foreign key dependencies appear as arrows from
the foreign key attributes of the referencing relation
to the primary key of the referenced relation.
AKN/IDBI.64Introduction to databases
Example: Schema Diagram
A
a1
a2
a3
B
ba1
b1
b2
bc1
C
c1
c2
c3
 ba1 is the foreign key attribute of the referencing
relation B to the primary key attribute a1 of the
referenced relation A
 Similarly bc1 is the foreign key attribute of the
referencing relation B to the primary key attribute c1
of the referenced relation C
AKN/IDBI.65Introduction to databases
Thank You

Weitere ähnliche Inhalte

Was ist angesagt?

Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational CalculusAmiya9439793168
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagramssadique_ghitm
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database DesignArchit Saxena
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...Raj vardhan
 
A short introduction to database systems.ppt
A short introduction to  database systems.pptA short introduction to  database systems.ppt
A short introduction to database systems.pptMuruly Krishan
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.netNgeam Soly
 
Database Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationDatabase Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationNickkisha Farrell
 
Database Normalization
Database NormalizationDatabase Normalization
Database NormalizationArun Sharma
 
Week 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data ModelingWeek 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data Modelingoudesign
 

Was ist angesagt? (20)

Sql ppt
Sql pptSql ppt
Sql ppt
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational Calculus
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
 
A short introduction to database systems.ppt
A short introduction to  database systems.pptA short introduction to  database systems.ppt
A short introduction to database systems.ppt
 
ER MODEL
ER MODELER MODEL
ER MODEL
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
DBMS PPT
DBMS PPTDBMS PPT
DBMS PPT
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Database Keys
Database KeysDatabase Keys
Database Keys
 
Database Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationDatabase Management Systems 4 - Normalization
Database Management Systems 4 - Normalization
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Sql fundamentals
Sql fundamentalsSql fundamentals
Sql fundamentals
 
Week 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data ModelingWeek 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data Modeling
 
DBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCLDBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCL
 

Andere mochten auch

Software Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramSoftware Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramAjit Nayak
 
Is your company fully engaged towards innovation?
Is your company fully engaged towards innovation?Is your company fully engaged towards innovation?
Is your company fully engaged towards innovation?Sebastien Juras
 
Things to know to improve your willpower
Things to know to improve your willpowerThings to know to improve your willpower
Things to know to improve your willpowerSebastien Juras
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementAjit Nayak
 
Innovation is almost impossible for older companies
Innovation is almost impossible for older companiesInnovation is almost impossible for older companies
Innovation is almost impossible for older companiesSebastien Juras
 
Software Engineering an Introduction
Software Engineering an IntroductionSoftware Engineering an Introduction
Software Engineering an IntroductionAjit Nayak
 
03 administracion de requisitos
03 administracion de requisitos03 administracion de requisitos
03 administracion de requisitosRicardo Quintero
 
The Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under controlThe Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under controlSebastien Juras
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Ricardo Quintero
 
Six things to know about your brain to become an expert
Six things to know about your brain to become an expertSix things to know about your brain to become an expert
Six things to know about your brain to become an expertSebastien Juras
 
Computer Networks Module III
Computer Networks Module IIIComputer Networks Module III
Computer Networks Module IIIAjit Nayak
 
Object Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIObject Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIAjit Nayak
 
Misiones en Honduras Mayo 2012
Misiones en Honduras Mayo 2012Misiones en Honduras Mayo 2012
Misiones en Honduras Mayo 2012Ricardo Quintero
 
Computer Fundamentals & Intro to C Programming module i
Computer Fundamentals & Intro to C Programming module iComputer Fundamentals & Intro to C Programming module i
Computer Fundamentals & Intro to C Programming module iAjit Nayak
 
Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagramsAjit Nayak
 
Introduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and RecoveryIntroduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and RecoveryAjit Nayak
 

Andere mochten auch (20)

Software Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramSoftware Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagram
 
Manual 02
Manual 02Manual 02
Manual 02
 
Is your company fully engaged towards innovation?
Is your company fully engaged towards innovation?Is your company fully engaged towards innovation?
Is your company fully engaged towards innovation?
 
Things to know to improve your willpower
Things to know to improve your willpowerThings to know to improve your willpower
Things to know to improve your willpower
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory Management
 
The Ultimate gift
The Ultimate giftThe Ultimate gift
The Ultimate gift
 
Innovation is almost impossible for older companies
Innovation is almost impossible for older companiesInnovation is almost impossible for older companies
Innovation is almost impossible for older companies
 
Software Engineering an Introduction
Software Engineering an IntroductionSoftware Engineering an Introduction
Software Engineering an Introduction
 
The badguy summary
The badguy   summaryThe badguy   summary
The badguy summary
 
03 administracion de requisitos
03 administracion de requisitos03 administracion de requisitos
03 administracion de requisitos
 
The Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under controlThe Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under control
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5
 
Six things to know about your brain to become an expert
Six things to know about your brain to become an expertSix things to know about your brain to become an expert
Six things to know about your brain to become an expert
 
Computer Networks Module III
Computer Networks Module IIIComputer Networks Module III
Computer Networks Module III
 
Object Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIObject Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part II
 
Misiones en Honduras Mayo 2012
Misiones en Honduras Mayo 2012Misiones en Honduras Mayo 2012
Misiones en Honduras Mayo 2012
 
Computer Fundamentals & Intro to C Programming module i
Computer Fundamentals & Intro to C Programming module iComputer Fundamentals & Intro to C Programming module i
Computer Fundamentals & Intro to C Programming module i
 
Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagrams
 
Introduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and RecoveryIntroduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and Recovery
 
Perfiles UML
Perfiles UMLPerfiles UML
Perfiles UML
 

Ähnlich wie Introduction to database-ER Model

Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...Mustafa Kamel Mohammadi
 
Entity Relationship Diagram – ER Diagram in DBMS.pptx
Entity Relationship Diagram – ER Diagram in DBMS.pptxEntity Relationship Diagram – ER Diagram in DBMS.pptx
Entity Relationship Diagram – ER Diagram in DBMS.pptxsukrithlal008
 
Entity Relationship Modelling
Entity Relationship ModellingEntity Relationship Modelling
Entity Relationship ModellingBhandari Nawaraj
 
Use analyzed requirements in the design of database.pptx
Use analyzed requirements in the design of database.pptxUse analyzed requirements in the design of database.pptx
Use analyzed requirements in the design of database.pptxMwangaPrayGod
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide sharefanta teferi
 
3. Chapter Three.pdf
3. Chapter Three.pdf3. Chapter Three.pdf
3. Chapter Three.pdffikadumola
 
Chapter-3 Data Modeling Using the Entity-Relationship Model
Chapter-3  Data Modeling Using the Entity-Relationship ModelChapter-3  Data Modeling Using the Entity-Relationship Model
Chapter-3 Data Modeling Using the Entity-Relationship ModelRaj vardhan
 
DBMS_unit2_Notes.pdf
DBMS_unit2_Notes.pdfDBMS_unit2_Notes.pdf
DBMS_unit2_Notes.pdfssuserf71896
 

Ähnlich wie Introduction to database-ER Model (20)

database
databasedatabase
database
 
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
 
Entity Relationship Diagram – ER Diagram in DBMS.pptx
Entity Relationship Diagram – ER Diagram in DBMS.pptxEntity Relationship Diagram – ER Diagram in DBMS.pptx
Entity Relationship Diagram – ER Diagram in DBMS.pptx
 
dbms mannual.pdf
dbms mannual.pdfdbms mannual.pdf
dbms mannual.pdf
 
Er diagrams
Er diagramsEr diagrams
Er diagrams
 
DBMS Part-2.pptx
DBMS Part-2.pptxDBMS Part-2.pptx
DBMS Part-2.pptx
 
Entity Relationship Modelling
Entity Relationship ModellingEntity Relationship Modelling
Entity Relationship Modelling
 
Unit02 dbms
Unit02 dbmsUnit02 dbms
Unit02 dbms
 
Use analyzed requirements in the design of database.pptx
Use analyzed requirements in the design of database.pptxUse analyzed requirements in the design of database.pptx
Use analyzed requirements in the design of database.pptx
 
Er model
Er modelEr model
Er model
 
E r model
E r modelE r model
E r model
 
Db lec 02_new
Db lec 02_newDb lec 02_new
Db lec 02_new
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide share
 
3. Chapter Three.pdf
3. Chapter Three.pdf3. Chapter Three.pdf
3. Chapter Three.pdf
 
ER Diagram_Kameshwari.docx
ER Diagram_Kameshwari.docxER Diagram_Kameshwari.docx
ER Diagram_Kameshwari.docx
 
Chapter-3 Data Modeling Using the Entity-Relationship Model
Chapter-3  Data Modeling Using the Entity-Relationship ModelChapter-3  Data Modeling Using the Entity-Relationship Model
Chapter-3 Data Modeling Using the Entity-Relationship Model
 
UNIT II DBMS.pptx
UNIT II DBMS.pptxUNIT II DBMS.pptx
UNIT II DBMS.pptx
 
Er Modeling
Er ModelingEr Modeling
Er Modeling
 
27 fcs157al3
27 fcs157al327 fcs157al3
27 fcs157al3
 
DBMS_unit2_Notes.pdf
DBMS_unit2_Notes.pdfDBMS_unit2_Notes.pdf
DBMS_unit2_Notes.pdf
 

Mehr von Ajit Nayak

Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testingAjit Nayak
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Ajit Nayak
 
Software Engineering : OOAD using UML
Software Engineering : OOAD using UMLSoftware Engineering : OOAD using UML
Software Engineering : OOAD using UMLAjit Nayak
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationAjit Nayak
 
Software Engineering : Process Models
Software Engineering : Process ModelsSoftware Engineering : Process Models
Software Engineering : Process ModelsAjit Nayak
 
Database Programming using SQL
Database Programming using SQLDatabase Programming using SQL
Database Programming using SQLAjit Nayak
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part IAjit Nayak
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt IIAjit Nayak
 
NS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIINS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIIAjit Nayak
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using CAjit Nayak
 
Object Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLObject Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLAjit Nayak
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPIAjit Nayak
 
Operating Systems Part I-Basics
Operating Systems Part I-BasicsOperating Systems Part I-Basics
Operating Systems Part I-BasicsAjit Nayak
 
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockOperating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockAjit Nayak
 
Introduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusIntroduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusAjit Nayak
 
Computer Networks Module II
Computer Networks Module IIComputer Networks Module II
Computer Networks Module IIAjit Nayak
 
Computer Networks Module I
Computer Networks Module IComputer Networks Module I
Computer Networks Module IAjit Nayak
 
Object Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part IIIObject Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part IIIAjit Nayak
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IAjit Nayak
 

Mehr von Ajit Nayak (19)

Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testing
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram
 
Software Engineering : OOAD using UML
Software Engineering : OOAD using UMLSoftware Engineering : OOAD using UML
Software Engineering : OOAD using UML
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & Specification
 
Software Engineering : Process Models
Software Engineering : Process ModelsSoftware Engineering : Process Models
Software Engineering : Process Models
 
Database Programming using SQL
Database Programming using SQLDatabase Programming using SQL
Database Programming using SQL
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
 
NS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIINS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt III
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
 
Object Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLObject Oriented Analysis Design using UML
Object Oriented Analysis Design using UML
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
 
Operating Systems Part I-Basics
Operating Systems Part I-BasicsOperating Systems Part I-Basics
Operating Systems Part I-Basics
 
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockOperating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
 
Introduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusIntroduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculus
 
Computer Networks Module II
Computer Networks Module IIComputer Networks Module II
Computer Networks Module II
 
Computer Networks Module I
Computer Networks Module IComputer Networks Module I
Computer Networks Module I
 
Object Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part IIIObject Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part III
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
 

Kürzlich hochgeladen

Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadaditya806802
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfRajuKanojiya4
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESNarmatha D
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsDILIPKUMARMONDAL6
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...Amil Baba Dawood bangali
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptxNikhil Raut
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 

Kürzlich hochgeladen (20)

Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasad
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdf
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIES
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teams
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
NO1 Certified Black Magic Specialist Expert Amil baba in Uae Dubai Abu Dhabi ...
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptx
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 

Introduction to database-ER Model

  • 1. Introduction to Databases ER Model Ajit K Nayak, Ph.D. Siksha O Anusandhan University
  • 2. AKN/IDBI.2Introduction to databases Entity-Relationship (ER) Data Model  The ER data model facilitates database design by allowing specification of an enterprise schema that represents the overall logical structure of a database.  It is very useful in mapping the meanings and interactions of real-world enterprises onto a conceptual schema.  The ER data model employs three basic concepts:  Entity Sets,  Relationship Sets,  Attributes.  The ER model also has an associated diagrammatic representation, the ER diagram, which can express the overall logical structure of a database graphically.
  • 3. AKN/IDBI.3Introduction to databases ER Data Model - II  ER Model is said to be the high-end tool of database design.  This data model uses a collection of  basic objects, called entities,  and relationships among these objects.  An entity is a ―thing‖ or ―object‖ in the real world that is distinguishable from other objects.  Ex: employee, student, account  An entity has a set of properties that uniquely identifies an entity called attributes.  Ex: Employee (empNo, empName, …)  Student (studNo, studName, branch, …)
  • 4. AKN/IDBI.4Introduction to databases ER Model: Entity Set  Entity Set : is a set of entities of the same type that share the same attributes.  Ex: The set of all people who are instructors at a given university, can be defined as the entity set instructor.  Ex: The set of all students at a given university, can be defined as the entity set student.
  • 5. AKN/IDBI.5Introduction to databases ER Diagram: Entity Set  Entities are represented graphically as follows:  A two part Rectangle represent an entity set.  Part I: entity set name  Part II: Attributes listed.  Underline indicates primary key attributes
  • 6. AKN/IDBI.6Introduction to databases ER Model: Relationship - I  Relationship: A relationship is an association among several entities.  Ex: Let‘s define a relationship advisor that associates instructor Katz with student Shankar.  Relationship set: is a set of relationships of same type between two or more entity sets. Relationship set advisor
  • 7. AKN/IDBI.7Introduction to databases ER Model: Relationship Set - II  The association between entity sets is referred to as participation.  Ex: Katz and Shankar participate in relationship instance of advisor  i.e. This relationship instance represents that in the university, instructor Katz is advising student Shankar.  Relationship may also have attributes called descriptive attributes.. Ex. the advisor relationship set between entity sets instructor and student have the attribute date which tracks when the student started being associated with the advisor
  • 8. AKN/IDBI.8Introduction to databases ER Model: Relationship Set - III  The function that an entity plays in a relationship is called that entity‘s role  Katz‘s role is „instructor‟, Shankar‘s is ‗student‟ in the relationship of ‗advisor‟  The same entity set participates in a relationship set more than once, in different roles is called recursive relationship set  Also known as unary relationship MTH 1001: Calculus I MTH 2001: Calculus II CSE1002: Discrete Maths CSE2011: COA MTH2002: Probability & Statistics prerequisite recursive relationship set Role of MTH2001: course Role of MTH1001: prerequisite course
  • 9. AKN/IDBI.9Introduction to databases ER Model: Degree of Relationship  The degree of a relationship set is the number of entity sets participate in the relationship.  The three most common relationship sets categorised according to the degree in ER models are  Binary: When two entity sets participates.  Ex: Teacher teaches some Students  Unary: when both participants are the same entity  Ex: Subject prerequisite of another Subject  Also known as recursive relation  Ternary: when three entities participate in the relationship.  Ex1: Instructor becomes project_guide to students and develops projects  Ex2: Teacher teaching_activity with Branch and Subject
  • 10. AKN/IDBI.10Introduction to databases ER Diagram: Degree of Relationship subject sub_id title credits prerequisite sub_id prereq_id instructor ID name salary student ID name tot_cred project . . . proj_guid e teacher ID name salary branch ID name tot_cred subject . . . teaching activity Unary: The labels ―sub_id‖ and “prereq_id” are called roles. Ternary: 3 entity sets participate in a relationship set employee ID name salary department deptNo building budget belongsTo Binary: Most of the relationships in real world are of this type.
  • 11. AKN/IDBI.11Introduction to databases ER Model: Attributes  Attributes are the properties of an entity set that are relevant to the database and about which the data values need to be stored.  For each attribute, there is a set of permitted values, called domain or value set  An attribute of an entity set is a function that maps from the entity set in to a domain.  Each entity can be described by a set of (attribute, value) pair.  Ex. A particular instructor entity may be represented as {(ID, 76766), (name, Crick), (dept, CSIT), (salary, 50000)}  Similarly a particular student entity {(ID, 34721),(name, Sid),(DoB, 30-12-1997),(branch, CSIT)}
  • 12. AKN/IDBI.12Introduction to databases Keys - I  The values of the attributes of an entity must be such that, they uniquely identify the entity.  No two entities in an entity set are allowed to have exactly the same value for all of its attributes.  A Key makes one entity distinguishable from other entity in the same entity set.  A key for an entity set is a set of attributes, whose value uniquely determines each and every entity in an entity set.  Different keys used are  Candidate key  Super key  Primary Key  Alternate key
  • 13. AKN/IDBI.13Introduction to databases Keys - II  Ex. Consider the entity set  Student(reg_no, name, branch, address, ph_no, DoB)  Candidate key: is an attribute who‘s value uniquely determine each and every entity in an entity set.  Ex. Candidate keys {name, ph_no}, {name, address} or {reg_no}  For a given entity set, more than one candidate keys can be designed.  Super Key: any superset of an candidate key is referred as super key  i.e. A candidate key is the minimal super key, of which no proper subset can again act as a key.  Ex. Super Keys: {reg_no, name}, {reg_no, name, ph_no}, {reg_no, name, branch}, {reg_no, name, address} or {reg_no, name, DoB}, . . .
  • 14. AKN/IDBI.14Introduction to databases Keys - III  Primary key: Out of multiple candidate keys, one of the key is chosen by the database engineer as the primary key.  Primary key is used as principal means to uniquely identify each and every entity in the entity set.  Ex. Primary key {reg_no}  Alternate Key: Rest of the candidate keys (excluding primary key) are called alternate keys  Ex. Alternate Keys {name, ph_no} and {name, address}  Keys are represented in ER Diagram by underlining the key attribute(s)
  • 15. AKN/IDBI.15Introduction to databases ER Model: Category of Attributes- I  Simple and Composite  Simple attributes are atomic and cannot be divided further.  Ex. (regNo)  Composite attributes are sub-divided further.  Ex. (name{first_name, middle_name, last_name})  Composite attributes may be represented in a hierarchy. Composite attributes are useful when it is needed to use either whole or part of the information of an attribute
  • 16. AKN/IDBI.16Introduction to databases ER Model: Category of Attributes- II  Single Valued and Multivalued  Attribute that maps to only one value in a domain are called single valued attribute  Ex. DoB, reg_no  Attribute that maps to more than one values in a domain are called multivalued attribute.  Ex. phone_no, email_id  Derived  If the value for an attribute can be computed from the values of other related attributes then is called derived attribute  Ex. age, net_salary, can be calculated from DoB and other salary components respectively.
  • 17. AKN/IDBI.17Introduction to databases ER Diagram: Attributes  Composite attribute: represented in indentation.  Ex. name with component attributes first_name,…, last_name  Ex. address with , city, state, and zip.  Ex. street with street_no, street name and apt_number  Multivalued attribute: represented using curly braces.  Ex. {phone_number} of instructor  Derived attribute: represented using parenthesis. Ex. age( )
  • 18. AKN/IDBI.18Introduction to databases ER Model: Constraints  Constraints are the reflections of business rules/logic to which the database design must comply to.  These are the characteristics of relationship set.  ER Model supports two types of constraints:  Mapping Cardinalities  How many entities in one entity set is associated with entities of another entity set?  Participation Constraints.  Tells about the total or partial participation of an entity set in a relationship set.  i.e. Whether all entities or few of them are participating in a relationship set.  Ex. Participation of Student entity set in the relationship advisor is total. But participation of Instructor may be partial
  • 19. AKN/IDBI.19Introduction to databases ER Model: Mapping Cardinalities - I  Mapping cardinalities or cardinality ratios tells the number of entities to which another entity can be associated via a relationship set.  One-to-One: An entity in entity set A is associated with at most one entity in another entity set B.  Ex. One Student enrolls in One course  One-to-Many: An entity in entity set A is associated with any number of entities in entity set B.  Ex. One Teacher advises Multiple students
  • 20. AKN/IDBI.20Introduction to databases ER Model: Mapping Cardinalities - II  Many-to-One: An entity in A is associated with at most one entity in B. An entity in B, however, can be associated with any number of entities in A.  Ex. Many Students are enrolled in One Course  Many-to-Many: An entity in A is associated with any number of entities in B and an entity in B is associated with any number of entities in A.  Ex. One Customer have Many bank Accounts and One Account can have Multiple number of Customers.
  • 21. AKN/IDBI.21Introduction to databases ER Diagram: Cardinality Constraints-I  One: A directed line () from relationship set to entity set  Many: an undirected line (—)  One-to-One relationship between an instructor and a student :  A student is associated with at most one instructor via the relationship advisor  Task: Draw ER diagram where, A student is associated with at most one department via stud_dept
  • 22. AKN/IDBI.22Introduction to databases ER Diagram: Cardinality Constraints-II  One-to-Many: an instructor is associated with several (including 0) students via advisor  Many-to-One: a student is associated with several (including 0) instructors via advisor
  • 23. AKN/IDBI.23Introduction to databases ER Diagram: Cardinality Constraints-III  Many-to-Many:  An instructor is associated with several (possibly 0) students via advisor  A student is associated with several (possibly 0) instructors via advisor
  • 24. AKN/IDBI.24Introduction to databases ER Diagram: Total and Partial Participation  Total participation is indicated by double line:  i.e. every entity in the entity set participates in at least one relationship in the relationship set Ex. participation of student in advisor relation is total  every student must have an associated instructor  Partial participation: some entities may not participate in any relationship in the relationship set  Ex. participation of instructor in advisor is partial
  • 25. AKN/IDBI.25Introduction to databases ER Diagram: Complex Constraints  A line may have an associated minimum and maximum cardinality, shown in the form l..h, where  A minimum value of 1 indicates total participation  A maximum value of 1 indicates that the entity participates in at most one relationship  A maximum value of * indicates no limit. Instructor can advise 0 or more students. A student must have 1 advisor; cannot have multiple advisors
  • 26. AKN/IDBI.26Introduction to databases Example: Represent Entities  Consider a retail store  Order 1 Date: 26-8-16, Amount:1620.00 Add: BBSR, Item1: rice, qty: 2, Price:90.00, Item2: trouser, qty:1, Price1200.00, Item3:soap, qty:3, Price150.00, Item4:biscuit, qty:3, Price:180.00  Order 2: . . .  Order 3: . . .
  • 27. AKN/IDBI.27Introduction to databases ER Model: Weak Entity Set - I  An entity set that cannot be uniquely identified by its attributes alone are called weak entity sets.  i.e. the entity set does not have sufficient attributes to form a primary key and are dependent on other entity sets for their existence.  An entity having own primary key is called a strong entity.  The strong entity upon which the weak entity depends is refereed as identity entity  The relationship set through which the weak entity is connected to its identity (strong) entity set is called identifying relationship set.
  • 28. AKN/IDBI.28Introduction to databases ER Diagram: Weak Entity Set  Ex. orderItem(item_no, quantity, price, discount) orderItem sitem_no quantity price discount order order_no order_date payment_info shipping_add contains  The relationship set with its identity entity (strong) set is represented using double line diamond  The line from weak entity to identifying relationship set is double lined  A set of attributes of a weak entity set is referred as the discriminator (or partial key) that is used as a means of distinguishing among all those entities in the weak entity set that depend on one particular strong entity
  • 29. AKN/IDBI.29Introduction to databases Weak Entity Set - III  The discriminator of a weak entity is underlined with dashed line.  The primary key of a weak entity set is formed by  the primary key of the identifying entity set, plus  the weak entity set‘s discriminator.  In the case of the entity set order, its primary key is {order_no, item_no, quantity, price, discount}  The participation of the weak entity set with its identifying relationship set is always total.  The cardinality of the identifying relationship set is always many-to-one from the weak entity set to its identifying entity set
  • 30. AKN/IDBI.30Introduction to databases Weak Entity Set - III  Discriminator?  Primary key?  primary key of section {course_id, sec_id, year, semester}  The identifying relationship set is not allowed to have any descriptive attribute  Weak entity can participate in any other relationship set after forming the primary key. section section_id semester year course course_id title credits secCourse
  • 31. AKN/IDBI.31Introduction to databases Participation Constraints account accNum balancedeposits loan loanNum loanAmt branch brID brName brAdd loanBranch borrows accWith lastAccessDate customer custNum name fName lName address {phoneNum} • Participation of entity set account in deposit relationship & accWith relationship is total • Participation of loan entity set in loanBranch relationship & borrows relationship is total
  • 32. AKN/IDBI.32Introduction to databases Extended ER Features  The extended ER features are  Specialization  Generalization  Aggregation
  • 33. AKN/IDBI.33Introduction to databases Specialization  An entity set may allow further sub-grouping within it based on the distinctive features (attributes)  Specialization is a technique of designating sub- grouping of entities within an entity set based upon the distinct attributes that the entity possess  Specialization is a refinement approach that stems from an entity set (higher level entity set ) in order to form multiple entity sets (lower level entity set )  The entities in the lower level entity sets are the sub- sets of the entities in its higher level entity set.  This is known as „IS A‟ relationship.  Ex. Tiger is an Animal, Cheetah is a Tiger  Also referred as ―Superclass – subclass‖ relationship
  • 34. AKN/IDBI.34Introduction to databases Generalization  Generalization is the approach of synthesizing multiple entity set (lower level) in order to form a higher level entity set based upon common features (attributes) posses by the lower level entity sets  Generalization stems from multiple lower level entity sets and forms a single higher level entity set.  In ER diagram it is represented in same way as specialization.  Ex. Given: Cat, Tiger, Wolf, Lion, elephant entity sets, we extract and use all the common features available in all entity sets to form another Animal entity set.
  • 35. AKN/IDBI.35Introduction to databases Specialization Examples MTechStud . . . MCAStud . . . student stud_id name . . . PGStud . . . UGStud . . . employee emp_id name desig regEmp salary leave partEmp perkPerHr hourPerWk
  • 36. AKN/IDBI.36Introduction to databases Attribute Inheritance  All the attributes including the primary key of the higher level entity set are inherited/derived and associated to all lower level entity sets  Ex. student and employee inherit the attributes of person.  Thus, student is described by its ID, name, and address attributes, and additionally a tot_cred attribute;  employee is described by its ID, name, and address attributes, and additionally a salary attribute.
  • 37. AKN/IDBI.37Introduction to databases Participation Inheritance  A lower-level entity set also inherits participation in the relationship sets in which its higher-level entity participates.  Participation inheritance applies through all tiers of lower-level entity sets.  Ex. suppose the person entity set participates in a relationship person_dept with department.  Then, the student, employee, instructor and secretary entity sets, which are subclasses of the person entity set, also implicitly participate in the person_dept relationship with department.  The above entity sets can participate in any relationships in which the person entity set participates.
  • 38. AKN/IDBI.38Introduction to databases Overlapping and Disjoint Constraints  Specialization is said to be overlapping if there exists at least one entity in the higher entity set that belongs to more than one lower level entity sets, otherwise called disjoint. Overlapping specialization disjoint specialization Overlapping Specialization the same entity may belong to more than one lower-level entity set within a single generalization Disjoint Specialization If an entity belong to no more than one lower-level entity set
  • 39. AKN/IDBI.39Introduction to databases Membership Constraint  To model an enterprise more accurately, certain constraints may be place on a particular generalization  Condition-defined Membership  A membership is confirmed if an entity satisfies an explicit condition.  Ex. student has an attribute student_type. Whose value can be „undergraduate‟ or „graduate‟  Then all entities that satisfy the condition student type = “undergraduate” are included in UGStud.  User-defined Membership  after 3 months of employment, university employees are assigned to one of four work teams.  The teams are represented as four lower-level entity sets of the higher-level employee entity set.  A given employee is assigned to a specific team entity set manually.
  • 40. AKN/IDBI.40Introduction to databases Completeness Constraint  Total generalization or specialization.  Each higher-level entity must belong to a lower-level entity set.  Ex. The student generalization is total: All student entities must be either post graduate or undergraduate.  Partial generalization or specialization.  Some higher-level entities may not belong to any lower-level entity set.  Partial generalization is the default.  Ex. The employee generalization is partial. Some employees are there who are neither an instructor nor a secretary.
  • 41. AKN/IDBI.41Introduction to databases Specialization/Generalization • Design two sub entity sets of account as sbAcc and currAcc. account accNum balancedeposits loan loanNum loanAmt branch brID brName brAdd loanBranch borrows accWith lastAccessDate customer custNum name fName lName address {phoneNum} installment instNum instAmt instDate payBack sbAcc rateOfInt currAcc odAmt • It is a disjoint specialization!
  • 42. AKN/IDBI.42Introduction to databases Problem  How to Modify the model s.t. an Instructor guiding a student on a project can file a monthly evaluation report containing instructor, student and project information instructor ID name salary student ID name tot_cred project . . . proj_guide
  • 43. AKN/IDBI.43Introduction to databases Aggregation -I  It can express relationship among relationship sets  Aggregation facilitates to treat a relationship set (along with all of its associated entity sets) as a higher level entity set and can participate in another relationship set.  i.e. Aggregation is an abstraction through which relationships are treated as higher-level entities.
  • 44. AKN/IDBI.44Introduction to databases Aggregation -II  The relationship set proj_guide is represented as a higher-level entity set called proj guide.  Such an entity set is treated in the same manner as is any other entity  We then create a binary relationship eval_for between proj_guide and evaluation to represent which combination an evaluation is for.
  • 45. AKN/IDBI.45Introduction to databases Reduction to Relational Schema  An E-R design can be Translated/mapped/reduced into a relational design.  Entity sets and relationship sets can be expressed uniformly as relation schemas that represent the contents of the database.  A database which confirms to an E-R diagram can be represented by a collection of schemas.  For each entity set and relationship set there is a unique schema that is assigned the name of the corresponding entity set or relationship set.  Each schema has a number of columns (generally corresponding to attributes), which have unique names
  • 46. AKN/IDBI.46Introduction to databases (R1) Mapping Strong Entity sets  A strong entity set reduces to a schema with the same attributes as in entity set. A a1 a2 a3  Mapping: A(a1,a2,a3) student ID name tot_cred  student(ID, name, tot_cred)
  • 47. AKN/IDBI.47Introduction to databases (R2) Mapping Relationship sets  A relationship set reduces to a schema with the primary key attributes of participating entities and descriptive attributes.  (R2.1) For a binary many-to-many relationship, the union of the primary-key attributes from the participating entity sets becomes the primary key. A a1 a2 a3 B b1 b2 b3 R r1  A(a1, a2, a3)  B(b1, b2, b3)  R(a1, b1, r1)
  • 48. AKN/IDBI.48Introduction to databases (R2) Mapping Relationship sets - II  (R2.2)For a binary one-to-one relationship set, the primary key of either entity set can be chosen as the primary key. The choice can be made arbitrarily A a1 a2 a3 B b1 b2 b3 R  A(a1, a2, a3)  B(b1, b2, b3)  R(a1, b1) or  R(a1, b1)
  • 49. AKN/IDBI.49Introduction to databases (R2) Mapping Relationship sets - III  (R2.3) For a binary many-to-one or one-to-many relationship, the primary key of the entity set on the ―many‖ side of the relationship set serves as the primary key. A a1 a2 a3 B b1 b2 b3 R  A(a1, a2, a3)  B(b1, b2, b3)  R(a1, b1)
  • 50. AKN/IDBI.50Introduction to databases (R2) Mapping Relationship sets - IV  (R2.4) For an n-ary relationship set without any arrows on its edges, the union of the primary key-attributes from the participating entity sets becomes the primary key.  (R2.5) For an n-ary relationship set with an arrow on one of its edges, the primary keys of the entity sets not on the ―arrow‖ side of the relationship set serve as the primary key for the schema.  A(a1, a2, a3)  B(b1, b2, b3)  B(c1, c2, c3)  R(a1, b1 , c1) A a1 a2 a3 B b1 b2 b3 R C c1 c2 c3
  • 51. AKN/IDBI.51Introduction to databases (R3) Referential Integrity  For each entity set Ei related to relationship set R, we create a foreign-key constraint from relation schema R, with the attributes derived from primary-key attributes of Ei. A a1 a2 a3 B b1 b2 b3 R  Two foreign key constraints are created on relation R  i.e. attribute r_a1 referencing primary key of A and attribute r_b1 referencing primary key of B.  A(a1, a2, a3)  B(b1, b2, b3)  R(r_a1, r_b1)
  • 52. AKN/IDBI.52Introduction to databases (R3) Mapping Composite attributes  While mapping a composite attribute to a relation, we form one attribute in the relation schema for each sub-attribute in the composite attribute of ER diagram.  Attribute is not created for the composite attribute itself.  A(a1, a21, a22, a3)A a1 a2 a21 a22 a3 B b1 b2 b21 b211 b212 b22 b3  B(b1, b211, b212, b22,b3)
  • 53. AKN/IDBI.53Introduction to databases (R4) Mapping Multivalued attributes  For a multivalued attribute m, we create a separate relation schema R with an attribute a that corresponds to m and the primary key of the entity set.  All of the attributes of R becomes the primary key of the relation R.  R(a1, m)A a1 a2 {m} instructor id name address {phone_no}  instructorPhone(id1, phone_no)  We create a foreign-key constraint on the relation schema created from the multivalued attribute.
  • 54. AKN/IDBI.54Introduction to databases (R5) Mapping Weak Entity Set  For schemas derived from a weak entity set, the combination of the primary key of the strong entity set and the discriminator of the weak entity set serves as the primary key of the schema.  No separate relation for R is required, however, if R contains a descriptive attribute, then it is added in A A a1 a2 B b1 b2 R  Primary key of B: b1  Discriminator of A: a1,a2  A foreign-key constraint is created on the relation A, specifying that the attributes b1, b2 reference the primary key of the relation B.  A(a1, b1, a2) and B(b1,b2)
  • 55. AKN/IDBI.55Introduction to databases (R2.5) Referential Integrity  For each entity set Ei related to relationship set R, we create a foreign-key constraint from relation schema R, with the attributes derived from primary-key attributes of Ei. A a1 a2 a3 B b1 b2 b3 R  Two foreign key constraints are created on relation R  i.e. attribute r_a1 referencing primary key of A and attribute r_b1 referencing primary key of B.  A(a1, a2, a3)  B(b1, b2, b3)  R(r_a1, r_b1)
  • 56. AKN/IDBI.56Introduction to databases (R3) Mapping Composite attributes  While mapping a composite attribute to a relation, we form one attribute in the relation schema for each sub-attribute in the composite attribute of ER diagram.  Attribute is not created for the composite attribute itself.  A(a1, a21, a22, a3)A a1 a2 a21 a22 a3 B b1 b2 b21 b211 b212 b22 b3  B(b1, b211, b212, b22,b3)
  • 57. AKN/IDBI.57Introduction to databases (R4) Mapping Multivalued attributes  For a multivalued attribute m, we create a separate relation schema R with an attribute that corresponds to m and the primary key of the entity set.  All of the attributes of R becomes the primary key of the relation R.  A(a1,a2)  R(a1, m) A a1 a2 {m} instructor id name address {phone_no}  Instructor(id,name,address)  instructorPhone(id, phone_no)  We create a foreign-key constraint on the relation schema created from the multivalued attribute.
  • 58. AKN/IDBI.58Introduction to databases (R5) Mapping Weak Entity Set  For schemas derived from a weak entity set, the combination of the primary key of the strong entity set and the discriminator of the weak entity set serves as the primary key of the schema.  No separate relation for R is required, however, if R contains a descriptive attribute, then it is added in A A a1 a2 B b1 b2 R  Primary key of B: b1  Discriminator of A: a1,a2  A foreign-key constraint is created on the relation A, specifying that the attributes b1 references the primary key of the relation B.  A(a1, b1, a2) and B(b1,b2)
  • 59. AKN/IDBI.59Introduction to databases (R6) Combination of Schemas  If entity sets participate in a total participation with cardinality constraint as many-to-one, then the schema for entity set in total participation and the relationship set may be reduced to a single schema.  The relation schema for other entity set remain as it is.  Now the first two schemas may further be reduced to one schema as  A(a1, a2, b1), where b1 is the foreign key for b1 in B A a1 a2 B b1 b2 R  A(a1, a2),  R(a1, b1)  B(b1, b2)
  • 60. AKN/IDBI.60Introduction to databases (R7.1) Mapping Generalization - I  Case I: (Overlapping, disjoint and partial)  Create a schema for higher level entity set.  Again create a schema for each lower level entity sets with attributes as follows  Primary key of higher level entity set  All attributes of lower level entity set A a1 a2 B b1 b2 C c1 c2  A(a1,a2)  B(a1,b1,b2)  C(a1,c1, c2);  Foreign key constraints  a1 of B and C refers to a1 of A
  • 61. AKN/IDBI.61Introduction to databases (R7.2) Mapping Generalization - II  Case II: (Disjoint and complete Generalization)  Schema for higher level entity set is created only with primary key attribute.  And The schema for lower level entities will have following attributes.  All higher level attributes.  All attributes of lower level entity set  A(a1)  B(a1,a2,b1,b2)  C(a1,a2,c1, c2);  Foreign key constraints? A a1 a2 B b1 b2 C c1 c2 total
  • 62. AKN/IDBI.62Introduction to databases (R8) Mapping Aggregation  The schema for the relationship set R between the aggregation of R and the entity set D includes an attribute for each attribute in the primary keys of the entity set D, and the relationship set R. C c1 c2 A a1 a2 B R R D d1 d2 b1 b2  A(a1,a2), B(b1, b2), C(c1, c2), D(d1, d2)  R(a1,b1,c1), R(a1,b1,c1,d1)  Foreign key constraints?
  • 63. AKN/IDBI.63Introduction to databases Schema Diagram  A database schema, along with primary key and foreign key dependencies, can be depicted by schema diagrams.  Each relation appears as a box, with the relation name at the top, and the attributes listed inside the box.  Primary key attributes are shown underlined.  Foreign key dependencies appear as arrows from the foreign key attributes of the referencing relation to the primary key of the referenced relation.
  • 64. AKN/IDBI.64Introduction to databases Example: Schema Diagram A a1 a2 a3 B ba1 b1 b2 bc1 C c1 c2 c3  ba1 is the foreign key attribute of the referencing relation B to the primary key attribute a1 of the referenced relation A  Similarly bc1 is the foreign key attribute of the referencing relation B to the primary key attribute c1 of the referenced relation C