Final Evaluation – SQL Course


SQL Database Examination



Total Marks: 100

Duration: 90–120 minutes

Format: Mixed (MCQs, Short Answer, Practical Queries)



Section A: Multiple Choice Questions (20 Marks)


Each question is 1 mark.



1. What SQL clause is used to sort results?


  • A) WHERE
  • B) GROUP BY
  • C) ORDER BY
  • D) HAVING

Answer: C



2. Which SQL function returns the total number of rows?


  • A) COUNT()
  • B) SUM()
  • C) TOTAL()
  • D) LENGTH()

Answer: A


3. A foreign key in SQL:

  • A) Ensures unique values
  • B) Links two tables
  • C) Is the same as a primary key
  • D) None of the above

Answer: B


4. Which keyword is used to remove a table from the database?

  • A) DELETE
  • B) ERASE
  • C) DROP
  • D) REMOVE

Answer: C


(Add more as needed.)


Section B: Short Answer (20 Marks)

Each question carries 5 marks. Write 3–4 lines.


1. Explain the difference between INNER JOIN and LEFT JOIN.


2. What is normalization and why is it important?


3. Define a view and give a use-case.


4. Explain the difference between WHERE and HAVING.


Section C: Practical SQL Queries (40 Marks)

Use the schema provided and write SQL queries for the following:


Schema:

students(id, name, department, age)
courses(id, title, credits)
enrollments(student_id, course_id, grade)


Tasks (8 marks each):

  1. List all students along with the names of courses they are enrolled in.
  2. Find students with no enrollments.
  3. Retrieve departments with more than 3 students.
  4. Display average grades per course.
  5. Write a query to find students who are enrolled in all courses offered.


Section D: Case Study & Analysis (20 Marks)


Case Study: Blogging Platform

Tables:

users(id, username)
posts(id, user_id, title)
likes(user_id, post_id)

Tasks:


  1. Write a query to find users with the most posts. (5 marks)
  2. Write a query to find the top 3 most liked posts. (5 marks)
  3. Identify users who liked their own posts. (5 marks)
  4. Suggest an index to optimize likes count per post and explain. (5 marks)