We have four collections countries, states, cities, and airports
We used the embedded document way to modeling these data.
That’s how we modeling these data
The country document
{
name: string,
code: string,
location: {
type: 'Point',
coordinates: [number, number]
},
currency: {
symbol: string,
name: string,
code: string,
},
translation: [
{
language: string,
name: string
}
]
}
And this is the state document
{
name: string,
code: string,
location: {
type: 'Point',
coordinates: [number, number]
},
country: {
name: string,
code: string,
location: {
type: 'Point',
coordinates: [number, number]
},
currency: {
symbol: string,
name: string,
code: string,
}
},
translation: [
{
language: string,
name: string,
country: {
name: string
}
}
]
}
And this is the city document
{
name: string,
code: string,
location: {
type: 'Point',
coordinates: [number, number]
},
state: {
name: string,
code: string,
location: {
type: 'Point',
coordinates: [number, number]
},
country: {
name: string,
code: string,
location: {
type: 'Point',
coordinates: [number, number]
},
currency: {
symbol: string,
name: string,
code: string,
}
}
},
translation: [
{
language: string,
name: string,
state: {
name: string,
country: {
name: string
}
}
}
]
}
and so on for the airport document
So we used this modeling technique for improving the searching query for a document cause we will make a lot of read queries and too much little write queries.
What i want to ask, are we right about that? or we should use the reference instead of the embedded and if we used it, will it affect the performance of the read query bcause of the lookup which will happen to find the reference?