30 SQL, RDBMS and Database Questions from Beginner to Advanced Level
Database knowledge is one of the most important skills for backend developers. Whether you work with Oracle, MySQL, PostgreSQL, SQL Server, or cloud databases, understanding SQL and database concepts is critical.
This assessment evaluates:
✅ SQL Fundamentals
✅ Joins
✅ Group By and Having
✅ Primary and Foreign Keys
✅ Indexes
✅ Normalization
✅ Transactions
✅ ACID Properties
✅ Oracle and MySQL Concepts
✅ Query Output Prediction
Sample Tables
EMPLOYEE
| EMP_ID | NAME | DEPT_ID | SALARY |
|---|---|---|---|
| 1 | John | 10 | 5000 |
| 2 | Mary | 20 | 6000 |
| 3 | Steve | 10 | 7000 |
| 4 | David | 30 | 4000 |
DEPARTMENT
| DEPT_ID | DEPT_NAME |
|---|---|
| 10 | IT |
| 20 | HR |
| 30 | Finance |
SET 1 – SQL Fundamentals
Q1. Which SQL statement retrieves data?
A. INSERT
B. UPDATE
C. SELECT
D. DELETE
Q2. What is the output?
SELECT COUNT(*)
FROM EMPLOYEE;
A. 3
B. 4
C. 5
D. NULL
Q3.
SELECT MAX(SALARY)
FROM EMPLOYEE;
A. 4000
B. 5000
C. 6000
D. 7000
Q4.
SELECT NAME
FROM EMPLOYEE
WHERE SALARY > 5000;
How many rows are returned?
A. 1
B. 2
C. 3
D. 4
Q5.
SELECT DISTINCT DEPT_ID
FROM EMPLOYEE;
A. 2 rows
B. 3 rows
C. 4 rows
D. 1 row
Q6. Which constraint uniquely identifies a row?
A. Foreign Key
B. Unique Key
C. Primary Key
D. Check
Q7. Which keyword sorts data?
A. GROUP BY
B. ORDER BY
C. SORT
D. ARRANGE
Q8. What does NULL represent?
A. Zero
B. Empty String
C. Unknown value
D. Space
Q9. Which SQL clause filters grouped data?
A. WHERE
B. HAVING
C. GROUP BY
D. ORDER BY
Q10. Which database is open source?
A. Oracle
B. DB2
C. MySQL
D. SQL Server
Answers – SET 1
| Q | Answer | Explanation |
|---|---|---|
| 1 | C | SELECT retrieves data from tables. |
| 2 | B | EMPLOYEE contains 4 rows. |
| 3 | D | Maximum salary is 7000. |
| 4 | B | Mary and Steve have salaries above 5000. |
| 5 | B | Departments 10, 20, and 30. |
| 6 | C | Primary key uniquely identifies rows. |
| 7 | B | ORDER BY sorts results. |
| 8 | C | NULL means unknown or unavailable value. |
| 9 | B | HAVING filters groups after aggregation. |
| 10 | C | MySQL is open source. |
SET 2 – Joins and Group By
Q1.
SELECT E.NAME,
D.DEPT_NAME
FROM EMPLOYEE E
INNER JOIN DEPARTMENT D
ON E.DEPT_ID=D.DEPT_ID;
A. 3 rows
B. 4 rows
C. 2 rows
D. 1 row
Q2. Which join returns all rows from both tables?
A. INNER JOIN
B. LEFT JOIN
C. RIGHT JOIN
D. FULL OUTER JOIN
Q3.
SELECT DEPT_ID,
COUNT(*)
FROM EMPLOYEE
GROUP BY DEPT_ID;
How many rows?
A. 2
B. 3
C. 4
D. 1
Q4.
SELECT DEPT_ID,
AVG(SALARY)
FROM EMPLOYEE
GROUP BY DEPT_ID;
Which clause is mandatory?
A. ORDER BY
B. GROUP BY
C. HAVING
D. DISTINCT
Q5.
SELECT *
FROM EMPLOYEE
WHERE DEPT_ID IN (10,20);
Rows returned?
A. 2
B. 3
C. 4
D. 1
Q6. Which join returns unmatched rows from the left table?
A. INNER JOIN
B. LEFT JOIN
C. CROSS JOIN
D. SELF JOIN
Q7.
SELECT DEPT_ID,
COUNT(*)
FROM EMPLOYEE
GROUP BY DEPT_ID
HAVING COUNT(*) > 1;
Result?
A. Department 10
B. Department 20
C. Department 30
D. All departments
Q8. Which operator checks for NULL?
A. = NULL
B. == NULL
C. IS NULL
D. NULL()
Q9. What does a Foreign Key do?
A. Sorts rows
B. Creates index
C. Maintains relationship between tables
D. Removes duplicates
Q10. Which clause executes first?
A. SELECT
B. GROUP BY
C. FROM
D. ORDER BY
Answers – SET 2
| Q | Answer | Explanation |
|---|---|---|
| 1 | B | All employees have matching departments. |
| 2 | D | FULL OUTER JOIN returns all rows. |
| 3 | B | Three departments exist. |
| 4 | B | Aggregation requires GROUP BY. |
| 5 | B | Employees in departments 10 and 20. |
| 6 | B | LEFT JOIN preserves left table rows. |
| 7 | A | Department 10 has two employees. |
| 8 | C | NULL comparison requires IS NULL. |
| 9 | C | Foreign key enforces referential integrity. |
| 10 | C | FROM executes before SELECT. |
SET 3 – Advanced Database Concepts
Q1. Which ACID property guarantees completed transactions?
A. Consistency
B. Atomicity
C. Isolation
D. Durability
Q2. What is normalization?
A. Data duplication
B. Organizing data to reduce redundancy
C. Indexing tables
D. Creating views
Q3. Which normal form removes repeating groups?
A. 1NF
B. 2NF
C. 3NF
D. BCNF
Q4. Which normal form removes transitive dependency?
A. 1NF
B. 2NF
C. 3NF
D. 4NF
Q5. What does an index improve?
A. INSERT speed only
B. UPDATE speed only
C. Query performance
D. Storage size
Q6.
CREATE INDEX IDX_EMP
ON EMPLOYEE(NAME);
Purpose?
A. Enforce uniqueness
B. Improve search performance
C. Create table
D. Create constraint
Q7. Which statement starts a transaction?
A. START TRANSACTION
B. BEGIN
C. COMMIT
D. Both A and B
Q8. What does COMMIT do?
A. Undo changes
B. Save changes permanently
C. Lock table
D. Create backup
Q9. What does ROLLBACK do?
A. Saves changes
B. Removes table
C. Undoes uncommitted changes
D. Creates index
Q10. Which Oracle feature automatically generates values?
A. Trigger
B. Sequence
C. Cursor
D. Synonym
Answers – SET 3
| Q | Answer | Explanation |
|---|---|---|
| 1 | B | Atomicity ensures complete success or failure of transactions. |
| 2 | B | Normalization reduces redundancy and anomalies. |
| 3 | A | 1NF removes repeating groups and ensures atomic values. |
| 4 | C | 3NF removes transitive dependencies. |
| 5 | C | Indexes speed up data retrieval operations. |
| 6 | B | Indexes improve lookup performance. |
| 7 | D | Both BEGIN and START TRANSACTION are supported. |
| 8 | B | COMMIT permanently saves transaction changes. |
| 9 | C | ROLLBACK restores previous state. |
| 10 | B | Oracle sequences generate unique values. |
Backend Developer Interview Evaluation
| Score | Rating |
|---|---|
| 27–30 | Excellent Database Knowledge |
| 24–26 | Strong SQL Skills |
| 20–23 | Good Fundamentals |
| 15–19 | Average |
| Below 15 | Needs Improvement |
Topics Covered
✅ SQL Queries
✅ SELECT Statements
✅ Aggregate Functions
✅ Joins
✅ Group By
✅ Having
✅ Primary Keys
✅ Foreign Keys
✅ Constraints
✅ ACID Properties
✅ Transactions
✅ Normalization
✅ Indexes
✅ Oracle Sequences
✅ MySQL Concepts
These assessments are ideal for:
- Java Backend Developers
- Spring Boot Developers
- Full Stack Developers
- Database Developers
- Oracle Developers
- MySQL Developers
- Technical Interview Preparation
- Campus Hiring Assessments
A backend developer who scores above 80% generally demonstrates strong SQL and database fundamentals expected in enterprise applications.