What is the correct way to store data

Hi everyone, I am creating a chat app. and I would like to know what is the correct way to store my data.

I am currently using Firebase to store messages and this is my logic:

  1. User get the list of messages
  2. User ads a message to the list
  3. User Stores the list in Firebase
    4.Cycle repeats

For 2 or 3 users I dont think this is a problem. But I don’t think it is the best way, why whould I have to store all messages again and again? What if my data size is 50,000 records? That will take long to download and store it back will be a pain…

Does anyone have any suggestion?

Thanks!

Firebase never that problem

Do you mean, that is not actually a problem? Why would you have to retrieve all data instead just the last records?