Liked Pages

Start Timer

0:00:00

Upvote
50
Downvote
Save question
Mark as completed
View comments (90)

Let’s say we want to build a naive recommender. We’re given two tables, one table called friends with a user_id and friend_id columns representing each user’s friends, and another table called page_likes with a user_id and a page_id representing the page each user liked.

Write an SQL query to create a metric to recommend pages for each user based on recommendations from their friend’s liked pages. 

Note: It shouldn’t recommend pages that the user already likes.

Example:

Input:

friends table

Column Type
user_id INTEGER
friend_id INTEGER

page_likes table

Column Type
user_id INTEGER
page_id INTEGER

Output:

Column Type
user_id INTEGER
page_id INTEGER
num_friend_likes INTEGER
.
.
.
.
.


Comments

Loading comments