Message History Logs Structure

For context, I have created a chat app that allows users and clients to message each other via Viber. Essentially, what I’m doing is setting up an API Endpoint to capture messages from clients using a webhook. Afterward, I save these messages in my Bubble database. Additionally, I save the messages sent by users via the app itself.

Here’s how my structure looks:

Message

  • User Message (text)
  • Client Message (text)
  • Mobile Number (text)
  • Conversation Header (Conversation)

Conversation

  • Client Messages (List of Messages)
  • User Messages (List of Messages)
  • Mobile Number (text)

I save the data I capture from client messages and the data I send from the user’s messages in the Message Table. Then, I add this data to the Conversation Table. This way, when I want to display the conversation history in RG, I can easily access the Conversation Table since it’s already grouped by Mobile Number.

My questions are:

  1. Is my database structure a good approach?
  2. Is this efficient, considering potential slowdowns due to large data in the future?

“Client Messages” and “User messages” are of type “list of things”, which is not a very good idea since it is not scalable.

FYI there is a hard limit to the max size of a list of things. It can not exceed 10000 things.
The hard limit is not the only downfactor to your approach. Your conversation object will also become heavier and heavier the more references to messages it needs to store. And last but not least, a databse querry is always faster than searching through a list of things.

One better approach would be to have in each message a referrence to the conversation.
So that you can do a search for relevant messages with something like :