Вы находитесь на странице: 1из 1

DATABASE STUDY EXERCISE

THE HOSPITAL CASE STUDY


The Database Schema:
DOCTORS
1

STAFF
ROOM
RoomNumber
RoomFloor
RoomType

EmployeeID
Specialty
Degree

NURSES
1

EmployeeID
Qualification
Chief

uc

EmployeeID
FirstName
LastName
Salary
YearsInService
Category
RoomNumber

Further Information:

an

gi

The relationship between the table Staff and Doctors (or Nurses) is one-to-one, as an employee ID may belong to a single
doctor or to a single nurse. In the tables Doctors and Nurses, the employee ID is both a primary and a foreign key.
The room type may be only one of the following: office, laboratory, reserve.
The room floor may take values from 1 to 6.
The years of service count the time from the employment date to the present date.
The category may be only one of the following: doctor, nurse.
The specialty may be: surgeon, pediatrician, internal.
The degree may be: intern, resident, physician.
The qualification may be: surgery, pediatrics, general.
The chief field accepts only two values: yes and no.

SQL Requests:

os

Display all the rooms in the hospital.


Display all the rooms on the third floor, grouped by room type.
Display all the labs on the 5th floor, in the descending order of the room numbers.
Display all the rooms whose number ends in 102.
Display all the labs and reserves in the hospital (2 ways).
Display all the labs on the 3rd and 4th floor (2 ways).
Display the number of rooms in the hospital.
Display the number of rooms on the first three floors.
Display the number of employees that the hospital has.
Display all the employees, in reverse alphabetical order.
Display all the hospitals employees having between 2 and 5 years in service (2 ways).
Display all the doctors having over 15 years in service.
Display all the doctors having either over 15 years in service or less than 5 years.
Display the oldest three employees in the hospital.
Display the maximum number of years in service that an employee has.
Display the average salary for the hospitals employees.
Display all the categories of employees in the hospital.
Display all the employees working in the rooms 1012 and 1014.
Display all the hospitals employees whose salary is above the hospitals average (subquery).
Display all the hospitals employees working on the third floor.
Display the number of doctors with more than five years in service working on the fifth floor.
Display all the nurses along with each ones room.
Display all the nurses along with each ones floor.
Display the physicians working on the 3rd floor.
Display all the chief nurses working on the 3rd floor.
Display all the doctors who are not physicians.

D
ra
g

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.

Вам также может понравиться