You are on page 1of 66

Last Lecture….

Attribute or Relationship
Attribute or Entity
Time Dependent Data
Many to Many Relationships
Ternary Relationships
Business Rules
ER Model (Entity Types)
ER Model (Attributes)
ER Model (Relationships)

Categories of Cardinality
1:1
1:M
M:N
Enhanced ERD
(EERD)
Enhanced E-R Model
The original E-R Model was developed
in mid-1970
Business environment has changed
dramatically
Some enhancement is made to E-R
Model to cope with the modern
business trends
Enhanced E-R Model
The model that has been resulted from
extending the original E-R Model
with new modeling constructs is
known as Enhanced entity
relationship(EER) model
Supertypes & Subtypes
Entity Type is collection of entities that
share common properties
Major challenge in Data Modeling is to
present entities that are same but
differ on one or two attributes that
are of the interest of organization
E-R Model have to include Super/Sub
Relationship
Super/sub Relationship
Subtype
A sub-grouping of the entities in a
entity type that are meaningful to the
organization
That share common attributes on a
relationship distinct from other sub-
grouping
Super/sub Relationship
Supertype
A generic entity type that has a
relationship with one or more subtypes
STUDENT entity type has two
subgrouping POSTGRADUATE
STUDENT and UNDERGRADUATE
STUDENT
Super/sub Relationship
Shared Attributes

SUPERTYPE

SUBTYPE1 SUBTYPE2

Attributes unique to Attributes unique to


Subtype 1 Subtype 1
Super-type\Subtype Notations
Supertype\Subtype Notations (MS Visio)
Supertype\Subtype Notations
Example
Suppose an organization has following
employees:
Hourly employee:
Employee_Number,Employee_Name,Address,
Date_Hired,Hourly_Rate
Salaried employee:
Employee_Number,Employee_Name,Address,
Date_Hired,Annual_Salary
Contract Consultant:
Employee_Number,Employee_Name,Address,
Date_Hired,Contract_Number,Billing_Rate
Super/sub Relationship
EMPLOYEE
Employee_Number
Employee_Name
Address
Date_Hired

HOURLY EMPLOYEE SALARIED EMPLOYEE CONSULTANT


Contract_Number
Hourly_Rate Annual_Salary Billing_Rate
Super/sub Relationship
How can we develop Super/Sub
Relationship?
There are two mental model that help
us to determine this type of
Relationship These are:
1. Generalization
2. Specialization
Generalization
Generalization is the process of
finding more general entity types from
set of specialized entity types
The generalization of these entity types
is VECHILE Entity type
Generalization
Specialization
Specialization is reverse of
Generalization
Process of defining one or more
subtypes from a supertype and
forming supertype/subtype relationship
Specialization
In a business environment we have an
entity Name PART
PART(Part_Number,Description,
Location,Routing_Number,Unit_Price)
It can be converted into specialized forms:
MANUFACTURED
PART(Routing_Number)
PURCHASED PART(Unit_Price)
Specialization
When to Use Super/Sub Type..
When some entity types has unique
attributes
The instances of entity type participate
in a relationship unique to the
super type
Example
In Rehman Hospital patients are of two
types OUTPATIENT (Patient_ID, Name,
Admit_Date, Checkback_Date) and
RESIDENT_PATIENT(Patient_ID, Name,
Admit_Date, Discharge_Date) which are
cared by RESPONSIBLE_PHYSICIAN(ID,
Name).
Resident patient is assigned a BED(ID)
When to Use Super/Sub Type..
Constraints of
Super/Sub
Constraints in Supertype/Subtype

Completeness Constraint

Disjoint-ness Constraint

Subtype Discriminator
Constraints in Super-type/Subtype
Completeness Constraint: A type of
constraint that addresses whether an
instance of a supertype must also be a
member of at least one subtype
It has two possible rules:
Total Specialization Rule
Partial Specialization Rule
Completeness Constraint
(Total Specialization Rule)

A rule that specifies that


each entity instance of a
supertype must be a
member of some subtype
in the relationship.
Completeness Constraint
(Partial Specialization Rule)
A rule that specifies that
an entity instance of a
supertype is allowed not
to belong to any
subtype
Completeness Constraint
Partial Specialization Rule Total Specialization Rule
Disjointness Constraints
A constraint that addresses whether an
instance of a supertype may
simultaneously be a member of two (or
more) subtypes
It has two rules:
Disjoint Rule
Overlap Rule
Disjointness Constraints
Disjoint rule: A rule that specifies that
an instance of a supertype may not
simultaneously be a member of two (or
more) subtypes

Overlap rule: A rule that specifies that


an instance of a supertype may
simultaneously be a member of two (or
more) subtypes.
Disjointness Constraints
Overlap rule Disjoint rule
Subtype Discriminators
An attribute of a supertype whose
values determine the target subtype or
subtypes
Subtype Discriminators
(For Disjoint Rule)
Subtype Discriminators
(For Overlap Rule)
Subtype Discriminators
(For Overlap Rule)
Supertype/subtype hierarchy

A hierarchical arrangement of Super-types


and Subtypes in which each subtype has
only one supertype.
Super type/subtype hierarchy
Database Development Process
Enterprise Modeling

Conceptual Data Modeling

Logical Database Design

Physical Database Design and definition

Database Implementation

Database Maintenance
Logical Database Design
Logical database design is the process
of transforming the conceptual
data model into logical data model
Relational Data Model will be used in
this regard
DBA has to decide DBMS at this stage
Relational Data Model
Following are the reasons to choose the
Relational Data Model
1. Based on concrete mathematical
theory
2. Most commonly used Data Model
3. Lot of CASE tools exists
4. Some of principals also apply to the
other Data Models
Relational Model
Relational Model consists of three
components:
1. Data Structure
Data is organized in the form of
Relations(tables) with rows and
columns
2. Data Manipulation
3. Data Integrity
Relation
A named two dimensional table
Columns are labeled
Rows are un-labeled
EMPLOYEE
Emp_ID Name Dept_Name Salary
100 Margaret Marketing 48,000
140 Allen Accounting 52,000
110 Chris Info Systems 20,000
190 Lorenzo Finance 55,000
150 Susan Marketing 35,000
Relation
We can express the relation using the short-
hand notation as:
EMPLOYEE(Emp_ID, Name, Dept_Name,Salary)

CUSTOMER

Customer_ID Customer_Name Address City State


Properties of a Relation
Each relation (or table) in a database has a unique
name
An entry at the intersection of each row and column is
atomic (or single valued) no multivalued
Each row is unique;
Each attribute (or column) within a table has a unique
name
The sequence of columns (left to right) is insignificant
The sequence of rows (top to bottom) is insignificant.
As with columns,
The order of the rows of a relation may be changed or
stored in any sequence.
Primary Key
An attribute(Column) or combination of
attributes that uniquely identify each row
in a relation
In short notation we can express this relation
as:
EMPLOYEE(Emp_ID,Name,Dept_Name,Salary)
Composite Key is Primary Key that consists of
more than one attributes
Foreign Key
Relationships in ERD are presented
using the foreign key at logical level
An attribute (primary key) in a
relation of a database that serves as
attribute (mostly part of composite
key )of another relation in the same
database
Schema of a Database
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

You might also like