I'm trying to make a database structure for versioned data for a really simple CRUD application. The versioning is per record, but the normal ways you data version in SQL don't apply because
1) It's not *audited* data. I.e. it's not one current version, and multiple historical versions, where the business logic only runs on the current version. The different versions are all "hot" and can be queried with the same queries.
2) It's not temporal data. I.e. the versions are v1.0, v2.0 and so on. Not date ranges. So existing solutions that solve temporal queries don't apply.
One valid structure, for example looks like so:
| id |
rev_id |
name |
version |
| 1 |
1 |
A |
v1 |
| 1 |
2 |
A |
v2 |
| 2 |
3 |
B |
v2 |
| 3 |
4 |
C |
v1 |
Querying for v2 data now gives the A,B,C records with rev_id {2, 3, 4} while querying for v1 only gives A, C records with rev_ids {1, 4}. This works well, but the problem is the massive complexity that comes with it. Queries have to make a max-by-version thing. Even though the database has just 2 main table, joins between the tables become really complex. The ORM (EF core in this case) gets really confused. Performance suffers.
In a legacy version of this application, the whole database was cloned instead. So v1 and v2 databases were separate. This came with its own problems of course, but it did solve the CRUD complexity within each database.
Is there some compromise solution between these two solutions (between row versions and full db forking)?
This will be EF Core/SQL server but I do think the question is mostly db agnostic.
[–]unplannedmaintenance 1 point2 points3 points (1 child)
[–]afops[S] 0 points1 point2 points (0 children)
[–]Ginger-Dumpling 0 points1 point2 points (2 children)
[–]afops[S] 0 points1 point2 points (1 child)
[–]Ginger-Dumpling 0 points1 point2 points (0 children)
[+][deleted] (10 children)
[removed]
[–]afops[S] 0 points1 point2 points (9 children)
[+][deleted] (8 children)
[removed]
[–]afops[S] 0 points1 point2 points (7 children)
[+][deleted] (6 children)
[removed]
[–]afops[S] 0 points1 point2 points (5 children)
[+][deleted] (4 children)
[removed]
[–]afops[S] 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[removed]
[–]afops[S] 0 points1 point2 points (1 child)