一个用户表单,需要用户选择所在地(省,市,区),并且要实现省市区三个下拉框的三级联动,数据库部分该怎么设计?
sql数据库下实现过,但mongodb下有没有更好的设计方案.
黄舟2017-04-21 11:19:32
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
PHP中文网2017-04-21 11:19:32
How to implement it under sql database? (The physical design part of the database is not code) Please give me some advice