Chapter Three-Data Models
Chapter Three-Data Models
DATABASE MODELS
Introduction
A data model is a conceptual representation of the data structures that are required by a
database. The data structures include the data objects, the associations between data
objects, and the rules which govern operations on the objects. As the name implies, the
data model focuses on what data is required and how it should be organized rather than
what operations will be performed on the data. To use a common analogy, the data model
is equivalent to an architect's building plans.
A data model is independent of hardware or software constraints. Rather than try to
represent the data as a database would see it, the data model focuses on representing the
data as the user sees it in the "real world". It serves as a bridge between the concepts that
make up real-world events and processes and the physical representation of those
concepts in a database.
Methodology
There are two major methodologies used to create a data model: the Entity-Relationship
(ER) approach and the Object Model. This document uses the Entity-Relationship
approach.
Data Modeling In the Context of Database Design
Database design is defined as: "design the logical and physical structure of one or more
databases to accommodate the information needs of the users in an organization for a
defined set of applications". The design process roughly follows five steps:
1. Planning and analysis
2. Conceptual design
3. Logical design
4. Physical design
5. Implementation
The data model is one part of the conceptual design process. The other, typically is the
functional model. The data model focuses on what data should be stored in the database
while the functional model deals with how the data is processed. To put this in the
context of the relational database, the data model is used to design the relational tables.
The functional model is used to design the queries which will access and perform
operations on those tables.
Components of a Data Model
The data model gets its inputs from the planning and analysis stage. Here the modeler,
along with analysts, collects information about the requirements of the database by
reviewing existing documentation and interviewing end-users.
The data model has two outputs. The first is an entity-relationship diagram which
represents the data structures in a pictorial form. Because the diagram is easily learned, it
is valuable tool to communicate the model to the end-user. The second component is a
data document. This a document that describes in detail the data objects, relationships,
and rules required by the database. The dictionary provides the detail required by the
database developer to construct the physical database.
ER Notation
Data Modeling As Part of Database Design
The data model is one part of the conceptual design process. The other is the function
model. The data model focuses on what data should be stored in the database while the
function model deals with how the data is processed. To put this in the context of the
relational database, the data model is used to design the relational tables. The functional
model is used to design the queries that will access and perform operations on those
tables.
Data modeling is preceeded by planning and analysis. The effort devoted to this stage is
proportional to the scope of the database. The planning and analysis of a database
intended to serve the needs of an enterprise will require more effort than one intended to
serve a small workgroup.
The information needed to build a data model is gathered during the requirments analysis.
Although not formally considered part of the data modeling stage by some
methodologies, in reality the requirements analysis and the ER diagramming part of the
data model are done at the same time.
Requirements Analysis
The goals of the requirements analysis are:
To determine the data requirements of the database in terms of primitive objects
To classify and describe the information about these objects
To identify and classify the relationships among the objects
To determine the types of transactions that will be executed on the database and
the interactions between the data and the transactions
To identify rules governing the integrity of the data
The modeler, or modelers, works with the end users of an organization to determine the
data requirements of the database. Information needed for the requirements analysis can
be gathered in several ways:
Review of existing documents - such documents include existing forms and reports,
written guidelines, job descriptions, personal narratives, and memoranda. Paper
documentation is a good way to become familiar with the organization or activity you
need to model.
Interviews with end users - these can be a combination of individual or group meetings.
Try to keep group sessions to under five or six people. If possible, try to have everyone
with the same function in one meeting. Use a blackboard, flip charts, or overhead
transparencies to record information gathered from the interviews.
Review of existing automated systems - if the organization already has an automated
system, review the system design specifications and documentation
The requirements analysis is usually done at the same time as the data modeling. As
information is collected, data objects are identified and classified as either entities,
attributes, or relationship; assigned names; and, defined using terms familiar to the end-
users. The objects are then modeled and analysed using an ER diagram. The diagram can
be reviewed by the modeler and the end-users to determine its completeness and
accuracy. If the model is not correct, it is modified, which sometimes requires additional
information to be collected. The review and edit cycle continues until the model is
certified as correct.
Three points to keep in mind during the requirements analysis are:
1. Talk to the end users about their data in "real-world" terms. Users do not think in
terms of entities, attributes, and relationships but about the actual people, things,
and activities they deal with daily.
2. Take the time to learn the basics about the organization and its activities that you
want to model. Having an understanding about the processes will make it easier to
build the model.
3. End-users typically think about and view data in different ways according to their
function within an organization. Therefore, it is important to interview the largest
number of people that time permits.
Relationships
Relationships are associations between entities. Typically, a relationship is indicated by a
verb connecting two or more entities. For example:
employees are assigned to projects
As relationships are identified they should be classified in terms of cardinality,
optionality, direction, and dependence. As a result of defining the relationships, some
relationships may be dropped and new relationships added. Cardinality quantifies the
relationships between entities by measuring how many instances of one entity are related
to a single instance of another. To determine the cardinality, assume the existence of an
instance of one of the entities. Then determine how many specific instances of the second
entity could be related to the first. Repeat this analysis reversing the entities. For
example:
Employees may be assigned to no more than three projects at a time; every project has at
least two employees assigned to it.
Here the cardinality of the relationship from employees to projects is three; from projects
to employees, the cardinality is two. Therefore, this relationship can be classified as a
many-to-many relationship.
If a relationship can have a cardinality of zero, it is an optional relationship. If it must
have a cardinality of at least one, the relationship is mandatory. Optional relationships are
typically indicated by the conditional tense. For example:
An employee may be assigned to a project
Mandatory relationships, on the other hand, are indicated by words such as must have.
For example:
A student must register for at least three course each semester
In the case of the specific relationship form (1:1 and 1:M), there is always a parent entity
and a child entity. In one-to-many relationships, the parent is always the entity with the
cardinality of one. In one-to-one relationships, the choice of the parent entity must be
made in the context of the business being modeled. If a decision cannot be made, the
choice is arbitrary.
Naming Data Objects
The names should have the following properties:
o Unique
o Have meaning to the end-user
o Contain the minimum number of words needed to uniquely and accurately
describe the object
For entities and attributes, names are singular nouns while relationship names are
typically verbs.
Some authors advise against using abbreviations or acronyms because they might lead to
confusion about what they mean. Other believe using abbreviations or acronyms are
acceptable provided that they are universally used and understood within the
organization.
You should also take care to identify and resolve synonyms for entities and attributes.
This can happen in large projects where different departments use different terms for the
same thing.
Object Definition
Complete and accurate definitions are important to make sure that all parties involved in
the modeling of the data know exactly what concepts the objects are representing.
Definitions should use terms familiar to the user and should precisely explain what the
object represents and the role it plays in the enterprise. Some authors recommend having
the end-users provide the definitions. If acronyms, or terms not universally understood
are used in the definition, then these should be defined .
While defining objects, the modeler should be careful to resolve any instances where a
single entity is actually representing two different concepts (homonyms) or where two
different entities are actually representing the same "thing" (synonyms). This situation
typically arises because individuals or organizations may think about an event or process
in terms of their own function.
An example of a homonym would be a case where the Marketing Department defines the
entity MARKET in terms of geographical regions while the Sales Departments thinks of
this entity in terms of demographics. Unless resolved, the result would be an entity with
two different meanings and properties.
Conversely, an example of a synonym would be the Service Department may have
identified an entity called CUSTOMER while the Help Desk has identified the entity
CONTACT. In reality, they may mean the same thing, a person who contacts or calls the
organization for assistance with a problem. The resolution of synonyms is important in
order to avoid redundancy and to avoid possible consistency or integrity problems.
Recording Information in Design Document
The design document records detailed information about each object used in the model.
As you name, define, and describe objects, this information should be placed in this
document. If you are not using an automated design tool, the document can be done on
paper or with a word processor. There is no standard for the organization of this
document but the document should include information about names, definitions, and, for
attributes, domains.
Two documents used in the IDEF1X method of modeling are useful for keeping track of
objects. These are the ENTITY-ENTITY matrix and the ENTITY-ATTRIBUTE matrix.
The ENTITY-ENTITY matrix is a two-dimensional array for indicating relationships
between entities. The names of all identified entities are listed along both axes. As
relationships are first identified, an "X" is placed in the intersecting points where any of
the two axes meet to indicate a possible relationship between the entities involved. As the
relationship is further classified, the "X" is replaced with the notation indicating
cardinality.
The ENTITY-ATTRIBUTE matrix is used to indicate the assignment of attributes to
entities. It is similar in form to the ENTITY-ENTITY matrix except attribute names are
listed on the rows.
Figure 2.2 shows examples of an ENTITY-ENTITY matrix and an ENTITY-
ATTRIBUTE matrix.
Developing the Basic Schema
Once entities and relationships have been identified and defined, the first draft of the
entity relationship diagram can be created. This section introduces the ER diagram by
demonstrating how to diagram binary relationships. Recursive relationships are also
shown.
Binary Relationships
Figure 2.3 shows examples of how to diagram one-to-one, one-to-many, and many-to-
many relationships.
Figure 2.3 Example of Binary relationships
One-To-One
Figure 1A shows an example of a one-to-one diagram. Reading the diagram from left to
right represents the relationship every employee is assigned a workstation. Because every
employee must have a workstation, the symbol for mandatory existence—in this case the
crossbar—is placed next to the WORKSTATION entity. Reading from right to left, the
diagram shows that not all workstation are assigned to employees. This condition may
reflect that some workstations are kept for spares or for loans. Therefore, we use the
symbol for optional existence, the circle, next to EMPLOYEE. The cardinality and
existence of a relationship must be derived from the "business rules" of the organization.
For example, if all workstations owned by an organization were assigned to employees,
then the circle would be replaced by a crossbar to indicate mandatory existence. One-to-
one relationships are rarely seen in "real-world" data models. Some practioners advise
that most one-to-one relationships should be collapsed into a single entity or converted to
a generalization hierarchy.
One-To-Many
Figure 1B shows an example of a one-to-many relationship between DEPARTMENT and
PROJECT. In this diagram, DEPARTMENT is considered the parent entity while
PROJECT is the child. Reading from left to right, the diagram represents departments
may be responsible for many projects. The optionality of the relationship reflects the
"business rule" that not all departments in the organization will be responsible for
managing projects. Reading from right to left, the diagram tells us that every project must
be the responsibility of exactly one department.
Many-To-Many
Figure 1C shows a many-to-many relationship between EMPLOYEE and PROJECT. An
employee may be assigned to many projects; each project must have many employee
Note that the association between EMPLOYEE and PROJECT is optional because, at a
given time, an employee may not be assigned to a project. However, the relationship
between PROJECT and EMPLOYEE is mandatory because a project must have at least
two employees assigned. Many-To-Many relationships can be used in the initial drafting
of the model but eventually must be transformed into two one-to-many relationships. The
transformation is required because many-to-many relationships cannot be represented by
the relational model. The process for resolving many-to-many relationships is discussed
in the next section.
Recursive relationships
A recursive relationship is an entity is associated with itself. Figure 2.4 shows an example
of the recursive relationship.
An employee may manage many employees and each employee is managed by one
employee.