I think what I would do is create a table that holds all the geographic info. Same structure as your permission table but without the person ID. It would contain all possible locations. Then you could use a query like this to get all relevant locations given one or more permission rows for a person:Of course your tables will have proper keys, constraints, and referential integrity
.select p.id ,h.continent ,h.country ,h.region ,g.statefrom permission pinner join geoHierchary h on h.continent = p.continent and h.country = coalesce(p.country, h.country) and h.region = coalesce(p.region, h.region) and h.state = coalesce(p.state, h.state)where p.id = @someonesID
Be One with the OptimizerTG