4.01 Database Design
4.01 Database Design
CS341
Database Design Methodology
Three main phases
Conceptual database design
Logical database design
Physical database design
Conceptual Design
Logical Design
Physical Design
2
Phases in DB Design
Conceptual Database Design
The process of constructing a model of the data used in an
enterprise
Discovering and analyzing organizational and user data
requirements
Logical Database Design
the process of deciding how to arrange the attributes of the
entities into database tables of a relational database.
The goal is to create well structured tables that properly reflect
the company's business environment
Based on a specific DATA MODEL (e.g. relational)
Independent of a particular DBMS
3
Phases in DB Design (cont.)
Physical Database Design
The process of producing a description of the implementation of
the database on secondary storage
It describes the base relations, file organizations, and indexes
design used to achieve efficient access to the data
Any associated integrity constraints and security measures are
included
It is DEPENDENT on our choice of the particular DBMS that we
want to use
We will describe the plan for how to build the tables
Appropriate data types
Field sizes
Indexes
4
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
Entity-Relationship Diagram (ERD) is developed based
on these components
Conceptual Data Model produces
ER diagrams, and
Description of the Diagram
5
Developing an E-R Diagram
Designing conceptual model
Identify the entities, attributes, relationships, and constraints
Analysis of requirements gathered
Nouns --- prospective entities
Adjectives --- prospective attributes
Verbs/verb phrases --- prospective relationships
Commanding Words --- prospective constraints
6
Developing an E-R Diagram (cont.)
Developing an E-R Model involves identifying the
Entities
Attributes
Relationships between entities
The E-R Model needs to be validated against the
requirement of the user
The E-R diagram is presented for review
Feedback is collected from users
The process is repeated until the end users and designers agree
7
The ER Model
Components of the ER Model
Entity
Relationship
Attributes
The ER diagram is used to represent database schema
Example
8
ER Diagram
In ER diagram:
A rectangle represents an entity set.
An ellipse represents an attribute.
A diamond represents a relationship.
Lines represent linking of attributes to entity sets and of entity
sets to relationship sets.
9
Entity
Entity (Entity Type)
A GROUP of objects with same properties identified by as
having an independent existence
Entity type or entity set is a collection of similar entities
Some examples of entity types are:
All students in HiLCoE, say STUDENT.
All courses in HiLCoE, say COURSE
Entity occurrence (instance)
Uniquely identifiable object of an entity type.
10
Entity (cont.)
There are different types of Entities
It can be an object with a physical existence
It can be an object with a conceptual existence
11
Attribute
An entity is described by its properties
These are the ATTRIBUTES of the entity
Entities are described in a database by a set of attributes
Example of attributes:
Attributes of CELLPHONE
Brand, Cost, and Weight
Attributes of STUDENT
Roll number, name, and grade
Attributes of EMPLOYEE
Employee’s name, Date of Birth, address, salary, and job
address
Date of
Employee Birth
Name
job salary
12
Relationship
A relationship is an association between entity types
The examples of relationship are:
Teaches is the relationship between LECTURER and STUDENT
Treatment is the relationship between DOCTOR and PATIENT
ER Diagram
13
Relationship (cont.)
Example
Employee WORKs FOR Department
14
ER Diagram - Example
STUDENT and CLASS are entities
Roll number and the Name are attributes of STUDENT
Subject Name and Hall Number are attributes of
CLASS
Attends is a relationship between entities STUDENT
and CLASS
15
Attributes
An Attribute is a property of an entity or a relationship
The Domain of an Attribute is the set of allowable values
for one or more attributes.
Attribute ( Structure based classification )
Simple Attribute
Composite Attribute
Attribute (Value based classification)
Single Value
Multivalued Attribute
Derived Attribute
16
Attributes (Value based classification)
Single-valued Attribute
Attribute that holds a single value for each occurrence of an
entity type.
Multi-valued Attribute
Attribute that holds multiple values for each occurrence of an
entity type.
Represented by double line ellipse in Traditional E-R
Derived Attribute
Attribute that represents a value that is derivable from value of a
related attribute, or set of attributes, not necessarily in the same
entity type.
Represented by a dotted line ellipse in Traditional E-R
17
Single-valued Attribute
Examples
age of a person
Roll number of the student,
Registration number of a car, etc
Representation of Single Value Attribute in ER Diagram
18
Multivalued Attribute
More than one value will be associated with a multivalue
attribute.
The skills associated to an employee are a multivalue
attribute.
19
Derived Attribute
The value of the derived attribute can be derived from
the values of other related attributes or entities.
Example: The Age of a person can be derived from the
date of birth of the person
Experience of an employee in an organization can be
derived from date of joining of the employee
20
Attributes(Structure based classification)
Simple Attribute
Attribute composed of a single component with an independent
existence.
Represented by an Ellipse in traditional E-R model
Composite Attribute
Attribute composed of multiple components, each with an
independent existence.
Indicated by extension ellipses of an attribute ellipse
21
Composite Attribute
Composite attribute is one which can be further
subdivided into simple attributes.
Example: Consider the attribute “address” which can be
further subdivided into Street name, City, and State.
22