division operation

the DIVISION operation, denoted by , is useful for a special kind of query that sometimes occurs in database applications. an example is "retrieve the names of employees who work on all the projects that 'John Smith' works on". to express this query using the DIVISION operation, proceed as follows. first, retrieve the list of project numbers that 'John Smith' works on in the intermediate relation SMITH_PNOS:
next, create a relation that includes a tuple <Pno, Essn> whenever the employee whose Ssn is Essn works on the project whose number is Pno in the intermediate relation SSN_PNOS:
finally, apply the DIVISION operation to the two relations, which gives the desired employees' Social Security numbers:
in general, the DIVISION operation is applied to two relations , such that . let be the set of attributes of that are not attributes of ; that is, (and hence ).
the result of DIVISION is a relation that includes a tuple if tuples appear in with , and with for every tuple in . this means that, for a tuple to appear in the result of the DIVISION, the values in must appear in in combination with every tuple in . note that in the formulation of the DIVISION operation, the tuples in the denominator relation restrict the numerator relation by selecting those tuples in the result that match all values present in the denominator. it is not necessary to know what those values are as they can be computed by another operation.
the DIVISION operation is defined for convenience for dealing with queries that involve universal quantification or the all condition. most rdbms implementations with sql as the primary query language do not directly implement division. sql has a roundabout way of dealing with the type of query.
[cite:@elmasri_db_2015 chapter 8.3.4 the DIVISION operation]
attr(R/S)=attr(R)-attr(S)