0
21kviews
Explain Division Operator.
0
639views
• As the name of this operation implies, it involves dividing one relation by another. - The division operator is used for queries which involve the ‘all’qualifier such as “Find the names of sailors who have reserved all boats”.
• Let A have 2 fields, x and y; B have only field y:

• A/B = $(\lt x \gt| \exists \lt x, y \gt \epsilon A \forall \lt y \gt \epsilon B)$
• i.e., A/B contains all x tuples (sailors) such that for every y tuple (boat) in B, there is an xy tuple in A.
• Or: If the set of y values (boats) associated with an x value (sailor) in A contains all y values in B, the x value is in A/B.
• In general, x and y can be any lists of fields; y is the list of fields in B, and x y is the list of fields of A

• The division operator is a bit tricky to explain, and perhaps best approached through examples as will be done here. Figure 1 explains that when the division operation is performed, it will retrieve only those lecturer from relation R who has taken a subject “Prolog” from relation S. Figure 2 explains that when the division operation is performed, it will retrieve only those lecturer from relation R who has taken a subject “Prolog” and “Database” from relation S. - Example: • Interpretation of the division operation A/B:
• Divide the attributes of A into 2 sets: A1 and A2.
• Divide the attributes of B into 2 sets: B2 and B3.
• Where the sets A2 and B2 have the same attributes.
• For each set of values in B2:
• Search in A2 for the sets of rows (having the same A1 values) whose A2 values (taken together) form a set which is the same as the set of B2’s.
• For all the set of rows in A which satisfy the above search, pick out their A1 values and put them in the answer.