ER_notes_3

Entity-Relationship Model
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.
Entity Relationship Modelling
Descriptive Attribute
• Used to record information about
relationship rather than about
participating entities.
• Eg: sunil works in HR department since
2010. since is attribute of relationship
works_in
Entity Relationship Modelling
Binary Relationship set
Entity Relationship Modelling
Ternary relationship set
Entity Relationship Modelling
Total and partial participation
• consider a relationship set "Manages"
which associates departments with
employees. If a department cannot
have more than one manager, this is an
example of a one-to-many relationship
set (it may be that an individual
manages multiple departments).
Entity Relationship Modelling
an individual manages
multiple
departments
Each employee works in at least one department and
each department has at least one employee.
Participation of both entities in works relationship is
total
Entity Relationship Modelling
• The participation of entity set employee
in relationship ‘Manages’ is partial – Not
every employee can become manager.
• Represent a total participation
constraint by using a thick line.
Entity Relationship Modelling
Entity Relationship Modelling
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
• Identifying relationship depicted using a
double diamond
Entity Relationship Modelling
• 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.
Entity Relationship Modelling
Entity Relationship Modelling
Keys
• Employee table:
Employee (
Employee ID,
FullName,
SSN,
DeptID
)
1. Super Key: If you add any other column/attribute to a
Primary Key then it become a super key, like
EmployeeID + FullName is a Super Key.
a set of attributes collectively identify an entity in the entity
set uniquely
Entity Relationship Modelling
2. Candidate Key: are individual
columns in a table that qualifies for
uniqueness of all the rows. Here in
Employee table EmployeeID & SSN are
Candidate keys.
It is minimal super key
Entity Relationship Modelling
3. Primary Key: is the columns you choose to
maintain uniqueness in a table. Here in
Employee table you can choose either
EmployeeID or SSN columns, EmployeeID is
preferable choice, as SSN is a secure value.
4. Alternate Key: Candidate column other the
Primary column, like if EmployeeID is PK then
SSN would be the Alternate key.
Entity Relationship Modelling
5. Composite Key: If a table do not have any
single column that qualifies for a Candidate key,
then you have to select 2 or more columns to
make a row unique. Like if there is no
EmployeeID or SSN columns, then you can
make FullName + DateOfBirth as Composite
primary Key. But still there can be a narrow
chance of duplicate row.
• Candidate key with one attribute- simple
attribute
• Candidate key with more than one attributecomposite attribute
Entity Relationship Modelling
Extended ER Features
• Generalization is a bottom-up approach in which two
lower level entities combine to form a higher level
entity. In generalization, the higher level entity can also
combine with other lower level entity to make further
higher level entity
Entity Relationship Modelling
Specialization
• Specialization is opposite to Generalization. It is a topdown approach in which one higher level entity can be
broken down into two lower level entity. In
specialization, some higher level entities may not have
lower-level entity sets at all.
Entity Relationship Modelling
Another way of representation
Entity Relationship Modelling
Aggregation
• Aggregation is a process when relation between two
entity is treated as a single entity. Here the relation
between Center and Course, is acting as an Entity in
relation with Visitor.
Entity Relationship Modelling
Entity Relationship Modelling