Predicate Logic and Databases
[5/100%]For the database from example 35 on p. 162, construct a relational algebra expression giving the list of surnames of employees in whose rooms there is no equipment. Construct a formula of predicate logic defining the same relation.
Example 35: the database has schema , with its state given by:
Let there be relations and with schemas and respectively. The quotient of dividing the relation by the relation is called the largest relation with attributes , each tuple of which, joined with each 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 corresponding formulas to obtain the following information from the database in example 35 on p. 162, and compute the result:
Example 35: the database has schema , with its state given by:
find all employees with a salary greater than 5500;
find all departments that have 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 who receive a salary from 6000 to 6500 and do not work on the third floor;
compile a list of rooms where all employees receive a salary less than 7500.
Determine which of the integrity constraints given in example 44 on the preceding page hold for the state of the database from example 35 on p. 162.
Example 35: the database has schema , with its state given by:
Example 44: three integrity constraints for the database of example 35:
-
the key constraint on Employees (attribute Number is a key): ;
-
the reference constraint (every employee who has a room in Rooms must occur in Employees): ;
-
the value constraint (every employee’s salary lies in the interval ): .
Write formulas expressing the following integrity constraints for the database from example 35 on p. 162, and determine which of them hold for its given state:
Example 35: the database has schema , with its state given by:
in the relation Rooms, the set of attributes (EmployeeNumber, RoomNumber) is a key;
for every person in the relation Employees, their 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.