5
VIVEKANANDHA COLLEGE OF ENGINEERING FOR WOMEN (AUTONOMOUS) DEPARTMENT OF INFORMATION TECHNOLOGY U14IT302 – DATABASE MANAGEMENT SYSTEMS LAB ASSIGNMENT - 2 QUESTIONS II - B.TECH – IT SEM: III 1. Consider the following database with primary keys underlined Project(P_No, P_Name, P_Incharge) Employee(E_No, E_Name) Assigned_To(P_No, E_No) Write the relational algebra for the following : (i) List details of the employees working on all the projects. (ii) List E_No of employees who do not work on project number DB2003. 2. Given the following relations : vehicle (reg_no, make, colour) Person (eno, name, address) Owner (eno, reg_no) Write expressions in relational algebra to answer the following queries : (i) List the names of persons who do not own any car. (ii) List the names of persons who own only Maruti Cars. 3.Consider the following relations Physician (rgno, phyname, addr, phno) Patient (ptname, ptaddr) Visits(rgno, ptname, dateofvisit, fees-charged) Answer the following in SQL : (i) Define the tables. Identify the keys and foreign keys. (ii) Create an assertion that the total fees charged for a patient can not be more than Rs.1000/- assuming that patients can visit the same doctor more than once. (iii) Create a view Patient_visits(name, times) where name is the name of the patient and times is the number of visits of a patient.

ASSIGN 2.doc

Embed Size (px)

Citation preview

Page 1: ASSIGN 2.doc

VIVEKANANDHA COLLEGE OF ENGINEERING FOR WOMEN

(AUTONOMOUS)

DEPARTMENT OF INFORMATION TECHNOLOGY

U14IT302 – DATABASE MANAGEMENT SYSTEMS LAB

ASSIGNMENT - 2 QUESTIONS II - B.TECH – IT SEM: III

1. Consider the following database with primary keys underlined

Project(P_No, P_Name, P_Incharge)

Employee(E_No, E_Name)

Assigned_To(P_No, E_No)

Write the relational algebra for the following :

(i) List details of the employees working on all the projects.

(ii) List E_No of employees who do not work on project number DB2003.

2. Given the following relations :

vehicle (reg_no, make, colour)

Person (eno, name, address)

Owner (eno, reg_no)

Write expressions in relational algebra to answer the following queries :

(i) List the names of persons who do not own any car.

(ii) List the names of persons who own only Maruti Cars.

3.Consider the following relations

Physician (rgno, phyname, addr, phno)

Patient (ptname, ptaddr)

Visits(rgno, ptname, dateofvisit, fees-charged)

Answer the following in SQL :

(i) Define the tables. Identify the keys and foreign keys.

(ii) Create an assertion that the total fees charged for a patient can not be more than

Rs.1000/- assuming that patients can visit the same doctor more than once.

(iii) Create a view Patient_visits(name, times) where name is the name of the patient and

times is the number of visits of a patient.

(iv) Display the ptname, ptaddr of the patient(s) who have visited more than one physician

in the month of May 2000 in ascending order of ptname

4. Let R(A, B) and S(A, C) be two relations. Give relational algebra expressions for the

following domain calculus expressions.

(i) a b a, b r b 17

(ii) a, b, c a, b ra, c s

Page 2: ASSIGN 2.doc

(iii) a b (c a, b r) a, c s)

5. Given R {ABCD} and a set F of functional dependencies on R given as F

ABC,ABD,CA, DB. Find any two candidate keys of R. Show each step. In what

normal form is R? Justify.

6. Consider the following relations

Employee (E#, Ename, salary, Bdate, D#)

Department (D#, Dname, mgremp#, Location)

Dependent (E#, DependentName)

a. Write tuple calculus queries for the following:

(i) List the names of mangers who have at least one dependent.

(ii) List the names of employees working for ‘research’ department. (6)

b. Write QBE queries for the following:

(i) List all the employees who earn more than the average salary of all employees.

(ii) Increase the salary of managers by 10%.

(iii) List the names of all employees working in Delhi.

(iv) Change the location of all departments to “Mumbai” which have location as

“Bombay”

7. Design a generalization-specialization hierarchy for a motor-vehicle sales company. The

company sells motorcycles which have an engine number and cost; cars which have a

chassis number, an engine number, seating capacity and cost; trucks which have chassis

number, an engine number and cost.

8. Map the following ER diagram to a relational database. Give the relation names and

attributes in them. Also mention the primary key and foreign keys if any for each table.

9. Give examples of :

(i) A many – to – many relationship in which one of the participants is another relationship;

(ii) A subtype that has an associated weak entity that dose not apply to the super Type

Page 3: ASSIGN 2.doc

10. The entity set EMPLOYEE is a generalization of the entity sets FULL_TIME_EMPLOYEE and

PART_TIME_EMPLOYEE. The former is a generalization of the entity sets FACULTY with

attributes degree and subject of interest and STAFF with attribute classification; the latter, is

a generalization of the entity sets TEACHING with attribute stipend and CASUAL_FACULTY

with attribute hour rate. STAFF inherits the attribute Salary of the entity set

FULL_TIME_EMPLOYEE and the latter, in turn, inherits the attributes of EMPLOYEE.

FULL_TIME_EMPLOYEE is a specialization of the entity set EMPLOYEE and is differentiated by

the additional attribute Salary. Similarly, PART_TIME_EMPLOYEE is specialization

differentiated by the presence of the attribute Type. Each employee must have attributes

empno, name and hire_date.

(i) Draw an E-R diagram for the system.

(ii) Convert this E-R diagram to relational tables.

11. The tourism department wishes to computerize its data. The information consists of

monuments of tourist interest, their location and history. Monuments are classified

according to historical, religious and architecture importance. The list of facilities available

at each sport is also available. These give (i) living accommodation in terms of hotels, their

names, category and the number of rooms available and (ii) local transport facilities in terms

of service provider name, tours with their tariff and timing. Arrive at an E-R diagram by

identifying the entities, relationships, attributes, primary keys and cardinality.

12. Consider the schema

Airport (code, name, city, country)

Flight (number, airline, from_airport_code, to_airport_code)

Reservation(flight_number, seat_number, date, passenger_name)

Answer the following using relational algebra

(i) List the flight numbers of flights that take off from India

(ii) List the passenger who are on flight number ‘SA 747’.

(iii) List all the flight information for Indian Airlines and Jet Airways.

13.

Page 4: ASSIGN 2.doc

14. Explain Boyce-Codd Normal Form with example and also Compare BCNF and 3NF.

15. Consider the following relations (8)

SALESPERSON(SSN, Name, Start_Year, Dept_No)

TRIP(SSN,From_City,To_City,Departure_Date,Return_Date,Trip_ID)

EXPENSE(Trip_ID, Account#, Amount)

Write queries in relational algebra

(i) Give the details (all attributes to TRIP relation) for the trips that exceeded $2000 in

expenses.

(ii) Print the SSN of salesman who took trips to ‘Chandigarh’.

(iii) Print the total trip expenses incurred by the salesman with SSN =‘234-56-7890’.