Reputation: 20135
We need the ability to map various types of entities to different types of hierarchical data in our web application. As an example, consider an entity called Vendor. We need the ability to map each instance of vendor to geographical areas. Geographical areas are in the following hierarchy:
We have a complete database of post codes, localities, towns, districts, provinces, regions, countries, zones and continents. This currently exists as tables in an RDBMS.
Our use cases:
There are many such mappings with many different types of hierarchical data, this is just one of the requirements.
Looking for suggestions on storing the hierarchical data and the mappings. Please do not post answers that involve storing the data and mappings in RDBMS tables, as I am already aware of the options using RDBMS.
Upvotes: 0
Views: 665
Reputation: 14388
I know that you are not looking for a RDBMS solution, since you "know the options for RDBMS" - but you don't state what options you have considered and why you are rejecting them. I believe there may be an RDBMS option you haven't considered which has the advantage of low data maintenance and ease of data retrieval.
I suggest that you group your geographical regions into a single table with an involuted relationship (adjacency model). This allows you to describe your vendor coverage as a list of geographical coverage records. The trick is to record vendor coverage at the highest possible level. You can then also list exclusions to the coverage.
Here is a suggested logical model:
The GEOGRAPHY
table could use nested sets to simplify the querying of the hierarchical geography data.
Determining vendor coverage of a particular area would be as easy as confirming that a vendor has COVERAGE
for the GEOGRAPHY
of interest (probably at the lowest level) while not also being in a COVERAGE EXCLUSION
for that same GEOGRAPHY
.
Upvotes: 2