Final Internal - DBMS
Final Internal - DBMS
a. Create a view for the students who have enrolled for the course ‘Data Mining’.
b. Check for the updatability. Provide an alternative solution If not updatable.
c. Write a stored procedure that updates each student grade based on his/her marks
4. Answer the flowing queries by considering the given schema
Student(sid :number, sname :string, cgpa:real)
Course(cid: number, cname:string, credits: number, sem: string)
Enrolled(sid: number, cid: number, , marks:number)
a. Display the student details who have enrolled for the all courses in V sem
b. Display the course names that are enrolled by the student 1201
c. Display the student details who have passed the course “DBMS’
d. Display the count of students who have passed in the “DBMS”
e. Display the student details who have enrolled for the courses “DBMS “ and “DWDM”
f. Create a stored procedure that finds the minimum of 2 numbers where the 2 numbers has
to be given as parameters
a. Find the sailors who have reserved red but not green boat.
b. Find the sailors with second highest rating.
c. Find the boat names which are reserved by “john”.
d. Find the boats ids which is having highest reservations
e. Crate a Procedure that displays prime numbers up to a given number.
8. A. I. Write SQL’s numeric functions, String Functions and Date Functions. (at least 6 from Each
category).
II. "Consider the following relation:
Employee (eno:integer, name:string, dept:string, salary:real, city:string)
Answer the following queries in SQL: Find the details of all employees whose name contains
second character as ‘a’ and name length should be 5
B. write a stored procedure to get the student marks when student id is passed as parameter.
10. The Prescriptions-R-X chain of pharmacies has offered to give you a free lifetime supply of
medicines. Given the rising cost of health care. Here’s the information that you gather:
a. Patients are identified by an SSN, and their names, addresses, and ages must be
recorded.
b. Doctors are identified by an SSN. For each doctor, the name, specialty, and years of
experience must be recorded.
c. Each pharmaceutical company is identified by name and has a phone number
d. For each drug, the trade name and formula must be recorded. Each drug is sold bya
given pharmaceutical company, and the trade name identifies a drug uniquely from
among the products of that company. If a pharmaceutical company is deleted, you need
not keep track of its products any longer.
e. Each pharmacy has a name, address, and phone number.
f. Every patient has a primary physician. Every doctor has at least one patient.
g. Each pharmacy sells several drugs and has a price for each. A drug could be sold at
several pharmacies, and the price could vary from one pharmacy to another.
h. Doctors prescribe drugs for patients. A doctor could prescribe one or more drugs for
several patients, and a patient could obtain prescriptions from several doctors. Each
prescription has a date and a quantity associated with it. You can assume that if a doctor
prescribes the same drug for the same patient more than once, only the last such
prescription needs to be stored.
i. Pharmaceutical companies have long-term contracts with pharmacies.
j. A pharmaceutical company can contract with several pharmacies, and a pharmacy can
contract with several pharmaceutical companies. For each contract, you have to store a
start date, an end date, and the text of the contract.
k. Pharmacies appoint a supervisor for each contract. There must always be a supervisor
for each contract, but the contract supervisor can change over the lifetime of the
contract.
Design the ER model for the above database design
B. Create a trigger which writes a record called “employees table has been changed” with time
in a log table whenever someone successfully changes the employee table