Database Design
Database Design
Objectives :
– State the phases in database design
– Tell what is E-R Model
– Define Entity and Attributes
– List Attribute types
– List & Identify E-R notations
– Identify the need of normalization
– Explain what is Normalization
– State & demonstrate the use of Normal Forms
2
Database Design
Phases in Database Design
Conceptual Design
– Data modeling ( E-R Diagrams)
– Normalisation
3
Database Design - Phases
Processing
User Requirements Requirements
Requirements
Formulation & Analysis DBMS
Characteristics
Requirement Specifications
Conceptual Design
Information Structure
Implementation Design
Logical Database
Structure
Hardware,
Physical Operating System
Design Characteristics
4
Entity Relationship Model
The Entity-Relationship (E-R) data model is
based on a perception of a real world that
consists of a basic set of objects called
entities, and of relationships among these
objects
5
Entity Relationship Model
Facilitates database design
Represents overall logical structure of a
database
Useful in mapping the meanings and
interactions of real-world entities onto
conceptual schema
6
Entity
An entity is a ‘thing’ or an ‘object’ in real
world that is distinguishable from all other
objects
An entity has a set of attributes that describe
the entity
7
Entity - Examples
8
Attribute
An entity has a set of attributes that describe
it
Values for some set of attributes may
uniquely identify that entity
Example :
Identify the attributes associated with
entities like employee, customer, vehicle.
9
Relationship
A relationship is an association among
several entities
Cardinality of relationship
– Cardinality express the number of entities to
which another entity can associated via
relationship set
10
Relationship
Cardinality Types
– One to One
– One to Many
– Many to One
– Many to Many
11
Data Modeling : E-R Diagram
Entity Relationship Diagram
– Identifies data objects and their relationships
– Uses a graphical notation
12
E-R Notations
Rectangle: Entity
– Data object in the system uniquely identifiable
by identifier
– Has attributes that describe it
– Example Employee
13
E-R Notations
Ellipse: Attribute
– Describes an entity
– Example Ename
Empno
Employee
14
E-R Notations
Diamond: Relationship
– Represents relationship among entities
– Relates two entities by identifiers
– Example
Works
M 1
Employee Department
15
E-R Notations
Line: Link
– Links attributes to entities and entities to
relationship
16
Un-normalised Data Structures
Contains redundant and disorganised data
Changing data in some tables can have
undesirable consequences called anomalies
Types of Anomalies
– Insertion
– Deletion
– Update
17
Normalisation
An analytical technique used during logical
database design
Refinement of the Data Model
Segregation of data over many entities or tables
Offers a strategy for constructing tables and
identifying keys
Normalised model converted to physical database
tables
18
Need for Normalisation
Improves database design
Ensures minimum redundancy of data
Reduces need to reorganise data when
design is modified / enhanced
Removes anomalies for database activities
19
Why Normalize - 1
emp code emp name join date dept code dept name dept mngr dept bdgt
7369 shah 17-Dec-80 prch purchase roy 5
7499 ray 20-Dec-81 prch purchase roy 5
7521 jain 2-Apr-82 prch purchase roy 5
7654 gupta 28-Sep-79 info infosery rao 6.5
redundancy
20
Why Normalize - 2
emp code emp name join date dept code dept name dept mngr dept bdgt
7369 shah 17-Dec-80 prch purchase roy 5
7499 ray 20-Dec-81 prch purchase roy 5
7521 jain 2-Apr-82 prch purchase roy 5
7654 gupta 28-Sep-79 info infosery rao 6.5
Deletion anomaly
21
Why Normalize - 3
emp code emp name join date dept code dept name dept mngr dept bdgt
7369 shah 17-Dec-80 prch purchase roy 5
7499 ray 20-Dec-81 prch purchase roy 5
7521 jain 2-Apr-82 prch purchase roy 5
7654 gupta 28-Sep-79 info infosery rao 6.5
Update anomaly
22
Why Normalize - 4
emp code emp name join date dept code dept name dept mngr dept bdgt
7369 shah 17-Dec-80 prch purchase roy 5
7499 ray 20-Dec-81 prch purchase roy 5
7521 jain 2-Apr-82 prch purchase roy 5
info infosery rao 6.5
Insertion anomaly
23
Normalisation Forms
First Normal Form
Second Normal Form
Third Normal Form
24