Question
Suppose we have a relation SocialNetwork(Person, Friend) which gives immediate friends of a person. A person may have many friends. This SocialNetwork relation is similar
Suppose we have a relation SocialNetwork(Person, Friend) which gives immediate friends of a person. A person may have many friends. This SocialNetwork relation is similar to Twitter in that friendship relationship is not necessarily bi-directional. This implies that if a tuple of SN says that A is a friend of B, then it does not imply that B is a friend of A. If B is a friend of A, which is possible, then it will be identified by another tuple. We want to define a recursive relation Follows whose pairs (p,f) are persons such that f was either a friend of p, or a friend of a friend, or so on.
c) Write a recursive SQL query that returns the set of pairs (p,f) such that f is a follow-on of p, but is neither a friend nor a friend of a friend.
d) Write a recursive SQL query that returns the set of pairs (p,f) such that f is a follow-on of p but f has at most one friend.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started