Grokking the System Design Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Could you elaborate a bit on the following:"If we go with a NoSQL database, we n...

JC Denton

Jan 10, 2022

Could you elaborate a bit on the following:

"If we go with a NoSQL database, we need an additional table to store the relationships between users and photos to know who owns which photo. Let’s call this table ‘UserPhoto’"

The Photo collection has a reference to userId, so I am guessing you could filter on that field without a UserPhoto table. Is the UserPhoto table an optimization?

6

0

Comments
Comments
D
DogBiscuit 4 years ago

The diagram is a little mixed up. The db schema diagram would be for a rdbms. With a nosql key value store, there's no user id field. Just key for photoid, and object as photo data

A
Aruna Kalagnanam4 years ago

Even for a NoSQL database, say, DynamoDB, it is possible to have a photoId as the primary key and still be able to filter on the userId attribute.

P
Prabhakar 4 years ago

To filter on userID, we may need something like DynamoDB 'Global Secondary Index' to be able to query on it. Is that right?

A
Aruna Kalagnanam4 years ago

Yes, with a Global Secondary Index, DynamoDB will allow a query by userId (partition key for the GSI) and will retrieve a list of photos for that userid.

On this page

  1. What is Instagram?

Try it yourself

Designing Instagram (video)

  1. Requirements and Goals of the System
  1. Some Design Considerations
  1. Capacity Estimation and Constraints
  1. High Level System Design
  1. Database Schema
  1. Data Size Estimation
  1. Component Design
  1. Reliability and Redundancy
  1. Data Sharding
  1. Ranking and News Feed Generation
  1. News Feed Creation with Sharded Data
  1. Cache and Load balancing