Chapter Three
Chapter Three
DATABASE DESIGN
1
Introduction
Database design is the process of coming up with different
kinds of specification for the data to be stored in the
database.
The database design part is one of the middle phases we
have in information systems development where the
system uses a database approach.
Design is the part on which we would be engaged to
describe how the data should be perceived at different levels
and finally how it is going to be stored in a computer system.
2
CONT…
Information System with Database application consists of several
tasks which include:
Planning of Information systems Design
Requirements Analysis,
Design (Conceptual, Logical and Physical Design)
Implementation
Testing and deployment
Operation and Support
From these different phases, the prime interest of a database
system will be the Design part which is again sub divided into
other three sub-phases. These sub-phases are:
Conceptual Design
Logical Design, and
Physical Design
3
Introduction Cont’d...
In general, one has to go back and forth between these tasks to refine
a database design, and decisions in one task can influence the choices
in another task.
In developing a good design, one should answer such questions as:
What are the relevant Entities for the Organization
What are the important features of each Entity
What are the important Relationships
What are the important queries from the user
What are the other requirements of the Organization and the
Users
4
Introduction Cont’d...
1.Conceptual Database Design
Conceptual design is the process of constructing a model
of the information used in an enterprise, independent of
any physical considerations.
It is the source of information for the logical design
phase.
Mostly uses an Entity Relationship Model to describe
the data at this level.
After the completion of Conceptual Design one has to
go for refinement of the schema, which is verification of
Entities, Attributes, and Relationships
5
CONT…
2. Logical Database Design
Logical design is the process of constructing a
model of the information used in an enterprise
based on a specific data model (e.g. relational,
hierarchical or network or object), but independent of
a particular DBMS and other physical considerations.
Normalization process
Collection of Rules to be maintained
Discover new entities in the process
Revise attributes based on the rules and the
discovered Entities
6
Introduction Cont’d...
3. Physical Database Design
Physical design is the process of producing a
description of the implementation of the database on
secondary storage. -- defines specific storage or access
methods used by database
Describes the storage structures and access methods
used to achieve efficient access to the data.
Tailored/Modified/ to a specific DBMS system --
Characteristics are function of DBMS and operating
systems
Includes estimate of storage space
7
CONCEPTUAL DATABASE DESIGN
Conceptual design revolves around discovering and
analyzing organizational and user data requirements
The important activities are to identify
Entities
Attributes
Relationships
Constraints
And based on these components develop the ER model
using
ER diagrams
8
CONCEPTUAL DATABASE DESIGN CONT’D...
9
CONT…
Relationships
Represents the association that exist between
entities
Represented by Diamond
Constraints
Represent the constraint in the data
Cardinality and Participation Constraints
10
CONCEPTUAL DATABASE DESIGN CONT’D...
Developing an E-R Diagram
Designing conceptual model for the database is not a one
linear process but an iterative activity where the design is
refined again and again.
To identify the entities, attributes, relationships, and
constraints on the data, there are different set of methods
used during the analysis phase.
These include information gathered by…
Interviewing end users individually and in a group
Questionnaire survey
Direct observation
Examining different documents
11
CONT…
Analysis of requirements gathered
Nouns prospective entities
Adjectives prospective attributes
Verbs/verb phrases prospective relationships
12
CONT…
Developing an E-R Diagram cont’d...
The basic E-R model is graphically depicted and presented
for review.
The process is repeated until the end users and designers
agree that the E-R diagram is a fair representation of the
organization‘s activities and functions.
Checking for Redundant Relationships in the ER Diagram.
Relationships between entities indicate access from one
entity to another - it is therefore possible to access one entity
occurrence from another entity occurrence even if there are
other entities and relationships that separate them - this is
often referred to as Navigation' of the ER diagram
The last phase in ER modeling is validating an ER Model
against requirement of the user. 13
Graphical Representations in ER Diagramming
Entity is represented by a RECTANGLE containing the name of the entity.
15
Example 2: Build an ER Diagram for the following
information:
A Personnel record management system will have
the following two basic data object categories with
their own features or properties: Employee will have an Id,
Name, DoB, Age, Tel and Department will have an Id,
Name, Location. Whenever an Employee is assigned in
one Department, the duration of his stay in the respective
department should be registered.
16
Structural Constraints on Relationship
1.Constraints on Relationship / Multiplicity/ Cardinality Constraints
Multiplicity constraint is the number or range of possible occurrence of an
entity type/relation that may relate to a single occurrence/tuple of an entity
type/relation through a particular relationship.
Mostly used to insure appropriate enterprise constraints.
One-to-one relationship:
A customer is associated with at most one loan via the relationship
borrower
A loan is associated with at most one customer via borrower
17
CONT’D...
Example: Relationship Manages between STAFF and BRANCH The multiplicity
of the relationship is:
One branch can only have one manager
1..1 Manages 0..1
Employee Branch
18
CONT’D....
Example: Relationship Leads between STAFF and PROJECT The multiplicity of
the relationship
One staff may Lead one or more project(s)
1..1 Leads 0..*
Employee Project
19
CONT’D....
Many-To-Many Relationship
A customer is associated with several (possibly 0) loans via borrower
A loan is associated with several (possibly 0) customers via borrower
20
Participation of an Entity Set in a Relationship Set
22
CONT’D...
Example 1: Participation of EMPLOYEE in ―belongs to relationship with
DEPARTMENT is total since every employee should belong to a department.
Participation of DEPARTMENT in ―belongs to relationship with
EMPLOYEE is total since every department should have more than one
employee.
1..* BelongsTo
1..1
Employee Department
Example 2:
Participation of employee in ―manages‖ relationship with
Department, is partial participation since not all employees are managers.
Participation of DEPARTMENT in ―Manages‖ relationship with
EMPLOYEE is total since every department should have a manager.
23
CONT’D...
The Entity-Relationship Model is a conceptual data model that views the
real world as consisting of entities and relationships.
The model visually represents these concepts by the Entity-Relationship
diagram. The basic constructs of the ER model are entities, relationships, and
attributes. Entities are concepts, real or abstract, about which information is
collected. Relationships are associations between the entities. Attributes are
properties which describe the entities.
While designing the ER model one could face a problem on the design
which is called a connection traps. Connection traps are problems arising
from misinterpreting certain relationships
There are two types of connection traps;
1..* Works 1..1 IsAssigned
EMPLOYEE 1..1 For BRANCH 1..*
CAR
24
CONT’D...
1. Fan trap:
Occurs where a model represents a relationship between
entity types, but the pathway between certain entity
occurrences is ambiguous.
May exist where two or more one-to-many (1:M)
relationships fan out from an entity.
The problem could be avoided by restructuring the
model so that there would be no 1:M relationships
fanning out from a singe entity and all the
semantics of the relationship is preserved.
25
CONT’D...
Semantics description of the problem;
2. Chasm Trap:
Occurs where a model suggests the existence of a relationship between entity
types, but the path way does not exist between certain entity occurrences.
Chasm trap may exist when there are one or more relationships with a
minimum multiplicity on cardinality of zero forming part of the pathway between
related entities.
27
CONT’D...
Example:
1..1 Has
BRANCH 1..*
EMPLOYEE 0..1
0..*
Manages PROJECT
If we have a set of projects that are not active currently then we can
not assign a project manager for these projects. So there are
project with no project manager making the participation to have
a minimum value of zero.
Problem:
How can we identify which BRANCH is responsible for
which PROJECT? We know that whether the PROJECT is
active or not there is a responsible BRANCH. But which branch
is a question to be answered, and since we have a minimum
participation of zero between employee and PROJECT we can‘t
identify the BRANCH responsible for each PROJECT. 28
CONT’D...
The solution for this Chasm Trap problem is to add another
relation ship between the extreme entities (BRANCH and
PROJECT)
29
Enhanced E-R (EER) Models
Object-oriented extensions to E-R model
EER is important when we have a relationship between two entities
and the participation is partial between entity occurrences.
In such cases EER is used to reduce the complexity in participation
and relationship complexity.
ER diagrams consider entity types to be primitive objects
EER diagrams allow refinements within the structures of entity
types
EER Concepts
Generalization
Specialization
Sub classes
Super classes
Attribute Inheritance
Constraints on specialization and generalization 30
CONT’D...
Generalization occurs when two or more entities
represent categories of the same real- world object.
Generalization is the process of defining a more general
entity type from a set of more specialized entity types.
A generalization hierarchy is a form of abstraction that
specifies that two or more entities that share common
attributes can be generalized into a higher level entity
type.
Is considered as bottom-up definition of entities.
Generalization hierarchy depicts relationship between
higher level super class and lower level subclass.
31
Generalization hierarchies can be nested. That is, a
subtype of one hierarchy can be a super type of another.
The level of nesting is limited only by the constraint of
simplicity.
Example: Account is a generalized form for having and
Current Accounts 32
CONT’D...
2.Specialization
Is the result of subset of a higher level entity set to form a lower level
entity set.
The specialized entities will have additional set of attributes
(distinguishing characteristics) that distinguish them from the generalized
entity.
Is considered as Top-Down definition of entities.
Specialization process is the inverse of the Generalization process.
Identify the distinguishing features of some entity occurrences, and
specialize them into different subclasses.
Reasons for Specialization
Attributes only partially applying to super classes
Relationship types only partially applicable to the super class
In many cases, an entity type has numerous sub-groupings of
its entities that are meaningful and need to be represented explicitly.
This need requires the representation of each subgroup in the 33ER
CONT’D...
The generalized entity is a superclass and the set of
specialized entities will be subclasses for that specific
Superclass.
Example: Saving Accounts and Current Accounts
are Specialized entities for the generalized entity
Accounts. Manager, Sales, Secretary: are specialized
employees.
34
CONT…
3. Subclass/Subtype
An entity type whose tuples have attributes that distinguish its
members from tuples of the generalized or Superclass entities.
When one generalized Superclass has various subgroups with
distinguishing features and these subgroups are represented by
specialized form, the groups are called subclasses.
Subclasses can be either mutually exclusive (disjoint) or
overlapping (inclusive).
A single subclass may inherit attributes from two distinct super
classes.
35
CONT’D...
A mutually exclusive category/subclass is when an entity instance
can be in only one of the subclasses.
E.g.: An EMPLOYEE can either be SALARIED or PART-
TIMER but not both.
An overlapping category/subclass is when an entity instance
may be in two or more subclasses.
E.g.: A PERSON who works for a university can
be both EMPLOYEE and a STUDENT at the
same time.
4.Superclass /Supertype
An entity type whose tuples share common attributes. Attributes
that are shared by all entity occurrences (including the identifier)
are associated with the supertype.
Is the generalized entity 36
CONT’D...
5.Relationship Between Super class and Subclass
The relationship between a superclass and any of its
subclasses is called a superclass/subclass or class/subclass
relationship
An instance can not only be a member of a subclass. i.e. Every
instance of a subclass is also an instance in the Superclass.
A member of a subclass is represented as a distinct database
object, a distinct record that is related via the key attribute to its
super-class entity.
An entity cannot exist in the database merely by being a member
of a subclass; it must also be a member of the super-class.
An entity occurrence of a sub class not necessarily should
belong to any of the subclasses unless there is full
participation in the specialization. 37
CONT’D...
The relationship between a subclass and a Superclass is an ―IS A or ―IS PART
OF type.
Subclass IS PART OF Superclass
Manager IS AN Employee
All subclasses or specialized entity sets should be connected with the super class
using a line to a circle where there is a subset symbol indicating the direction of
subclass/super class relationship.
An entity that is a member of a subclass inherits all the attributes of the entity as a
member of the super class.
The entity also inherits all the relationships in which the super class participates.
An entity may have more than one subclass categories.
All entities/subclasses of a generalized entity or super class share a
common unique identifier attribute (primary key). i.e. The primary key of the
superclass and subclasses are always identical.
39
CONT’D...
Consider the EMPLOYEE supertype entity shown
above. This entity can have several different subtype
entities (for example: HOURLY and SALARIED),
each with distinct properties not shared by other
subtypes. But whether the employee is Hourly or
Salaried, same attributes (EmployeeId, Name, and
DateHired) are shared.
The Supertype EMPLOYEE stores all properties that
subclasses have in common. And HOURLY employees
have the unique attribute Wage (hourly wage rate), while
SALARIED employees have two unique attributes,
StockOption and Salary.
40
Constraints on specialization and generalization
Completeness Constraint
The Completeness Constraint addresses the issue of
whether or not an occurrence of a Superclass must also
have a corresponding Subclass occurrence.
The completeness constraint requires that all instances of the
subtype be represented in the supertype.
The Total Specialization Rule specifies that an entity
occurrence should at least be a member of one of the
subclasses. Total Participation of superclass instances on
subclasses is diagrammed with a double line from the
Supertype to the circle as shown below.
41
CONT’D...
46
Thank you for your presence
47