Design Twitter Are joins required?


Q: Are joins required?


Yes. For Example, when you’re fetching all the followers of a User, there is a separate table that maintains follower relation, so you’ll have to join the user table with the followers table to get the required data.


not sure why we are going with mysql when it can be easily done using nosql.
we can have the following documents in mongo to support our tweet system-

  1. User- {id, name: string, age: int, address: string , password: string, followers: [ ]}
  2. post- {id, user_id, timestamp, likes: int, share_cnt: int, liked_by: [ ] }
    we can store user details in a cache so that user profile and user details queries are not repeated frequently.
    Talking about how to read data -
  • to get all user followers, we can get by querying “User” table.
  • to get all user post, likes, etc- we can filter based on user_id.

Please tell me what am i thinking wrong ?