Practice Problem Statement For DMSL Practical Exam
Practice Problem Statement For DMSL Practical Exam
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.
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.6) Design the MySQL Database Schema for Student Library scenario
Student(Stud_no : integer,Stud_name: string)
Membership(Mem_no: integer,Stud_no: integer)
Book(book_no: integer, book_name:string, author: string)
Iss_rec(iss_no:integer, iss_date: date, Mem_no: integer, book_no: integer)
For the above schema, perform the following—
a) Create the tables with the appropriate integrity constraints
b) Insert around 10 records in each of the tables
c) List all the student names with their membership numbers
d) List all the issues for the current date with student and Book names
e) List the details of students who borrowed book whose author is CJDATE
f) Give a count of how many books have been bought by each student
g) Give a list of books taken by student with stud_no as 5
h) List the book details which are issued as of today
i) Create a view which lists out the iss_no, iss _date, stud_name, book name
j) Create a view which lists the daily issues-date wise for the last one week
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
Consider the following relational schema. An employee can work in more than
one department.
Emp(eid: integer, ename: string, salary: real)
Works(eid: integer, did: integer)
Dept(did: integer, dname: string, managerid: integer, floornum: integer)
Write the following Queries:
1. Print the names of all employees who work on the 10th floor and
make less than Rs. 50,000.
2. Print the names of all managers who manage three or more
departments on the same floor.
3. Write a procedure to Give every employee who works in the toy
department a 10 percent raise.
4. Print the names and salaries of employees who work in both the toy
department and the Music department.
5. Print the names of employees who earn a salary that is either less
than Rs. 10,000 or more than Rs. 100,000.
6. Print all of the attributes for employees who work in some
department that employee Abhishek also works in.
7. Print the names of employees who make more than Rs. 20,000 and
work in either the video department or the toy department.
8. Print the name of each employee who earns more than the manager
of the department that he or she works in.
9. Print the name of each department that has a manager whose last
name is pantamabe and who is neither the highest-paid nor the
lowest-paid employee in the department.
10. Write a Procedure to Print the names of all employees who work on
the floor(s) where Amar Arora works.
11. Write a trigger to update department id from department,
corresponding table must be reflected accordingly.
Shops sell items at varying prices. Customers buy items from shops. This is
described by the following relations:
Shops (ShopId, name, address)
Items (ItemId, name, description)
Sells (ShopId, ItemId, price)
Customers (CustomerId, name, address)
Sales (SaleId, CustomerId, ItemId, ShopId, date)
a) Draw an E/R diagram that describes the database.
b) Create the table Sells. Invent suitable types for the attributes (itemId shall have
the type char(10)) and indicate reasonable integrity constraints.
c) Print the name and address of all customers who haven’t bought any item.
d) Print the number of shops that sell items with id’s starting with 'EF'.
e) Print the name and address of the shop(s) that sell the item with id = 'EF123-
A' at the lowest price.
f) For all customers that have bought at least one item: print the customer id and
the total sum of all purchases.
g) Display total price per customer.
h) Display the name of Highest buyer.
i) Write a procedure to display total items per customer.
j) Write a trigger to delete item, corresponding tables must have reflected
according.
TABLE :DEPT
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
--TABLE: EMP
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-Dec-80 800 20
7499 ALLEN SALESMAN 7698 20-Feb-81 1600 300 30
7521 WARD SALESMAN 7698 22-Feb-81 1250 500 30
7566 JONES MANAGER 7839 2-Apr-81 2975 20
7654 MARTIN SALESMAN 7698 28-Sep-81 1250 1400 30
7698 BLAKE MANAGER 7839 1-May-81 2850 30
7782 CLARK MANAGER 7839 9-Jun-81 2450 10
7788 SCOTT ANALYST 7566 9-Dec-82 3000 20
7839 KING PRESIDENT 17-Nov-81 5000 10
7844 TURNER SALESMAN 7698 8-Sep-81 1500 0 30
7876 ADAMS CLERK 7788 12-Jan-83 1100 20
7900 JAMES CLERK 7698 3-Dec-81 950 30
7902 FORD ANALYST 7566 3-Dec-81 3000 20
7934 MILLER CLERK 7782 23-Jan-82 1300 10
Solve following queries
1) Display all the ANALYSTs whose name doesn’t ends with ‘S’
2) Display all the employees who are earning more than all the managers.
3) Display all the managers working in 20 & 30 department.
4) Display all the managers who don’t have a manager
5) Display the second maximum salary.
6) Display the departments that are having more than 3 employees under it.
7) Display job-wise average salaries for the employees whose employee
number is not from 7788 to 7790.
8) Display department-wise total salaries for all the Managers and Analysts,
only if the average salaries for the same is greater than or equal to 3000.
9) Display the third maximum salary.
10)Display all the managers & clerk who work in Accounting and Marketing
(SALES) departments.
11)Display all the managers & clerks who work in Accounts and Marketing
departments.
12)Display all the employees who have joined before their managers.
13) Select all the employees name along with their manager names, and if an
employee does not have a manager, display him as “CEO”.
14) Write a trigger to delete department, dependent table must be reflected
accordingly.
15)Write a procedure to Display job-wise maximum salary.