mongodb下求一个用户所在地collection设计方案
ringa_lee
ringa_lee 2017-04-21 11:17:32
0
3
795

一个用户表单,需要用户选择所在地(省,市,区),并且要实现省市区三个下拉框的三级联动,数据库部分该怎么设计?
sql数据库下实现过,但mongodb下有没有更好的设计方案.

ringa_lee
ringa_lee

ringa_lee

reply all (3)
黄舟

The elements of the collection should basically be three levels of nesting
{"province":{"pname":p1,"city":[{"cname":c11,"area":[{"aname":a11}]}]}}
{"province":{"pname":p2,"city":[{"cname":c21,"area":[{"aname":a21}]}]}}
{"province":{"pname":p3,"city":[{"cname":c31,"area":[{"aname":a31}]}]}}
When used, retrieve the name of the province based on province, then iterate over the city (array) embedded in the province document to obtain the name, and iterate over the area (area) embedded in each city document to obtain the names of all districts

    迷茫

    Array Collection

      Ty80

      How to implement it under sql database? (The physical design part of the database is not code) Please give me some advice

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!