Hello together,
we are designing a protocol system for an invoice handling software system.
Within the life cycle of an invoice, many so called protocol entries are created (about 50)
for example:
- invoice uploaded
- invoice edit
- invoice checked for virus
- invoice paid
- invoice changed ( {newAmount:100$}…)
I want to monitor all this protocol entries for an invoice.
Our system will serve many millions of invoices and there for even more protocol entries
My big question is, how to store that protocol entries in mongodb.
There are two main ideas:
(1)
a mongo db document represents a protocol entry
{
"action_datetime": "2007-12-03T10:15:30+01:00",
"issuer": "myusername-for-compliance",
"action_trigger": "approval",
"action_name": "changed",
"details": {
"new_amount": 123.45
},
"object_id": "12345678-1234-5678-12345-12345678912345",
"object_type": "document"
}
(2)
a mongo db document represenets an invoice and has a set of protocol entries
{
"invoice_id": "ABC45678-1234-5678-12345-12345678912345",
"protocol_entries":
[
{
"action_datetime": "2007-12-03T10:15:30+01:00",
"issuer": "myusername-for-compliance",
"action_trigger": "approval",
"action_name": "changed",
"details": {
"new_amount": 123.45
},
"object_id": "12345678-1234-5678-12345-12345678912345",
"object_type": "document"
},
{
"action_datetime": "2007-12-03T10:15:30+01:00",
"issuer": "myusername-for-compliance",
"action_trigger": "payment_system",
"action_name": "paid",
"details": {
"iban": "..."
},
"object_id": "12345678-1234-5678-12345-12345678912345",
"object_type": "document"
}
]
}
Using (1) will cause only an insert for a new protocol entry with a reference field to invoice
Using (2) will cause a read and an update
Can you give me a hint where mongodb performs better?