-2

I was trying to develop an mobile app which have some similar idea just like Uber, which is real time update driver & customer location. So here I am seeking for suggestion for what I was thinking for the app structure.

For what I research, in order to provide fast real time update location, I may need to make use of real time database such as Firebase for the backend. So, I was thinking to combine 2 different type of database to achieve what I was thinking...

Firebase - For real time fast update user location MySQL - For backend api business logic

However, I have no experience with firebase, so I hope you all can give some advise. I plan to only store the user location coordinate information in firebase database, then retrieve it from mobile app to update realtime.

My problem is I not sure should I forever persist those driver coordinate data in firebase database? Since the coordinate data keep changing update in firebase, so should I delete those coordinate data from firebase as soon as the driver have reach the destination. (No need to keep those data persist, only real time data keep change on firebase)

Thanks for reading such long question, I will also happy that if you all can remind to me any other concern if I use 2 different database for my application.

Shinance
  • 161
  • 3
  • 12

1 Answers1

1

You'll typically keep a list of drivers and their locations in Firebase:

driverlocations
  driver1id: location
  driver2id: location

This means that you're not adding new data, but updating existing data. So you don't have to worry about the list constantly growing.

To ensure you don't have stale data for drivers that closed the app/stopped driving, you can use Firebase's onDisconnect() handlers to remove the data when they disconnect.

Now querying this data for nearby drivers is still tricky. You'll want to look at GeoFire for that. I recently explained why that is needed and how it works here: Sort array by distance near user location from firebase

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Hi, thanks for your suggestion! Your knowledge has clear my doubt ^^ I will definitely take a look for the link you provided. I know it was not an easy task, but I always like to learn, hopefully I can understand how it work... – Shinance Dec 03 '17 at 00:52