REDUCTION TO
RELATIONAL SCHEMAS
Summary of Symbols used in ER
Notation
Contd..
Contd..
ER Diagram Design Issues
• Use of Entity Sets v/s Attributes
• Use of Entity Sets v/s Relationship Sets
• Binary v/s n-ary relationships
• Placement of Relationship Attributes
Use of Entity Sets v/s Attributes
Use of Entity Sets v/s Relationship
Sets
(a)
(b)
One possible guideline in determining
whether to use an entity set or a
relationship set is to designate a
relationship set to describe an action
that occurs between entities.
Binary v/s n-ary relationships
Ternary relationship versus three binary
relationships
Placement of Relationship
Attributes
• The design decision of where to place descriptive
attributes for a relationship or for an entity should
reflect the characteristics of the enterprise being
modeled.
ER
Diagram
for
a
University
Enterprise
Reduction to Relational Schemas
Introduction
• A conceptual ER model can be reduced to relation
schemas because the two models employ similar design
principles.
• The quality of the resulting set of relation schemas
depends on the quality of the original ER diagram.
• Entity sets and relationship sets can be expressed
uniformly as relation schemas with the name of the
corresponding entity set or relationship set.
• Each schema has a number of columns (attributes),
which have unique names.
Example
Entity Set Relational Schema
Employees
ssn
name
lot
Employees(ssn, name, lot)
Create table Employees (
ssn number(5),
name varchar (10),
lot number(5),
primary key(ssn));
Example
Representation of Strong Entity
Sets with Simple Attributes
• A strong entity set reduces to a schema with the
same attributes
• Example: course(course_id, title, credits)
• For schemas derived from strong entity sets, the
primary key of the entity set serves as the primary
key of the resulting schema.
Representation of Strong Entity
Sets with Complex Attributes
• Complex Attributes – Composite, Multi-valued and
Derived Attributes.
• Represent composite attributes by creating a
separate attribute for each of the component
attributes(sub-parts).
• Represent multi-valued attributes itself as a separate
schema.
• Derived attributes are not explicitly represented in
relational model.
Representation of Composite
Attributes
Representation of Multivalued Attributes
Example
Instructor
(ID, first_name, middle_initial,
last_name, street_number,
street_name, apt_number, city, state,
zip_code, date_of_birth)
Representation of Weak Entity Sets
• 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.
• Example : section ( course_id, sec_id, sem, year )
Representation of Relationship Sets
• Binary many-to-many relationship set is represented
as a schema with the union of primary keys of the
two participating entity sets.
• Example: schema for relationship set advisor
advisor = (s_id, i_id)
Contd..
• Binary one-to-one relationship set is represented as a
schema with the primary key of any one of the two
participating entity sets.
• Binary many-to-one or one-to-many relationship set
is represented as a schema with primary key of the
entity set on the “many” side.
Contd..
• N-ary relationship set:
 Without any arrows: represented as a schema
with union of primary key attributes.
 With arrows on one side: represented as a schema
with primary key of the entity set not on the
“arrow” side.
For one-to-one relationship without total
participation
For one-to-one relationship with one entity
set having total participation
For one-to-many/many-to-one relationship with
one entity set having total participation on “many”
side
For many-to-many relationship
Redundancy of Schemas
• The schema corresponding to a relationship set
linking a weak entity set to its identifying entity set
is redundant.
• In the example E-R diagram, the weak entity set
section is dependent on the strong entity set course
via the relationship set sec course.
Contd..
• The primary key of section is {course id, sec id, semester,
year} and the primary key of course is course id.
• Since sec_course has no descriptive attributes, the
sec_course schema has attributes {course id, sec id,
semester, year} as the primary key
• Thus, the sec_course schema is redundant.
{course id, sec id, semester, year}
{course id, title, credits}
{course id, sec id, semester, year}
Combination of Schemas
• Consider a many-to-one relationship set AB from
entity set A to entity set B.
• Resulting schemas: A, B, and AB
• If the participation of A in the relationship is total;
i.e., every entity A in the entity set B must
participate in the relationship AB, then
– Combine the schemas A and AB to form a single
schema consisting of the union of attributes of
both schemas.
• The primary key of the combined schema is the
primary key of the entity set into whose schema the
relationship set schema was merged.
Contd..
• Many-to-one and one-to-many relationship sets that are total
on the many-side can be represented by adding an extra
attribute to the “many” side, containing the primary key of
the “one” side
• Example: Instead of creating a schema for relationship set
inst_dept, add an attribute dept_name to the schema arising
from entity set instructor
MIND MAP
• ER Diagram Design Issues
– Use of Entity Sets v/s Attributes
– Use of Entity Sets v/s Relationship Sets
– Binary v/s n-ary relationships
– Placement of Relationship Attributes
REDUCTION TO RELATIONAL SCHEMA
• Representation of Strong Entity Sets with simple
attributes
• Representation of Strong Entity Sets with complex
attributes
o Composite attributes
o Multi-valued attributes
o Derived attributes
• Representation of Weak Entity Sets
• Representation of Relationship Sets
o Redundancy of Schemas
o Combination of Schemas
Summary

19IS305_U1_LP3_LM3-22-23-2.pdf

  • 1.
  • 2.
    Summary of Symbolsused in ER Notation
  • 3.
  • 4.
  • 5.
    ER Diagram DesignIssues • Use of Entity Sets v/s Attributes • Use of Entity Sets v/s Relationship Sets • Binary v/s n-ary relationships • Placement of Relationship Attributes
  • 6.
    Use of EntitySets v/s Attributes
  • 7.
    Use of EntitySets v/s Relationship Sets (a) (b) One possible guideline in determining whether to use an entity set or a relationship set is to designate a relationship set to describe an action that occurs between entities.
  • 8.
    Binary v/s n-aryrelationships Ternary relationship versus three binary relationships
  • 9.
    Placement of Relationship Attributes •The design decision of where to place descriptive attributes for a relationship or for an entity should reflect the characteristics of the enterprise being modeled.
  • 11.
  • 12.
  • 13.
    Introduction • A conceptualER model can be reduced to relation schemas because the two models employ similar design principles. • The quality of the resulting set of relation schemas depends on the quality of the original ER diagram. • Entity sets and relationship sets can be expressed uniformly as relation schemas with the name of the corresponding entity set or relationship set. • Each schema has a number of columns (attributes), which have unique names.
  • 14.
    Example Entity Set RelationalSchema Employees ssn name lot Employees(ssn, name, lot) Create table Employees ( ssn number(5), name varchar (10), lot number(5), primary key(ssn));
  • 15.
  • 16.
    Representation of StrongEntity Sets with Simple Attributes • A strong entity set reduces to a schema with the same attributes • Example: course(course_id, title, credits) • For schemas derived from strong entity sets, the primary key of the entity set serves as the primary key of the resulting schema.
  • 18.
    Representation of StrongEntity Sets with Complex Attributes • Complex Attributes – Composite, Multi-valued and Derived Attributes. • Represent composite attributes by creating a separate attribute for each of the component attributes(sub-parts). • Represent multi-valued attributes itself as a separate schema. • Derived attributes are not explicitly represented in relational model.
  • 19.
  • 20.
  • 21.
    Example Instructor (ID, first_name, middle_initial, last_name,street_number, street_name, apt_number, city, state, zip_code, date_of_birth)
  • 22.
    Representation of WeakEntity Sets • 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. • Example : section ( course_id, sec_id, sem, year )
  • 24.
    Representation of RelationshipSets • Binary many-to-many relationship set is represented as a schema with the union of primary keys of the two participating entity sets. • Example: schema for relationship set advisor advisor = (s_id, i_id)
  • 25.
    Contd.. • Binary one-to-onerelationship set is represented as a schema with the primary key of any one of the two participating entity sets. • Binary many-to-one or one-to-many relationship set is represented as a schema with primary key of the entity set on the “many” side.
  • 26.
    Contd.. • N-ary relationshipset:  Without any arrows: represented as a schema with union of primary key attributes.  With arrows on one side: represented as a schema with primary key of the entity set not on the “arrow” side.
  • 27.
    For one-to-one relationshipwithout total participation
  • 28.
    For one-to-one relationshipwith one entity set having total participation
  • 29.
    For one-to-many/many-to-one relationshipwith one entity set having total participation on “many” side
  • 30.
  • 31.
    Redundancy of Schemas •The schema corresponding to a relationship set linking a weak entity set to its identifying entity set is redundant. • In the example E-R diagram, the weak entity set section is dependent on the strong entity set course via the relationship set sec course.
  • 32.
    Contd.. • The primarykey of section is {course id, sec id, semester, year} and the primary key of course is course id. • Since sec_course has no descriptive attributes, the sec_course schema has attributes {course id, sec id, semester, year} as the primary key • Thus, the sec_course schema is redundant. {course id, sec id, semester, year} {course id, title, credits} {course id, sec id, semester, year}
  • 33.
    Combination of Schemas •Consider a many-to-one relationship set AB from entity set A to entity set B. • Resulting schemas: A, B, and AB • If the participation of A in the relationship is total; i.e., every entity A in the entity set B must participate in the relationship AB, then – Combine the schemas A and AB to form a single schema consisting of the union of attributes of both schemas. • The primary key of the combined schema is the primary key of the entity set into whose schema the relationship set schema was merged.
  • 34.
    Contd.. • Many-to-one andone-to-many relationship sets that are total on the many-side can be represented by adding an extra attribute to the “many” side, containing the primary key of the “one” side • Example: Instead of creating a schema for relationship set inst_dept, add an attribute dept_name to the schema arising from entity set instructor
  • 35.
  • 36.
    • ER DiagramDesign Issues – Use of Entity Sets v/s Attributes – Use of Entity Sets v/s Relationship Sets – Binary v/s n-ary relationships – Placement of Relationship Attributes REDUCTION TO RELATIONAL SCHEMA • Representation of Strong Entity Sets with simple attributes • Representation of Strong Entity Sets with complex attributes o Composite attributes o Multi-valued attributes o Derived attributes • Representation of Weak Entity Sets • Representation of Relationship Sets o Redundancy of Schemas o Combination of Schemas Summary