Thursday, August 6, 2015

Basic Database Interview Question & Answer

What we normally check for in the Database Testing? 
In Database Testing we need to check,
1) The field size validation
2) Check constraints.
3) Indexes are done or not (for performance related issues)
4) Stored procedures
5) The field size defined in the application is matching with that in the db.

What is Database testing? 
Database testing includes the following.
1) Data validity testing: For doing data validity testing you should be good in SQL queries.
2) Data Integrity testing: For data integrity testing you should know referential integrity and different constraints.
3) Performance related to database: For performance related things you should have idea about the table structure and design.
4) Testing of Procedure triggers and functions: For this a clear understanding of testing procedure triggers and functions is required.

Database testing is all about testing joins, views, imports and exports, testing the procedures, checking locks; indexing etc.

How can we do manual testing of database? Explain with an example 
It involves observing operations that are operated on front-end are effected on the back-end or not. The approach can be explained like:
While adding a record through the front-end, check back-end that addition of record is effected or not. It applies to delete, update,......etc.
For Example: Enter the employee record in database through the front-end and check manually if the record is added or not to the back-end.

What is data-driven test? 
Data driven test is used to test the multi-numbers of data in a data-table. With help of this we can easily replace the parameters at the same time from different locations e.g.: using .xls sheets.

What is data-driven test? 
Data driven test is used to test the multi-numbers of data in a data-table. With help of this we can easily replace the parameters at the same time from different locations e.g.: using .xls sheets.

While doing database testing, how do we know that a trigger is fired or not? 
It can be verified by querying the common audit log where we are able to see if the triggers is fired or not.

Is a "A fast database retrieval rate" a testable requirement? 
No. Since the requirement seems to be ambiguous. The SRS should clearly mention the performance or transaction requirements i.e. It should specify clearly like - Database retrieval rate of 5 microseconds.

How do you test whether a database in updated when information is entered in the front end? 
It depends upon the application interface.
1) If your application provides view functionality for the entered data, then you can verify that from front end only. This way Black- box test engineers verify the functionality most of the times.
2) If your application has only data entry from front end and there is no view from the front end, then you have to go to Database and run relevant SQL query. 

What steps does a tester take in testing Stored Procedures? 
First the tester should to go through the requirement, as to why the particular stored procedure is written for.

Then check whether all the required indexes, joins, updates, deletions are correct comparing with the tables mentioned in the Stored Procedure. And also he has to ensure whether the Stored Procedure follows the standard format like comments, updated by, etc.

Then check the procedure calling name, calling parameters, and expected Reponses for different sets of input parameters.

Then run the procedure yourself with database client programs like TOAD, or mysql, or Query Analyzer
Rerun the procedure with different parameters, and check results against expected values.



What are the pre-requisites for writing test cases for database testing? 
Following pre-requisites are necessary before writing the database test cases.
1) First of all we need to understand the related documentation.
2) Understand the functional requirement of the application thoroughly.
3) Then you 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 used and output parameters used for developing that requirement.
4) After knowing all these things you have to write the test case with different input values for checking all the paths of SP.

Write a query to find the second largest value in a given column of a table 
To find the second largest salary amount from employee table
select max(salary) from employees
where pin < (select max(salary) from employees)
Select Max(sal) from Emp where Sal < (select Max(sal) from Emp)

Now suppose i have 50 records of employee table. 
1) I want to find the person who is having 22nd highest salary. 
2) I want to delete a person with position number 39 with commission < 100 
3) Update record no 45
select emp_id,emp_name, sal from employee a where &n = (select count(distinct(salary)) from employee b where a.sal <=b.sal)
&n=22 ( U will be asked to enter the number and then enter for which record u want to retrieve)
a.sal <=b.sal (this can be used to retrieve max record)
a.sal >=b.sal( this can be used to retrieve min record)
select min(sal) from (select distinct sal from employee order by sal desc) where rownum

What are the test scenarios to test a database migrated from SQL Server 2005 to SQL Server 2008?
We need to check out what was all the enhancement the SQL Server 2008 has in it. We need to design our test case considering the following points.
1) Data type used
2) Length of the data field it should be same as it was in SQL 2005
3) All the jobs should be scheduled properly

No comments:

Post a Comment