Formulate the following queries in relational algebra, tuple relational calculus, and domain relational calculus.
The following tables form part of a database held in a Relational Database Management System: Employee (empID, fName, lName, address, DOB, sex, position, deptNo) Department (deptNo, deptName, mgrEmpID)
Project (projNo, projName, deptNo) WorksOn (empID, projNo, hoursWorked)
where Employee contains employee details and empID is the key. Department contains department details and deptNo is the key. mgrEmpID identifies the employee who is the manager of the department. There is only one manager for each department. Project contains details of the projects in each department and the key is projNo (no two departments can run the same project).
and WorksOn contains details of the hours worked by employees on each project, and empID/projNo form the key.
(1) List all employees.
(2) List all the details of employees who are female.
(3) List the names and addresses of all employees who are Managers.
(4) Produce a list of the names and addresses of all employees who work for the ‘IT’ department.
(5) Produce a list of the names of all employees who work on the ‘SCCS’ project.
(1) RA: Employee
TRC: {E | Employee(E) }
DRC: {empID, fName, lName, address, DOB, sex, position, deptNo |
Employee(empID, fName, lName, address, DOB, sex, position, deptNo) }
(2) RA: ? sex = ‘F’ (Employee)
TRC: {E | Employee(E) ? E.sex = ‘F’}
DRC: {empID, fName, lName, address, DOB, sex, position, deptNo |
Employee(empID, fName, lName, address, DOB, sex, position, deptNo) ?
sex = ‘F’}
(3) RA: ? fName, lName, address (? position = ‘Manager’ (Employee))
TRC: {E.fName, E.lName, E.address | Employee(E) ? E.position = ‘Manager’}
DRC: {fName, lName, address | (?empID, DOB, sex, position, deptNo)
(Employee(empID, fName, lName, address, DOB, sex, position, deptNo) ?position = ‘Manager’}
(4) RA: ? lName, address (? deptName = ‘IT’ (Department) 3 deptNo Employee)
TRC: {E.lName, E.address | Employee(E) ? (?D)(Department(D) ?
(D.deptNo = E.deptNo ) ? D.deptName = ‘IT’)}
DRC: {lName, address | (?empID, fName, DOB, sex, position, deptNo, deptNo1,
deptName, mgrEmpID) (Employee(empID, fName, lName, address, DOB, sex,
position, deptNo) ?
Department(deptNo1, deptName, mgrEmpID) ? (deptNo = deptNo1) ?
deptName = ‘IT’)}
(5) RA: ? fName, lName (? projName = ‘SCCS’ (Project) 3 projNo (WorksOn 3 empID Employee))
TRC: {E.fName, E.lName | Employee(E) ? (?P) (?W) (Project(P) ? WorksOn(W) ?
(E.empID = W.empID ) ? (W.projNo = P.projNo) ? P.projName = ‘SCCS’)}
DRC: {fName, lName | (?empID, address, DOB, sex, position, deptNo, projNo,
projName, deptNo1, empID1, projNo1, hoursWorked)
(Employee(empID, fName, lName, address, DOB, sex, position, deptNo) ?
Project(projNo, projName, deptNo1) ? WorksOn(empID1, projNo1,
hoursWorked) ? (empID = empID1) ? (projNo = projNo1) ?
projName = ‘SCCS’)}
You might also like to view...
Which of the following promotions of primitive types is not allowed to occur?
a. char to int. b. double to float. c. int to double. d. short to long.
Rewrite the Python program of Fig. 11.2. Create a multiple-selection list of colors. Al- low the user to select one or more colors and copy them to a ScrolledText component.
What will be an ideal response?