Search code examples
mongodbdocument-databasedatabase

Using MongoDB for time-versioned documents


I have a requirement to store different objects relating to an entity and it's current state and attributes. The objects will not be homogenous so a relationship database doesn't make sense as the structures will all be so different. I will also need to link objects. Eg I will need

Main entity data Entity accessory data Current entity state

All as separate objects, but linked together. State will be updated daily, the other two rarely.

The most important thing about the requirement is the ability to pull "as-of" versions and mix and match. So I might want todays entity data, yesterdays accessory data and the latest state as of 1pm, 6 days ago.

I'm trying to decide which database platform would suit this best and for the time being I am looking at MongoDb, however I can't see a huge amount of support for the versioning, unless you have a timestamp field and use that as part of the querying, which would degrade performance substantially I imagine.

Can anyone suggest if this is a good solution for the requirement?


Solution

  • unless you have a timestamp field and use that as part of the querying, which would degrade performance substantially I imagine.

    No, it probably won't. Even time-based specialised databases use similar structure, and it's hard to imagine you will be able to pull and mix data based on date without timestamps.

    Also, with a day period of change, you are far from any space or time limits of any modern database. Unless your real challenge is elsewhere, Mongo will, as many others, do perfectly fine.