Predicate Logic and Databases
[7/100%]Let the following attributes be given:
Let the relation with schema equal
and let the relation with schema equal
Determine the results of the following relational algebra expressions:
;
;
;
;
.
Determine whether the operations of filtering and projection are distributive over union, intersection, and difference, that is, whether the following equalities hold:
;
;
;
;
;
.
For the database in fig. 7 on the previous page, construct a relational algebra expression giving the list of surnames of the employees in whose rooms there is no equipment at all. Construct a formula of predicate logic defining the same relation.
Fig. 7: State of the database.
Let there be relations and with schemas and respectively. The quotient of dividing the relation by the relation is the largest relation with attributes each of whose tuples , joined with every tuple , belongs to , that is, . Construct a relational algebra expression equivalent to , and a formula of predicate logic defining this relation.
Write SQL queries and the corresponding formulas to obtain the following information from the database in fig. 7 on the preceding page, and compute the result:
find all employees with a salary greater than 5500;
find all departments in which there are employees with a salary greater than 8000;
compile a list of positions and the salaries received for them;
compile a list of employees of the sales department earning a salary from 6000 to 6500 and not working on the third floor;
compile a list of rooms where all employees receive a salary less than 7500.
Fig. 7: State of the database.
Determine which of the following integrity constraints hold for the state of the database in fig. 7 on p. 83:
Комнаты
Сотрудники
Fig. 7: State of the database.
Write formulas expressing the following integrity constraints for the database in fig. 7 on p. 83, determine which of them hold for the given state of it:
in the relation Комнаты (Rooms) the set of attributes (EmployeeNumber, RoomNumber) is a key;
for every person from the relation Сотрудники (Employees) a workplace is defined in the relation Комнаты (Rooms);
in the relation Комнаты (Rooms) the numbers of all rooms on the second floor are greater than 10 but less than 20, and the numbers of all rooms on the third floor are greater than 20.
Fig. 7: State of the database.