Database Reference
In-Depth Information
Chapter 8. Social Networking
In this chapter, we'll explore how you could use MongoDB to store the social graph for a so-
cial networking site. We'll look at storing and grouping followers as well as how to publish
events to different followers with different privacy settings.
Solution Overview
Oursolution assumes a directed social graphwhere ausercan choose whether ornottofollow
another user. Additionally, the user can designate “circles” of users with which to share up-
dates, in order to facilitate fine-grained control of privacy. The solution presented here is de-
signed in such a way as to minimize the number of documents that must be loaded in order to
display any given page, even at the expense of complicating updates.
The particulars of what type of data we want to host on a social network obviously depend on
the type of social network we're designing, and is largely beyond the scope of this use case.
In particular, the main variables that you would have to consider in adapting this use case to
your particular situation are:
What data should be in a user profile?
This may include gender, age, interests, relationship status, and so on for a “personal” so-
cial network, or may include resume-type data for a more “business-oriented” social net-
work.
What type of updates are allowed?
Again, depending on what flavor of social network you are designing, you may wish to
allow posts such as status updates, photos, links, check-ins, and polls, or you may wish to
restrict your users to links and status updates.
Schema Design
In the solution presented here, we'll use two main “independent” collections and three “de-
pendent” collections to store user profile data and posts.
Search WWH ::




Custom Search