Topic 3 - Database Design
Topic 3 - Database Design
Database design: The process of creating a design for a database that will support the enterprise’s
operations and objectives. After data requirements collection and analysis, database design is
performed in three main phases (stages) namely:
Conceptual design,
Logical design
Physical design.
The database design process consists of a number of steps listed below.
Many DBMS systems use an implementation data model, so the conceptual schema is
transformed from the high-level data model into the implementation data model.
This step is called logical design or data model mapping, which results in the implementation
data model of the DBMS.
Step 4: Physical Design
Internal storage structures, indexes, access paths and file organizations are specified.
Application programs are designed and implemented
The Entity Relationship Model
Relational Model
The most popular data model in DBMS is the Relational Model. It is more scientific a model than
others. This model is based on first-order predicate logic and defines a table as an n-ary relation.
All the entities in the data model have attributes also known as properties of an entity
Example: people have names and addresses
An Entity set is a set of an entity of all same type that shares the same properties.
Example: set of all persons, companies, trees
ER Diagram
Example: In the Case of Client entity Client_no is the primary key of Client entity which is
used to uniquely identified among the Client ‘s entity set. In the case of Customer Entity,
Customer_id is the primary key of Customer Entity which is used to uniquely identify among
the Customer’s entity set. Strong Entity type is represented by rectangle Symbol
Strong entity
ii. Weak entity: This is an entity that does not have sufficient attributes to form a primary key
(unique identifier). Entity type which is dependent on some other entity type is called as Weak
entity type. Weak entity type is dependent on a strong entity and cannot exist on its own. The
existence of a weak entity is indicated by a double rectangle in the ER diagram.
Weak entity
iii. Recursive Entity: This is an entity in which a relationship can exist between occurrences of
the same entity. This occurs in a unary relationship. For instance, a doctor can be a patient.
They are represented as follows:
Treat
Doctor
iv. Composite Entities: An entity created to resolve Many to Many relationship to one-to-many. It
is also referred to as a bridge entity. Bridge entity is composed of the primary keys of each of
the entities to be connected. A composite entity is represented by a diamond shape within a
rectangle in an ER Diagram.
Remarks:
Generalization: The process of defining a more general entity type from a set of more
specialized entity types. Bottom-Up
Specialization: The process of defining one or more subtypes of the supertype and forming
supertype/subtype relationships. Top-Down
b) Identification of relationships
A relationship is a meaningful association between entity types.
Classifying relationships:
i. Degree
ii. Cardinality
iii. Optionality
1. Classification according to degree
Degree: The number of entity types participating in a relationship.
i. Unary (recursive) relationship: One entity type participates in a relationship.
DOCTOR DOCTOR
PRESCRIPTION PHARMICST
PATIENT
…
iv. n-ary relationship: n entity types participate in a relationship.
In a relationship, cardinality refers to the number of entity occurrences involved in the relationship. It
also defined as minimum and maximum number of entity occurrences that can participate in a
relationship.
Examples
One-to-one − One entity from entity set A can be associated with at most one entity of entity
set B and vice versa.
One-to-many − One entity from entity set A can be associated with more than one entities of
entity set B however an entity from entity set B, can be associated with at most one entity.
Many-to-one − More than one entities from entity set A can be associated with at most one
entity of entity set B, however an entity from entity set B can be associated with more than one
entity from entity set A.
Many-to-many − One entity from A can be associated with more than one entity from B and
vice versa.
M
M 1
1
DOCTOR PATIENT MEDICATION
treat takes
(0, N) (0, N)
(1, 1) (1, 1)
DOCTOR PATIENT
MEDICATION
Example 1 : IDEF1X
The above model will be read as follows:
Each DOCTOR must treat one or more PATIENTS. Each patient must be treated by a doctor.
Each PATIENT may take one or more MEDICATIONS. Each MEDICATION is given to one
PATIENT.
Treats Takes
has
ORDER
From the figure above, the conceptual data model is the entities that describe the data and the
relationships between those entities.
The process of constructing a database based on specific database management system (DBMS)
and database model. For example a relational Database model. It considers how the data are
represented using the structures offered by the DBMS:
Steps followed:
Select database model.
Map Entity-Relationship Diagrams(from conceptual data model into logical model)
Identify the attributes
Normalize database
Design the ERD (logical data model) and validate with the users.
Create a data dictionary
Attributes
Begin with a list of all of the fields that must appear in the database.
Do not include computed fields
You can get this information from a printed document used by the system e.g. reports.
Additional attributes besides those for the entities described on the document can be added to the
database.
v). Design the ERD (logical data model) and validate with the users.
In this step we use the normalized forms and standard notations to draw the ERD. Such notations
include Rein95, IDEFl1X, Chen, Crow’s foot among others.
Relationship
line
Relationship
Optional symbol
One(1) symbol 1
Many(M) M
symbol
Composite
entity
Weak entity
A logical data model describes the data in as much detail as possible, without regard to how they will
be physically implemented in the database. A logical data model is used to explore the domain
concepts, and their relationships, of the problem. This could be done for the scope of a single project
or for the entire enterprise. The logical data model depict the logical entity types, typically referred to
simply as entity types, the data attributes describing those entities, and the relationships between the
entities.
In a logical data model, primary keys are present, whereas in a conceptual data model, no primary
key is present.
In a logical data model, all attributes are specified within an entity. No attributes are specified in a
conceptual data model.
Relationships between entities are specified using primary keys and foreign keys in a logical data
model. In a conceptual data model, the relationships are simply stated, not specified, so we simply
know that two entities are related, but we do not specify what attributes are used for this relationship.
Physical data model represents how the model will be built in the database.
A physical database model shows all table structures, including column name, column data type,
column constraints, primary key, foreign key, and relationships between tables.
Features of a physical data model include:
i. Specification of all tables and columns.
ii. Foreign keys are used to identify relationships between tables.
iii. De-normalization may occur based on user requirements.
iv. Physical considerations may cause the physical data model to be quite different from the
logical data model.
v. Physical data model will be different for different RDBMS. For example, data type for a
column may be different between MySQL and SQL Server.
SUPPLIER
1 PRODUCT
ORDER
Comparing the logical data model shown above with the logical data model diagram, we see the main
differences between the two:
Revision questions
a) Describe four functions of a database management system (DBMS). [8 Marks]
b) Describe the three levels of database architecture. [6 Marks]
c) Discuss the logical and physical data independence. [4 Marks]
d) Define the following attributes as used in relational database design. [6 Marks]
i). Multi-valued attribute
ii). Composite attribute
iii). Derived attribute
e) Identify at least three attributes for each of the following entities below and choose one of your
attributes as the identifier for the entities.
i). Customer. [3 Marks]
ii). Organization. [3 Marks]
f) Discuss the differences in the following data modelling notations.
i). Chen
ii). IDEF1X
iii). Rein85
iv). Crow’s foot
g) Describe the process of physical database design. [8 Marks]
h) Briefly explain the following database storage devices.
i). Optical storage
ii). Magnetic disk
iii). Tape storage [6 Marks]
i) Explain the following database access methods.
i). Hash
ii). Indexed sequential access [6 Marks]