0% found this document useful (0 votes)
56 views63 pages

DBS Lecture#16 18

The document discusses the process of transforming an EER diagram into relational tables. It outlines 7 main steps: 1. Map strong entities to tables with their attributes 2. Map weak entities to tables with foreign keys linking to strong entities 3. Map binary relationships as tables linking the primary keys of related entities 4. Map associative entities similar to many-to-many relationships 5. Map unary relationships by including recursive foreign keys 6. Transform ternary relationships into binary relationships using associative entities 7. Map supertype/subtype relationships to separate tables, with subtypes linking to supertypes

Uploaded by

Connor Muench
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)
56 views63 pages

DBS Lecture#16 18

The document discusses the process of transforming an EER diagram into relational tables. It outlines 7 main steps: 1. Map strong entities to tables with their attributes 2. Map weak entities to tables with foreign keys linking to strong entities 3. Map binary relationships as tables linking the primary keys of related entities 4. Map associative entities similar to many-to-many relationships 5. Map unary relationships by including recursive foreign keys 6. Transform ternary relationships into binary relationships using associative entities 7. Map supertype/subtype relationships to separate tables, with subtypes linking to supertypes

Uploaded by

Connor Muench
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/ 63

Last Lecture….

Super/Sub Types
Identifying Super/Sub Types (Generalization,
Specialization)
When to use Super/Sub Type
Completeness Constraint:
Total Specialization Rule
Partial Specialization Rule
Disjoint-ness constraints
Subtype Discriminator
Subtype Hierarchies
Transformation (Step 1 and Step 2)
TRANSFORMATION
EER INTO
RELATIONS
Transformation EER\Relations
The process of converting EER diagram
into Relation consist of different steps
In ER we have:
Entities(Regular,Weak,Associative),
Relationship(Degree,Cardinality)
Attributes(Single value,Multi-
values,Composite,Derived etc.)
Transformation
Step 1: Map Strong entities
Step 2: Map Weak Entities
Step 3: Map Binary Relationship
Step 4: Map Associative Entities
STEP 5: Map Unary Relationship
Step 6: Map Ternary Relations
Step 7: Map Super/Sub
STEP 1: Map Regular Entities
EMPLOYEE
Employee_ID
Employee_Name
Address

EMPLOYEE

Employee_ID Employee_Name Address


STEP 1: Map Regular Entities (Composite
Attributes)

EMPLOYEE
Employee_ID
Employee_Name
Address(Stree_Address, City, State)
EMPLOYEE

Employee_ID Employee_Name City Street_Address State


STEP 1: Map Regular Entities (Multi-Valued)
EMPLOYEE
Employee_ID
Employee_Name
Dept_Name
{Skill}
EMPLOYEE
Employee_ID Employee_Name Dept_Name

EMPLOYEE_SKILL
Employee_ID Skill
EMPLOYEE
Emp_ID Name Dept_Name Skill

100 Margaret Marketing Dbms,Marketing

140 Allen Accounting Java

110 Chris Info Systems C++,Oracle

190 Lorenzo Finance Analyst

150 Susan Marketing C#


EMPLOYEE Skill
Emp_ID Skill

Emp_ID Name Dept_Name 100 Dbms

100 Margaret Marketing 100 Marketing

140 Allen Accounting 140 Java

110 Chris Info Systems 110 C++

190 Lorenzo Finance 110 Oracle


150 Susan Marketing 190 Analyst

150 C#
Step 2: Map Weak Entities
Weak entity is an entity type whose
existence depends on some other
entity type(Strong)
1. Define a new table for each weak
entity
2. The primary key of strong entity
relation serve to make foreign key in
the weak entity relation
Step 2: Map Weak Entities
Surrogate primary key
A serial number or other system
assigned primary key for a relation
Step 3: Map Binary Relationship
A relationship between two entities
known as binary relationship
The cardinality of Binary Relationship
can be of following types:
1:M
M:N
1:1
Step 3: Map Binary Relationship
One to Many Relationship(1:M)
1. Create relations(tables) for each entity
type participating in relationship
2. Include primary key attribute of one
side entity type in the table of many
side entity type as a foreign key
CUSTOMER ORDER
Customer_ID Submit Order_ID
Customer_Name Order_Date
Customer_Address

CUSTOMER
Customer_ID Customer_Name Customer_Address

ORDER

ORDER_ID Order_Date Customer_ID


Step 3: Map Binary Relationship
Many to Many Relationship(M:N)
In M:N relationship we have to create
three relations in spite two
Two relation based on Entity types involved
in relationship
Third relation is based on relationship
type
The primary key attributes of the first
relation work as foreign keys in this relation
Date_Assigned

EMPLOYEE PROJECT
Employee ID Project ID
Employee Name Is_assigned Description

EMPLOYEE
Employee_ID Employee_Name

ASSIGNMENT
Employee_ID Project_ID Date_Assigned

PROJECT
Project_ID Project_Description
Step 3: Map Binary Relationship
One-to-One Relationship(1:1)
1. Two relations(tables) are created
one for each participating entity
2. Primary key of one of relation is
included as foreign key in the other
relation
Employee_ID Employee_Name Department_ID Department_Nam

EMPLOYE DEPARTMENT

Manages

EMPLOYEE
Employee_ID Employee_Name

Department
Department_ID Department_Name Employee_Manager
Step 4: Map Associative Entities
M:N relations may be converted into
Associative Entities
The process of Associative Entities is
same as the Many-to-Many binary
relationship
There may be two situations(identifier
defined or not defined)
Identifier Not Defined
Identifier Defined
STEP 5: Map Unary Relationship
Unary One-to-Many
The Unary entity type is mapped using
the procedure of Step 1
A recursive foreign key also included
in the relation
Recursive foreign key reference the
primary key value of same relation
Unary One-to-Many
Empl
oyee_
ID

Supervise EMPLOYE Birth_Place

Employee_Name

EMPLOYEE
Employee_ID Employee_Name Birth_Place Supervisor_ID
STEP 5: Map Unary Relationship
Unary Many-to-Many
Two relations are created one for the
entity type and other for relationship
A recursive foreign key also included
in the relation
Recursive foreign key reference the
primary key value of same relation
Item_
No
Quantity

ITEM Name
Contains

Unit_Cost

• ITEM(Item_No,Name,Unit_Cost)
• COMPONENT(Item_No, Component_No,
Quantity)
Unary Many-to-Many

COURSE
Course ID
Course Title
Is_
Prerequisite_
For
Many-to-Many Relationship
Is_
COURSE Prerequisite_
Course ID For
Course Title
Step 6: Map Ternary Relations
Ternary relationship is a relationship type in
which three participating entities are
involved
Good ER design is to convert this type of
relationship into three binary relationships
by making associative entity
We can transform ternary relation into tables
without this simplification
Step 6: Map Ternary Relations
1. Make a table for each participating
entity
2. Make one table for the relationship
3. The primary keys of all
participating tables work as foreign
key in relationship table
PART

VENDOR Supplies WAREHOUSE

Shipping_mode Unit_cost

• VENDER(….)
• PART(…….)
• WAREHOUSE(…….)
• SUPPLY_SCHEDULE(Part_No,Vendor_ID,War
ehouse_ID,Shipping_Mode,Unit_cost)
Step 7: Map Super/Sub
Relational data model did not support
Super/Sub Model. Following guidelines can
be uses:
1. Create separate relation for Super type and
each Sub
2. Assign common attributes to Super
Relation
3. Assign Primary key of Super to Sub
tables
Step 7: Map Super/Sub
Many strategies can be used to convert Super\Sub
relation, Most commonly used guidelines are as
following:
1. Create a separate relation for the supertype and for
each of its subtypes.
2. Assign to the relation created for the supertype the
attributes that are common
3. Assign to the relation for each subtype the primary
key of the supertype and unique attributes of
subtype.
4. Assign one (or more) attributes of the supertype to
function as the subtype discriminator
Step 7: Map Super/Sub
Step 7: Map Super/Sub
Transformation
Step 1: Map Strong entities
Step 2: Map Weak Entities
Step 3: Map Binary Relationship
Step 4: Map Associative Entities
STEP 5: Map Unary Relationship
Step 6: Map Ternary Relations
Step 7: Map Super/Sub
Example 1
PIANO MODEL DESIGNER
Serial Number ID Number Designer ID
Mfg Completion Date Name Designer Name
Mfg Completion Date
Serial Number
PIANO
Quality Grade
Inspection Date

2
Employee Number
TECHNICIAN

TECHNICIAN
Employee Number
Supervises
Example 2
INTEGRITY CONSTRAINTS
Integrity Constraints
Data Integrity refers to the
correctness and consistency of
stored data
Integrity constraints are the
rules(Business rules) that the database
users are not permitted to violate
Integrity Constraints
Common type of integrity constraints
are:
1. Domain Constraints
2. Entity Integrity (Primary Key Rule)
3. Referential Integrity (Foreign Key Rule)
4. General Constraints (Business Rules)
Domain Constraints
All of the values that appear in a column of a relation
must be from the same domain.
A domain is the set of values that may be assigned to
an attribute.
A domain definition usually consists of the following
components:
domain name,
meaning,
data type,
size (or length),
allowable values or allowable range (if applicable).
Integrity Constraints
Entity Integrity
This rule applies on the primary key
attribute of a relation
According to the Entity integrity rule,
Primary Key should be unique
no primary key attribute( or component
of a primary key attribute) can be Null
Referential Integrity
Association between the tables are
defined using the foreign keys
Referential Integrity is a constraint
on foreign key values
Either the foreign the value must
match with the primary key of its
home relation or it must be
completely Null
Integrity Constraints
General Constraints
General constraints are the
restrictions that are expressible only
as arbitrary predicates about the data
Suppose in university database no
class may be scheduled for room H221
after 2 P.M
CUSTOMER

Customer_ID Customer_Name Address City State


ORDER

Order_ID Order_Date Customer_ID

ORDER LINE
Order_ID Product_ID Quantity

PRODUCT

Product_ID Product_Description Price


Implementation
Review
Top Down Process of database design
1. Enterprise Modeling
2. Data Modeling(Analysis)
1. Output of analysis is EERD and Business Rules
3. Logical Database design
1. Convert ERD into relations
4. Validate relations well-structured-ness
using Normalization process
Normalization as Database
Design(Bottom Up )
In top down process(ER diagramming)
we start from un-detailed concepts such
as entities work toward detailed
relations and their attributes
Normalization could be used as an
another design approach
Normalization is bottom-up
Normalization as Database
Design(Bottom Up )
Normalization if used for design can be uses
as follows:
Collect attribute of Organization
Write them in tabular form
Perform Normalization
Create EERD
Normalization
Normalization start from detailed set of
attributes and work upward to
correctly structured relations, each
of which represent a real world entity
type, and whose foreign keys
represent relationship that also exist
in real world
Normalization
Normalization is a step by step
(1NF,2NF,3NF,..) process of converting
a relation(universal relation) into a well
structured relations(Free of
anomalies)
Well Structured Relation
A relation that contains minimum
redundancy and allows user to insert,
modify and delete the rows in table
without errors and inconsistencies
Relation without anomalies
Anomaly
Redundancies in a table may result
errors or inconsistencies called
anomalies
Anomalies are of three types:
1. Insertion anomaly
2. Deletion anomaly
3. Modification anomaly
EMPLOYEE
Emp_ID Name Dept_Name Salary Course_ Date_com
Title pleted
100 Margaret Marketing 48,000 SPSS 6/19/2001
100 Margaret Marketing 48,000 Surveys 7/19/1998
140 Allen Accounting 52,000 Tex_Acc 12/19/2001
110 Chris Info Systems 20,000 C++ 1/20/1997
110 Chris Info Systems 20,000 Database 12/19/2001
190 Lorenzo Finance 55,000
150 Susan Marketing 35,000 java 11/19/1990
150 Susan Marketing 35,000 C++ 12/19/2001
Normalization
Normalization is the process of
decomposing relations(attributes)
with anomalies to produce smaller,
well-structured relations(relations
without anomalies)
Normalization Steps
Attributes or table with
repeating values(Universal Relation) Remove repeating
values
First Normal Form(1NF)
Remove Partial
Dependencies
Second Normal Form(2NF)
Remove transitive
Dependencies
Third Normal Form(3NF)
Remove multi-valued
Dependencies
Fourth Normal Form(4NF)
Dependency Structure
Normal forms are based on certain
dependencies
1. 3NF and lower are based on
Functional Dependencies(FDs)
2. 4NF is based on Multi-valued
dependencies
3. 5NF is based on projection-join
dependencies
Functional Dependencies
A constraint between two attributes or
set of attributes
For any relation R attribute B is
functionally dependent on attribute
A if the value of A uniquely
determines the value of B
Each value of A is associated with
exactly one value of B

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy