Professional Documents
Culture Documents
10 DBDesignStG-4up
10 DBDesignStG-4up
CSC343 – Introduction to Databases Database Design — 1 CSC343 – Introduction to Databases Database Design — 2
CSC343 – Introduction to Databases Database Design — 3 CSC343 – Introduction to Databases Database Design — 4
1
Performance Analysis
Logical Design Steps
o It is helpful to divide the design into An ER schema is restructured to optimize:
two steps: Cost of an operation (evaluated in terms of the
number of occurrences of entities and relationships
o Restructuring of the Entity- that are visited during the execution of an
Relationship schema, based on operation);
criteria for the optimization of the Storage requirements (evaluated in terms of
schema and the simplification of the number of bytes necessary to store the data
following step; described by the schema).
o Translation into the logical In order to study these parameters, we need to know:
model, based on the features of the Projected volume of data;
logical model (in our case, the Projected operation characteristics.
relational model).
CSC343 – Introduction to Databases Database Design — 5 CSC343 – Introduction to Databases Database Design — 6
Cost Model
The cost of an operation is measured in terms of Employee-Department Example
the number of disk accesses required. A disk
access is, generally, orders of magnitude more
expensive than in-memory accesses, or CPU
operations.
For a coarse estimate of cost, we assume that
a Read operation (for one entity or
relationship) requires 1 disk access;
A Write operation (for one entity or
relationship) requires 2 disk accesses (read
from disk, change, write back to disk).
There are many other cost models depending on
use and type of DB
Warehouse (OLAP - On-Line Analysis
Processing)
Operational DB (OLTP - On-Line Transaction
CSC343 – Introduction to Databases Database Design — 7 CSC343 – Introduction to Databases Database Design — 8
Processing)
2
Typical Operations Workload Design
Operation 1: Assign an employee to a project. During initial design and requirements
Operation 2: Find an employee record, including her analysis
department, and the projects she works for.
Operation 3: Find records of employees for a
Estimate operations and frequency
department. Gross estimates at best
Operation 4: For each branch, retrieve its After database is operational
departments, and for each department, retrieve the
last names of their managers, and the list of their Tools record actual workload
employees. characteristics
Need operations and their volume/frequency
CSC343 – Introduction to Databases Database Design — 9 CSC343 – Introduction to Databases Database Design — 10
Analysis of Redundancies
Analysis
Steps A redundancy in a conceptual
schema corresponds to a piece of
information that can be derived
(that is, obtained through a series
of retrieval operations) from other
data in the database.
An Entity-Relationship schema
may contain various forms of
redundancy.
CSC343 – Introduction to Databases Database Design — 11 CSC343 – Introduction to Databases Database Design — 12
3
Deciding About Redundancies
Examples of Redundancies The presence of a redundancy in a database
may be
an advantage: a reduction in the number of
accesses necessary to obtain the derived
information;
a disadvantage: because of larger storage
requirements, (but, usually at negligible cost) and
the necessity to carry out additional operations
in order to keep the derived data consistent.
The decision to maintain or eliminate a
redundancy is made by comparing the cost of
operations that involve the redundant
information and the storage needed, in the
case of presence or absence of redundancy.
CSC343 – Introduction to Databases Database Design — 13 CSC343 – Introduction to Databases Database Design — 14
Removing Generalizations
Cost Comparison: An Example
The relational model does not allow direct
representation of generalizations that may
be present in an E-R diagram.
For example, here is an ER schema with
generalizations:
CSC343 – Introduction to Databases Database Design — 15 CSC343 – Introduction to Databases Database Design — 16
4
Option 1 Option 3
Note!
Possible
...Two
Restructuring
More...
s
Option 2 Option 4 (combination)
CSC343 – Introduction to Databases Database Design — 17 CSC343 – Introduction to Databases Database Design — 18
5
Example of Partitioning
Deletion of Multi-Valued Attribute
CSC343 – Introduction to Databases Database Design — 21 CSC343 – Introduction to Databases Database Design — 22
Suppose that
composition
represents Are these equivalent?
current and
past
compositions
of a team
6
Selecting a Primary Key Translation into a Logical Schema
Every relation must have a unique primary
key. The second step of logical design consists of a
translation between different data models.
The criteria for this decision are as follows:
Starting from an E-R schema, an equivalent
Attributes with null values cannot form primary
keys;
relational schema is constructed. By
“equivalent”, we mean a schema capable of
One/few attributes is preferable to many representing the same information.
attributes;
Internal key preferable to external ones (weak We will deal with the translation problem
entity); systematically, beginning with the
A key that is used by many operations to
fundamental case, that of entities linked by
access the instances of an entity is preferable many-to-many relationships.
to others.
At this stage, if none of the candidate keys
satisfies the above requirements, it may be
best to introduce a new attribute (e.g.,Database
CSC343 – Introduction to Databases
social Design — 25 CSC343 – Introduction to Databases Database Design — 26
7
Ternary Relationships One-to-Many Relationships
CSC343 – Introduction to Databases Database Design — 29 CSC343 – Introduction to Databases Database Design — 30
8
Optional One-to-One
Relationships A Sample ER Schema
CSC343 – Introduction to Databases Database Design — 33 CSC343 – Introduction to Databases Database Design — 34
E5 R4 E6
E5 E6
R5
9
Weak Entities Many-to-Many Relationships
R3
R3
E1 R1 E5 R4 E6
E1 R1 E5 R4 E6
R5
R5 R6
R6
CSC343 – Introduction to Databases Database Design — 39 CSC343 – Introduction to Databases Database Design — 40
10
...More Rules... …Even More Rules...
CSC343 – Introduction to Databases Database Design — 41 CSC343 – Introduction to Databases Database Design — 42
CSC343 – Introduction to Databases Database Design — 43 CSC343 – Introduction to Databases Database Design — 44
11
Logical Design Using CASE Tools
The logical design phase is partially supported by
database design tools: Logical
the translation to the relational model is carried out Design
by such tools semi-automatically; with a
the restructuring step is difficult to automate and
CASE tools provide little or no support for it. CASE
Most commercial CASE tools will generate automatically Tool
SQL code for the creation of the database.
Some tools allow direct connection with a DBMS and
can construct the corresponding database
automatically.
[CASE = Computer-Aided Software Engineering]
CSC343 – Introduction to Databases Database Design — 45 CSC343 – Introduction to Databases Database Design — 46
12