0% found this document useful (0 votes)
73 views8 pages

Practice Problem Statement For DMSL Practical Exam

Uploaded by

dkmishra2701
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)
73 views8 pages

Practice Problem Statement For DMSL Practical Exam

Uploaded by

dkmishra2701
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
You are on page 1/ 8

Q Consider the following set of requirements for a university database used to

. maintain student grade reports (transcripts).


1.
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.

B. Each department is described by a name, department code, office


number, office phone, and college. Name and code values each uniquely
characterize a department.

C. Each course has a course name, description, course number, number of


quarter hours credit, and offering department. The combination of a course
number and an offering department uniquely designates a course.

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.
Design the MySQL Database with following entities,
 SAILORS (SID: INTEGER, SNAME:STRING,
RATING:INTEGER(Must be in between 1 to 10), AGE:REAL)
 BOATS (BID: INTEGER, BNAME: STRING, COLOR: STRING)
 RESERVES (SID: INTEGER, BID: INTEGER, DAY: DATE)

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

Q.10) ROADWAY TRAVELS “Roadway Travels” is in business since 1977


with several buses connecting different places in India. Its main office is in Pune.
The company wants to computerize its operations in the following areas:
 Reservations
 Ticketing
 Cancellations

Reservations: Reservations are directly handled by booking office. Reservations


can be made 60 days in advance in either cash or credit. In case the ticket is not
available, a wait listed ticket is issued to the customer. This ticket is confirmed
against the cancellation.

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.

1. Bus: - Bus No, Source, Destination, Couch Type

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

5. Cancellation: -PNR NO, Journey date, Seat No, Contact No


Design the suitable ER Diagram and execute following queries.
a) Create the tables with the appropriate integrity constraints
b) Insert around 10 records in each of the tables.
c) Display all the names of male passengers.
d) Find the ticket numbers of the passengers whose name start with ‘r’ and
ends with ‘h’.
e) Find the names of passengers whose age is between 30 and 45.
f) Display the sorted list of passenger’s names.
g) Find the number of tickets booked by a passenger where the number of
seats is greater than 1.
h) Display the Total number of Reservation per bus number.
Write a procedure to display the ticket numbers and names of all the passenger
Bank Database:
A bank database keeps record of the details of customers, accounts,
loans and transactions such as deposits or withdraws. Customer
record should include customer id, customer name, address, age,
contact number, email id etc., accounts details involves account
number, account type(fixed account, savings account, monthly
account etc), date of creation of the account, balance. Transaction
detail keeps information about amount deposited or withdrawn
to/from a particular account and the date of transaction. The database
should also store record of loans which include loan amount, loan
date and the account number to which the loan is granted.
Make appropriate tables for the above database and try to find out
the following queries: (Apply appropriate triggers whenever
required)
a) List the details of account holders who have a ‘savings’ account.
b) List the Name and address of account holders with loan amount
more than 50,000.
c) Change the name of the customer to ‘ABC’ whose account
number is ’TU001’
d) List the account number with total deposit more than 80,000.
e) List the number of fixed deposit accounts in the bank.
f) Display the details of customers who created their accounts
between ’20-jan-08’ to ’20-aug-08’.
g) Display the detailed transactions on 28th Aug, 2008.
h) Display the total amount deposited and withdrawn on 29th Aug,
2008.
i) List the details of customers who have a loan.
j) Write a procedures to display Savings and Loan information of all
customers.
k) Write a trigger to delete the customer.

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.

Create the table WORKER with the fields (worker_id, name,


wage_per_hour, specialized_in, manager_id) Constraints on table WORKER:
worker_id primary key, name not null, manager_id primary key, check for
wage_per_hour>=0.
Create the table JOB with the fields (job_id, type_of_job, status):
Create the table JOB_ASSIGNED with the fields (worker_id, job_id,
starting_date, number_of_days)
Constraints on table JOB_ASSIGNED: worker_id references WORKER table,
job_id references JOB table.
1. Display the date on which each worker is going to end his presently
assigned job.
2. Display how many days remain for each worker to finish his job.
3. Display the STARTING_DATE in the following format - 'The fifth day of
month of October, 2004'.
4. Change the status to 'Complete' for all those jobs, which started in year
2008.
5. What is total number of days allocated for printing on the goods for all the
workers together.
6. Which workers receive higher than average wage per hour.
7. Display details of workers who are working on more than one job.
8. Which workers having specialization in polishing start their job in
September?
9. Display details of workers who are specialized in the same field as that of
Mr.Cacophonix or have a wage per hour more than any of the workers.
10. Display job details of all those jobs where at least 25 workers are
working.
11. Display all those jobs that are already incompleted.
12. Find all the jobs, which begin within the next two weeks.
13. List all workers who have their wage per hour ten times greater than the
wage of their managers.
14. List the names of workers who have been assigned the job of Packing.
15. Find the names of the workers who are getting more then 50 Rs. as wages
per hour.
16. Find the jobs which are assigned after 31-DEC-2008.

You might also like