This question is a follow up question to the one posted here:
Firestore: Clients and invoices, how to model it
I am trying to understand the thought process behind modelling evolving requirements in Firebase/Firestore.
Assuming the accepted answer was used for the model, then 2 months you get a new requirement after the app has been released. Now the requirement says: We need to get the invoice detail (not only id but the full details) for user whose last name is xyz.
How can model this assuming the database/app has been live for 2 months (so there is data in there already). The last name is already an attribute of the user details.
Thank you
According to the requirements that we see in this post, which I understand are mandatory in your project:
and
The most appropriate schema that can I recommend you, is the one in which you should add a new property called
userId
, beneath eachinvoice
object.So please consider using this tehnique, which is actually called a the reverse lookup. It will help you query your database more easily and will also help you solve both problems.