Skip to content
From Past interviews
- How to connect to SQL Server using JDBC in Java? (your question)
- Write Java code for JDBC connection with a SELECT statement. (your question)
- Can we automate comparison of 30+ DB columns across multiple tables? (your question)
- How to validate test cases involving DB queries in automation? (your question)
- How to fetch data from DB and compare with UI in Selenium tests? (your question)
- How do you validate CDR (Call Detail Records) from the DB in telecom testing? (your question)
- How do you handle DB validation when writing automation scripts in Java/Python? (your question)
- Why is database testing important in test automation frameworks? (your question)
- How to write SQL queries inside a Java Selenium test for validation? (your question)
- How do you check for duplicate records in DB using SQL? (your question)
Database Basics (0–2 Years)
- What is a primary key?
- What is a foreign key?
- What is the difference between INNER JOIN, LEFT JOIN, and RIGHT JOIN?
- What is a unique key vs. primary key?
- What is normalization? Explain different normal forms.
- What is denormalization?
- What is the difference between clustered and non-clustered indexes?
- Write a query to fetch the second highest salary from an employee table.
- Write a query to count duplicates in a column.
- Write a query to get employees who don’t have a manager.
- Write a query to fetch only distinct records.
- What is a view in SQL?
- What is a stored procedure vs. a function?
- What is a trigger in SQL?
- How do you find NULL values in a column?
Intermediate Level (3–6 Years)
- Explain transaction properties (ACID).
- What is indexing? When would you use it?
- What is a deadlock in DB? How do you resolve it?
- How do you optimize a slow query?
- What are CTEs (Common Table Expressions)? Give an example.
- What is the difference between RANK(), ROW_NUMBER(), and DENSE_RANK()?
- Write a query to get top 5 employees with the highest salary from each department.
- Write a query to join 3 tables.
- Write a query to transpose rows into columns.
- What are aggregate functions in SQL?
- What are window functions?
- How do you test a stored procedure?
- How do you test triggers in a database?
- How do you check DB constraints are working as expected?
- How do you validate DB changes after an application update?
Advanced (7–10 Years)
- Difference between OLTP and OLAP databases.
- Explain database partitioning and sharding.
- What is replication in databases?
- What are materialized views?
- Explain CAP theorem.
- How do you design a database for scalability?
- What is query execution plan? How do you use it?
- What is database indexing strategy for high-traffic apps?
- How do you handle data migration testing between DB versions?
- How do you ensure data integrity in distributed systems?
- What is database connection pooling?
- How do you test DB performance in automation?
- How do you automate DB schema validation across environments?
- How do you ensure DB rollback works correctly during failures?
- Explain database caching strategies.
Database + Automation (Python/Java)
- How do you connect to a database using Python?
- Write Python code to fetch records from a DB table.
- How do you validate DB values against API response in Python automation?
- How do you use PyODBC or SQLAlchemy for DB automation?
- Write a Java JDBC code snippet to run a SELECT query. (your question)
- How do you handle DB credentials securely in automation scripts?
- How do you automate DB verification in Selenium test cases?
- How do you read DB data and compare with Excel test data in Python?
- How do you parameterize DB queries in automation frameworks?
- How do you integrate DB validations into CI/CD pipelines?
Real-Time Scenarios
- How would you test data consistency between UI and DB?
- How do you validate DB records created after a user action (e.g., placing order in Amazon)?
- How do you test rollback when a transaction fails?
- How do you verify data migration after a DB upgrade?
- How do you check DB synchronization across environments (Dev/QA/Prod)?
- How do you test data archiving in DB?
- How do you verify stored procedure output using automation?
- How do you detect and handle DB deadlocks in automation?
- How do you compare millions of records between two DBs?
- How do you automate validation of telecom CDRs stored in DB?