I am dealing with app that manages data sampled from sensors. At its most fundamental the object model is something like this:
Experiment <-->> Run <-->> Sample <--> Data
Sample –> MeasurementDescriptor
An Experiment may contain many Runs. A Run may contain many Samples (all of which were collected at the same time, have the same duration, etc. - but each of which is associated with a specific MeasurementDescriptor, e.g. “Temperature °C”, “Temperature °F”, “Pressure psi”, etc.). Finally, each Sample has one Data which is used to store the raw data. The Sample object has attributes for storing metadata like minimum, maximum, mean, etc.
The sampled data typically refers to explicit measurements like temperature, wind speed, pressure. But, when it comes to graphs or tables, there is a need to represent implicit measurements, like time.
So, I would like to have two kinds of Samples that responded to the same selectors but with one kind persisting and the other kind being transient. Why? So that I don’t end up persisting “Time s” and “Time min” and “Time hrs” for numerous Runs, when these time-based Samples are derivable. Each Run has its own period and duration.
Three possible scenarios have occurred to me:
1.) Store time-based Samples in separate Managed Object Context and, somehow, never save this context. This doesn’t sound trivially easy.
2.) When app terminates, delete all time-based Samples.
3.) Time-based Samples persist but they lack an associated Data object.
I am leaning toward option #3 but wonder if there is some Core Data mechanism that would be perfect for this kind of design.