G
G
Gleb2017-09-25 11:16:37
NoSQL
Gleb, 2017-09-25 11:16:37

How to properly design MongoDB?

Colleagues, good day!
The question arose about designing a database - a list of countries and cities. It is not possible to use ready-made APIs, because the base will be collected from a bunch of different sources (api transport companies).
To solve the problem, there is a desire to use MongoDB with the content of subcollections.
Example:

{
country: "Россия",
regions: [
{
region: "Тюменская область",
cities: [
{city: "Тюмень", .....},
....
]
}
]
}

Be sure to plan a search for cities with auto-suggestions.
Microservice architecture.
I want to hear opinions regarding the choice of the database for the task and the implementation of the search.
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Wolf, 2017-09-25
@mannaro

IMHO, I would take an ordinary relational database here.

A
Abcdefgk, 2017-09-25
@Abcdefgk

In such nested attachments, then search by indexes does not work, but for the first time.
It is necessary to "design" so that there are fewer attachments, but there are sending fields. All separate collections.
Well, like a collection (model) City
{
name: String,
region: String,
country: String
}
And then, to select all the cities of Chukotka located in the USA, you can simply query:

City
  .find()
  .where('region', 'Чукотка')
  .where('country', 'США')
  .exec(...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question