Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9130573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:59:15+00:00 2026-06-17T07:59:15+00:00

I want to implement a taxonomy structure (geo terms) for my node.js application with

  • 0

I want to implement a taxonomy structure (geo terms) for my node.js application with NoSQL database. I had a similar taxonomy structure with MySQL but it’s time to move forward and learn something new so I decided to try a different approach and use NoSQL (document-oriented) for my test app. The taxonomy structure is simple – there’re five different levels: country (i.e. United Kingdom) → region (England) → county (Merseyside) → city/town/village (Liverpool) → part of the city (Toxteth).

The obvious choice is to use a tree structure but the devil is in the detail – historically some cities and towns belonged to other counties. The idea was to tag persons who were born in certain cities or towns with those terms and to filter them later by geo tags so I have to respect the fact Liverpool or Manchester (among others) were part of Lancashire at the time some people were born. Otherwise the result any user gets with my geo filter will be incorrect.

Example: John Doe was born in Blackburn (Lancashire) back in 1957. Paul Brown was born in 1960 in Liverpool (Lancashire, now Merseyside). Georgia Doe (nee Jones) was born in Wirral (Cheshire, now Merseyside) 5 years later. Their son Ringo was born in Liverpool (Merseyside by that time) in 1982.

John is Lancastrian by birth, Paul is Lancastrian and Merseysider, Georgia is from Cheshire and Merseyside at the same time, Ringo is from Merseyside. So they should be categorized accordingly when I search by county. But with simple one-to-many structure that follows modern structure of the country they’ll never be filtered as they should be.

How to implement the collection respecting the complexity of its structure with NoSQL (first of all document-oriented) solutions? I googled it and did some research over stack* but still had no clue what to do next with it. There’s a few possible ways to solve it in my opinion:

  1. Use SQL-like data structure:

    {
        {'name': 'United Kingdom', 'unique_id': 1},
        {'name': 'England', 'unique_id': 2, 'parents': [1]},
        {'name': 'Merseyside', 'unique_id': 3, 'parents': [2]},
        {'name': 'Lancashire', 'unique_id': 4, 'parents': [2]},
        {'name': 'Liverpool', 'unique_id': 5, 'parents': [3, 4]},
    }
    
  2. Use tree structure with some references:

    {    
        {'name': 'United Kingdom', 'unique_id': 1
            {'name': 'England', 'unique_id': 2]
                {'name': 'Merseyside', 'unique_id': 3]
                    {'name': 'Liverpool', 'unique_id': 5, 'alternate_parents': [4]},
                },
                {'name': 'Lancashire', 'unique_id': 4},
            },
        },
    }
    
  3. Use tree structure with no references (one-to-many) and add “alternate parent” tag to a document manually:

    {    
        {'name': 'United Kingdom', 'unique_id': 1
            {'name': 'England', 'unique_id': 2]
                {'name': 'Merseyside', 'unique_id': 3]
                    {'name': 'Liverpool', 'unique_id': 5},
                },
                {'name': 'Lancashire', 'unique_id': 4},
            },
        },
    }
    
  4. Stick with SQL.

  5. Try to implement database-less taxonomy.

Give me advice on that matter please. I’m a newby with any NoSQL (currently I’ve designed no such databases) so there’s a real design issue for me.

And I’m new to stack* so feel free to correct me if I did anything wrong with this post 🙂 Thank you!

EDIT
I’ve chosen @Jonathan answer as a solution. I think it suits better for my needs (there’ll be other documents to store in my database and tag them with those terms) especially with mapReduce functionality suggested by @Valentyn.

But if there’s no document collections needed for your app a graph database (based on relationships not documents) suggested by @Philipp is probably the best solution possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:59:16+00:00Added an answer on June 17, 2026 at 7:59 am

    Firstly, picking between NoSQL and a SQL database is hard if you’re not familiar with the basic principles. If this is the only data you are storing, go with a relational (SQL). If there is more data (which I assume) and it requires more of a interwoven schema, stick with NoSQL hands down.

    I would take the relational route on this to keep it from getting too complex… start several collections; one for countries, region and so on. Don’t get discouraged from doing relational (SQL) type schemas in a NoSQL database; most of the time they are the best solution.

    Then, in each of the sub-groups, have a field which names the parent.

    For example:

    {
        {'name': 'United Kingdom'},
        {'name': 'United States'}
    }
    
    {
        {'name': 'England', 'parent': 'United Kingdom'},
        {'name': 'California', 'parent': 'United States'}
    }
    

    That way, your data-set doesn’t get so nested that the returned data is unmanageable. Then you can grab the countries and the corresponding regions… etc with ease.

    Best of luck!

    EDIT: Answering OP’s questions:

    (Firstly, I’d recommend MongoDB – it’s a great solution all around.)

    1. Because when you start working with MongoDB, you’ll realize that it stores data side by side on the hard drive. If you edit a huge record like that, it will most likely be pushed to the back of the disk, making your hard drive similar to Swiss cheese. Once you get to that point, you’ll have to do a repair to condense it once more. Also, this way the data is more easily separated in your application, that way, if you need to do something with the data, you won’t have to apply it to the entire object. I am assuming that you will have a large dataset since there are many different locations in the world.

    2. Don’t worry too much about that kind of thing. You can use ID’s for the parent and match the children with the ID if you plan on changing names a lot. I just did it this way because I assumed you wouldn’t need to change a location database.

    3. Rather than an array, I would use a nested document to store multiple parents. That way, it can be more easily queried and indexed. I would use the following method:

      {
          {
              'name': 'England,
              'parent': {
                  1: 1,
                  568: 1
              }
           }
       }
      

    So that way you can employ your idea of indexes and find where db.region.$.568 = 1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement the Wikitude API in my iPhone Application. But while implementing
I want implement in my software solution an VBA editor but in c# 3.0.
I want to implement an application which will work as a parser. User will
I want to implement a job scheduler in my windows azure application. My aim
I want to implement login using facebook in my windows phone 7.1 application When
I want to implement a kind of xor constraint on foreign keys in mysql
I want to implement spring3.2.0 web mvc following the example: http://programmersplanet.wordpress.com/2011/11/26/4/ but I fail.
I Want Implement a Software by C#.net.I want Use a DataBase Manager Software like
I want to implement a feature similar to the Related Questions list shown when
I want to implement test feedback in my web application in the following manner

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.