couchdb - NoSQL Documents for Relational Like Data (Locations) -
i have list of locations, in mysql has hierarchy above continent > country > county/region/state > provence > location. if store these locations in nosql store (like couchdb). store continent top level object , rest child arrays of objects continent. use map/reduce create various views countries, counties etc. recommended structure kind of data? make each continent document big?
{ name: "europe", type: "continent", countries: [ { name: "england" counties: [...] } ] }
this suggestion , speculation on part, think may have idea. (i highly recommend looking geocouch location-type data.)
if want proceed yourself, can store each location of levels of detail stored attributes:
{ "continent": "north america", "country": "united states", "state": "texas", "city": "houston" } i'm us, i'm using use determining location. (i noticed used provence, county, etc. can incorporated model)
anyways, view function this:
function (doc) { emit([doc.continent, doc.country, doc.state, doc.city], null); } this view output:
{ "key": ["north america", "united states", "texas", "houston"], "value": null } now, know redundant data, since it's stored every location. that's ok, we're dealing nosql, there's no need continue thinking relationally. (that's why you're looking @ solution couchdb)
anyways, can use view parameter group_level "drill-down" locations. using group_level=1 view result grouped continent. group_level=2 group country, group_level=3 group state, etc.
using reduce function can counts , other statistics each of these groupings. hope helps!
Comments
Post a Comment