Choosing Database Systems & Sharding Schemes for Twitter Data Models

I was practicing twitter's system design, I came up with high level table schemas and access patterns for them. , I was thinking of using existing systems like MySQL, MongoDb, Cassandra, DynamDb But I can't decide which database system will be good for storing what type of data.

Below is what I came up with. I would really appreciate If someone can map table to database and may be put some explanation.

Schema

User

  • Username
  • Email
  • Country
  • Location
  • Photo

Tweet

  • Id
  • Owner User::Username
  • Text content
  • Media
  • Timestamp
  • Like_id Like::id
  • Comment_id Comment::id

Comment

  • Id
  • Content
  • reply Comment::id
  • tweet_id Tweet:Id

Like

  • Id tweet:Id
  • User: Id

Follow

  • Followee_id User:id
  • Follower:id User::id

Table Access Patterns

User

  • Fetch user data from user name

Tweet

  • Fetch All the tweets for the user

Comment

  • Fetch all the comments by tweet id
  • Fetch all the replies by comment id

Like

  • Fetch count of like for tweet id
  • Fetch all user by tweet id

Timeline Generation

  • Follow Table :: Fetch all the user ids followed by user
  • Tweet Table :: Fetch all the tweets made by all this users whose timestamp is greater than X
Comments (0)