Tải bản đầy đủ (.pdf) (24 trang)

Module 7: Implementing Data Integrity

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (334.81 KB, 24 trang )


Module 7: Implementing Data Integrity






Module 1: Course
Overview
Module 4: Deriving a
Logical Data Design
Module 5: Normalizing the
Logical Data Design
Module 6: Deriving a
Physical Data Design
Module 7:
Implementing Data
Integrity
Module 2: Solution
Design Processes
Module 3: Using a
Conceptual Design for Data
Requirements
Module 8: Designing
Data Services
Module 9: Data Storage
Considerations
Designing Data
Services and
Data Models


Overview of Data
Integrity
Implementing Business
Rules and Data Integrity
Activity 7.1: Identifying Data
Integrity Requirements
Activity 7.2: Determining
Business and Data Integrity
Implementations
Module 7: Implementing
Data Integrity

Module 7: Implementing Data Integrity 147




!
!!
! Overview
"
Overview of Data Integrity
"
Implementing Data Integrity Requirements
"
Review
In this module...
In this module...



At the end of this module, you will be able to:
"
Identify business rules that relate to data integrity.
"
Identify the data integrity requirement type to which a business rule applies.
"
Evaluate and determine a location for implementing data integrity.
"
List implementation techniques for a given data integrity requirement.

Slide Objective
To provide an overview of
this module’s topics and
objectives.
Lead-in
In this module, you will learn
how to enforce business
rules and maintain data
integrity.
148 Module 7: Implementing Data Integrity





!
!!
! Overview of Data Integrity
"
Data Integrity Categories

"
Referential Integrity
"
Data Validation
"
Identifying Data Integrity Requirements
"
Activity 7.1: Identifying Data Integrity
Requirements
In this section...
In this section...


In this section, you will learn about different types of data integrity
requirements.
Slide Objective
To provide an overview of
data integrity.
Lead-in
This section discusses data
integrity rules and ways of
enforcing them.
Module 7: Implementing Data Integrity 149




Data Integrity Categories
Domain Integrity
(

columns
)
Entity Integrity
(
rows
)
"
Domain integrity determines
the allowable values for an
attribute
"
Entity integrity ensures that
an instance of an entity is
unique
Referential
Integrity


Data integrity refers to the consistency and accuracy of data. An important step
in database planning is deciding how to ensure this integrity.
Three categories of data integrity can be employed: domain, entity, and
referential. Here you will learn about domain and entity integrity. (Referential
integrity will be discussed in detail in the following topic.)
Domain integrity
Domain (or column) integrity specifies a set of legitimate data values for a
column and determines whether null values are to be allowed. Implementing
validity checking can often enforce domain integrity. Restricting the data type,
format, or range of possible values allowed in a column can also enforce
domain integrity.
Entity integrity

Entity (or row) integrity requires that all rows in a table have a unique
identifier, known as the primary key value. Whether the primary key value can
be changed, or whether an entire row can be deleted, depends on the level of
referential integrity required between the primary key of the table and the
foreign keys of any other tables.
When used together, domain and entity integrity help to ensure that each entity
in a physical design maintains consistency. When planning for databases in
your design, you must consider consistency among entities and data validity
within the entities as important additional aspects of data integrity.
Slide Objective
To introduce the concept of
data integrity.
Lead-in
Data integrity refers to the
consistency and accuracy of
data and falls into three
categories: domain, entity,
and referential.
150 Module 7: Implementing Data Integrity





Referential Integrity
"
Ensures that each child entity has a related parent
entity
"
Is built on domain and entity integrity principles



The domain and entity integrity categories suffice for enforcing data integrity in
a single table; however, many databases contain multiple tables with parent and
child entities that are related. When both the entities in a relationship must exist
and must have a valid link to one another, referential integrity makes sure that
these conditions are met.
Referential integrity ensures that the relationships between the primary keys (in
the parent entity’s table) and foreign keys (in the child entity’s table) are always
maintained.
As a result of the restrictions that referential integrity imposes on tables, it is
important for you to consider what to do when a primary key must be updated
or deleted. If the primary key’s value in the parent entity is changed or deleted,
then the instance of that entity has been modified, thus necessitating
corresponding modifications in all child entities that reference the parent. By
cascading, or walking, through all related child tables and updating or deleting
data as necessary, the database can maintain referential integrity.
Slide Objective
To explain the concept of
referential integrity.
Lead-in
Whereas domain and entity
integrity help ensure
accuracy of data within a
table, referential integrity
helps ensure accuracy of
data between tables.
Module 7: Implementing Data Integrity 151





Data Validation
"
Ensures that proper values are supplied
$
Range checking
$
Data format
$
Data type checking
"
Is implemented by two means of checking
$
Client-side
$
Server-side


It is important to have valid data. Domain, entity, and referential integrity
ensure that data exists where necessary and that entities follow a basic set of
rules for existence. None of these data integrity categories, however, can
determine whether the data is valid. You can ensure that the data is correct by
checking it in the following ways:
"
Range checking involves making sure the data’s value falls within a set of
limits determined by the functional specification.
"
Data format checking involves making sure the data conforms to a set of
format specifications, such as currency formatting, telephone number

formatting, or length-of-character strings.
"
Data type checking involves making sure the data belongs to the proper data
type and that an invalid data type is not used to represent the data when it is
written to the database.

To ensure that queries return the correct information, you must make sure that
the information being stored is valid. You can validate data in two ways:
"
Client-side checks can ensure that invalid data is not posted to a database.
These checks can be coded as a script, as part of an executable program, or
as part of a Web page. For example, if a field denotes a monetary value, a
script can make sure that the information in that field is the proper data type
and format.
"
Server-side checks, which are executed by the DBMS engine, can be
implemented with field data types, default values, and constraints. These
checks can also ensure that invalid data is not stored in the database.

Slide Objective
To introduce the concept of
data validation.
Lead-in
Validity of data is of the
utmost importance. This
topic discusses ways to help
achieve data validity.
152 Module 7: Implementing Data Integrity






The methods or combination of methods that you use depends on the objectives
and requirements of your solution; each method or combination has its value.
Although more difficult to maintain than server-side checks, client-side checks
can help decrease the processing load on the DBMS server. Although easier to
maintain, server-side checks might present a bottleneck if the server has to
validate many client requests.
Module 7: Implementing Data Integrity 153




Identifying Data Integrity Requirements
"
Use data requirements as a guide
"
Look for explicit or implicit constraints or limits
"
Determine where uniqueness within the requirements
must exist (produces domain and entity integrity)
"
Determine where relationships within the
requirements must exist (produces referential
integrity)


Identifying data integrity requirements helps ensure that all logical and physical
requirements for a solution are met and that the physical design supports the

full intent of your specification.
When attempting to identify the data integrity requirements of a solution, you
must start with the data requirements specified during the solution’s design.
When examining the data requirements, you should identify areas within the
requirements in which uniqueness, or limits and constraints, have been
specified or deemed necessary to help ensure that entities can exist and be
implemented correctly.
If limits and constraints or limits have been specified or deemed necessary, you
must determine whether the limits and constraints are bound to an entity or to a
relationship between entities.
For example, suppose you need to determine whether a particular task can exist
without a related job number. If it can’t, you must implement a data integrity
requirement to make sure that no instance of that task is created without a
corresponding job number. Alternatively, suppose a consultant must submit a
weekly timesheet for a client. No timesheet can duplicate another timesheet,
and no two timesheets can represent the same time or work performed by a
consultant. Therefore, a data integrity requirement exists for guaranteeing the
uniqueness of timesheet information. Each timesheet within the database must
be represented by a unique attribute or a combination of unique attributes.
Finally, you must implement referential integrity requirements to ensure that all
relationships are maintained. For example, if a customer wants to be removed
from Ferguson and Bardell, Inc.’s database, a referential integrity requirement
must ensure that the customer cannot be deleted as long as payment has not
been received for any outstanding invoices.
Slide Objective
To introduce the method for
identifying integrity
requirements within a
physical design.
Lead-in

Identifying integrity
requirements helps validate
your physical design and
also ensures valid data.

×