Show how to express the relational operators of projection, selection, Cartesian product, natural join, union, and set-di?erence using Datalog.
What will be an ideal response?
Projection on the ?rst and third arguments of relation Rel with four attributes:
Projection(?A,?C) :- Rel(?A,?B,?C,?D).
Selection on the second attribute of the form ?B=1 and ?B > 12:
Selection1(?A,1,?C,?D) :- Rel(?A,1,?C,?D).
Selection2(?A,?B,?C,?D) :- Rel(?A,?B,?C,?D), ?B > 12.
Cartesian product and natural join (for join, we assume that the second attribute of Rel1 has the same name as the ?rst attribute of Rel2:
Product(?A,?B,?X,?Y,?Z) :- Rel1(?A,?B), Rel2(?X,?Y,?Z).
Join(?A,?B,?Y,?Z) :- Rel1(?A,?B), Rel2(?B,?Y,?Z).
Union and set-di?erence:
Union(?A,?B) :- Rel1(?A,?B) ; Rel2(?A,?B).
Difference(?A,?B) :- Rel1(?A,?B), not Rel2(?A,?B).
Computer Science & Information Technology
You might also like to view...
A(n) ________ chart displays two different types of data using multiple chart types in a single chart
Fill in the blank(s) with correct word
Computer Science & Information Technology
?To check how data is collected and used when you are on their sites, you can check the Facebook Data Policy page or the Google _____ page.
A. ?Privacy Basics B. ?Privacy Policy C. ?My Account D. ?LinkedIn
Computer Science & Information Technology