Database Reference
In-Depth Information
Figure 8.4. A social network of users and movies they like
What we want to do now is find all movies that John's direct contacts (both friends and
work colleagues) like. Looking at
figure 8.4
,
you'd expect the result to contain the movies
Fargo
and
Alien
.
Top Gun
shouldn't be part of the result as it's liked by John himself.
Godfather
and
Great Dictator
shouldn't be part of the result because only John's friends'
friends like them (and you only want the movies liked by John's direct contacts).
The following listing illustrates the traversal implementation.