How to create the database schemas for our Firebase shopping app? — Part 2

A tutorial for creating the Cloud Firestore and the Realtime Database structure for the e-commerce app.

Alex Mamo
Firebase Tips & Tricks

--

This is the second part of our series. In the first part, we met FireMag, an Android shopping application completely built with Firebase and Jetpack Compose. We’ve seen all functionalities, and now it’s time to understand what the database structures look like behind the scenes. I said “structures”, because we’ll use Cloud Firestore, as well as the Realtime Database in the same project. Because each database has a different billing mechanism, we’ll use the Realtime Database when having lower bandwidth and storage usage, and Firestore when we have to deal with fewer reads, writes, and deletes. We’ll also take a look at what the directory structure looks like in Cloud Storage for Firebase, where have uploaded all the images that are used in our application.

Let’s get started with auth screen. Since in order to be able to use the app, we need to authenticate the users first, we have to write the user data in the database. For that I choose to create a collection of users in Firestore that has the following structure:

db-root
|
--- users (collection)
|
--- $uid (document)
|…

--

--