0% found this document useful (0 votes)
31 views4 pages

Final Internal - DBMS

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

Final Internal - DBMS

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

1. A.

Design the ER model for the following requirements


a. Professors have an SSN, a name, an age, a rank, and a research specialty. Projects have a
project number, a sponsor name (e.g., NSF), a starting date, an ending date, and a budget.
b. Graduate students have an SSN, a name, an age, and a degree program (e.g., M.S. or Ph.D.).
c. Each project is managed by one professor (known as the project’s principal investigator).
d. Each project is worked on by one or more professors (known as the project’s co-
investigators).
e. Professors can manage and/or work on multiple projects.
f. Each project is worked on by one or more graduate students (known as the project’s research
assistants).
g. When graduate students work on a project, a professor must supervise their work on the
project. Graduate students can work on multiple projects, in which case they will have a
(potentially different) supervisor for each one.
h. Departments have a department number, a department name, and a main office.
i. Departments have a professor (known as the chairman) who runs the department.
j. Professors work in one or more departments and for each department that they work in, a
time percentage is associated with their job.
k. Graduate students have one major department in which they are working on their degree.
Each graduate student has another, more senior graduate student (known as a student advisor)
who advises him or her on what courses to take.
B. Create a Employee trigger which generates empid,ename with time in a log table whenever
anyone attempts to delete a record in employees table.

2. 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 “DBMS” course
b. Display the course names that are in V sem
c. Display the count of students who have enrolled for the course ‘DBMS”
d. Display the count of each course enrollments
e. Write a PL/SQL Function which returns the count of no. of boats reserved by sailor x,where
x is passed as a parameter.

3. Student(sid :number, sname :string, cgpa:real)


Course(cid: number, cname:string, credits: number, sem: string)
Enrolled(sid: number, cid: number, marks:number)

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

5. Sailors(sid:integer, sname:string, age:integer, rating :integer)


Boats (Bid: integer, bname: String, colour: string)
Reserves(sid: Integer, bid: integer, day: Date)
Implement the following using SQL nested quries
a. Find the names of sailors who have reserved a red boat but not 103
b. Find the name of sailors who have reserved all boats
c. Find the names of sailors who have highest rating and reserve a red boat
d. Find the number of reservations for each boat
e. Find the number of reservation for each sailor, display if count is minimum 3.
f. 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.

6. Emp( eid: integer, ename: string, age: integer, salary: real)


Works( eid: integer, did: integer, peLtime: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer)
Answer the following for the given schema:
a. Write the SQL statements required to create the preceding relations, including appropriate
versions of all primary and foreign key integrity constraints.
b. Define the Dept relation in SQL so that every department is guaranteed to have a manager.
c. Write an SQL statement to add John Doe as an employee with eid = 101, age = 32 and
salary = 15,000.
d. Write an SQL statement to give every employee a 10 percent raise.
e. Write an SQL statement to delete the Toy department. Given the referential integrity
Constraints you chose for this schema, explain what happens when this statement is Executed.
f. Create a trigger which writes a new record with old details and new details ,time in a log
table whenever anyone attempts to update employees table.
7. Sailors(sid:integer, sname:string, age:integer, rating :integer)
Boats (Bid: integer, bname: String, colour: string)
Reserves(sid: Integer, bid: integer, day: Date)

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.

9. Sailors(sid:integer, sname:string, age:integer, rating :integer)


Boats (Bid: integer, bname: String, colour: string)
Reserves(sid: Integer, bid: integer, day: Date)
Implement the following using SQL quries using JOINS
a. Find the names of sailors who have reserved a “Interlake “ boat
b. Find the name of sailors who have not reserved any boats
c. Find the names of boats which is not having any reservations
d. Find the boat IDs reserved by a sailor ‘x’
e. Find the names of boats which is having maximum reservations
f. Create a stored procedure which takes deparment_id as parameter and returns the
name of the department.

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

You might also like