Reputation: 739
Suppose I am creating a transaction app.
How will I store transactions?
I know I need to denormalize.
Would I save the transaction within a transaction node at the first db level? Or would i save the transaction node under each user's node? Or would i save it in both the transaction node on the first level and the transaction node under each user's node?
What if the user changed their name, how would I reflect these changes in both the transaction history of the user and the business?
I feel like the best way is to put it in just the first level of the database and have the user's query the entire list to see their transaction history.
But, If i have a lot of users wouldn't this be extremely slow?
Or is firebase smart enough and fast enough to handle such queries.
Does the user's internet speed affect this querying, especially on a mobile device?
Can you display the transaction on the screen as it is being loaded?
Would firebase indexing allow me to do these very large dataset queries easily? Perhaps indexing a user's username that is contained inside each transaction?
Upvotes: 2
Views: 922
Reputation: 5821
First, rather than filtering history of transaction data using username
I would suggest using userId
which will never changed and always unique.
Second, I think saving the transaction globally (without using '/userId'
) is better. Because :
limitToFirst()
just like pagination in web (infinite scroll in android). There is great tutorial hereUpvotes: 2