Skip to Content
MongoDB Applied Design Patterns
book

MongoDB Applied Design Patterns

by Rick Copeland
March 2013
Intermediate to advanced
174 pages
3h 58m
English
O'Reilly Media, Inc.
Content preview from MongoDB Applied Design Patterns

Chapter 8. Social Networking

In this chapter, we’ll explore how you could use MongoDB to store the social graph for a social 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

Our solution assumes a directed social graph where a user can choose whether or not to follow another user. Additionally, the user can designate “circles” of users with which to share updates, in order to facilitate fine-grained control of privacy. The solution presented here is designed 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” social network, or may include resume-type data for a more “business-oriented” social network.
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

MongoDB Fundamentals

MongoDB Fundamentals

Amit Phaltankar, Juned Ahsan, Michael Harrison, Liviu Nedov, Sam Anderson
MongoDB Basics

MongoDB Basics

David Hows, Peter Membrey, Eelco Plugge
MongoDB in Action, Second Edition

MongoDB in Action, Second Edition

Tim Hawkins, Kyle Banker, Shaun Verch, Douglas Garrett, Peter Bakkum
MongoDB: The Definitive Guide

MongoDB: The Definitive Guide

Kristina Chodorow, Michael Dirolf

Publisher Resources

ISBN: 9781449340056Errata Page