Professional Documents
Culture Documents
Code UE : NFA008
Ce sujet comporte : 5 pages
Intitule de l’UE : Base de données (English version)
In an enterprise, we would like to represent the personal and their affectation. Each employee
is affected to a service. Each service is described by its name; its leader who is necessarily
affected to the service and the list of the service premises. The personal is of 3 categories: admin,
technicians and managers.
Each employee has an employee number, a first name, a last name, an address, a salary and a
banking identification defined by: name of the bank, name of the agent and an account number.
Patient
pid name age address
Doctor
did name Department_id Specialty
Doc_availability
Admission
pid did roomNumber Admission_Date Duration_of_stay
Department
Nurse
nid name Department_id
Room
roomNumber Department_id capacity CostPerDay
Notes:
• The duration of stay in table Admission is in Days.
• A nurse can work for more than 1 department.
• The capacity in Room= the number of beds inside the room
Part 1- Choose the correct answer. (4 pts)
1.1) Give all the pid and names of patients who live in Beirut
a) SELECT PID, NAME FROM PATIENT HAVING ADDRESS=’BEIRUT’
b) SELECT PID, NAME FROM PATIENT WHERE ADDRESS EXISTS ‘BEIRUT’
c) SELECT PID, NAME FROM PATIENT WHERE ADDRESS= ’BEIRUT’
d) SELECT PID, NAME, ADDRESS=’BEIRUT’ FROM PATIENT
1.8) Give all the names of the doctors and their IDs for those are specialized in
anykind of cancer. For example, breast cancer, colon cancer… and so on.
a) SELECT NAME, DID FROM DOCTOR WHERE SPECIALTY = ‘CANCER’
b) SELECT NAME, DID FROM DOCTOR WHERE SPECIALTY LIKE ‘CANCER’
c) SELECT NAME, DID FROM DOCTOR WHERE SPECIALTY = ‘%CANCER%’
d) SELECT NAME, DID FROM DOCTOR WHERE SPECIALTY LIKE ‘%CANCER%’
Part 2- Write the corresponding SQL statement to create the tables Departments and Doctor.
Don’t forget the primary keys and foreign keys constraints.
All foreign key constraints are set to reject any violations. (2 pts)
Question 3 Functional dependencies and Normalization 5 pts
Part A (1 pt)
Consider the table T (A, B, C, D, E, F) and the function dependencies:
A→ B,C
C→ D
D → E
F→ E
Part B (4 pts)
Consider the table Student with 5 attributes.
ID name age Course_code Course_name
516 Sara Najem 19 CS375 Database
516 Sara Najem 19 CS310L Software lab
600 Ali Sayed 21 CS375 Database
600 Ali Sayed 21 CS10L Software lab
600 Ali Sayed 21 CS300 Logic design
Good Luck