I've got a problem I was wondering if there's an elegant solution to. It is a real business problem and not a class assignment!
I have a table with thousands of records, some of which are groups related to each other.
The database is SQL 2005.
ID is the primary key. If the record replaced an earlier record, the ID of that record is in the REP_ID column.
ID REP_ID
E D
D B
C B
B A
A NULL
So in this example, A was the original row, B replaced A, C replaced B unsuccessfully, D replaced B successfully and finally E replaced D.
I'd like to be able to display all the records in this table in a grid. Then, I'd like for the user to be able to right click any record in any group, and for the system to locate all the related records and display them in a some sort of tree.
Now I can obviously brute force a solution to this but I'd like to ask the community if they can see a more elegant answer.