drop down menu - Storing country state city in MongoDB -


i working on building database store country-state-city information later used drop down menus in our website.

i wanted few suggestions on schema have decided how efficiently work.

i using mongodb store data.

the schema have designed follows:

{ _id: "xxxx", country_name: "xxxx", more fields state_list:[     {         state_name: "xxxx",         more fields         city_list:[             {                 city_name : "xxxx",                 more fields             },             {                 city_name : "xxxx",                 more fields             }          ]      } ] 

}

the data increasing. there long list of cities each state.

how schema work intended purpose?

should use linking documents technique (this require manual coding map _id) ?

i think data increase , schema collapse. best way break database in 3 schemas , use refrence of ids.

country schema:

{ _id: "xxxx", country_name: "xxxx", more fields state_list:[{   "_id": reference id state object }] } 

state schema :

{  _id: "xxxx",  state_name: "xxxx",  more fields  city_list:[{    "_id" : reference city object  }] } 

city schema:

{  _id: "xxxx",  city_name: "xxxx",  more fields 

}


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -