Database Testing-Nice
Database Testing-Nice
Database testing nothing but testing the database .it can be tested manually or
automatically using tools.
a) Data validity testing: in validity testing we should known about SQL quires and how
to use it.
b) Data integrity testing: in integrity testing we should known about integrity
performance of database.
c) Data manipulation and performance testing: in that testing we have to know about
data design table and data implementation.
d) Data triggering and functionality testing: in that testing we have to known about
data triggering concepts and functionality of add, delete, update and modify concepts in
database.
3).what are the SQL statement have you used in database testing?
2. Create table (table name) murugan (id int, name varchar (10), address varchar
c) Testing the applications vs. testing the DBMS (Database Management System)
· Database size ~15 terabytes (this is total for all database)
Outer join:
Left outer join display all the records from 1st table even
rignt outer join display all the record from the 2nd table
TRUNCATE
1. It is DDL.
2. Speed is faster
4. Roll back is not possible.it will delete the structure of the table.
DELETE
1. It is not a DDL
2. Speed is slow
4. We can rollback.
Database Testing
Why test the database?
The database persists data that your application (and organization) depends on. The
data thus persisted is most often of mission-critical nature and a key asset for the
organization. Also, many of today's data-enabled applications implement a fair amount
of their functionality and business logic in the database itself. For an enterprise class
application, the data in the database would be accessed and updated
(insert/modify/delete) simultaneously by a large number of users (think thousands to
millions depending on the scale of your application's usage).
The above statements highlight a few areas where database testing is needed. One, to
validate the quality of data being persisted. Two, if we plan to test the application code,
it is imperative that we also test the code in the database which implements the
business functionality and three, we should plan for non-functional database testing to
support the usage of the database in a real-world deployment scenario.
Testing the quality of the data may be approached in three ways - data validity testing,
data integrity testing and data format testing.
a) Data validity testing - is done to verify the validity of the data that is stored in the
database. When data is entered via the front end application, check if the data is
correctly updated in the back-end database. Apart from the positive checks, look for
other behavior such as data truncation, verify how null/empty field values are handled,
verify how special characters or code snippets are handled in the database. Check that
the right columns in the right tables are being updated. Data validity testing normally
involves use of SQL queries to validate the data.
c) Data format testing - involves verifying the size and type of fields that store data in
the database with those that accept data in the application. This can help identify
mismatches between the type or size of data that is accepted by the front-end vs what
the database can store. Example: the application may accept text data but try to store in
a numeric or date field in the database or else the application may accept data of greater
length than the max length for the corresponding field in the database. This may not
throw errors during routine application usage but may store incorrect or erroneous data
in the database which could have repercussions elsewhere or at a later stage
2. Database code testing - involves testing the code in the database which implements
business logic and functionality. Examples of such code include, stored procedures,
views (read-only/updateable) and event driven items such as triggers. Each stored
procedure is tested distinctly for its functionality. When a stored procedure implements
multiple functions, each function is tested separately. Stored procedure testing would
look at testing the arguments that are passed to the stored procedure in terms of the
number, type and order of arguments plus the return value. Both positive and negative
tests can be devised to test stored procedures. Views both read only and updateable are
tested either as stored queries that dynamically retrieve values from the database
and/or allow updates to the database. In case where updates are allowed, data validity
and integrity testing is done. Event driven items are tested by verifying the events that
could trigger actions and the actions themselves for functional correctness
1. Check if correct data is getting saved in database upon successful page submit
2. Check values for columns which are not accepting null values
3. Check for data integrity. Data should be stored in single or multiple tables based on
design
4. Index names should be given as per the standards e.g. IND__
5. Tables should have primary key column
6. Table columns should have description information available (except for audit
columns like created date, created by etc.)
7. For every database add/update operation log should be added
8. Required table indexes should be created
9. Check if data is committed to database only when the operation is successfully
completed
10. Data should be rolled back in case of failed transactions
11. Database name should be given as per the application type i.e. test, UAT, sandbox,
live (though this is not a standard it is helpful for database maintenance)
12. Database logical names should be given according to database name (again this is
not standard but helpful for DB maintenance)
13. Stored procedures should not be named with prefix “sp_”
14. Check is values for table audit columns (like createddate, createdby, updatedate,
updatedby, isdeleted, deleteddate, deletedby etc.) are populated properly
15. Check if input data is not truncated while saving. Field length shown to user on page
and in database schema should be same
16. Check numeric fields with minimum, maximum, and float values
17. Check numeric fields with negative values (for both acceptance and non-
acceptance)
18. Check if radio button and dropdown list options are saved correctly in database
19. Check if database fields are designed with correct data type and data length
20. Check if all table constraints like Primary key, Foreign key etc. are implemented
correctly
21. Test stored procedures and triggers with sample input data
22. Input field leading and trailing spaces should be truncated before committing data
to database
23. Null values should not be allowed for Primary key column
Keep following points in mind when doing database testing. hope this will helpfull.
Field size validation
Check constraints
Indexes are done or not (for performance related issues)
Store procedure
Field size defined in the application is matching with that in database
Events like insert, update, delete
Data integrity, data validity and data manipulation and update
Field Validations
1. Is ‘Allow Null’ condition removed at database level for mandatory fields on UI
2. Is ‘Null’ as value not allowed in database
3. Is Field not mandatory while allowing NULL values on that field
4. Is the Field length specified on UI same as field length specified in table to store same
element from UI into database.
5. Is the length of each field of sufficient size
6. Is the Data type of each field is as per specifications
7. Does all similar fields have same names across tables
8. Is there any computed field in the Database
Check Constraints
1. Is required Primary key constraints are created on the Tables
2. Is required Foreign key constraints are created on the Tables
3. Are valid references are done for foreign key
4. Is Data type of Primary key and the corresponding foreign key same in two tables
5. Does Primary key’s ‘Allow Null’ condition not allowed
6. Does Foreign key contains only not NULL values
Indexes
1. Are required Clustered indexes created on the tables
2. Are required Non Clustered indexes created on the tables
Stored Procedures/ Functions
1. Is proper coding conventions followed
2. Is proper handling done for exceptions
3. Are all conditions/loops covered by input data
4. Does TRIM is applied when data is fetched from Database
5. Does executing the Stored Procedure manually gives the correct result
6. Does executing the Stored Procedure manually updates the table fields as expected
7. Does execution of the Stored Procedure fires the required triggers
8. Are all the Stored Procedures/Functions used by the application (i.e. no unused stored
procedures present)
9. Does Stored procedures have ‘Allow Null’ condition checked at data base level
10. Are all the Stored Procedures and Functions successfully executed when Database is
blank
Data Integrity
1. Is the complete data in the database is stored in tables
2. Is the data well logically organized
3. Is the data stored in tables is correct
4. Is there any unnecessary data present
5. Is the data present in the correct table
6. Is the data present in correct field within the table
7. Is the data stored correct with respect to Front End updated data
8. Is LTRIM and RTRIM performed on data before inserting data into database
An1:
Data driven test is used to test the multinumbers of data in a data-table, using this we
can easy to replace the paramerers in the same time from deferent locations.
e.g: using .xsl sheets.
An2:
Re-execution of our test with different input values is called Re-testing. In validate our
Project calculations, test engineer follows retesting manner through automation tool.Re-
testing is also called DataDriven Test.There are 4 types of datadriven tests.
1) Dynamic Input submissiion ( key driven test) : Sometines a test engineer conducts
retesting with different input values to validate the calculation through
dynamic submission.For this input submission, test engineer use this function in TSL
scriipt– create_input_dialog (“label”);
2) Data Driven Files Through FLAT FILES ( .txt,.doc) : Sometimes testengineer conducts
re-testing depends on flat file contents. He collect these files from Old Version databases
or from customer side.
3)Data Driven Tests From FRONTEND GREAVES : Some times a test engineer create
automation scripts depends on frontend objects values such as (a) list (b) menu (c)
table (d) data window (5) ocx etc.,
4)Data Driven Tests From EXCEL SHEET : sometimes a testengineer follows this type of
data driven test to execute their script for multiple inputs. These multiple inputs consists
in excel sheet columns. We have to collect this testdata from backend tables .
It can be verified by querying the common audit log where we can able to see the
triggers fired.
Before testing Data Base Procedures and Triggers, Tester should know that what is the
Input and out put of the procedures/Triggers, Then execute Procedures and Triggers,
if you get answer that Test Case will be pass other wise fail.
These requirements should get from DEVELOPER
8. How to test a DTS package created for data insert update and delete? What should be
considered in the above case while testing it?What conditions are to be checked if the
data is inserted, updated or deleted using a text files?
Data Integrity checks should be performed. IF the database schema is 3rd normal form,
then that should be maintained. Check to see if any of the constraints have thrown an
error. The most important command will have to be the DELETE command. That is where
things can go really wrong.
Most of all, maintain a backup of the previous database.
By writing scripting procedure in the TCL we can connect to the database and we can
test data base and queries.
The exact proccess should be:
1)connect to the database
db_connect(“query1″,DRIVER={drivername};SERVER=server_name;
UID=uidname;PWD=password;DBQ=database_name “);
2)Execute the query
db_excecute_query(“query1″,”write query u want to execute”);
-Condition to be mentioned-
10. How do you test whether a database in updated when information is entered in the
front end?
1. If your application provides view functionality for the entered data, then you can
verify that from front end only. Most of the time Black box test engineers verify the
functionality in this way.
2. If your application has only data entry from front end and there is no view from front
end, then you have to go to Database and run relevent SQL query.
11. How do you test whether the database is updated as and when an information are
added in the front end?Give me an example?
verify field level data in the database with respect to frontend transactions
verify the constraint (primary key,forien key ….)
verify the performance of the procedures
verify the triggrs (execution of triggers)
verify the transactions (begin,commit,rollback)
in QTP
using output databse check point and database check point ,
select SQL manual queries option
and enter the “select” queris to retrive data in the database and compare the expected
and actual
An1:
Database testing is all about testing joins, views, imports and exports , testing the
procedures, checking locks, indexing etc. Its not about testing the data in the database.
Usually database testing is performed by DBA.
An2:
Database testing involves some in depth knowledge of the given application and requires
more defined plan of approach to test the data.
Key issues include:
1) Data Integrity
2) Data Validity
3) Data Manipulation and updates
Tester must be aware of the database design concepts and implementation rules.
An3:
Data bas testing basically include the following.
1)Data validity testing.
2)Data Integritity testing
3)Performance related to data base.
4)Testing of Procedure,triggers and functions.
for doing data validity testing you should be good in SQL queries
For data integrity testing you should know about referintial integrity and different
constraint.
For performance related things you should have idea about the table structure and
design.
for testing Procedure triggers and functions you should be able to understand the same.
The most important statement for database testing is the SELECT statement, which
returns data rows from one or multiple tables that satisfies a given set of criteria.
You may need to use other DML (Data Manipulation Language) statements like INSERT,
UPDATE and DELTE to manage your test data.
You may also need to use DDL (Data Definition Language) statements like CREATE
TABLE, ALTER TABLE, and DROP TABLE to manage your test tables.
You may also need to some other commands to view table structures, column
definitions, indexes, constraints and store procedures.
You have to do the following things while you are involving in Data Load testing.
1. You have know about source data (table(s), columns, datatypes and Contraints)
2. You have to know about Target data (table(s), columns, datatypes and Contraints)
3. You have to check the compatibility of Source and Target.
4. You have to Open corresponding DTS package in SQL Enterprise Manager and run the
DTS package (If you are using SQL Server).
5. Then you should compare the column’s data of Source and Target.
6. You have to check the number to rows of Source and Target.
7. Then you have to update the data in Source and see the change is reflecting in Target
or not.
8. You have to check about junk character and NULLs.
An1:
You have to do the following for writing the database testcases.
1. First of all you have to understand the functional requirement of the application
throughly.
2. Then you have to find out the back end tables used, joined used between the tables,
cursors used (if any), tiggers used(if any), stored procedures used (if any), input
parmeter used and output parameters used for developing that requirement.
3. After knowing all these things you have to write the testcase with different input
values for checking all the paths of SP.
One thing writing testcases for backend testing not like functinal testing. You have to use
white box testing techniques.
An2:
To write testcase for database its just like functional testing.
1.Objective: Write the objective that you would like to test. eg: To check the shipment
that i load thru xml is getting inserted for perticular customer.
2.Write the method of input or action that you do. eg: Load an xml with all data which
can be added to a customer.
3.Expected :Input should be viewd in database. eg: The shipment should be loaded
sucessfully for that customer,also it should be seen in application.4.You can write ssuch
type of testcases for any functionality like update,delete etc.
An3:
At first we need to go through the documents provided.
Need to know what tables, stored procedures are mentioned in the doc.
Then test the functionality of the application.
Simultaneously, start writing the DB testcases.. with the queries you have used at the
backend while testing, the tables and stored procedures you have used in order to get
the desired results. Trigers that were fired. Based on the stored procedure we can know
the functionality for a specific peice of the application. So that we can write queries
related to that. From that we make DB testcases also.
1. Data integrity
The complete data belonging to each entity should be stored in the database. Depending
on the database design, the data may be present in a single table or multiple related
tables. Parent-child relationships should exist in the data. There should not be any
missing data.
The data should be present in the correct table and correct field within the table.
3. Correctness and completeness of data migration (in case some or all the original data
has come from another source)
5. Database performance (query execution times, throughput etc.) and locking problems
You may identify the main queries (or procedures) that are used in the application and
time them with sample data. Locking problems may become apparent when multiple
inserts/ updates are being made
to the same entity simultaneously.
6. Data security
You may check if any data that should be encrypted e.g. passwords, credit card numbers
is in plain text or not. The database should not have the default passwords. Even
application accounts should have passwords that are complex and not easily guessed.
1. Database fields (if they meet the specifications e.g. width, data type etc. as given in
the design documentation/ data dictionary etc.)
2. Normalization level