Phase I: (Due: 29 April, 2012 - Sunday)
Electronic submission under phase3
Complete the implementation of the Datalog/DatalogQ interpreter by writing
code to execute Datalog/DatalogQ queries and displaying the answer to the
query. A sample run is shown below:
[raj@tinman phase3]$ java DLOG company type "help;" for usage... Message: Database Provided: Database Directory is ./company DLOG> @q1; ----------INPUT QUERY---------------- ANSWER(F,M,L) :- EMPLOYEE(F,M,L,S,_,_,_,_,_,5), WORKS_ON(S,P,H), PROJECTS('ProductX',P,_,_), H >= 21. ------------------------------------ ANSWER Relation is: Number of tuples = 1 John:B:Smith: DLOG> @q2; ----------INPUT QUERY---------------- ANSWER(F,M,L) :- EMPLOYEE(F,M,L,S,_,_,_,_,_,_), DEPENDENT(S,F,_,_,_). ------------------------------------ ANSWER Relation is: Number of tuples = 1 Alec:C:Best: DLOG> @q3; ----------INPUT QUERY---------------- ANSWER(F,M,L) :- EMPLOYEE(F,M,L,_,_,_,_,_,S,_), EMPLOYEE('Franklin',_,'Wong',S,_,_,_,_,_,_). ------------------------------------ ANSWER Relation is: Number of tuples = 3 John:B:Smith: Ramesh:K:Narayan: Joyce:A:English: DLOG> @q4; ----------INPUT QUERY---------------- TEMP1(S,P) :- EMPLOYEE(_,_,_,S,_,_,_,_,_,_), PROJECTS(_,P,_,4). TEMP2(S,P) :- WORKS_ON(S,P,_). TEMP3(S) :- TEMP1(S,P), not TEMP2(S,P). ANSWER(F,M,L) :- EMPLOYEE(F,M,L,S,_,_,_,_,_,_), not TEMP3(S). ------------------------------------ ANSWER Relation is: Number of tuples = 2 Alicia:J:Zelaya: Ahmad:V:Jabbar: DLOG> @q5; ----------INPUT QUERY---------------- TEMP1(S) :- WORKS_ON(S,_,_). ANSWER(F,M,L) :- EMPLOYEE(F,M,L,S,_,_,_,_,_,_), not TEMP1(S). ------------------------------------ ANSWER Relation is: Number of tuples = 2 Bob:B:Bender: Kate:W:King: DLOG> @q6; ----------INPUT QUERY---------------- TEMP1(S) :- WORKS_ON(S,P,_), PROJECTS(_,P,'Houston',_). TEMP2(S) :- EMPLOYEE(_,_,_,S,_,_,_,_,_,D), not DEPT_LOCATIONS(D,'Houston'). ANSWER(F,M,L,A) :- EMPLOYEE(F,M,L,S,_,A,_,_,_,_), TEMP1(S), TEMP2(S). ------------------------------------ ANSWER Relation is: Number of tuples = 1 Jennifer:S:Wallace:291 Berry, Bellaire, TX: DLOG> @q7; ----------INPUT QUERY---------------- TEMP1(S) :- WORKS_ON(S,P,_), PROJECTS(_,P,'Houston',_). TEMP2(S) :- EMPLOYEE(_,_,_,S,_,_,_,_,_,D), not DEPT_LOCATIONS(D,'Houston'). ANSWER(F,M,L,A) :- EMPLOYEE(F,M,L,S,_,A,_,_,_,_), TEMP1(S). ANSWER(F,M,L,A) :- EMPLOYEE(F,M,L,S,_,A,_,_,_,_), TEMP2(S). ------------------------------------ ANSWER Relation is: Number of tuples = 38 James:E:Borg:450 Stone, Houston, TX: Franklin:T:Wong:638 Voss, Houston, TX: Jennifer:S:Wallace:291 Berry, Bellaire, TX: Ramesh:K:Narayan:971 Fire Oak, Humble, TX: Alicia:J:Zelaya:3321 Castle, Spring, TX: Ahmad:V:Jabbar:980 Dallas, Houston, TX: Jared:D:James:123 Peachtree, Atlanta, GA: Alex:D:Freed:4333 Pillsbury, Milwaukee, WI: John:C:James:7676 Bloomington, Sacramento, CA: Jon:C:Jones:111 Allgood, Atlanta, GA: Justin:null:Mark:2342 May, Atlanta, GA: Brad:C:Knight:176 Main St., Atlanta, GA: Evan:E:Wallis:134 Pelham, Milwaukee, WI: Josh:U:Zell:266 McGrady, Milwaukee, WI: Andy:C:Vile:1967 Jordan, Milwaukee, WI: Tom:G:Brand:112 Third St, Milwaukee, WI: Jenny:F:Vos:263 Mayberry, Milwaukee, WI: Chris:A:Carter:565 Jordan, Milwaukee, WI: Kim:C:Grace:6677 Mills Ave, Sacramento, CA: Jeff:H:Chase:145 Bradbury, Sacramento, CA: Bonnie:S:Bays:111 Hollow, Milwaukee, WI: Alec:C:Best:233 Solid, Milwaukee, WI: Sam:S:Snedden:987 Windy St, Milwaukee, WI: Nandita:K:Ball:222 Howard, Sacramento, CA: Bob:B:Bender:8794 Garfield, Chicago, IL: Jill:J:Jarvis:6234 Lincoln, Chicago, IL: Kate:W:King:1976 Boone Trace, Chicago, IL: Lyle:G:Leslie:417 Hancock Ave, Chicago, IL: Billie:J:King:556 Washington, Chicago, IL: Jon:A:Kramer:1988 Windy Creek, Seattle, WA: Ray:H:King:213 Delk Road, Seattle, WA: Gerald:D:Small:122 Ball Street, Dallas, TX: Arnold:A:Head:233 Spring St, Dallas, TX: Helga:C:Pataki:101 Holyoke St, Dallas, TX: Naveen:B:Drew:198 Elm St, Philadelphia, PA: Carl:E:Reedy:213 Ball St, Philadelphia, PA: Sammy:G:Hall:433 Main Street, Miami, FL: Red:A:Bacher:196 Elm Street, Miami, FL: DLOG> @q8; ----------INPUT QUERY---------------- TEMP1(S) :- DEPENDENT(S,_,_,_,_). ANSWER(L) :- EMPLOYEE(_,_,L,S,_,_,_,_,_,_), DEPARTMENT(_,_,S,_), not TEMP1(S). ------------------------------------ ANSWER Relation is: Number of tuples = 2 Borg: James: DLOG> exit; [raj@tinman phase3]$ java DLOG movies type "help;" for usage... Message: Database Provided: Database Directory is ./movies DLOG> @m1; ----------INPUT QUERY---------------- ANSWER(A) :- ACTOR([*]:MOVIE(*),A). ------------------------------------ ANSWER Relation is: Number of tuples = 1 Marlon Brando: DLOG> @m2; ----------INPUT QUERY---------------- ALLMOVIESACTOR(A) :- ACTOR([*]:MOVIE(*),A). ANSWER(A) :- ACTOR(_,A), not ALLMOVIESACTOR(A). ------------------------------------ ANSWER Relation is: Number of tuples = 3 Al Pacino: Robert Duvall: James Caan: DLOG> @m3; ----------INPUT QUERY---------------- APERSON(A) :- ACTOR(_,A). R(A,D) :- ACTOR(T,A), DIRECTOR(T,D). ANSWER(D) :- R([*]:APERSON(*),D). ------------------------------------ ANSWER Relation is: Number of tuples = 1 Francis Ford Copolla: DLOG> @m4; ----------INPUT QUERY---------------- ANSWER(A1,A2) :- ACTOR([*]:ACTOR(*,A2),A1), ACTOR([*]:ACTOR(*,A1),A2), A1 < A2. ------------------------------------ ANSWER Relation is: Number of tuples = 1 Al Pacino:Robert Duvall: DLOG> @m5; ----------INPUT QUERY---------------- FFCMOVIE(T) :- DIRECTOR(T,'Francis Ford Copolla'). ANSWER(A) :- ACTOR([#]:FFCMOVIE(#),A). ------------------------------------ ANSWER Relation is: Number of tuples = 1 James Caan: DLOG> d director; DIRECTOR(TITLE:VARCHAR,DNAME:VARCHAR) Number of tuples = 4 The Godfather I:Francis Ford Copolla: Gone With The Wind:Victor Fleming: Taxi Driver:Martin Scorcese: The Godfather II:Francis Ford Copolla: DLOG> d actor; ACTOR(TITLE:VARCHAR,ANAME:VARCHAR) Number of tuples = 10 The Godfather I:Al Pacino: Gone With The Wind:Al Pacino: The Godfather I:Marlon Brando: Gone With The Wind:Marlon Brando: Taxi Driver:Marlon Brando: The Godfather II:Marlon Brando: The Godfather I:Robert Duvall: Gone With The Wind:Robert Duvall: The Godfather I:James Caan: The Godfather II:James Caan: DLOG> d movie; MOVIE(TITLE:VARCHAR) Number of tuples = 4 The Godfather I: Gone With The Wind: Taxi Driver: The Godfather II: DLOG> exit; Exiting...