Unit 5: Introduction to SQL - Subjective Questions

INT322 — Computing System And Technologies • Practice Questions with Detailed Answers

20 questions

1

Define SQL. Explain its main features and the role it plays in a relational database management system.

2

What are DDL commands? Explain the purpose and syntax of CREATE, ALTER, TRUNCATE, DROP, and RENAME.

3

Explain DML commands with suitable examples. Distinguish between INSERT, UPDATE, DELETE, and SELECT.

4

What is DCL? Describe how GRANT and REVOKE are used to control database security.

5

Explain TCL commands and describe how they maintain transaction consistency. Illustrate COMMIT, ROLLBACK, and SAVEPOINT with an example.

6

Differentiate DDL, DML, DCL, and TCL on the basis of purpose, objects affected, and examples.

7

Define a database key. Explain super key, candidate key, primary key, alternate key, foreign key, composite key, and unique key.

8

Given Student(StudentID, Email, Name) and Enrollment(StudentID, CourseID, Semester), identify suitable keys and justify your choices.

9

Explain the aggregate functions MIN, MAX, SUM, AVG, and COUNT with suitable SQL examples.

10

Describe how aggregate functions handle NULL values. Compare COUNT(*), COUNT(column), and COUNT(DISTINCT column).

11

What is the GROUP BY clause? Explain its rules and write a query to calculate the number of employees and average salary in each department.

12

Differentiate the WHERE and HAVING clauses. Write a query that displays departments having more than five employees whose salary is at least 30000.

13

Explain the ORDER BY clause. How can data be sorted by multiple columns and by an aggregate result?

14

What is a self join? Describe a practical use of it and write a query to display every employee with the employee's manager.

15

Define an equi join. Write an equi-join query for Employee and Department, and explain how duplicate join columns may appear.

16

Explain an inner join. What happens to unmatched rows, and how is an inner join different from a Cartesian product?

17

Describe left, right, and full outer joins. Compare their treatment of matched and unmatched rows.

18

What is a cross join? Derive the number of rows produced and state two practical uses of a cross join.

19

Compare self join, equi join, inner join, outer join, and cross join. Explain why these terms are not all mutually exclusive.

20

Using Employee(EmployeeID, Name, DepartmentID, Salary) and Department(DepartmentID, DepartmentName), write and explain a query that lists departments with at least three employees, shows their minimum, maximum, total, average salary and employee count, and sorts them by total salary in descending order.