Database Chapter 2 by Hatem
Database Chapter 2 by Hatem
1- Requirements Analysis
2- Conceptual Database Design
3- Logical Database Design
4- Schema Refinement
5- Physical Database Design
6- Application and Security Design
1- Requirements Analysis
- The first step in designing a DBase application is to
understand:
• what data is to be stored in the database,
• what applications must be built on top of it, and
• what operations are most frequent and subject to
performance requirements.
Manages
since
8-11-99
225- ahmed-5777 50- comp -577
12-10-98
226- aly- 5687 52- math- 567
25-6-96
227- fahd- 5638 53- stat- 568
20-12-93
228- saad- 5678
Employees WORKS_IN
11-11-95 Departments
Ex.: suppose that each department has offices in several
locations. This relationship is ternary because we must
record an association between an employee, a department,
and a location.
since
ssn name lot did dname budget
Employees
Supervisor Subordinate
Reports_To
2.4 ADDITIONAL FEATURES OF THE ER MODEL
There are some constructs in the ER model that allow us to
describe some subtle properties of the data. The
expressiveness of the ER model is a big reason for its
widespread use.
2.4.1 Key Constraints
Consider the Works_In relationship
since
ssn name lot did dname budget
Manages Departments
Employees
567- ahmed-5678 5-11-90
3- 3-99
5- computer-578
568- aly- 6745
4- 5- 98
6- math- 645
569- fahd- 5689
6- 2- 92
7- statistics- 569
570-tarek-7234
Manages Departments
Employees
Manages Departments
Employees
If we add the restriction that each employee can manage
at most one department to the Manages relationship set,
which would be indicated by adding an arrow from
Employees to manages we have a one-to-one relationship
set.
since
ssn name lot did dname budget
Employees Departments
Manages
Key Constraints for Ternary Relationships
If an entity set E has a key constraint in a relationship set R,
each entity in an instance of E appears in at most one
relationship in (a corresponding instance of) R. To indicate
a key constraint on entity set E in relationship set R, we
draw an arrow from E to R.
since
ssn name lot did dname budget
570-tarek-7234 1-10-97
cairo-58
Employees Works_In3
Key constraint Reyad- 65
maskat- 56
Locations
2.4.2 Participation Constraints
since
ssn name lot did dname budget
Manages
since
Weak Entities
we have assumed that the attributes associated with an
Book edition
Published
Ex.: The entity set transaction has attributes transaction-
number, date and amount. Different transactions on
different accounts could share the same number.
These are not sufficient to form a primary key (uniquely
identify a transaction).
?
Aid amoun Adate tnumber date
t
account transaction
On
Ex.: suppose that employees can purchase insurance
policies to cover their dependents.
Employees Dependents
Policy
We might choose to identify a dependent by name alone in
this situation, since it is reasonable to expect that the
dependents of a given employee have different names.
Thus the attributes of the Dependents entity set might be
pname and age.
Employees Dependents
Policy
2.4.4 Class Hierarchies
Employees
Employees
since
Started_on pbudget did dname budget
We treated Sponsors as an
entity set for purposes of Monitors until
defining the Monitors
relationship set.
name Employees ssn
lot
When should we use aggregation?
we use it when we need to express a relationship among
relationships.
can we not express relationships involving other
relationships without using aggregation?
Employees address
Address Employees
Has_Address
from to
ssn name lot did dname budget
Duration
from to
2.5.2 Entity versus Relationship
since
ssn name lot did dname budget
since dbudget
since dbudget
IS_A
Managers Manages3
since dbudget
ssn name lot did dname budget
Employees Works_In Departments
Policies
cost policyid
Suppose that we have the following additional
requirements:
1- A policy cannot be owned jointly by two or more
employees.
2- Every policy must be owned by some employee.
3-Dependents is a weak entity set, and each dependent
entity is uniquely identified by taking pname in conjunction
with the policyid of a policy entity (which, intuitively, covers
the given dependent).
1- A policy cannot be owned jointly by two or more
employees.
ssn name lot age pname
Policies
cost policyid
The first requirement suggests that we impose a key
constraint on Policies with respect to Covers, but this
constraint has the unintended side effect that a policy can
cover only one dependent.
2- Every policy must be owned by some employee.
Policies
cost policyid
Dependents
Employees Purchaser Beneficiacy
Policies
cost policyid
Ex.: (ternary relationship) entity sets Parts, Suppliers, and
Departments, and a relationship set Contracts (with
descriptive attribute qty) that involves all of them.
Pn Pnam lot qty Sn Sname
e
Parts Contracts Suppliers
Departments
Dname Dn
Contracts
Departments
Dname Dn
deals
Departments
Dname Dn
deals
Departments
Dname Dn
2.5.4 Aggregation versus Ternary Relationships
since
Started_on pbudget did dname budget
lot
each sponsorship is monitored by one or more employees.
If we don't need to record the until attribute of Monitors,
then we might reasonably use a ternary relationship, say,
Sponsors2.
lot
Consider the constraint that each sponsorship (of a project
by a department) be monitored by at most one employee.
we cannot express this constraint in terms of the Sponsors2
relationship set.
lot
On the other hand, we can easily express the constraint by
drawing an arrow from the aggregated relationship Sponsors
to the relationship Monitors. Thus, the presence of such a
constraint serves as another reason for using aggregation
rather than a ternary relationship set.
since did
Started_on pbudget dname budget
pid Projects Sponsors Departments
Monitors until