Basic Database Testing Interview Questions with Answers
These database testing interview questions are frequently asked in manual testing, automation testing, and SQL interviews. They cover basic concepts like joins, keys, and constraints.
1. What is a Cross Join?
A Cross Join returns the Cartesian product of two tables. It combines every row from the first table with every row from the second table.
SELECT * FROM Employees CROSS JOIN Departments;
If Table A has 3 rows and Table B has 4 rows, the result will have 12 rows.
2. What is a Self Join?
A Self Join is a join in which a table is joined with itself. It is useful when data in the same table is related.
SELECT A.emp_name, B.emp_name AS manager_name
FROM Employees A
JOIN Employees B
ON A.manager_id = B.emp_id;
3. What is a Foreign Key?
A Foreign Key is a column that creates a relationship between two tables. It references the Primary Key of another table.
It helps maintain referential integrity in the database.
CREATE TABLE Orders (
order_id INT PRIMARY KEY,
customer_id INT,
FOREIGN KEY (customer_id) REFERENCES Customers(customer_id)
);
4. What is a Primary Key?
A Primary Key uniquely identifies each record in a table.
- Cannot contain NULL values
- Must be unique
- Only one primary key per table
5. What is the difference between Primary Key and Foreign Key?
| Primary Key | Foreign Key |
|---|---|
| Uniquely identifies a record | Creates relationship between tables |
| Cannot be NULL | Can be NULL |
| One per table | Multiple allowed |
6. What is the difference between INNER JOIN and LEFT JOIN?
INNER JOIN returns only matching records from both tables.
LEFT JOIN returns all records from the left table and matching records from the right table.
SELECT * FROM A
INNER JOIN B ON A.id = B.id;
SELECT * FROM A
LEFT JOIN B ON A.id = B.id;
7. What is Normalization?
Normalization is the process of organizing data to reduce redundancy and improve data integrity.
Common normal forms:
- 1NF – Atomic values
- 2NF – No partial dependency
- 3NF – No transitive dependency
8. What is Denormalization?
Denormalization is the process of combining tables to improve read performance.
It is used mainly in reporting and data warehouse systems.
9. What is a Unique Key?
A Unique Key ensures that all values in a column are unique.
- Allows one NULL value
- More than one unique key allowed per table
10. What is Database Testing?
Database Testing involves validating:
- Data accuracy
- Data integrity
- Stored procedures
- Triggers
- Data migration
Conclusion
These basic database testing interview questions help testers understand SQL concepts clearly and confidently face interviews. Practicing SQL queries along with theory gives you an added advantage.
Happy Learning & Happy Testing! 🚀
No comments:
Post a Comment