0% found this document useful (0 votes)
3 views1 page

SQL Practise Query

The document outlines SQL queries and relational algebra operations for managing hotel and employee databases. It includes tasks such as listing guest information, retrieving hotel bookings, and querying employee details based on various conditions. Additionally, it explains second and third normal forms with an example of normalization for a given relation.

Uploaded by

pradeepshettar50
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)
3 views1 page

SQL Practise Query

The document outlines SQL queries and relational algebra operations for managing hotel and employee databases. It includes tasks such as listing guest information, retrieving hotel bookings, and querying employee details based on various conditions. Additionally, it explains second and third normal forms with an example of normalization for a given relation.

Uploaded by

pradeepshettar50
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/ 1

1.

Consider the following tables: Hotel(hotelno, name, city),Room(roomno, hotelno, type, price),
Booking(hotelno, guestno, datefrom, dateto, roomno), Guest(guestno, name, address)
Construct the SQL statements for the following:
i. List the names and addresses of all guest alphabetically ordered by name.
ii. List all family rooms with a price below Rs. 400 per night.
iii. List the details of booking for hotel “DasPrakash”.
iv. Retrieve all the details of the hotels in Mysuru city.

2. For the company relational schema given below construct the following queries using relational
algebra

 Employee (FName, Mint, LName, SSN, BDate, Address, Gender, Salary, SuperSSN, DNo)
 Department (DName, DNumber, MgrSSN, MgrStartDate)
 Project (PName, PNumber, PLocation, DNum)
 WorksOn (ESSN, PNo, Hours)
 Dependent (ESSN, DependentName, Gender, BDate, Relationship)

i) Retrieve the names of all employees in department 5 who work more than 10 hours per week on
“Product X” project
ii) Retrieve the ssn of all employees who either work in department number 5 or directly supervise
an employee who works in department number 5
iii) Find the names of employees who work on all projects controlled by department number 5.
iv) List the name and address of all employees who work for research dept

For the company DB Schema formulate the following queries in SQL


i) Retrieve the names of all employees whose supervisor’s supervisor has “888665555” for SSN
ii) Retrieve the names of employees who make at least $10,000 more than the employee who is paid
the least in the company
iii) For each department whose average employee salary is more than $30,000 retrieve the
department name and the number of employees working for that department
iv) Create a view that has the project name, controlling department name, number of employees and
total hours worked per week on the project for each project with more than one employee
working on it.
Create a view that has the department name, manager name and manager salary for every department

3. Explain second and third normal form with an example. Consider the relation
EMP_PROJ= {Ssn, Pnumber, Hours, Ename, Pname, Plocation}.
Assume {Ssn, Pnumber} as primary key. The dependencies are
Ssn, Pnumber  {Hours}
Ssn  {Ename}
Pnumber  {Pname, Plocation}.
Identify whether the given relation is in 2NF or not. If not, normalize the relation into 2NF.

You might also like