SlideShare a Scribd company logo
E-R MODEL
Agenda
 Entity Set
 Attribute Types
 Relationship Sets
 Mapping Constraints
 E-R Diagram
 Keys
 Design Issues
 EXTENDED E-R FEATURES
Types of Attribute
 Attribute: A characteristic of an entity.
 Domain: A set of possible values for an
attribute.
 Attribute types:
 Simple and composite attributes.
 Single-valued and multi-valued attributes
 Derived attributes
 Simple : cannot further divided.
Eg: Age, Customer_no .
 Composite : divided eg: Name ,
address,
 Single-value: salary, id, roll no.
 Multivalue : phone number.
 Derived : Age from Birth year.
Composite Attributes
Relationship Sets
 A relationship is an association among several
entities
 A relationship set is a mathematical relation
among n  2 entities, each taken from entity
sets
{(e1, e2, … en) | e1  E1, e2  E2, …, en  En}
where (e1, e2, …, en) is a relationship
Degree of a Relationship Set
 Refers to number of entity sets that participate in a
relationship set
 Relationship sets that involve two entity sets are
binary (or degree two). Generally, most
relationship sets in a database system are binary.
 Relationship sets may involve more than two
entity sets. Like Ternary relationship.
 Or N-Ary
Mapping Cardinalities
 Express the number of entities to which another
entity can be associated via a relationship set.
 Most useful in describing binary relationship
sets.
 For a binary relationship set the mapping
cardinality must be one of the following types:
 One to one
 One to many
 Many to one
 Many to many
Mapping Cardinalities
One to one One to many
Note: Some elements in A and B may not be mapped to any
elements in the other set
Many to one Many to many
Note: Some elements in A and B may not be mapped to any
elements in the other set
E-R Diagrams
 Rectangles represent entity sets.
 Diamonds represent relationship sets.
 Lines link attributes to entity sets and entity sets to
relationship sets.
 Ellipses represent attributes
 Double ellipses represent multivalued attributes.
 Dashed ellipses denote derived attributes.
 Underline indicates primary key attributes
E-R Diagram With Composite,
Multivalued, and Derived Attributes
Relationship Sets with
Attributes
Roles
 Entity sets of a relationship need not be distinct
 The labels “manager” and “worker” are called
roles; they specify how employee entities
interact via the works-for relationship set.
 Roles are indicated in E-R diagrams by labeling
the lines that connect diamonds to rectangles.
 Role labels are optional, and are used to clarify
semantics of the relationship
Cardinality Constraints
 We express cardinality constraints by drawing either a
directed line (), signifying “one,” or an undirected line
(—), signifying “many,” between the relationship set and
the entity set.
 E.g.: One-to-one relationship:
 A customer is associated with at most one loan via the
relationship borrower
 A loan is associated with at most one customer via
borrower
One-To-Many Relationship
 In the one-to-many relationship a loan is
associated with at most one customer via
borrower, a customer is associated with several
(including 0) loans via borrower
Many-To-One Relationships
 In a many-to-one relationship a loan is
associated with several (including 0) customers
via borrower, a customer is associated with at
most one loan via borrower
Many-To-Many Relationship
 A customer is associated with several (possibly 0)
loans via borrower
 A loan is associated with several (possibly 0)
customers via borrower
Participation of an Entity Set
in a Relationship Set
 Total participation (indicated by double line):
every entity in the entity set participates in at
least one relationship in the relationship set
 E.g. participation of loan in borrower is
total
 every loan must have a customer
associated to it via borrower
 Partial participation: some entities may not
participate in any relationship in the
relationship set
 E.g. participation of customer in borrower is
partial
dbms er model
Alternative Notation for
Cardinality Limits
 Cardinality limits can also express
participation constraints
Keys
 A super key of an entity set is a set of one or
more attributes whose values uniquely
determine each entity.
 A candidate key of an entity set is a minimal
super key
 Customer-id is candidate key of customer
 account-number is candidate key of account
 Although several candidate keys may exist, one
of the candidate keys is selected to be the
primary key
Keys for Relationship Sets
 The combination of primary keys of the
participating entity sets forms a super key of a
relationship set.
 (customer-id, account-number) is the super key
of depositor
 Must consider the mapping cardinality of the
relationship set when deciding the what are the
candidate keys
 Need to consider semantics of relationship set
in selecting the primary key in case of more
than one candidate key
E-R Diagram with a Ternary
Relationship
Binary Vs. Non-Binary
Relationships
 Some relationships that appear to be non-binary
may be better represented using binary
relationships
 E.g. A ternary relationship parents, relating
a child to his/her father and mother, is best
replaced by two binary relationships, father
and mother
 Using two binary relationships allows
partial information (e.g. only mother
being know)
 But there are some relationships that are
naturally non-binary
 E.g. works-on
Converting Non-Binary
Relationships to Binary Form
 In general, any non-binary relationship can be represented
using binary relationships by creating an artificial entity set.
 Replace R between entity sets A, B and C by an entity
set E, and three relationship sets:
1. RA, relating E and A
2.RB, relating E and B
3. RC, relating E and C
 Create a special identifying attribute for E
 Add any attributes of R to E
 For each relationship (ai , bi , ci) in R, create
1. a new entity ei in the entity set E
2. add (ei , ai ) to RA
3. add (ei , bi ) to RB
4. add (ei , ci ) to RC
 Also need to translate constraints
 Translating all constraints may not be possible
 There may be instances in the translated schema that
cannot correspond to any instance of R
 Exercise: add constraints to the relationships RA, RB
and RC to ensure that a newly created entity
corresponds to exactly one entity in each of entity sets
A, B and C
 We can avoid creating an identifying attribute by making E
a weak entity set (described shortly) identified by the three
relationship sets
Weak Entity Sets
 An entity set that does not have a primary key is
referred to as a weak entity set.
 The existence of a weak entity set depends on the
existence of a identifying entity set
 it must relate to the identifying entity set via a
total, one-to-many relationship set from the
identifying to the weak entity set
 Identifying relationship depicted using a double
diamond
 The discriminator (or partial key) of a weak entity
set is the set of attributes that distinguishes among
all the entities of a weak entity set.
 The primary key of a weak entity set is formed by
the primary key of the strong entity set on which the
weak entity set is existence dependent, plus the
weak entity set’s discriminator.
Weak Entity Sets (Cont.)
 We depict a weak entity set by double
rectangles.
 We underline the discriminator of a weak entity
set with a dashed line.
 payment-number – discriminator of the
payment entity set
 Primary key for payment – (loan-number,
payment-number)
Weak Entity Sets (Cont.)
 Note: the primary key of the strong entity set is
not explicitly stored with the weak entity set,
since it is implicit in the identifying
relationship.
 If loan-number were explicitly stored, payment
could be made a strong entity, but then the
relationship between payment and loan would
be duplicated by an implicit relationship
defined by the attribute loan-number common
to payment and loan
Design Issues
 Use of entity sets vs. attributes
Choice mainly depends on the structure of the
enterprise being modeled, and on the semantics
associated with the attribute in question.
 Use of entity sets vs. relationship sets
Possible guideline is to designate a relationship
set to describe an action that occurs between
entities
 Binary versus n-ary relationship sets
Although it is possible to replace any nonbinary
(n-ary, for n > 2) relationship set by a number
of distinct binary relationship sets, a n-ary
relationship set shows more clearly that several
entities participate in a single relationship.
 Placement of relationship attributes
EXTENDED E-R
FEATURES
Specialization
 Top-down design process; we designate
subgroupings within an entity set that are
distinctive from other entities in the set.
 These subgroupings become lower-level
entity sets that have attributes or
participate in relationships that do not
apply to the higher-level entity set.
 Depicted by a triangle component
labeled ISA (E.g. customer “is a”
person).
Specialization Example
Generalization
 A bottom-up design process – combine a
number of entity sets that share the same
features into a higher-level entity set.
 Specialization and generalization are
simple inversions of each other; they are
represented in an E-R diagram in the
same way.
 The terms specialization and
generalization are used interchangeably.
Specialization and
Generalization (Contd.)
 Can have multiple specializations of an entity
set based on different features.
 E.g. permanent-employee vs. temporary-
employee, in addition to officer vs. secretary vs.
teller
 Each particular employee would be
 a member of one of permanent-employee or
temporary-employee,
 and also a member of one of officer,
secretary, or teller
 The ISA relationship also referred to as
superclass - subclass relationship
 Union of subtype members is
always equal to the set
supertype. (Generalization)
 Eg: vehicals : air, surface, water.
 Union of subtype members is
not always equal to the set
supertype. (Specialization)
 Eg: employee : manager and
clerk.
Design Constraints on a
Specialization/Generalization
 Attribute inheritance:
 It is a crucial property of the higher and lower
level entities created by specialization and
generalization
 It is a lower-level entity set inherits all the
attributes and relationship participation of the
higher-level entity set to which it is linked.
 A higher level entity set with attributes and
relationships that apply to all of its lower-level
entity sets
 Lower level entity sets with distinctive features
that apply only within a particular lower-level
entity set
 Constraint on which entities can be members
of a given lower-level entity set.
 condition-defined
 E.g. all customers over 65 years are
members of senior-citizen entity set;
senior-citizen ISA person.
 user-defined
 It is not constrained by a given condition,
The database user assigns entities to a
given entity set.
 Constraint on whether or not entities may
belong to more than one lower-level entity set
within a single generalization
 Disjoint
 an entity can belong to only one lower-
level entity set
 Noted in E-R diagram by writing disjoint
next to the ISA triangle.
 Example : An account entity can satisfy
only one condition for the account-type
attribute; an entity can be either a savings
account or a checking account, but
cannot be both
 Overlapping
 an entity can belong to more than one
lower-level entity set
Example of overlapping
 Assume that certain managers
participate in more than one
work team.
 suppose generalization applied
to entity sets customer and
employee leads to a higher-level
entity set person. The
generalization is overlapping if
an employee can also be a
customer.
 Completeness constraint -- specifies whether or
not an entity in the higher-level entity set must
belong to at least one of the lower-level entity
sets within a generalization.
 total : an entity must belong to one of the
lower-level entity sets
 partial: an entity need not belong to one of
the lower-level entity sets
Aggregation
 Consider the ternary relationship works-on,
which we saw earlier
 Suppose we want to record managers for tasks
performed by an employee at a branch
Aggregation (Cont.)
 Relationship sets works-on and manages
represent overlapping information
 Every manages relationship corresponds to a
works-on relationship
 However, some works-on relationships may
not correspond to any manages relationships
 So we can’t discard the works-on
relationship
 Eliminate this redundancy via aggregation
 Treat relationship as an abstract entity
 Allows relationships between relationships
 Abstraction of relationship into new entity
 Without introducing redundancy, the following diagram
represents:
 An employee works on a particular job at a particular
branch
 An employee, branch, job combination may have an
associated manager
E-R Design Decisions
 The use of an attribute or entity set to represent
an object.
 Whether a real-world concept is best expressed
by an entity set or a relationship set.
 The use of a ternary relationship versus a pair
of binary relationships.
 The use of a strong or weak entity set.
 The use of specialization/generalization –
contributes to modularity in the design.
 The use of aggregation – can treat the aggregate
entity set as a single unit without concern for
the details of its internal structure.
Summary of Symbols Used in
E-R Notation
Summary of Symbols (Cont.)
Alternative E-R Notations
 Construct an E-R diagram for a
car-insurance company, that
has a set of customer. Each
customer own one or more cars.
Each car has associated with it
zero to any number of recorded
accidents.
 Construct an ER diagram for the
Company that handles the
projects from various clients.
The Company has different
business units headed by the
unit heads. Each Business unit
have employees to work on
client's projects. Identify all the
Entities and relationships and
design a logical schema also.
 Construct an E-R diagram for a
hospital with a set of patients
and a set of medical doctors.
Associate with each patient a
log of the various tests and
examinations conducted.
 A university registrar’s office maintains
data about the following entities: (a)
courses, including number, title, credits,
syllabus, and prerequisites; (b) course
offerings, including course number, year,
semester, section number,
instructor(s),timings, and classroom; (c)
students, including student-id, name, and
program; and (d) instructors, including
identification number, name, department,
and title. Further, the enrollment of
students in courses and grades awarded to
students in each course they are enrolled
for must be appropriately modeled.
Reduction of an E-R Schema to Tables
Reduction of an E-R Schema
to Tables
 Primary keys allow entity sets and relationship
sets to be expressed uniformly as tables which
represent the contents of the database.
 A database which conforms to an E-R diagram
can be represented by a collection of tables.
 For each entity set and relationship set there is a
unique table which is assigned the name of the
corresponding entity set or relationship set.
 Each table has a number of columns (generally
corresponding to attributes), which have unique
names.
 Converting an E-R diagram to a table format is
the basis for deriving a relational database
design from an E-R diagram.
Conversion of Strong Entities
 For each strong entity in E-R
diagram, create a separate table
with the same name. Include all
simple attributes of the strong
entity with the same name.
 Create a key for the table
Conversion of Weak Entities
 A weak entity set becomes a
table that includes a column for
the primary key of the identifying
strong entity set, along with its
own attributes
Example
Conversion of Strong
Entity(Customer)
Conversion of Weak
Entity(payment)
Conversion of one-one
Relationship
 For each one-one relationship,(betn
A and B),modify one of the table
(A or B),to include the P.Key of
other relation as F.Key
 If relationship has attributes,it must
be transferred to the modified
relation
 If any relation has a total
participation, only that table must
be modifed
Conversion of one-many
Relationship
 For each one-Many relationship,
modify N-side relation to hold the
primary key of other as a foreign
key
Conversion of many-many
Relationship
 A many-to-many relationship set is
represented as a table with columns
for the primary keys of the two
participating entity sets, and any
descriptive attributes of the
relationship set.
Advantages Of E-R model
1. Conceptual Simplicity
2. Maps well to the relational model
3. Simple and easy to understand
4. It is acting as a effective
communication tool between user
and developer
Disadvantages Of E-R model
1. Limited Constraint representation
2. Limited Relationship
representation
3. Loss of Information content
4. Suitable only for big projects

More Related Content

PDF
Difference between fact tables and dimension tables
PPTX
Slide 6 er strong & weak entity
PPTX
Difference Between Sql - MySql and Oracle
PPT
Advanced sql
PPTX
Basic SQL and History
PPTX
STRUCTURE OF SQL QUERIES
PDF
Database backup and recovery
PPTX
Data Manipulation Language
Difference between fact tables and dimension tables
Slide 6 er strong & weak entity
Difference Between Sql - MySql and Oracle
Advanced sql
Basic SQL and History
STRUCTURE OF SQL QUERIES
Database backup and recovery
Data Manipulation Language

What's hot (20)

PPTX
8. sql
PPTX
SQL Basics
PPTX
SQL - DML and DDL Commands
PPTX
5. stored procedure and functions
PPTX
SQL Operators.pptx
PPTX
DBMS and its Models
PPT
Chapter08 structuring system requirements
PPTX
ODP
Ms sql-server
PPT
Unit03 dbms
PPTX
Group By, Order By, and Aliases in SQL
PPTX
BACKUP & RECOVERY IN DBMS
PPT
Lecture 01 introduction to database
PPTX
Query optimization
DOCX
Chapter-3 Data Modeling Using the Entity-Relationship Model
PPTX
Charcteristics of System
PPTX
1.4 data independence
PPT
Mysql
8. sql
SQL Basics
SQL - DML and DDL Commands
5. stored procedure and functions
SQL Operators.pptx
DBMS and its Models
Chapter08 structuring system requirements
Ms sql-server
Unit03 dbms
Group By, Order By, and Aliases in SQL
BACKUP & RECOVERY IN DBMS
Lecture 01 introduction to database
Query optimization
Chapter-3 Data Modeling Using the Entity-Relationship Model
Charcteristics of System
1.4 data independence
Mysql
Ad

Similar to dbms er model (20)

PPT
E R Model details.ppt
PPT
ER Model and other topics in DBMS
PPTX
Unit 3 final.pptx
PDF
Basic concepts of Data and Databases
PPTX
Entity Relationship Diagram Concept.pptx
PDF
Data & Databases
PPTX
Pertemuan-4------------------------------------------------
PPT
Er Model Nandha&Mani
PPT
Entity Relationship Diagram Models UML.ppt
PPT
ER-model_for_web_development_1111111.ppt
PPT
Entity Relation -model presentation ppts
PPT
Entity Relation -model presentation ppts
PPTX
PPTX
Database Management System DBMS ER diagram.
PPT
Test presentation
PPT
2. Entity Relationship Model in DBMS
PPTX
entityrelationshipmodel.pptx
PPT
Er model
PPT
ER model
PPT
E R Model details.ppt
ER Model and other topics in DBMS
Unit 3 final.pptx
Basic concepts of Data and Databases
Entity Relationship Diagram Concept.pptx
Data & Databases
Pertemuan-4------------------------------------------------
Er Model Nandha&Mani
Entity Relationship Diagram Models UML.ppt
ER-model_for_web_development_1111111.ppt
Entity Relation -model presentation ppts
Entity Relation -model presentation ppts
Database Management System DBMS ER diagram.
Test presentation
2. Entity Relationship Model in DBMS
entityrelationshipmodel.pptx
Er model
ER model
Ad

More from Surya Swaroop (20)

PDF
Pie chart - qualitative aptitude
PPTX
Simplification and data interpretation table
PPTX
Quantitative aptitude table data interpretation
PDF
Environmental engineering text book
PPT
Development of surfaces
PPT
Elasticity
PDF
Design and Drawing of Steel Structures
PDF
Design & Drawing of Steel Structures
PDF
design drawing of steel structures
PDF
design-and-drawing Steel structures
PDF
design drawing steel structures
PDF
Integration material
PDF
Probability
PDF
Other transform dip
PPT
deadlock and locking - dbms
PPT
transaction management, concept & State
PPT
relational algebra Tuple Relational Calculus - database management system
PPT
relational database
PPT
er question dbms
PPT
data base
Pie chart - qualitative aptitude
Simplification and data interpretation table
Quantitative aptitude table data interpretation
Environmental engineering text book
Development of surfaces
Elasticity
Design and Drawing of Steel Structures
Design & Drawing of Steel Structures
design drawing of steel structures
design-and-drawing Steel structures
design drawing steel structures
Integration material
Probability
Other transform dip
deadlock and locking - dbms
transaction management, concept & State
relational algebra Tuple Relational Calculus - database management system
relational database
er question dbms
data base

Recently uploaded (20)

PDF
IGGE1 Understanding the Self1234567891011
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
Empowerment Technology for Senior High School Guide
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
1_English_Language_Set_2.pdf probationary
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
Indian roads congress 037 - 2012 Flexible pavement
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
What if we spent less time fighting change, and more time building what’s rig...
IGGE1 Understanding the Self1234567891011
Weekly quiz Compilation Jan -July 25.pdf
B.Sc. DS Unit 2 Software Engineering.pptx
FORM 1 BIOLOGY MIND MAPS and their schemes
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
Practical Manual AGRO-233 Principles and Practices of Natural Farming
TNA_Presentation-1-Final(SAVE)) (1).pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Empowerment Technology for Senior High School Guide
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
1_English_Language_Set_2.pdf probationary
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Indian roads congress 037 - 2012 Flexible pavement
Unit 4 Computer Architecture Multicore Processor.pptx
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
Paper A Mock Exam 9_ Attempt review.pdf.
What if we spent less time fighting change, and more time building what’s rig...

dbms er model

  • 2. Agenda  Entity Set  Attribute Types  Relationship Sets  Mapping Constraints  E-R Diagram  Keys  Design Issues  EXTENDED E-R FEATURES
  • 3. Types of Attribute  Attribute: A characteristic of an entity.  Domain: A set of possible values for an attribute.  Attribute types:  Simple and composite attributes.  Single-valued and multi-valued attributes  Derived attributes
  • 4.  Simple : cannot further divided. Eg: Age, Customer_no .  Composite : divided eg: Name , address,  Single-value: salary, id, roll no.  Multivalue : phone number.  Derived : Age from Birth year.
  • 6. Relationship Sets  A relationship is an association among several entities  A relationship set is a mathematical relation among n  2 entities, each taken from entity sets {(e1, e2, … en) | e1  E1, e2  E2, …, en  En} where (e1, e2, …, en) is a relationship
  • 7. Degree of a Relationship Set  Refers to number of entity sets that participate in a relationship set  Relationship sets that involve two entity sets are binary (or degree two). Generally, most relationship sets in a database system are binary.  Relationship sets may involve more than two entity sets. Like Ternary relationship.  Or N-Ary
  • 8. Mapping Cardinalities  Express the number of entities to which another entity can be associated via a relationship set.  Most useful in describing binary relationship sets.  For a binary relationship set the mapping cardinality must be one of the following types:  One to one  One to many  Many to one  Many to many
  • 9. Mapping Cardinalities One to one One to many Note: Some elements in A and B may not be mapped to any elements in the other set
  • 10. Many to one Many to many Note: Some elements in A and B may not be mapped to any elements in the other set
  • 11. E-R Diagrams  Rectangles represent entity sets.  Diamonds represent relationship sets.  Lines link attributes to entity sets and entity sets to relationship sets.  Ellipses represent attributes  Double ellipses represent multivalued attributes.  Dashed ellipses denote derived attributes.  Underline indicates primary key attributes
  • 12. E-R Diagram With Composite, Multivalued, and Derived Attributes
  • 14. Roles  Entity sets of a relationship need not be distinct  The labels “manager” and “worker” are called roles; they specify how employee entities interact via the works-for relationship set.  Roles are indicated in E-R diagrams by labeling the lines that connect diamonds to rectangles.  Role labels are optional, and are used to clarify semantics of the relationship
  • 15. Cardinality Constraints  We express cardinality constraints by drawing either a directed line (), signifying “one,” or an undirected line (—), signifying “many,” between the relationship set and the entity set.  E.g.: One-to-one relationship:  A customer is associated with at most one loan via the relationship borrower  A loan is associated with at most one customer via borrower
  • 16. One-To-Many Relationship  In the one-to-many relationship a loan is associated with at most one customer via borrower, a customer is associated with several (including 0) loans via borrower
  • 17. Many-To-One Relationships  In a many-to-one relationship a loan is associated with several (including 0) customers via borrower, a customer is associated with at most one loan via borrower
  • 18. Many-To-Many Relationship  A customer is associated with several (possibly 0) loans via borrower  A loan is associated with several (possibly 0) customers via borrower
  • 19. Participation of an Entity Set in a Relationship Set  Total participation (indicated by double line): every entity in the entity set participates in at least one relationship in the relationship set  E.g. participation of loan in borrower is total  every loan must have a customer associated to it via borrower  Partial participation: some entities may not participate in any relationship in the relationship set  E.g. participation of customer in borrower is partial
  • 21. Alternative Notation for Cardinality Limits  Cardinality limits can also express participation constraints
  • 22. Keys  A super key of an entity set is a set of one or more attributes whose values uniquely determine each entity.  A candidate key of an entity set is a minimal super key  Customer-id is candidate key of customer  account-number is candidate key of account  Although several candidate keys may exist, one of the candidate keys is selected to be the primary key
  • 23. Keys for Relationship Sets  The combination of primary keys of the participating entity sets forms a super key of a relationship set.  (customer-id, account-number) is the super key of depositor  Must consider the mapping cardinality of the relationship set when deciding the what are the candidate keys  Need to consider semantics of relationship set in selecting the primary key in case of more than one candidate key
  • 24. E-R Diagram with a Ternary Relationship
  • 25. Binary Vs. Non-Binary Relationships  Some relationships that appear to be non-binary may be better represented using binary relationships  E.g. A ternary relationship parents, relating a child to his/her father and mother, is best replaced by two binary relationships, father and mother  Using two binary relationships allows partial information (e.g. only mother being know)  But there are some relationships that are naturally non-binary  E.g. works-on
  • 26. Converting Non-Binary Relationships to Binary Form  In general, any non-binary relationship can be represented using binary relationships by creating an artificial entity set.  Replace R between entity sets A, B and C by an entity set E, and three relationship sets: 1. RA, relating E and A 2.RB, relating E and B 3. RC, relating E and C  Create a special identifying attribute for E  Add any attributes of R to E  For each relationship (ai , bi , ci) in R, create 1. a new entity ei in the entity set E 2. add (ei , ai ) to RA 3. add (ei , bi ) to RB 4. add (ei , ci ) to RC
  • 27.  Also need to translate constraints  Translating all constraints may not be possible  There may be instances in the translated schema that cannot correspond to any instance of R  Exercise: add constraints to the relationships RA, RB and RC to ensure that a newly created entity corresponds to exactly one entity in each of entity sets A, B and C  We can avoid creating an identifying attribute by making E a weak entity set (described shortly) identified by the three relationship sets
  • 28. Weak Entity Sets  An entity set that does not have a primary key is referred to as a weak entity set.  The existence of a weak entity set depends on the existence of a identifying entity set  it must relate to the identifying entity set via a total, one-to-many relationship set from the identifying to the weak entity set  Identifying relationship depicted using a double diamond  The discriminator (or partial key) of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set.  The primary key of a weak entity set is formed by the primary key of the strong entity set on which the weak entity set is existence dependent, plus the weak entity set’s discriminator.
  • 29. Weak Entity Sets (Cont.)  We depict a weak entity set by double rectangles.  We underline the discriminator of a weak entity set with a dashed line.  payment-number – discriminator of the payment entity set  Primary key for payment – (loan-number, payment-number)
  • 30. Weak Entity Sets (Cont.)  Note: the primary key of the strong entity set is not explicitly stored with the weak entity set, since it is implicit in the identifying relationship.  If loan-number were explicitly stored, payment could be made a strong entity, but then the relationship between payment and loan would be duplicated by an implicit relationship defined by the attribute loan-number common to payment and loan
  • 31. Design Issues  Use of entity sets vs. attributes Choice mainly depends on the structure of the enterprise being modeled, and on the semantics associated with the attribute in question.  Use of entity sets vs. relationship sets Possible guideline is to designate a relationship set to describe an action that occurs between entities  Binary versus n-ary relationship sets Although it is possible to replace any nonbinary (n-ary, for n > 2) relationship set by a number of distinct binary relationship sets, a n-ary relationship set shows more clearly that several entities participate in a single relationship.  Placement of relationship attributes
  • 33. Specialization  Top-down design process; we designate subgroupings within an entity set that are distinctive from other entities in the set.  These subgroupings become lower-level entity sets that have attributes or participate in relationships that do not apply to the higher-level entity set.  Depicted by a triangle component labeled ISA (E.g. customer “is a” person).
  • 35. Generalization  A bottom-up design process – combine a number of entity sets that share the same features into a higher-level entity set.  Specialization and generalization are simple inversions of each other; they are represented in an E-R diagram in the same way.  The terms specialization and generalization are used interchangeably.
  • 36. Specialization and Generalization (Contd.)  Can have multiple specializations of an entity set based on different features.  E.g. permanent-employee vs. temporary- employee, in addition to officer vs. secretary vs. teller  Each particular employee would be  a member of one of permanent-employee or temporary-employee,  and also a member of one of officer, secretary, or teller  The ISA relationship also referred to as superclass - subclass relationship
  • 37.  Union of subtype members is always equal to the set supertype. (Generalization)  Eg: vehicals : air, surface, water.  Union of subtype members is not always equal to the set supertype. (Specialization)  Eg: employee : manager and clerk.
  • 38. Design Constraints on a Specialization/Generalization  Attribute inheritance:  It is a crucial property of the higher and lower level entities created by specialization and generalization  It is a lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set to which it is linked.  A higher level entity set with attributes and relationships that apply to all of its lower-level entity sets  Lower level entity sets with distinctive features that apply only within a particular lower-level entity set
  • 39.  Constraint on which entities can be members of a given lower-level entity set.  condition-defined  E.g. all customers over 65 years are members of senior-citizen entity set; senior-citizen ISA person.  user-defined  It is not constrained by a given condition, The database user assigns entities to a given entity set.
  • 40.  Constraint on whether or not entities may belong to more than one lower-level entity set within a single generalization  Disjoint  an entity can belong to only one lower- level entity set  Noted in E-R diagram by writing disjoint next to the ISA triangle.  Example : An account entity can satisfy only one condition for the account-type attribute; an entity can be either a savings account or a checking account, but cannot be both  Overlapping  an entity can belong to more than one lower-level entity set
  • 41. Example of overlapping  Assume that certain managers participate in more than one work team.  suppose generalization applied to entity sets customer and employee leads to a higher-level entity set person. The generalization is overlapping if an employee can also be a customer.
  • 42.  Completeness constraint -- specifies whether or not an entity in the higher-level entity set must belong to at least one of the lower-level entity sets within a generalization.  total : an entity must belong to one of the lower-level entity sets  partial: an entity need not belong to one of the lower-level entity sets
  • 43. Aggregation  Consider the ternary relationship works-on, which we saw earlier  Suppose we want to record managers for tasks performed by an employee at a branch
  • 44. Aggregation (Cont.)  Relationship sets works-on and manages represent overlapping information  Every manages relationship corresponds to a works-on relationship  However, some works-on relationships may not correspond to any manages relationships  So we can’t discard the works-on relationship  Eliminate this redundancy via aggregation  Treat relationship as an abstract entity  Allows relationships between relationships  Abstraction of relationship into new entity
  • 45.  Without introducing redundancy, the following diagram represents:  An employee works on a particular job at a particular branch  An employee, branch, job combination may have an associated manager
  • 46. E-R Design Decisions  The use of an attribute or entity set to represent an object.  Whether a real-world concept is best expressed by an entity set or a relationship set.  The use of a ternary relationship versus a pair of binary relationships.  The use of a strong or weak entity set.  The use of specialization/generalization – contributes to modularity in the design.  The use of aggregation – can treat the aggregate entity set as a single unit without concern for the details of its internal structure.
  • 47. Summary of Symbols Used in E-R Notation
  • 50.  Construct an E-R diagram for a car-insurance company, that has a set of customer. Each customer own one or more cars. Each car has associated with it zero to any number of recorded accidents.
  • 51.  Construct an ER diagram for the Company that handles the projects from various clients. The Company has different business units headed by the unit heads. Each Business unit have employees to work on client's projects. Identify all the Entities and relationships and design a logical schema also.
  • 52.  Construct an E-R diagram for a hospital with a set of patients and a set of medical doctors. Associate with each patient a log of the various tests and examinations conducted.
  • 53.  A university registrar’s office maintains data about the following entities: (a) courses, including number, title, credits, syllabus, and prerequisites; (b) course offerings, including course number, year, semester, section number, instructor(s),timings, and classroom; (c) students, including student-id, name, and program; and (d) instructors, including identification number, name, department, and title. Further, the enrollment of students in courses and grades awarded to students in each course they are enrolled for must be appropriately modeled.
  • 54. Reduction of an E-R Schema to Tables
  • 55. Reduction of an E-R Schema to Tables  Primary keys allow entity sets and relationship sets to be expressed uniformly as tables which represent the contents of the database.  A database which conforms to an E-R diagram can be represented by a collection of tables.  For each entity set and relationship set there is a unique table which is assigned the name of the corresponding entity set or relationship set.  Each table has a number of columns (generally corresponding to attributes), which have unique names.  Converting an E-R diagram to a table format is the basis for deriving a relational database design from an E-R diagram.
  • 56. Conversion of Strong Entities  For each strong entity in E-R diagram, create a separate table with the same name. Include all simple attributes of the strong entity with the same name.  Create a key for the table
  • 57. Conversion of Weak Entities  A weak entity set becomes a table that includes a column for the primary key of the identifying strong entity set, along with its own attributes
  • 61. Conversion of one-one Relationship  For each one-one relationship,(betn A and B),modify one of the table (A or B),to include the P.Key of other relation as F.Key  If relationship has attributes,it must be transferred to the modified relation  If any relation has a total participation, only that table must be modifed
  • 62. Conversion of one-many Relationship  For each one-Many relationship, modify N-side relation to hold the primary key of other as a foreign key
  • 63. Conversion of many-many Relationship  A many-to-many relationship set is represented as a table with columns for the primary keys of the two participating entity sets, and any descriptive attributes of the relationship set.
  • 64. Advantages Of E-R model 1. Conceptual Simplicity 2. Maps well to the relational model 3. Simple and easy to understand 4. It is acting as a effective communication tool between user and developer
  • 65. Disadvantages Of E-R model 1. Limited Constraint representation 2. Limited Relationship representation 3. Loss of Information content 4. Suitable only for big projects