create table s (sno char(5), sname char(20), status decimal(3),
city char(15), primary key(sno));
create table p (pno char(6) primary key, pname char(20), color char(6),
weight decimal(3), city char(15));
create table sp (sno char(5), pno char(6), qty decimal(5),
primary key(sno,pno),
foreign key(sno) references s, foreign key(pno) references p);
Figure 1: A database schema denition in SQL
have the same entries in
both
of these columns. Referen-
tial integrity constraints indicate that each supplier number
(
sno
) appearing in table
sp
must appear in table
s
and that
each part number (
pno
) app earing in table
sp
must appear
in table
p
.
Software Testing
Testing is one of the most widely used means of validating
software. When testing a program, one executes the pro-
gram on selected inputs and checks that the resulting out-
puts agree with the specied values. Additional information
may also b e logged to help evaluate how thoroughly the soft-
ware has been tested. While no testing technique short of
exhaustive testing (testing on every p ossible input, whichis
almost always infeasible because of the numb er of possible
alternatives) can guarantee that a program is correct, test-
ing can often b e an eective practical means of discovering
software faults, as well as other system characteristics such
as performance under particular loads. A primary goal of
software testing research is the developmentof systematic
means of selecting test sets that are small enough to b e fea-
sible in practice, yet whichcover a wide variety of situations
the software could p otentially face.
The test generation technique described in this pap er is
loosely based on category-partition testing [16], which for-
malizes and partially automates a widely-used informal
specication-based testing technique. The tester identies
important categories of data (e.g. input parameters, envi-
ronment factors), provides sample values for each category,
and partitions each category into groups (called
choices
)
which might b e handled dierently by the application. A
tool then constructs test cases by combining elements of
dierent choices from the various categories. To keep the
numb er of test cases reasonable and to avoid generation of
impossible combinations (such as an unsorted arraywith0
elements), the tester can provide various constraints.
3. ISSUES IN TESTING DB APPLICA-
TIONS
In this section, we discuss several issues that arise in
testing database applications. We illustrate these issues
with the following simple hypothetical example, an appli-
cation program that a telephone company might use to pro-
cess customers' orders for new features (call-waiting, call-
forwarding, etc.).
Assume the database includes a customer-feature table, with
information ab out customers, including customer ID num-
ber, customer address, and features to which the customer
subscribes, and a billing table, with customer ID numbers
and information pertinent to issuing monthly bills, as well
as other tables. The application program's sp ecication is
as follows:
Input a customer's ID number and the name
of the telephone feature to which the customer
wishes to subscribe. If the ID number or the fea-
ture name is invalid, return code 0; otherwise, if
the customer lives in an area in which that fea-
ture is available, and that feature is not incom-
patible with any other feature to whichthecus-
tomer already subscribes, add the selected fea-
ture to the customer's customer-feature record,
update the billing table appropriately, and send
a notice to the provisioning department (which
will initiate the feature); return co de 1. If the
customer does not live in an area in whichthis
feature is available, return code 2; If the feature is
available in the customer's area, but it is incom-
patible with other features to which the customer
subscribes, return co de 3.
The role of the database state
A database application, like any other program, can be
viewed as computing a (partial) function from an input
space
I
to an output space
O
. Its sp ecication can be ex-
pressed as a function (or, more generally, a relation) from
I
to
O
. Thus, we can test a database application by select-
ing values from
I
, executing the application on them, and
checking whether the resulting values from
O
agree with
the sp ecication. However, unlike \traditional" programs
considered in most of the testing literature and by most
existing testing to ols, the input and output spaces havea
complicated structure, which makes selecting test cases and
checking results more diÆcult.
On the surface, it appears that the inputs to the program
are the customer ID and the feature name, while the output
is a numeric co de b etween 0 and 3. This suggests that gener-
ating test cases is a matter of nding various \interesting"
customer IDs and features, and that checking each result
involves examining a single integer. However, a moment's
reection reveals that the expected and actual results of exe-
cuting the application on a given (customer-ID, feature) pair
also depend on the state of the database before executing
the application. Similarly,knowledge of expected and actual
values of the database state after executing the application
are needed in order to determine whether the application
behaved correctly. For example, the intended b ehavior of
the program on a given (customer-ID, feature) pair dep ends
on whether the customer ID is valid, what features the cus-
148149