Data Types
So, how we are going to store and model this data in our database. We know we’re going to need a few key tables and features like users, and messages and we are also going to probably need this concept of conversations, which will be groups of users who are supposed to receive messages.
- Starting with the user’s table, we are going to have a unique ID for this user. We are also going to have something like a username or a name for them to display and a last active timestamp.
- We are going to need a messages table and this is going to have a unique ID but it is also going to store a reference to the user who made the message
- We are also going to have a reference or an ID for the conversation that it belongs to.
- We are also going to need the text of the message as well and if we want to support something like media uploads like images or videos we also want to store a media URL here in our database as well.
- This won’t be the actual data but it will be the URL where the user can access this data to download it.
The last thing we need is a way to query and understand which users are part of a conversation and which conversations a user is part of. So for that, we are going to add one more table which we are going to call conversation_users and it’s just going to store the mapping from a conversation id to our user id.
Designing Facebook Messenger | System Design Interview
We are going to build a real-time Facebook messaging app, that can support millions of users. All the chat applications like Facebook Messenger, WhatsApp, Discord, etc. can be built using the same design. In this article, we will discuss the high-level architecture of the system as well as some specific features like building real-time messaging, group messaging, image and video uploads as well and push notifications.
Important Topics for Facebook Messenger System Design
- Requirements
- Design of Facebook Messenger
- Communication Protocol for Facebook Messenger
- API Used for Facebook Messenger
- Database Design for Facebook Messenger
- Data Types
- Scalability for Facebook Messenger
- Conclusion
Contact Us