I need some help to know if this solution in SQL I'm thinking exists.
For example I have the tables "person" and "from_to":
"person"
CURRENT_ID | DATE
0004 | 2022-09-14 10:00:00
"from_to"
PREVIOUS_ID | CURRENT_ID
0001 | 0001
0001 | 0002
0002 | 0002
0002 | 0003
0003 | 0003
0003 | 0004
0004 | 0004
My doubt, is it possible to have a hierarchy by levels of this data, for example:
level 1 | level 2 | level 3 | level 4
0001 0002 0003 0004
UPDATE / Additional Info
Every time a person changes their data, the id changes too, this information is registered in "from_to", and the current_id is in the "person" table, what I need is something to help me register these changes, to find possible errors in the main table.
For example, this record by levels would help to find duplicate "people", because during id changes some value got broken.
Example:
PREVIOUS_ID | CURRENT_ID
0001 | 0001
0001 | 0002
0002 | 0002
---FROM_TO_BROKEN---
0003 | 0003
0003 | 0004
0004 | 0004
in this case we would have two "CURRENT_ID" for a single "person".
CURRENT_ID | DATE
0002 | 2022-09-14 10:00:00
0004 | 2022-09-14 10:00:00
I'm looking for the best solution to be able to classify this in SQL, will help you find "person" that are "duplicate":
name | level_1 | level_2 | level_3 | level_4
user_1 0001 0002 0003 0004