We’ve a Point of Sale mobile app. On average, our users record 150 transactions per day (mobile payments).
We’re discussing about our Data Model and the main question is, Should we create one document per transaction or append transaction within a particular document, for example per day? Our biggest concern is about performance (app speed) for creating and query documents.
Given this use case: there is a “Sales Report” that shows all transactions (date, amount, ticket id, etc…) sort by timestamp. The user can changes the dates range.
Scenario 1: one document per transaction
- I’ll work with 150 documents per day (about 1,000 doc for a whole week). The mapping function will take longer, at least the first time if there is a lot documents without index.
- Easy to get the transactions details.
Scenario 2: one document per day with all transaction appended within an array.
- I’ll work with a few documents.
- More complex to I will need more logic to push and pull transactions.
- it’ll consume more data traffic. Everytime I add a new transactions, the whole document will be sync.
- It seems to be faster for query because I just work with a few documents?
Given your experience, what scenario do you recommend? Any suggestion?