W
W
wawa2018-04-14 17:57:12
Django
wawa, 2018-04-14 17:57:12

How to present time series data if using ORM?

I am using Django.
In terms of business logic, there is an object A with characteristics a1,a2,a3...
It perfectly fits the ORM idea - a corresponding model A is created and it is perfectly mapped into the "a_table" table in the RDBMS (Postgres). Also, at the request of the business logic, a history of changing one certain characteristic x for each object A is needed. At the RDBMS level, everything is simple - a table is created with three fields (a_id, value, change_time). But it is not clear how this should be represented at the application level with ORM. Creating a "Change in Characteristics x" model seems ridiculous. Still, models should represent objects of business logic, and it operates with the concept of "time series" and does not allocate points in this series somehow separately into objects.
Actually, I repeat the question: how is it customary to present such data in a system with ORM?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-04-14
@wawa

As you understand, so imagine.
A model in jung does not mean business logic, it means, in fact, a table in the database. In addition to your option, the database can easily contain tables with lists, for example, cities, countries, currencies, colors, or characteristics.
The only thing you can do with Dzhang is that it seems to be not obvious. This is to override the Save () method of model A and check. If the object already exists (that is, the object is being updated, not created), then before saving, reset the old values ​​\u200b\u200bin your "ChangeOptions" which consists of fields (link to A, old_value and DataTime).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question