Database Testing Concept

What is Database Testing:
Database testing is a process of working with data stored in database. Data is stored in tables which is considered as an object in database. Database may have other objects like Views, functions, stored procedures etc. Now-a-days, the Applications are becoming more complex with new technologies and platforms. In order to ensure the quality and security of data and validate the data effectively, we need to learn database testing.

Database testing mainly includes the following:
-> Database Objects (Table, Views, Stored Procedures)
-> Data Accuracy & Validity (Field size validation)
-> Data Integrity (Check constraints, insert, delete, update)
-> Data Transaction Consistency and Concurrency (States & Locks)
-> Data Migration (Import, Export)
-> Performance related to database (Indices, number of triggers and procedures)
-> Security related to database – Data Accessing ( unauthorized access)

How to Test Database?
The general test process for Database testing is very similar to any other application. It requires the tester to expertise in checking tables, writing queries and procedures. Testing can be performed in web application or desktop and database can be used in the application like SQL or Oracle. Below are some of the points on how to test database.
-> List all database specific requirements
-> Create test cases/scenarios for each requirement
-> Figure out the tables used for the application and try to write all queries for the database tables to execute
-> Test all the tables carefully for the data added/updated/deleted
-> If database is more complex due to business logic, then tester can get the queries from developer to test the appropriate functionality
-> Validate data according to the expected results
-> Report the findings to the corresponding stakeholders

Why should we test a database ?
Below, are some reasons why database records need to be validated

1) Data Mapping: In the software applications, data often travels back and forth from the User Interface to the backend database and vice versa. So, we need to check whether the fields in the UI/Front end forms are mapped correctly with the corresponding DB table.  Generally, this mapping information is defined in the requirements document itself. Whenever a certain action is performed in the front end of an application, a corresponding action(Create, Retrieve, Update and delete) gets invoked at the back end. A tester needs to check if the right action is invoked and the invoked action is successful or not.

2) ACID properties validation:  ACID property refers to atomicity, consistency, isolation and durability. Every transaction in DB has to adhere to these four properties.
Atomicity: means the ability of the database to make sure that a transaction either fails or passes. Even if a single part of transaction fails, then it means the whole transaction has failed. This is called the ‘All-or nothing’ rule.
Consistency: It ensures that the database remains in a consistent state before the start of the transaction and after the transaction is over (whether successful or not). A transaction will always result in a valid state of the DB
Isolation: It ensures that if a transaction is going on, then any other operations cannot access or see the data in an intermediate state.If there are multiple transactions and they all are executed at once, the result/state of the DB should be the same as if they were executed one after the other.
Durability: Durability ensures that once a transaction is done and committed, it will persist, and not be undone. It should survive the  system failure, power loss or any crash.

Leave a comment