0% found this document useful (0 votes)
105 views

Assignment2 DBMS

This document contains an assignment for a Database Management Systems course. It provides the schema for 15 different SQL queries across 3 different data sets. The queries include finding names of students enrolled in specific courses, subjects taken by students, teachers of subjects, names of students taking certain subjects, details of subjects and students, and more. It also provides the schema for additional queries about employees borrowing books and information about people, pizzerias, and pizza orders.

Uploaded by

Krishna Aravind
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views

Assignment2 DBMS

This document contains an assignment for a Database Management Systems course. It provides the schema for 15 different SQL queries across 3 different data sets. The queries include finding names of students enrolled in specific courses, subjects taken by students, teachers of subjects, names of students taking certain subjects, details of subjects and students, and more. It also provides the schema for additional queries about employees borrowing books and information about people, pizzerias, and pizza orders.

Uploaded by

Krishna Aravind
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

National Engineering College, Kovilpatti

Department of Computer Science and Engineering


15CS44C- Database Management Systems
Assignment 2: SQL Query Assignment

1. Consider the following Schema.

student(id, name)
enrolledIn(id, code)
subject(code, lecturer,dept)

Write the following queries.

a) What are the names of students enrolled in cs3020?


b) Which subjects is Hector taking?
c) Who teaches cs1500?
d) Who teaches cs1500 or cs3020?
e) Who teaches at least two different subjects?
f) What are the names of students in cs1500 or cs3010?
g) What are the names of students in both cs1500 and cs1200?
h) What are the names of students in at least two different subjects?
i) What are the codes of all the subjects taught in each department?
j) List the names of all the students ending with ‘a’?
k) What are the names of all the students in cs1500?
l) What are the names of students taking a subject taught by Roger.
m) What are the names of students who are taking a subject not taught by Roger?
n) List the details of subjects having their dept name as ‘- - -’.
o) List the details of students who are not enrolled in any of the courses.

2. Consider the following schema:

Employee (empno,name,office,age)
Books(isbn,title,authors,publisher)
Loan(empno,isbn,date,amount)

Write the following queries.

a) Find the name of employees who have borrowed a book published by XYZ
Ltd.
b) Display the maximum number of books published publisher.
c) Find the name of employees who have borrowed more than 5 books published
by XYZ Ltd.
d) For each Publisher, find the names of employees who have borrowed more
than five books of that publisher.
e) Fetch the loan amount of employee dated today.
3. Consider the following schema:
Person ( name, age, gender )
Frequents ( name, pizzeria )
Eats ( name, pizza )
Serves ( pizzeria, pizza, price )

Write the following queries.

a) Find all pizzerias frequented by at least one person under the age of 18.
b) Find the names of all females who eat either mushroom or pepperoni pizza (or
both).
c) Find the names of all females who eat both mushroom and pepperoni pizza.
d) Find all pizzerias that serve at least one pizza that Amy eats for less than
$10.00.
e) For each person, find all pizzas the person eats that are not served by any
pizzeria the person frequents. Return all such person (name) / pizza pairs.

You might also like