0

I am trying to create a List or Snapshot that is comprised of message posts uploaded by the people a user is following.

or in other terms:

"create a user feed generated by the people you are following."

Within firebase there are three tables ( I know they are not referred to as tables, but i'm coming from a SQL background)

My intentions were to keep the data shallow, based on things i've read, i'm assuming this is a good practice. I also made the Keys in the Following table and Followers table the UIDs of the users.

The UIDs is also stored as part of the POST in the Posts table. I assumed that the UID could be used to link the data across a these tables.

I have 2 main questions?:

  1. Does the structure of the data need to be changed to make this work in Firebase?

  2. If not, I understand that joins are not a feature of Firebase, but I assume there is an alternative or work around. What would that query look like?

M.Write
  • 31
  • 2

1 Answers1

0

As you've seen Firebase Database does not support server-side joins, like what you're used to in SQL.

If you need data from multiple entities in a single place in your app, yYou have two broad options:

  1. Duplicate the data for the entities into a single place, that you then listen to.
  2. Reading the data from multiple locations, as your app needs it, or by caching part of it.

There is no single answer on what is better. It all depends on the needs of your app, your comfort level with either approach, and personal preference.

There are some good sources to learn more about this:

And probably some of my previous answers, like:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807