Internal storage, presented in pseudo-Rails ORM notation. DDL designates schema-upfront. JSON designates document storage.
- has_many Sensors
- metadata about maintainer (DDL)
- descriptions of attributes that sensors in the network can have (JSON)
- has_many SensorObservations
- location in lat-lon (DDL)
- attributes particular to this sensor (JSON)
- descriptions of attributes that observations from this sensor can have (JSON)
- timestamp (DDL)
- individual sensor values (JSON)
I think my main interest would be from the GET side but probably without knowing an observation ID. It would be more along the lines of wanting all observations, filtered by some combination of sensor, time, and observation type. Do you have any thoughts what that would look like?
Being duly sensitive to bikeshedding, could there be anything to separating data from metadata? It seems as if including both in every reply could involve a lot of repetition and not necessarily make it easy for the consumer (me) to detect changes in metadata. What if there were two APIs -- one to deliver data (used frequently) and one to deliver metadata (used infrequently)? This, of course, requires knowing when to call the metadata API. As a thought, what if the data API had either a flag to indicate this was the first data observation since a metadata change or the identifier (observation ID if sequential or timestamp) of the first data observation after a metadata change? That could be a trigger to the consumer to call the metadata API. Of these two, I prefer the latter approach. The former has the risk of missing the flagged data observation and then being out of sync for an extended period of time.
In either case of the above, one obviously could get more complicated by flagging different types of metadata changes instead of a simple "something changed" signal. I do not have a strong opinion on that at this point. I could cook up use cases for making this really fancy but complexity has all sorts of cost -- not least, increasing risk of error as multiple entities try to stay in sync -- and there may be something to the idea of just being told to hit the metadata API for that sensor and either reload everything or check the elements I care about and deal with any changes found.