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 940229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:55:15+00:00 2026-05-15T21:55:15+00:00

I’m designing a Core Data app which needs to keep dated records. Imagine a

  • 0

I’m designing a Core Data app which needs to keep dated records.

Imagine a user works with the program for a while and some records are stored. The user then changes important attributes and relationships (which transcend individual records), and continues using the program with this new configuration. Imagine now that the user looks back to the first records. I’d like to somehow store the old configuration so that, when the user is looking at any given record, the changed data (which, I repeat, transcends individual records) looks as it did when the record was written. (Note that the types of changes that need to be recorded are very infrequent.)

  1. Storing a copy of the entire object graph, filed by date, each time a change is made, is obviously terrible (though it would provide the behavior I seek, if my description above was incomprehensible).

  2. I considered storing only the changed objects each time, and deriving the up-to-date graph for any given record by collating all previous time periods. (If this were the case, how would I keep track of the lack of an object in a to-many relationship, I wondered? And would I be able to write something for NSManagedObject in general, or would I need to add this feature to each relevant entity?)

Is there a simpler or better way to do this sort of date-relative data storage?

  • 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-15T21:55:16+00:00Added an answer on May 15, 2026 at 9:55 pm

    Since you need to store the old relationships as well as individual objects, you really don’t have a choice but to save a snapshot of the old object graph in some fashion.

    There are several options for doing so:

    (1) If the changes are rare and the graph small, then saving a snapshot of the entire object graph might be the simplest and most robust solution. Why add complexity for a seldom used feature?

    (2) Use fetched relationships for all relationships. The fetch predicate will fetch on date stamp. The disadvantage of this is complexity. You have to configure a fetch for every relationship and nothing works automatically. Neither can the context enforce graph integrity as easily.

    (3) Linked stack: Each entity has a previous and a next relationship that points to the previous and next version of itself. When an attribute/relationship is changed, a new object and new objects for its relation targets are pushed on their respective link stacks. This would clone a big chunk of the graph every time you made a change. Finding a previous graph would be a matter of walking the previous relationship until the proper date was found.

    (4) Entities for relationships: Say you have two entities A and B. Normally, you would just have a relationship such as A<-->>B. However, you need to persist old relationships so you create an intermediate entity whose sole task is to model and track the changing relationship between A and B. So something like:

    AlinkB {
        dateStamp:Date;
        a<-->>A.theBs;
        b<<-->B.theA;
    }
    

    To find a previous relationship, you would search the relationships for the right date range. You’ll need a custom subclass for each so you automatically manage the adding and transversing of the link entities.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 454k
  • Answers 454k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you are on a Mac, you can get the… May 15, 2026 at 9:55 pm
  • Editorial Team
    Editorial Team added an answer The reason is your return false. This will work: $('#form1').live("click… May 15, 2026 at 9:55 pm
  • Editorial Team
    Editorial Team added an answer Read wiki about .NET Framework http://en.wikipedia.org/wiki/.NET_Framework and here's a book… May 15, 2026 at 9:55 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.