educative.io

Educative

Instagram - database schema

In the DB Schema for instagram why do we need and extra table UserPhoto for storing relation between users and photos for NoSQL whereas for SQL we don’t need an extra table?

Why can’t we use the same photos table which also contain the UserID along with other details like we do for SQL Databases?

i was about to ask same question.It create lot of doubts.What i would suggest is that we dont need an y such extra table.One thing we can do is that they mentioned to store all photoid of a user in separete table.Well this is required for both sql and nosql.But it does not make sense to me.Extra table for faster search.We can create index on photos table , to allow search by user id.That is all based how much speed we need.