Salman Fazal
Salman Fazal

Reputation: 587

Structure data in Firebase Firestore

I need help understanding the best approach to structure my firestore data.

I come from traditional SQL background and have a little bit of nosql mongodb background as well. I am building a small football prediction app and here is the user flow:

User:

  1. User registers/signs in
  2. They can pick a contest to join
  3. Enter their predictions every week

Admin:

  1. Create contests and add/edit games to contest every week (an api will fetch all the data like fixtures and results)
  2. Set a deadline for when users can enter their last prediction for the game week

Other:

  1. Leaderboard

Now I did create a diagram on how I would traditionally structure this data but it would be nice if someone can exaplain to me the simplest approach to structuring such an app in Firestore enter image description here

Upvotes: 0

Views: 917

Answers (1)

Mark Eccles
Mark Eccles

Reputation: 49

It looks reasonable but I would be concerned about storing the passwords in Firestore DB. Firestore should not ideally be concerned with authentication. Check Firebase Authentication for different auth options with Firebase. You'll probably end up only having to store the user ID as other information is in the User object.

Also check out Supported data types. You probably want to change varchar(x) to (UTF-8) string or byte types. Moreover, there is a reference type so you could reference the actual user document from the other tables.

One main design will be whether to use nested collections (Hierarchical Data).

You might be able to nest score under competitions.

Upvotes: 1

Related Questions