Sei sulla pagina 1di 46

Data Base Testing

Objectives

What is DB Testing ?

Testing at the Data Access Layer

Scope of DB Testing

Need for Testing DB Objects

Common rob!ems that affect the App!ication

Testing App!ication "s DB Testing

contd##
Objectives

Sho$!d Testers %no& Databases

Testing the erformance of the Database

Data 'ntegrity

(nderstanding )*+ ,ode!

'dentifying defects in )*+ Diagrams

Case St$dies on )*+ Diagrams

Writing Test Cases to Test Databases

Database Testing inc!$des Testing for


Data 'ntegrity - Data "a!idity - Data
manip$!ation#

Database Objects can be tab!es- vie&s -


stored proced$res - inde.es etc

Time ta/en for +etrieva! of +ecords from


the Database

Time for 0$ery ).ec$tion


What is Database Testing

C!ient Layer 1 's responsib!e for the


presentation of data- receiving $ser events and
contro!!ing the $ser interface#

App!ication Layer 2 B$siness2objects that


imp!ement the b$siness r$!es 3!ive3 here- and
are avai!ab!e to the c!ient2tier

Data Layer 4 This tier is responsib!e for data


storage
Layers in a App!ication

Sing!e Tier Architect$re

C!ient 5 B$siness Logic 5 Data Storage are a!!


&rapped together

6 Tier Architect$re

B$siness Logic and Data Storage are together and


the C!ient is a separate !ayer

7 or the N tier Architect$re

C!ient - the B$siness Logic and the Datastorage are


/ept separate!y
App!ication Types
Client Layer
Business Logic
Layer
Database Layer
7 or N Tier Architect$re

Testing the 8ront )nd * 9(' * C!ient Layer

Testing the B$siness Logic Layer

Testing the Database

+evie&ing )*+ Diagrams

+evie&ing the Database Designs

+evie&ing the Tab!es- vie&s - stored


proced$res etc
Testing Sho$!d 'nc!$de

Data is stored in the tab!es

Stored roced$res &i!! hand!e the 'nsertion -


de!etion 5 (pdation 5 +etrieva! of 'nformation
from the Database

No Testing*'mproper testing &i!! res$!t in


missing critica! app!ication f$nctiona!ity
Why Test Database Objects

Traditiona!!y a!! the data testing is done at


the 9(' Leve!

Corr$ption of data can occ$r at any !ayer

We m$st present verification of


app!ication correctness as data trave!s
thro$gh the system#
9(' "s Database Testing

Data corruption

Occ$rs d$e to poor design

Redundant data

:idden d$p!icate records ;same c$stomer added


t&ice &ith different primary /eys<#

Inconsistent data

Data records added to the same database thro$gh m$!tip!e


app!ications can add inconsistent data#

Redundant validation

Validating business rules on the db, as well as the client,


can cause conflicts if

theyre not well-coordinated


rob!ems if Database Testing is
'gnored

'nade=$ate /no&!edge of +e!ationa! db design


f$ndamenta!s !eads to !ogic errors and very
common b$gs in systems

Basic normalization principles can and


should be tested but isnt -- because most
testers have no idea what that is

)ffective DB testers sho$!d be ab!e to $ncover


design prob!ems =$ic/!y
Why Sho$!d Test rofessiona! /no&
DB,S

Data 'ntegrity )ns$res the Consistency and


correctness of Data stored in a Database

,aintenance of data va!$es according to data


mode! and data type# 8or e.amp!e- to maintain
integrity- n$meric co!$mns &i!! not accept
a!phabetic data#
Data 'ntegrity
>
't?s the process of efficient!y
organi@ing data in a database#
>
The database comm$nity has deve!oped a series
of g$ide!ines for ens$ring that databases are
norma!i@ed# These are referred to as norma!
forms

Norma!isation
9oa!s of Norma!isation

There are t&o goa!s of the norma!i@ation


process

liminate redundant data

!toring Related Data in a "able


>
8irst Norma! 8orm
>
Second Norma! 8orm
>
Third Norma! 8orm
>
Boyce Codd Norma! 8orm

Norma!isation
'n the 8irst Norma! 8orm

)very Ce!! sho$!d contain a sing!e va!$e#

)!iminate red$ndant data ;for e.amp!e-


storing the same data in more than one
tab!e<

Create separate tab!es for each gro$p of


re!ated data and identify each ro& &ith a
$ni=$e co!$mn ;the primary /ey<#
Norma!i@ation
Norma!i@ation
)mp Code Dept rojCode :o$rs
)ABA Systems A- 6 -
7
A6-AC-AD
)AB6 8inance 6-7 AC-AD
'n the Second Norma! 8orm

,eet a!! the re=$irements of the first norma!


form#

And )very attrib$te in the ro& is f$nctiona!!y


dependent $pon the &ho!e /ey and not part
of the /ey
Norma!isation
8$nctiona! Dependany

9iven a tab!e +- Attrib$te A is f$nctiona!!y


dependant on attrib$te B if each va!$e of
A is associated precise!y &ith one va!$e of
B

)g# 'n the )mp!oyee Tab!e against every


)mpCode there &i!! on!y one Name so
Name is f$nctiona!!y dependant on
)mpCode
Norma!isation
)Code rojCode Dept :o$rs
)ABA 6E Systems FB
)7BG 6E 8inance AB
)GBH GA Admin ABA
)ABA GA Systems ABA
)ABA 6B Systems DB
Norma!i@ation

The Above Tab!e is in the 8irst Norma!


8orm#

The Above tab!e &i!! !ead to the fo!!o&ing


prob!ems 4

'nsertion 1 dept of a partic$!ar emp!oyee


cannot be inserted $nti!! the emp!oyee is
assigned a project
Norma!i@ation

(pdation 4'f an emp!oyee is transferred


from one department to another the
changes have to be made n n$mber of
times in the tab!e

De!etion 4 When the roject is over and


the record de!eted &e &i!! !oose
information abo$t the department for that
emp!oyee
Norma!isation

% I )code J rojCode

The above tab!e is in the 8irst Norma! 8orm &e


need to chec/ if its in 6
nd
Norma! 8orm

:o$rs is not f$nctiona!!y dependent on )code#

:o$rs is not f$nctiona!!y dependent on


rojCode

:o$rs is f$nctiona!!y dependent on


)codeJrojCode
Norma!isation

Dept is f$nctiona!!y dependent on )code#

Dept is not 8$nctiona!!y dependent on rojCode

Dept is f$nctiona!!y dependent on part of the


/ey ;)codeJrojCode<

Therefore tab!e is not in 6 N 8

Therefore !ace Dept a!ong &ith )code in a


separate tab!e
Norma!isation
)code Dept
)ABA Systems
)7BG Sa!es
)GBH Admin
EMPLOYEEDEPT
Norma!isation
PROJECT
)code rojCode :o$rs
)ABA 6E FB
)ABA GA ABA
)ABA 6B DB
)7BG 6E AB
'n the Third Norma! 8orm

,eet a!! the re=$irements of the second


norma! form#

+emove co!$mns that are not dependent


$pon the primary /ey#

'n other &ords a re!ation is said to be in 7N8


&hen every non /ey attrib$te is f$nctiona!!y
dependent on!y on the rimary %ey
Norma!isation
Norma!i@ation
)code Dept Dept:ead
)ABA Systems )FBA
)7BG 8inance )FBD
)CB6 Sa!es )FBD
)GBH Admin )FBH
)DBE 8inance )FBF
)DBH 8inance )FBF

The rimary %ey is )code

Dept is f$nctiona!!y dependent on )code

Dept:ead is f$nctiona!!y dependent on the


primary %ey )code#

A!! attrib$tes are f$nctiona!!y dependent on


the &ho!e /ey )code Therefore Tab!e is in
6N8

B$t Dept:ead is f$nctiona!!y dependent on


Dept #
Norma!i@ation

The rimary %ey is )code

Dept is f$nctiona!!y dependent on )code

Dept:ead is f$nctiona!!y dependent on the


primary %ey )code#

A!! attrib$tes are f$nctiona!!y dependent on


the &ho!e /ey )code Therefore Tab!e is in
6N8

B$t Dept:ead is f$nctiona!!y dependent on


Dept #
Norma!i@ation
The tab!e is not in the 7 N8 beca$se as per the
third Norma! 8orm every attrib$te sho$!d be
f$nctiona!!y dependent on!y on the rimary
%ey#
'dentify and remove the attrib$tes that are not
f$nctiona!!y dependent on the primary /ey#
!ace them in a different tab!e
Norma!i@ation
Norma!i@ation
)code Dept
)ABA Systems
)7BG 8inance
)CB6 Sa!es
)GBH Admin
)DBE 8inance
Employee
Norma!i@ation
Dept Dept:ead
Systems )FBA
Sa!es )FBD
Admin )FBH
8inance )FBF
Department
Denorma!i@ation is the process of
attempting to optimi@e the performance
of a database by adding red$ndant data
Denorma!isation

"a!idate the tab!e naming conventions

"a!idate the co!$mn naming conventions

To chec/ if the correct datatype is se!ected


for a co!$mn

To chec/ the consistency in datatypes for


co!$mns common across tab!es

To ens$re the $sage of correct fie!d &idth


What do &e Test at the DB Leve!

To ens$re consistency in fie!d &idth for


co!$mns common across tab!es

).istence of a primary /ey on a tab!e

).istence of a foreign /ey on a tab!e

"a!idity of chec/ constraints

"a!idity of defa$!t constraints

Chec/ for presence of inde.es on a co!$mn


What do &e Test at the DB Leve!

Chec/ for (ni=$e inde.es

).istence of non2c!$stered inde.es

).istence of c!$stered inde.es

Note the time of e.ec$tion of =$eries

Note the time of compi!ation of =$eries


What do &e Test at the DB Leve!

)va!$ate the =$ery e.ec$tion p!an

Note the time of e.ec$tion of stored


proced$res

Note the time of compi!ation of stored


proced$res

)va!$ate the =$ery e.ec$tion p!an

Denorma!i@e the tab!es

Norma!i@e the tab!es


What do &e Test at the DB Leve!
#rite Review $ases for the following
"able !tructures %$hec& for "able
'aming $onventions, Data"ype, (ield
!ize , )eys ,$onstraints*
Case St$dy
Data 8actory 4 0$est Soft&are
Data generator too! and data manager for
database testing
S0L T$ner 4 )mbaradero
)ases the comp!e.ity of &riting high2
performance S0L code by providing b$i!t2in
he!p for &riting syntactica!!y correct S0L-
and by assisting in every aspect of comp!e.
t$ning efforts#
Database Test Too!s
Datatect 4 Banner Soft&are
9enerate a variety of rea!istic test data to
+DB,S inc!$ding Orac!e- Sybase- S0L
Server- and 'nformi.
DB Stress 4 DT,
(ti!ity for stress testing the server parts of
information systems and app!ications- as
&e!! as DB,Ss and servers themse!ves#
Database Test Too!s
Datatect 4 Banner Soft&are
9enerate a variety of rea!istic test data to
+DB,S inc!$ding Orac!e- Sybase- S0L
Server- and 'nformi.
DB Stress 4 DT,
(ti!ity for stress testing the server parts of
information systems and app!ications- as
&e!! as DB,Ss and servers themse!ves#
Database Test Too!s
1
Database +pensource "est !uite
1
The Database Openso$rce Test S$ite
;DOTS< is a set of test cases designed for
the p$rpose of stress2testing database
server systems in order to meas$re
database server performance and re!iabi!ity#
Database Test Too!s
1
DB,onster
1
DB,onster is an app!ication to generate
random data for testing S0L database
driven app!ications $nder heavy !oad#
Database Test Too!s

Potrebbero piacerti anche