We need a table to maintain a hierarchy to perform all the CRUD operations.
Sample:
- Karnataka
-- Bangalore
--- Kormanagala
-- Hubli
- Madhya Pradesh
-- Gwalior
- Delhi
I thought of the following structure:
Table 1:
State ID(uuid) Name childCount
101 Karnataka 2
102 Bangalore 1
103 Kormangala 0
104 Hubli 0
105 Madhya Pradesh 1
106 Gwalior 0
107 Delhi 0
Table 2:
Parent_Id child_id
101 102
101 104
102 103
105 106
Please suggest a better solution.