Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 516205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:42:25+00:00 2026-05-13T07:42:25+00:00

I’m considering using MongoDB or CouchDB on a project that needs to maintain historical

  • 0

I’m considering using MongoDB or CouchDB on a project that needs to maintain historical records. But I’m not sure how difficult it will be to store historical data in these databases.

For example, in his book “Developing Time-Oriented Database Applications in SQL,” Richard Snodgrass points out tools for retrieving the state of data as of a particular instant, and he points out how to create schemas that allow for robust data manipulation (i.e. data manipulation that makes invalid data entry difficult).

Are there tools or libraries out there that make it easier to query, manipulate, or define temporal/historical structures for key-value stores?

edit:

Note that from what I hear, the ‘version’ data that CouchDB stores is erased during normal use, and since I would need to maintain historical data, I don’t think that’s a viable solution.

P.S. Here’s a similar question that was never answered: key-value-store-for-time-series-data

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:42:26+00:00Added an answer on May 13, 2026 at 7:42 am

    There are a couple options if you wanted to store the data in MongoDB. You could just store each version as a separate document, as then you can query to get the object at a certain time, the object at all times, objects over ranges of time, etc. Each document would look something like:

    {
        object : whatever,
        date : new Date()
    }
    

    You could store all the versions of a document in the document itself, as mikeal suggested, using updates to push the object itself into a history array. In Mongo, this would look like:

    db.foo.update({object: obj._id}, {$push : {history : {date : new Date(), object : obj}}})
    
    // make changes to obj
    ...
    
    db.foo.update({object: obj._id}, {$push : {history : {date : new Date(), object : obj}}})
    

    A cooler (I think) and more space-efficient way, although less time-efficient, might be to store a history in the object itself about what changed in the object at each time. Then you could replay the history to build the object at a certain time. For instance, you could have:

    {
        object : startingObj,
        history : [
            { date : d1, addField : { x : 3 } },
            { date : d2, changeField : { z : 7 } },
            { date : d3, removeField : "x" },
            ...
        ]
    }
    

    Then, if you wanted to see what the object looked like between time d2 and d3, you could take the startingObj, add the field x with the value 3, set the field z to the value of 7, and that would be the object at that time.

    Whenever the object changed, you could atomically push actions to the history array:

    db.foo.update({object : startingObj}, {$push : {history : {date : new Date(), removeField : "x"}}})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.