Vous êtes sur la page 1sur 7

Database Testing Interview Questions by Mr.

Kanaka Suresh Macherla

Q. What is Database testing? Database testing is the testing which involves testing the application for the accuracy of data that is entered by the user. This includes both storing the data and retrieving the data. Q. What are the things we test in database testing? The main things that have to be taken care in database testing are: 1. Data Integrity 2. Data Validity 3. Data Manipulation and updates 4. Check constraints 5. Database Indexing (for performance related checks) 6. Data Retrieval. Q. What is the query language used for database testing? SQL (Structured Query Language) is used for database testing. Q. What SQL statements have you used in Database Testing? 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. Q. How to test data loading in Data base testing? 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.

Q. What is way of writing test cases for database testing? To write test case for database its just like functional testing. 1.Objective:Write the objective that you would like to test. e.g. To check the shipment that is loaded thru xml is getting inserted for particular customer. 2.Write the method of input or action that you do. e.g. Load an xml with all data which can be added to a customer. 3.Expected :Input should be viewed in database. e.g. The shipment should be loaded successfully for that customer, also it should be seen in application.4.You can write such type of test cases for any functionality like update, delete etc. Q. Can we use SQL queries in QTP? If yes then how? In QTP using output database check point and database check point ,select SQL manual queries option and enter the "select" queries to retrieve data in the database and compare the expected and actual Q. Can we join 4 tables using SQL joins statements? Which type of join should be used? Write the query. We can join 4 table using equi join. We need to keep in mind that there should be 41, i.e. 3 join conditions. Q. What are the different stages involved in Database Testing? Verify the data in the database with respect to front-end transactions. Verify the constraints (primary key, foreign key, Null, Not null, check constraints etc) Verify the execution of procedures Verify the execution of triggers Verify the transactions (commit, rollback) Q. How to verify if a trigger is fired or not while doing Database testing? The trigger details can be verified by querying the common audit log. Q. Explain the procedure to write test cases for database testing? Below is the procedure to wrote test cases for database testing: 1. Understand the functional requirement of the application thoroughly. 2. Find out the components in the GUI/front-end which store/retrieve data from the backend database. 3. Find out what are the tables in the database to which the GUI connects to store/retrieve data. Find out the constraints of each table. Find out the joins if any. 4. Find out the triggers, cursors, stored procedure etc that have been used in these database tables.

5. Understand the business logic of the different features of the application. You have to write these test cases. Then start writing test cases based on these information that you collected in the previous steps. Q. What is join in database tables? How many types of joins are there? Explain each. Join is the SQL statement for combining two or more tables from a relational database using some common attributes between these tables. There are three basic types of joins. These are: Inner Join (or Equi join), Outer Join (Left and Right) and Self Join. An inner join is a join that selects only those records from both database tables that have matching values. Records with values in the joined field that do not appear in both of the database tables will be excluded from the query. One or more fields can serve as the join fields An outer join selects all of the records from one database table and only those records in the second table that have matching values in the joined field. In a left outer join, the selected records will include all of the records in the first database table. In a right outer join, the selected records will include all records of the second database table. One or more fields can serve as the join fields. A self join divides the same table into two duplicate tables and then combines these two duplicate tables to display the relative values of columns basing on one common criteria present on both the duplicate tables. Lets say there are two tables Employees and Orders. Employees: Employee_ID 01 02 03 04 Orders: Prod_ID 123 234 345 AC Refrigerator Product Printer 01 03 03 Employee_ID Tim Roth Goran Ivaniscivic Kevin Peterson Name Mark Jefferson

We can select data from two tables by referring to two tables, like this:

INNER JOIN: Who has ordered a product, and what did they order? SELECT Employees.Name, Orders.Product FROM Employees INNER JOIN Orders ON Employees.Employee_ID=Orders.Employee_ID The INNER JOIN returns all rows from both tables where there is a match. If there are rows in Employees that do not have matches in Orders, those rows will not be listed Result Name Mark Jefferson Goran Ivaniscivic Goran Ivaniscivic Product Printer AC Refrigerator

LEFT OUTER JOIN: List all employees, and their orders - if any. SELECT Employees.Name, Orders.Product FROM Employees LEFT JOIN Orders ON Employees.Employee_ID=Orders.Employee_ID The LEFT JOIN returns all the rows from the first table (Employees), even if there are no matches in the second table (Orders). If there are rows in Employees that do nop hate matahes hn Nrders, thmq` ropq also uihh `d hiqtdd* Reptlt Lam`Ppmdtgt Hapj Ffgberson Tim Roth Goran Ivaniscivic Goran Ivaniscivic Kevin Peterson AC Refrigerator Printer

RIGHT OUTER JOIN List all orders, and who has ordered - if any. SELECT Employees.Name, Orders.Product FROM Employees RIGHT JOIN Orders ON Employees.Employee_ID=Orders.Employee_ID The RIGHT JOIN returns all the rows from the second table (Orders), even if there are no matches in the first table (Employees). If there had been any rows in Orders that did not have matches in Employees, those rows also would have been listed. Result Name Mark Jefferson Goran Ivaniscivic Goran Ivaniscivic Example Who ordered a printer? SELECT Employees.Name FROM Employees INNER JOIN Orders ON Employees.Employee_ID=Orders.Employee_ID WHERE Orders.Product = 'Printer' Result Name Mark Jefferson Q. What steps should be followed to test Stored Procedures? While testing Stored Procedures, we are passing the Input parameters and easily getting the output fast compare to testing the through business logic in front end. In SQL server we can use the below statement: exec {procedure Name} input1,input2. We need to enter the input values and check if the output values are matching with the expected results. Product Printer AC Refrigerator

Q. Write a query to find the second highest salary in employees table. To find the second highest salary amount from employee table. select max(salary) from employees where salary < (select max(salary) from employees) Q. Write a query to find the third highest salary in employees table. To find the third highest salary amount from employee table. select max(salary) from employees where salary < (select max(salary) from employees where salary < (select max(salary) from employees)) Q. How to test a SQL Query in Winrunner without using Database Check Points? Follow the below steps: 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 mentioned3)disconnect the connection db_disconnect("query"); Q. What steps should be followed to test Stored Procedures? While testing Stored Procedures, we are passing the Input parameters and easily getting the output fast compare to testing the through business logic in front end. In SQL server we can use the below statement: exec {procedure Name} input1,input2. We need to enter the input values and check if the output values are matching with the expected results. Q. Write a query to find the second highest salary in employees table. To find the second highest salary amount from employee table. select max(salary) from employees where salary < (select max(salary) from employees)

Q. How do you test whether the database is updated immediately after information are added in the front end? Give me an example. First enter the data using the front of the application. Then go to the database and fire queries to retrieve data from the respective table and verify if the data retrieved reflects the data added using the front end. You can also use a tool to check this. There are many tools available on the internet such as TOAD, SQL NAVIGATOR etc. Use the tool to connect to the database and look into that particular table if the data you entered using the front-end has been updated in the backend table. Q. I have 100 records of employee table. I want to find the person who is having 63rd highest salary. Write the query to do this. select emp_id,emp_name, sal from employee a where &n = (select count(distinct(salary)) from employee b where a.sal <=b.sal) After pressing enter it will ask for the value of n runtime. Give 63 and press enter. This will give the result. Q. Is a "Fast data retrieval rate" a testable requirement? No. This is not a testable requirement because "Fast" does not have a value and hence it is meaningless. Instead the requirement should be say "10mbps data retrieval rate". In this case 10mbps is measurable and hence it is a testable requirement. Q. What is Data Driven testing? Is this a part of database testing? Data driven testing is a process in automation testing tools which pick a large amount of similar data from a data sheet and supplies the data to the automation tool so that testing can be done for all the data set. No, This is not a part of database testing as we are not testing any data integrity, data validation etc in this. We just need to add the values in a data sheet and then feed it to the automation tool and the tool checks if the application features work for all the values in that particular data set.

Vous aimerez peut-être aussi