0% found this document useful (0 votes)
70 views5 pages

Question Bank

The document contains a series of SQL query questions related to various databases, including a book database, a participant management system, and a university course structure. It also includes tasks for converting ER diagrams to relational schemas and writing expressions in Tuple Relational Calculus. Additionally, it discusses DBMS architecture, the differences between database schema and instance, and relational algebra operations.

Uploaded by

dahiyaneha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views5 pages

Question Bank

The document contains a series of SQL query questions related to various databases, including a book database, a participant management system, and a university course structure. It also includes tasks for converting ER diagrams to relational schemas and writing expressions in Tuple Relational Calculus. Additionally, it discusses DBMS architecture, the differences between database schema and instance, and relational algebra operations.

Uploaded by

dahiyaneha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Question BANK PRE SESIONAL

Q.1. Write the SQL queries for the following database


a) BOOK(BID, TITLE, AUTHOR, PRICE, PUBYEAR, PUBID)
PUBLISHER(PUBID, PUBNAME, CITY, DISCOUNT)
a) Display details of all books in descending order of PRICE.
b) Display TITLE and AUTHOR of books published in 2010 or 2015.
c) Display TITLE, AUTHOR, PUBYEAR of books published before 2012.
d) Display PUBNAME and DISCOUNT from table PUBLISHER.
e) Display the number of books published each year from BOOK.
f) Display TITLE, AUTHOR, PRICE, DISCOUNT by joining BOOK and PUBLISHER
where DISCOUNT > 10.
g) Write a query to display the minimum price and maximum price of books from BOOK.
h) Display TITLE, PUBNAME, and EffectivePrice = PRICE * (1 − DISCOUNT/100) for
books from publisher with PUBID = 'P02'.
i) Write a query to count the number of distinct PUBYEARs from BOOK.
j) Write a query to display the total and average price of all books from BOOK.

Q.2. Write the SQL queries for the following database


Dronathon Management System
PARTICIPANT(PID, PNAME, COLLEGE, DOJ, CID, DOB)
CATEGORY(CID, CATEGORY, FEES, SPONSORSHIP)
EVENT(EID, ENAME, EDATE, VENUE)
REGISTRATION(PID, EID, STATUS)
1. Display details of all participants in descending order of their DOJ.
2. Display PNAME and COLLEGE of those participants whose CID is either 'S02' or
'S03'.
3. Display PNAME, COLLEGE, and CATEGORY name of those participants who
joined in the year 2020.
4. Display CATEGORY and ANNUAL_FEES from table CATEGORY
(ANNUAL_FEES = FEES * 12).
5. Find the minimum DOJ and maximum DOB of participants.
6. Display CATEGORY and (FEES + SPONSORSHIP) for category code 'S02'.
7. List participants who were born after the year 2000.
8. Display the total and average fees of all categories.
9. Show PNAME and COLLEGE of participants in the Photography category.
10.Display details of participants in ascending order of DOB.
Q3. A University has an entity "COURSE" with a large number of courses in the catalogue.
The attribute of course includes Course_No, Course_Name and Course CreditUnits. Each
course may have one or more different courses as pre-requisites or may have nothing.
Similarly, a particular course may be a pre-requisite for any number of courses or may not
be for any other course. Draw an ER diagram and reduce it into appropriate tables.
Q4 Convert following ER diagram to relational schema

Q. Some of the entities relevant to a College Management System are given below:
STUDENT and COURSE (Students register for courses)
COURSE and FACULTY (Courses are taught by faculty)
FACULTY and DEPARTMENT (Faculty belong to departments)
CLASSROOM and COURSE (Courses are scheduled in classrooms)
LIBRARY and BOOK (Library stores books)
For each of them, draw ER diagram indicate the type of relationship that exists
between them.

Q Some of the entities relevant to a Technical University are given below : (i)
STUDENT and ENGG-BRANCH (Students register for engineering
branches)
(ii) BOOK and BOOK_COPY (Books have copy)
(iii) ENGG BRANCH and SECTION (Branches have sections)
(iv) SECTION and CLASS ROOM (Sections are scheduled in classrooms)
(v) FACULTY and ENGG BRANCH (Faculty trains in a particular branch)
For each of them, indicate the type of relationship that exists between them.

Q. Consider the following database (primary keys in bold):


student(StudentID, student_name, street, city)
enrolls(StudentID, college_name, gpa)
college(college_name, city)
advisor(StudentID, advisor_name)
Give an expression in Tuple Relational Calculus (TRC) for each of the following:
(a) Find the names of all students who study at “National Institute of Technology”.
(b) Find the names, street addresses, and cities of all students who study at “National
Institute of Technology”.
(c) Find all students who live in the same city as the colleges they attend.
(d) Find all students who do not study at “National Institute of Technology”.

Q Explain DBMS Architecture. How database schema is different from database


instance.
Q Explain any one Open Source and one Commercial DBMS each. Explaim
a. DBMS and Traditional File System
b. DBMS Instance and schema.
c. Arity
d. Cardinality
e. Referential integrity
f. Total Participation
g. Identifying relationship
h. Equi join vs natural join
i. DRC with example
j. Explain Joins in relational algebra with Example.
k. Explain any one Open Source and one Commercial DBMS each.
RELATIONAL ALGEBRA
Answer the following using proper relational algebra notation (σ, π, ∪, ∩, −, ×, ρ, ⋈, ÷).
Consider the schema:
a) Schemas:
EMPLOYEE(EmpID, EmpName, DeptID, Salary)
DEPARTMENT(DeptID, DeptName, Location)
WORKS(EmpID, DeptID)
1. Retrieve employees who earn more than 50,000.
2. List only the names and salaries of employees.
3. Find all Department IDs appearing in either EMPLOYEE or DEPARTMENT.
4. Find Department IDs common to both EMPLOYEE and DEPARTMENT.
5. Find Department IDs present in EMPLOYEE but not in DEPARTMENT.
6. List all possible pairs of employees and departments.
7. Rename the EMPLOYEE relation to WORKER.
8. List employee names with their corresponding department names.
9. Find employees who work in all departments located in 'Delhi'.

b)
PATIENT(PID, PName, Age, Disease, WardNo)
DOCTOR(DID, DName, Specialty, WardNo)
Retrieve the names of all patients who are older than 60 and show only their names and
diseases.
(i) List all Ward numbers that appear in either PATIENT or DOCTOR relations.
(ii) Find Ward numbers that are common to both PATIENT and DOCTOR relations.
(iii) Find Ward numbers assigned to patients but not to any doctor.
List all possible pairs of patients and doctors (Cartesian product). Rename PATIENT
relation as INMATE.
Retrieve the names of patients along with the names of doctors who are assigned to the
same ward.
Find patients who are treated in all wards handled by doctors of ‘Cardiology’ specialty.
TRC/DRC
Consider the following schemas:
employee(employee-name, street, city)
works(employee-name, company-name, salary)
company(company-name, city)
manages(employee-name, manager-name)
Give an expression in Tuple Relational Calculus (TRC) for each query:
(a) Find the names of all employees who work for First Bank Corporation.
(b) Find the names, street addresses, and cities of residence of all employees who work for
First Bank Corporation and earn more than 10,000.
(c) Find all employees who live in the same cities as the companies for which they work.
(d) Find all employees who do not work for First Bank Corporation.

You might also like