最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rdbms - How to structure a database to sum over overlapping hierarchies - Stack Overflow

programmeradmin1浏览0评论

I am making software that analyses data for a country.

This country has two regions. In each region there are four municipalities; in each municipality there are four cities and each city has four people.

Income per geographical level is easy to query. For "get people from region A" I sum the income.

I want to create geographical levels that are not logical but serve an analytical purpose. For example, split region A into two sub-regions, with two municipalities each.

My first approach (which might be a wrong one) would be to create another table.

I have a table with sub-regions 1 and 2 which are parts of region A.

Region A is divided in sub-region 1, sub-region 2 and four municipalities let's say B C D E. But B and C are part of sub-region 1 and D E are part of sub-region 2.

If I want to see the people in Region A, I'll count some people twice because they are in sub-region 1 but also in municipalitiy B.

What is the way to deal with these virtual groups?

发布评论

评论列表(0)

  1. 暂无评论