Firebase - App developing - calculate the delta without generating a high data traffic

115 views Asked by At

We are developing a social app with Firebase (swift / iOS).

We face the problem that we have two data trees and have to calculate the delta without generating a high data traffic.

Example: We have a structure cars and a structure user. The structure cars contain 100 different vehicle models. The user structure contains all vehicle models that have already been driven by the user. We now want to implement a high-performance solution in order to determine all the vehicles that have not yet been driven by a user without downloading the whole tree structure.

The number of users and the number of vehicles are growing steadily.

Does anyone have a solution approach or idea in which direction we need to think?

love, alex

1

There are 1 answers

0
Forest Kunecke On

I think they key to effectively using firebase is data duplication. So if you want to display a list of cars the user has and hasn't driven, create a separate table containing only the information displayed in that list, like the path to an image, the make & model, using unique IDs as the keys to entries in that table. You wouldn't need to know things like top speed and price until they tap into details, right? (I'm making some assumptions here though.)

Then, simply get the list of unique IDs for the cars the user already has driven, and manipulate your offline model accordingly.

Right now I'm using an external server to manage data duplication, that propagates a write operation to other places in the database when necessary. I'm on my phone right now but I think Ray Wenderlich has an article about this.