No, it wouldn’t be a bad idea. You only need to update the node in the middle
So if for example, you have the following structure:
[LIST]
[*]Company (1)
- Division1 (2)
[LIST]
- Sub Division 1 (3)
[LIST]
- Employee 1 (4)
- Employee 2 (5)
- Employee 3 (6)
[/LIST]
- Sub Division 2 (7)
[LIST]
- Employee 4 (8)
- Employee 5 (9)
- Employee 6 (10)
[/LIST]
- Sub Division 3 (11)
[LIST]
- Employee 7 (12)
- Employee 8 (13)
- Employee 9 (14)
[/LIST]
[/LIST]
- Division2 (15)
[LIST]
- Sub Division 4 (16)
[LIST]
- Employee 10 (17)
- Employee 11 (18)
- Employee 12 (19)
[/LIST]
- Sub Division 5 (20)
[LIST]
- Employee 13 (21)
- Employee 14 (22)
[/LIST]
[/LIST]
- Division3 (23)
[LIST]
- Sub Division 6 (24)
[LIST]
- Employee 15 (25)
- Employee 16 (26)
[/LIST]
- Sub Division 7 (27)
[LIST]
- Employee 17 (28)
- Employee 18 (29)
[/LIST]
- Sub Division 8 (30)
[LIST]
- Employee 19 (31)
- Employee 20 (32)
[/LIST]
- Sub Division 9 (33)
[LIST]
- Employee 21 (34)
- Employee 22 (35)
[/LIST]
[/LIST]
[/LIST]And your table structure is something like this: Node (NodeID, NodeName, ParentNodeID)
So your data would be essentially (showing down through sub division2)
1, Company, 0
2, Division1, 1
3, Sub Division 1, 2
4, Employee 1, 3
5, Employee 2, 3
6, Employee 3, 3
7, Sub Division 2, 3
8, Employee 4, 7
9, Employee 5, 7
10, Employee 6, 7
Now, say they decide to re-organize and move sub-division 6 to Division 2, and the employees of Sub Division 9 are moving to Sub Division 8 and Sub Division 9 is being eliminated. You could do all this in three sql statements:
-- move the sub-division
UPDATE Node SET ParentNodeID = 15 WHERE NodeID = 24
-- move the employees
UPDATE Node SET ParentNodeID = 30 WHERE ParentNodeID = 33
-- delete the sub-division
DELETE FROM Node WHERE NodeID = 33
To me, that’s efficient. Is there a more efficient structure you’re thinking of? How would you structure it?