0% found this document useful (0 votes)
233 views16 pages

Chapter 6 Converting ERD To Relational Model

This document discusses how to convert an entity-relationship (E-R) diagram into a relational database model. Each entity type becomes a table, with attributes as columns and the entity's primary key as the table's primary key. Composite attributes are split into separate columns. Multivalued attributes require a separate table, with a foreign key reference. Relationship types are modeled by including primary keys as foreign keys between tables, or by creating an associative entity table for many-to-many relationships. The conversion process specifies the schema, primary keys, and foreign key references for each table.

Uploaded by

Leong Chee Hao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
233 views16 pages

Chapter 6 Converting ERD To Relational Model

This document discusses how to convert an entity-relationship (E-R) diagram into a relational database model. Each entity type becomes a table, with attributes as columns and the entity's primary key as the table's primary key. Composite attributes are split into separate columns. Multivalued attributes require a separate table, with a foreign key reference. Relationship types are modeled by including primary keys as foreign keys between tables, or by creating an associative entity table for many-to-many relationships. The conversion process specifies the schema, primary keys, and foreign key references for each table.

Uploaded by

Leong Chee Hao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Chapter 6

Converting E-R Diagrams


to Relational Model
Introduction
 E-R model : the database represented is
viewed as a graphical drawings of:
 Entities and attributes
 Relationships among those entities
 - not tables
 Relational model: the database is viewed as a
 Tables
 And their attributes (keys)
E-R Diagrams
 Need to convert E-R diagrams to an
implementation schema.
 Easy to map E-R diagrams to relational model,
and then to SQL.
 Three components of conversion process:
 Specify schema of relation itself
 Specify primary key on the relation
 Specify any foreign key references to other
relations
Strong entity
 Each entity type becomes a table.
 Each single-valued attribute becomes a
column
 Derived attributes are ignored
 Composite attributes are represented by
components
 Multi-valued attributes are represented by a
separate table
 The key attribute of the entity type becomes
the primary key of the table
Example 1: single value
attribute
Example 2
Composite attribute – attribute which
can be broken into few attribute

 Relational model doesn’t handle composite


attributes
 When mapping E-R composite attributes to relation
schema:
 –Each component attribute maps to a separate
attribute in relation schema
 –In relation schema, simply can’t refer to composite
as a whole
Composite attribute - example
Multivalued attribute
 Multivalued attributes require a separate
relation schema
 No such thing as a multivalued attribute in
relational model
 For multivalued attribute M in entity-set E
 Create a relation schema R to store M, with few
attribute A corresponding to M
 A is single-valued version of M
 Attributes of R are: A and primary key for E
 Primary key of R includes all attributes of R
 Foreign key constraint from R to E, is the
primary key of E attribute
Multivalued attribute -
Example
Relationship-set Primary key (1)
 For binary relationship-sets:
 e.g. between strong entity-sets A and B
 For one-to-one relationship mapping, one
relation will include the primary key from the
other relation as FK or vice versa.
 A (a1, a2, a3, b1), B (b1, b2, b3, b4) OR
 b1 is the FK for the relation A
 A (a1, a2, a3). B (b1, b2, b3, b4, a1)
 a1 is the FK for the relation B
Relationship-set Primary key (2)
 For many-to-one or one-to-many mappings:
 e.g. between strong entity-sets A and B
 Primary key from one side relation schema will
become the FK of the many side relation.
 Example: relationship R between A and B
 One-to-many mapping, with B on “many” side
 Schema for A will be  A (a1, a2, a3, a4, a5)
 Schema for B will be  B (b1, b2, b3, b4, a1)
Relationship-set Primary key (2)
 For many-to-many relationship, need to
create a separate entity (called associative
entity), and this entity will has attributes which
are the PK from the two participating entities.
 For example:
A (a1, a2, a3, a4)
B (b1, b2, b3, b4, b5)
C (a1, b1)
Relational-set : Example
Exercises…

You might also like