0
votes

Please give me some advice on structuring data in FireStore we are going to have about 10K users for insurance using an App, logging products/tools covered and adding photos.

I have seen Hierarchic structure Firestore and subcollections , this helps but its not exactly what I wanted to ask.

Option 1: A single query/subscription Option 2: More queries/subscription but less data exchange overall as requestes can be made for individual sections

Option 1....

ClientID
  ClientData
    Name
    Address
  Product
    ProductID
    PolicyNumber
    StartDate
    ExpriyDate
  Tools
    ProductID
    PolicyNumber
    StartDate
    ExpriyDate
    Photos
      0
      1
      2
  Claims
    ClaimID
    PolicyNumber
    Date
    Photos

Option 2....

ClientData
  Name
  Address
Product
  ClientID
    ProductID
    PolicyNumber
    StartDate
    ExpriyDate
Tools
  ClientID
    ProductID
    PolicyNumber
    StartDate
    ExpriyDate
    Photos
      0
      1
      2
Claims
  ClientID
    ClaimID
    PolicyNumber
    Date
    Photos
1
Have you looked at this video on Firestore and NoSQL? - Jason Berryman
The structure is usually determined by the query patterns. Can you explain a bit more of the use cases you expect? If the client is going to need all (or most of the data) than Option 1 probably makes sense. If you are concerned about about them not accessing data they don't need, Option 2 could be better. It's hard to know the impact of multiple requests vs one large request since Firestore maintains an open connection. Often the request overhead is much higher than a bit of extra data - joelm

1 Answers

0
votes

Yes you are right, it is by query as 99% of the time it will be "where client ID =" so I guess option 1 so I can just do

firebase.database().ref('db/' + this.user.uid'...