Dbms Chapter 3
Dbms Chapter 3
DBMS I 1
Database Design
Database design is the process of coming up with different
kinds of specification for the data to be stored in the
database.
The ability to design databases and associated applications is
critical to the success of the modern enterprise.
Database design requires understanding both the
operational and business requirements of an organization
as well as the ability to model and realize those
requirements using a database.
Developing database and information systems is performed
using a development lifecycle, which consists of a series of
steps.
As it is one component in most information system
development tasks, there are several steps to follow in
designing a database system.DBMS I 2
The requirements gathering and specification provides you
with a high-level understanding of the organization, its
data, and the processes that you must model in the
database.
Database design involves constructing a suitable model of
this information.
Since the design process is complicated, especially for
large databases, database design is mainly focused on this
three phases:
• Conceptual Design
• Logical Design, and
• Physical Design
In general, one has to go back and forth between these
tasks to refine a database design, and decisions in one task
DBMS I 3
can influence the choices in another task.
DBMS I 4
1. Conceptual Database Design
construct the organizational and user data requirements
discovered and analyzed during requirement analysis.
is the process of constructing a model of the
information used in an enterprise.
is used as input or source of information for the logical
database design phase.
it is a phase which is independent of all physical
considerations (DBMS, OS, . . . ).
it is carried out using entity-relationship model
(conceptual level, conceptual schema).
The conceptual design activities are:
1. Identify all entities and their relationships
DBMS I 5
Questions that are addressed during conceptual
design:
What are the entities and relationships of interest?
What information about entities and relationships
among entities needs to be stored in the database?
What are the constraints (or business rules) that (must)
hold for the entities and relationships?
A database schema in the ER model can be represented
pictorially using (Entity-Relationship diagram).
DBMS I 6
REASONS FOR CONCEPTUAL MODELING
DBMS I 16
3. Composite and Simple Attributes
A composite attribute, is an attribute that can be
further subdivided to yield additional attributes.
For example, the attribute ADDRESS can be
subdivided into street_Address, city, state, and Postal
code.
Similarly, the attribute PHONE_NUMBER can be
subdivided into area code and exchange number.
A simple attribute is an attribute that cannot be
subdivided.
For example, age, sex, and marital status would be
classified as simple attributes.
To facilitate detailed queries, it is wise to change
composite attributes into a series of simple attributes.
DBMS I 17
An attribute
broken into
component parts
DBMS I 21
Figure 3. 4 Entity with a multivalued attribute (Skill)
and derived attribute (Years_Employed)
DBMS I 22
5. Derived versus Stored Attributes
A derived attribute is an attribute whose value is
calculated (derived) from other attributes.
Derived attributes are sometimes referred to as computed
attributes.
The derived attribute need not be physically stored within
the database; instead, it can be derived by using an
algorithm.
It is used to save storage space because computation
always yields current value.
But the derived attributes have its own disadvantages such
as, uses CPU processing cycles, increases data access time
and adds coding complexity to queries.
The attribute of an employee for example, Age called a
derived attribute and is said to be derivable from the
BirthDate attribute, which DBMS
is called
I
a stored attribute. 23
Stored attribute- is an attribute in which the value is stored in
the attribute of the entity. For example, Birthdates is called a
Stored attribute.
Stored attribute on the other hand, saves CPU processing
cycles, saves data access time, data value is readily available
and can be used to keep track of historical data
However, stored attributes has disadvantages such as, requires
constant maintenance to ensure derived value is current,
especially if any values used in the calculation change.
DBMS I 24
Fig 3.5 Depiction of a derived attribute
Domains
Attributes have a domain. A domain is the set of possible values
for a given attribute.
For example, the domain for the grade point average (GPA)
attribute is written (0,4) because the lowest possible GPA value
is 0 and the highest possible value is 4.
The domain for the gender attribute consists of only two
possibilities: M or F (or some other equivalent code).
Attributes may share a domain. For instance, a student address
and a professor address share the same domain of all possible
addresses.
In fact, the data dictionary may let a newly declared attribute
inherit the characteristics of an existing attribute if the same
attribute name is used.
For example, the PROFESSOR and STUDENT entities may
each have an attribute namedDBMSADDRESS
I and could therefore
25
Example 1: Build an ER Diagram for the
following information:
• A student record management system will have
the following two basic data object categories with
their own features or properties: Students will
have an Id, Name, Dept, Age, GPA and Course
will have an Id, Name, Credit Hours . Whenever a
student enroll in a course in a specific Academic
Year and Semester, the Student will have a grade
for the course
26
27
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, Tel.
• 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.
28
Example 3
DBMS I 36
An entity on one side of the relationship can have many related
entities, but an entity on the other side will have a maximum of
one related entity.
(1,1) (0,3)
DBMS I 46
3. Relationship Degree
• Degree of a relationship: refers to the number of entity
types that participate in the relationship type (unary,
binary, ternary).
A) Unary Relationships
A unary relationship exists when an association is
maintained within a single entity.
B) Binary Relationships
• A binary relationship exists when two entities are
associated in a relationship. Binary relationships are most
common.
C) Ternary Relationships
• A ternary relationship implies an association among three
different entities.
DBMS I 47
Figure 3. Degree of Relationships
DBMS I 48
5. Recursive Relationships
A recursive entity is one in which a relationship can
exist between occurrences of the same entity set.
A recursive entity is found within a unary relationship.
• A relationship type with the same participating entity type
in distinct roles
• Example: the SUPERVISION relationship
• EMPLOYEE participates twice in two distinct roles:
– supervisor (or boss) role
– supervisee (or subordinate) role
• Each relationship instance relates two distinct
EMPLOYEE entities:
– One employee in supervisor role
– One employee in supervisee role
Another Example, a COURSE may be a prerequisite to
a COURSE. DBMS I 49
Weak Entity Sets
• An entity set that does not have a primary key is referred
to as a weak entity set.
• The existence of a weak entity set depends on the
existence of a identifying entity set
It must relate to the identifying entity set via a total, one-
to-many relationship set from the identifying to the weak
entity set
Identifying relationship depicted using a double diamond
• The discriminator (or partial key) of a weak entity set is
the set of attributes that distinguishes among all the
entities of a weak entity set.
• The primary key of a weak entity set is formed by the
primary key of the strong entity set on which the weak
entity set is existence dependent,
DBMS I
plus the weak entity set’s
50
• We depict a weak entity set by double rectangles.
• We underline the discriminator of a weak entity set with a
dashed line.
• payment-number – discriminator of the payment entity set
• Primary key for payment – (loan-number, payment-
number)
DBMS I 51
• Note: the primary key of the strong entity set is not explicitly
stored with the weak entity set, since it is implicit in the
identifying relationship.
• If loan-number were explicitly stored, payment could be
made a strong entity, but then the relationship between
payment and loan would be duplicated by an implicit
relationship defined by the attribute loan-number common
to payment and loan
• In a university, a course is a strong entity and a course-
offering can be modeled as a weak entity
• The discriminator of course-offering would be semester
(including year) and section-number (if there is more than
one section)
• If we model course-offering as a strong entity we would
model course-number as an attribute.
• Then the relationship with DBMS
course
I would be implicit in 52the
Associative Entities
DBMS I 54
Figure 3-11b – An associative entity (CERTIFICATE) 55
Enhanced E-R (EER) Models