Report
Graph Databases
CS341 Distributed Information Systems
ed in further rec-
ommendations for Pizza places. The figure shows one possible (graphical) solution by
looking at other user’s recommendations based on Alex’ favorites.
Figure 1: An example graph illustrating a graphical solution for finding additional rec-
ommendations for user Alex based on his existing recommendations.
user recommends
Alex C
Alex D
Luke D
Luke E
Table 1
Table 1 shows the recommends edges for the presented graph in a relational database.
By a simple lookup, we find all recommendations of Alex. Then, we have to reach
other users that recommended the same places (Luke in our case). This is done by
self-joining the table. Now, we again have to use a self-join to ‘traverse’ from Luke to his
recommendations. The following SQL query shows a possible solution:3
SELECT * FROM recommendations r1
JOIN recommendations r2 ON
r2. user <> r1. user AND
r2. recommends = r1. recommends
JOIN recommendations r3 ON
r3. user = r2. user
Notice that the filtering of already r
图数据库原理 来自淘豆网www.taodocs.com转载请标明出处.