want to log some data, in order to see change over time.
In order to conserve space, I'd store revisions, containing only changed properties, rather than the full object each time.
This would cause my tables to look somewhat like this, with content:
+-----+-----+-----+-----+-----+
| _id | name| a | b | c |
+-----+-----+-----+-----+-----+
| 1 | x | 1 | 11 | 111 |
| 2 | x | 2 | | |
| 3 | x | | 33 | |
+-----+-----+-----+-----+-----+
_id is an a unique id for that row.
name is a common identifier for the revisions,
a, b and c are data properties.
For now, this is all fine, but it starts to get complicated when I want to query this.
I'd have to write a query that would get the newest info where name is x.
This should produce:
+-----+-----+-----+-----+
| name| a | b | c |
+-----+-----+-----+-----+
| x | 2 | 33 | 111 |
+-----+-----+-----+-----+
I don't even know if that is possible, and if it is, its probably very inefficient.
Anyone got any good idea on how to tackle this?
Some SQL already store transaction logs internally
Initial table should be: _id | name | field ("a","b","c") | value
Обсуждают сегодня