Anda di halaman 1dari 17

Database Testing

Agenda
 What is Database Testing
 Database Testing Architecture
 Stages involved in Database Testing
 Fundamentals of Database Testing
 Components of the database
 Introduction to SQL
What is Database testing
 A database is a collection of files kept together within a computer
application that can be easily accessed and retrieved. A common database
software is MS Access.

 Databases at different servers may not be of same type, i.e. databases


may be heterogeneous. So many kinds of implementation and integration
errors may occur in large database systems which leads to Low
Performance, Inconsistency, Unreliability and Insecurity

 In order to obtain a database which satisfy ACID properties of DBMS,


we need to test it, so the term database testing came into picture

 Database Testing includes Testing for Data Integrity , Data Validity , Data
manipulation
ACID Properties
ACID (Atomicity, Consistency, Isolation, Durability) is a set of
properties that guarantee that the database transactions are processed
reliably.

Atomicity
 Atomicity requires that each transaction is "all or nothing": if one part
of the transaction fails, the entire transaction fails, and the database
state is left unchanged.

 An atomic system must guarantee atomicity in each and every


situation, including power failures, errors, and crashes.
ACID Properties
Example : Atomicity failure
 Assume that a transaction attempts to subtracts 100 from Account A
and adds 100 to Account B. This is a valid transaction, since the data
continue to satisfy the constraint after it has executed.

 However, assume that after removing 100 from A, the transaction is


unable to update Account B. If the database retained A's new value,
then atomicity property is violated.

 Atomicity requires that both parts of this transaction, or neither, be


complete.
ACID Properties
Consistency
 Data is in a consistent state when a transaction starts and when it ends.

 For example, in an application that transfers funds from one account to


another, the consistency property ensures that the total value of funds in
both the accounts is the same at the start and end of each transaction.

 All validation rules must be checked to ensure consistency.

 If the transaction removes 100 from A and added to B successfully, here


atomicity is achieved. However, a validation check will show that A + B =
90. That is not consistent according to the rules of the database.

 The entire transaction must be cancelled and the affected rows should be
rolled back to their pre-transaction state.
ACID Properties
Isolation
 Every transaction has a well-defined boundary, that is, it is isolated
from another transaction.
 Data modifications made by one transaction must be isolated from the
data modifications made by all other transactions.
 A transaction sees data in the state it was in before another
concurrent transaction modified it, or it sees the data after the
transaction has completed, but it doesn’t see an intermediate state

Example: Isolation failure


 To demonstrate isolation, we assume two transactions execute at the
same time, each attempting to modify the same data.
 One of the two must wait until the other completes in order to
maintain isolation.
ACID Properties
Consider two transactions.
T1 transfers 10 from A to B.
T2 transfers 20 from B to A. Combined, there are four actions:
subtract 10 from A
add 10 to B.
subtract 20 from B
add 20 to A.
If these operations are performed in order,
isolation is maintained, although T2 must wait. Consider what
happens, if T1 fails half-way through. The database eliminates T1's
effects, and T2 sees only valid data.
ACID Properties
Durability
 Data modifications that occur within a successful transaction are kept
permanently within the system regardless of what else occurs.
 A system crash or any other failure must not be allowed to lose the
results of a transaction or the contents of the database.
 Transaction logs are maintained to restore the database to its original
state before the failure.
 As each transaction is completed, a row is entered in the database
transaction log.
ACID Properties
Example : Durability failure
Assume that a transaction transfers 10 from A to B. It removes 10
from A. It then adds 10 to B. At this point, a "success" message is
sent to the user.
However, the changes are still queued in the disk buffer waiting
to be committed to the disk.
Power fails and the changes are lost. The user assumes (validly)
that the changes have been made.

Durability can be achieved by flushing the


transaction's log records to Non–Volatile Storage before
acknowledging commitment.
DB Testing Architecture

Front
End
User
Interface
Database

Backup DB
Fundamentals of Database Testing
 Applications are used by end users and they enter a group of raw data

 This data is later collated and used by management to arrive at


meaningful information

 Before we first understand the technical aspects of database, we must


understand the business data clearly (means you have to understand
the functional requirement of the application thoroughly

 Have to find out the back end tables used, joins used between the
tables, cursors used (if any), triggers used(if any), stored procedures
used (if any), input parameter’s used and output parameters used for
developing that requirement.

 Also identify the relationship between the data.


Components of the Database
 Database
Tables
 Views
 Stored Procedures & Functions
 Triggers
 Cursors
 Indexes
 Constraints
 Users (for database security)
 Sequences
Introduction to SQL
What is SQL?
 SQL stands for Structured Query Language

 SQL lets you access and manipulate databases

 SQL is an ANSI (American National Standards Institute)


standard
Introduction to SQL (contd…)
What Can SQL do?
 execute queries against a database
 retrieve data from a database
 insert records in a database
 update records in a database
 delete records from a database
 create new databases
 create new tables in a database
 can create stored procedures in a database
 create views in a database
 set permissions on tables, procedures, and views
Stages involved in Database Testing
 Object Level validations
 Schema level validations
 Constraints check
 Data validation
 Triggers(Insert/Update/Delete)
 Stored Procedures
 Indexes are done or not (for performance related issues)
Interview Questions
1) What is Database Testing
2) What are ACID Properties
3) What are the Components of a Database
4) What are different stages of validations we do in
Database Testing

Anda mungkin juga menyukai