SL-I MySQL Questions
SL-I MySQL Questions
SL-I MySQL Questions
A. The university records each student's name, social security number (SSN),
address, phone, birthdate, major department, and degree program (B.A., B.S.,
etc.). An SSN uniquely designates a student.
D. Each section has an instructor, semester, year, course and section number.
The section number distinguishes different sections of the same course that are
taught during the same quarter and year.
E. A grade report has a student, section, and grade (A,B,C, and D). The
combination of a student and section uniquely characterizes a grade report.
Draw the E-R diagram. Create the database in MySQL. Frame and execute the
SQL queries for the following:
1. List name of all students who have registered for courses in more than one
department.
2. List name and SSN of all students who have registered for more than one
course in a specified department.
3. List name of all students who have got at least B grade in all the courses
taken by him/her.
4. List name of all students who have got A in all the courses offered by CS
department.
5. List the highest grade obtained in each course by students majoring in each
of the departments.
Q.2) Define the schema for the following databases with specific data type and
constraints, the table nameand its fields name are to be taken from database
description which are given below:
Make appropriate tables and add required data for the above database. Frame and
execute the SQL queries for the following:
a) Find the names of sailors who have reserved a red or a green boat.
b) Find the names of sailor's who have reserved both a red and a green boat.
c) Find the sids of all sailor's who have reserved red boats but not green boats.
d) Find sailors whose rating is better than some sailor called Rajesh.
e) Find the sailor's with the highest rating using ALL.
f) Find the name and age of the oldest sailor.
g) Find the names of sailors who are older than the oldest sailor with a rating of
10.
h) Displays all the sailors according to rating (Lower Rating First), if rating is
same then sort according to age (Younger First).
i) Find the age of youngest sailor with age >= 18 for each rating with at least 2
such sailors.
j) Write a procedure to delete records from sailors table by reading SID from
Keyboard.
Q.4) Design the MySQL Database with following entities,
Make appropriate tables and add required data for the above database. Frame and
execute the SQL queries for the following:
1. Find the names of sailors who have reserved boat number 123.
2. Find names of the sailors who have reserved at least one boat.
3. Create a view for Expert Sailors ( A sailor is a Expert Sailor if his rating is
more than 7).
4. Find average age of Expert sailors.
5. Write the following queries on Expert Sailor View.
5.1 Find the Sailors with age > 25 and rating equal to 10.
5.2 Find the total number of Sailors in Expert Sailor view.
5.3 Find the number of Sailors at each rating level ( 8, 9, 10).
5.4 Find the age of Oldest as well as Youngest Expert Sailor.
6. Write cursor to display sailor records according to rating.
7. Write appropriate cursor to update rating of sailors by 2 if rating is less than 5,
by 1 if rating is >5 and doesn’t change the rating if it is equal to 10.
Q.5) Design the MySQL Database with following entities,
Customer(Cust id : integer, cust_name: string)
Item(item_id: integer,item_name: string, price: integer)
Sale(bill_no: integer, bill_data: date, cust_id: integer, item_id: integer, qty_sold:
integer)
Cancellation and modification: Cancellations are also directly handed at the booking
office. Cancellation charges will be charged. Wait listed tickets that do not get
confirmed are fully refunded.
Analyze the problem and following with the entities in it. Identify what Data must be
persisted in the databases.
2. Reservation: - PNR NO, Journey date, Contact No, No-of-Seats, Bus No, Address
3. Ticket: - Ticket No, Journey date, Age, Dep-Time, Sex, Source, Destination, Bus
No
4. Passenger: - Ticket No, PNR NO, Age, Sex, Contact NO, Name