Follow action schema for Mongo DB

Schema design for twitter like follow action with MongoDB

It has been asked so many times on stack overflow and other tech blogs. And there are many effectively solutions are already there. Just consider it YASS “Yet Another Schema Solution”.

  • All the schemas are a separate collection, you can name it “follow” or “what the fcuk” if you like it that way.
  • The absence of end field indicates that the user is still following and vice versa. Keeping it this way, helps you track the history without much complications.

If your followers and followee are only one data node e.g. users, this schema will work for you.

If your followers are only users but your followees can be multiple data nodes e.g. page, user etc, this schema will work for you.

If your followers and followees can be multiple data nodes e.g. page, user etc, this schema will work for you.

Well, that’s it. Enjoy ☺

Data Engineering, Data Visualization, Infrastructure Automation, Distributed systems

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store