Professional Documents
Culture Documents
Diagrams
• All entities in an entity set have the same set of attributes. (Until we
consider ISA hierarchies, anyway!)
• Each entity set has a key.
name
aadhar
Employees cabin
Complex Attributes
• Attribute types:
– Simple and composite attributes.
– Single-valued and multivalued attributes
• Example: multivalued attribute: phone_numbers
– Derived attributes
• Can be computed from other attributes
• Example: age, given date_of_birth
• Domain – the set of permitted values for each attribute
Composite Attributes
Redundant Attributes
• Suppose we have entity sets:
– instructor, with attributes: ID, name, dept_name,
salary
– department, with attributes: dept_name, building,
budget
• We model the fact that each instructor has an
associated department using a relationship set
inst_dept
• The attribute dept_name appears in both entity sets.
Since it is the primary key for the entity set
department, it replicates information present in the
relationship and is therefore redundant in the entity set
instructor and needs to be removed.
• BUT: when converting back to tables, in some cases
the attribute gets reintroduced, as we will see later.
Relationship Sets
• Relationship: Association among two or more entities.
E.g., John works in Physics department.
name
aadhar cabin dname
did budget
Works
Employees Departments
in
since
Relationships (contd.)
• Ternary Relationship-example
since
name
aadhar cabin dname
did budget
Works
Employees Departments
in2
Locations
address capacity
Roles in a relationship set
• The same entity set could participate in different
relationship sets, or in different “roles” in same set
name
aadhar cabin
Employees
Supervisor Subordinate
Reports
to
Key Constraints (contd.)
Participation Constraints
• Does every department have a manager? If so, this is a participation
constraint.
name since
aadhar cabin dname
did budget
Works in
since
Weak Entities
• A weak entity can be identified uniquely only by considering the
primary key of another (owner) entity.
– Each weak entity is existence dependent on the identifying entity set.
– Owner entity set and weak entity set must participate in a one-to-many
relationship set (one owner, many weak entities).
name cost
aadhar cabin pname age
name
aadhar cabin
Employees
Hourly_ Hours_Wor
OfferID
Wage ked ISA
Hourly_Emps Perma_Emps
Aggregation
• Used when we have to model a relationship involving (entitity sets and) a relationship set.
• Aggregation allows us to treat a relationship set as an entity set for purposes of participation in (other)
relationships.
• Example: Each department that sponsors a project might assign employees to oversee the sponsorship.
– Why not have a ternary relationship? (Ans: sponsors may have different attributes from oversees, for example, dates)
name
aadhar cabin
Employees
overs
ees
Projects Spons
Departments
ors
Aggregation (example
• Consider a DB with information about employees who work
on a particular special project and use a number of machines
doing that work
name
number location
Machinery
uses
hours
Reduction to Relation Schemas
Representing Entity Sets
• A strong entity set reduces to a schema with the same
attributes
Employees(aadhar, name, cabin)
name cost
aadhar cabin pname age
• Relationship set keys: Let R involve entity sets E1..En and let pk(Ei) denote
the primary key of Ei.
since
Representing Relationship Sets (contd.)
• Case1: one manager can manage many departments
eid did since
101 A123 2010
101 B123 2010
201 C123 2010
• Case3: one manager can manage many departments and one department has
several managers eid did since
101 A123 2010
101 B123 2010
201 B123 2010
• Case4: one manager can manage only one department and each department has
one manager
eid did since
101 A123 2010
201 B123 2010
301 C123 2010
Representing Relationship Sets
(contd.)
• Primary key is -
• {did} if one manager can manage many departments;{eid} if one
department has several managers
• {eid,did} if if one manager can manage many departments and if one
department has several managers
• {eid } or {did} if one manager can manage only one department
name
aadhar cabin dname
did budget
Worksinf
Employees Departments
or
from to
Entity vs Attribute (contd.)
• Accomplished by introducing new entity
set, Duration.
name
aadhar cabin dname
did budget
Worksinf
Employees Departments
or
Duration
from to
Entity vs Relationship
• This ER diagram OK if a manager gets a separate discretionary budget for each dept.
• What if a manager gets a discretionary budget that covers all managed depts?
– Redundancy: dbudget stored for each dept managed by manager.
– Misleading: Suggests dbudget associated with department-mgr combination.
• Solution??????
name
aadhar cabin dname
did budget
Manages
Employees Departments
2
since dbudget
• Add a new specialized entity set Managers under Employees. Have the attribute
dbudget for Managers and relationship “Manages3” from Managers to Departments
Summary of Conceptual Design