Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 6 2 pts Consider the schema described below where bold face attributes indicate primary keys. Suppose this is a simplified schema for a social

image text in transcribed

Question 6 2 pts Consider the schema described below where bold face attributes indicate primary keys. Suppose this is a simplified schema for a social network. person(person_id, name, startdate) message( message_id, person_id, topic, date) group(group_id, topic) groupmember(group_id, person_id) likes(message_id, person_id) A pair of persons have similar interests if they are a member of the same group and like the same message, or if they have similar interests to the same (third) person. A person does not have similar interests to themselves. Which of the following Datalog queries correctly represents: Find all pairs of person names for all people with similar interests? same group(X, Y) :- groupmember(G, X), groupmember(G, Y) same_message(X,Y) :- likes(M, X), likes( MY) same interests(X,Y) -- same group(X,Y), same_message(X,Y) same interests(X,Y):- same interests(X. Z), same_interests(Z.Y) result(X, Y):- same_interests(A, B), person(A, X, SD1), person(B, Y, SD2) ?result(X,Y) same group(X, Y):- groupmember(G, X).groupmember(GY), X !=Y same_message(X, Y):- likes(M. X), likes( MY). X != Y same_interests(X,Y) - same_group(X,Y), same_message(X,Y) same interests(X,Y):- same interests(X, Z). same interests(Z.Y) ?same_interests(X, Y) same_group(X,Y) :- groupmember(G, X).groupmember(G, Y). X !=Y same message(X,Y):- likes/M, X), likes(M.Y). X != Y same interests(X,Y):- same_group(X,Y), same_message(X,Y) same_interests(X, Y):- same_interests(X, Z), same_interests(Z.Y) result(X,Y) :- same interests(A, B). person(A. X. SD1), person(B, Y. SD2) ?result(X,Y) same_group(X, Y):- groupmember(G,A), groupmember(G. B), person(A. X, SD1), person(B, Y, SD2) same message(X, Y):- likes(M. A), likes(M. Bp. person(A. X. SD1), person(B. Y, SD2) same_interests(X, Y):- same_group(X, Y), same_message(X,Y) same interests(X,Y):- same interests(X, Z). same interests(z. Y) ?same_interests(X,Y)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions