Sample Header Ad - 728x90

Should I design my Firestore database with different collections for each userId or one collection for all userIds?

0 votes
1 answer
282 views
I have a Firestore db where I have setup the structure: registrations/[userId]/symptoms/[documentId]/[some kind of document] I did like this because the user should only read its own symptoms, and therefore I thought it would be good to separate the symptoms on userId. The document has no knowledge about the userId. When I now export it to BigQuery I don't know how to get the correlation between a document and userId, maybe it is not possible. Should I instead have it like: symptoms/[documentId]/[some kind of document with a userId] And then only filter out the documents for the specific userId? What is the difference in the number of reads? I imagine that with my solution right now the user will only read the documents that is under /[userId]/, but with other solution every user has to read every document and then filter? Or is that handled by Firestore, and is not counted as a read?
Asked by matsmats (101 rep)
Nov 29, 2021, 11:11 AM
Last activity: Dec 4, 2021, 08:47 PM