Apologies if this is not the right SE site to ask.
I'm designing an application for catalogue management. Any element in the hierarchy has to be versioned, i.e. when I change a property of it, a new version is created. The new version can also have different children than the previous. The user can switch between versions when she manages the catalogue, so I'll need to list all the existing versions of a child. When switching version, all the descendant will be updated).
My first thought was something like
| A | | B | | C | |--------------| |--------------| |--------------| | ID (k) | | ID (k) | | ID (k) | | VER (k) | | VER (k) | | VER (k) | | ... | | A_ID (fk) | | B_ID (fk) | | | | A_VER (fk) | | B_VER (fk) | |--------------| | ... | | ... | |--------------| |--------------| Where the entities' key is always something like (ID, VER) and the parent's fk is (P_ID, P_VER).
Is this a good way to implement it?
Update: It's apparently more complicate than that. The meaning of the versioning is that elements have a validity time and we need to keep the older version. E.g. a client buys product with price x. After 1 January it's gonna cost y. New clients after 1 January get new price y, but old client keeps paying x.
Adding a timestamp column is probably the best option here.