首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >航空航天数据建模与查询

航空航天数据建模与查询
EN

Stack Overflow用户
提问于 2015-10-05 20:05:33
回答 1查看 242关注 0票数 4

假设我在JAVA中有以下模型

代码语言:javascript
复制
class Shape {
    String type;
    String color;
    String size;
}

假设我有以下基于上述模型的数据。

代码语言:javascript
复制
Triangle, Blue, Small
Triangle, Red, Large
Circle, Blue, Small
Circle, Blue, Medium
Square, Green, Medium
Star, Blue, Large

我想回答以下问题

代码语言:javascript
复制
Given the type Circle how many unique colors?
    Answer: 1
Given the type Circle how many unique sizes?
    Answer: 2

Given the color Blue how many unique shapes?
    Answer: 2
Given the color Blue how many unique sizes?
    Answer: 3

Given the size Small how many unique shapes?
    Answer: 2
Given the size Small how many unique colors?
    Answer: 1

我想知道我是否应该用以下的方式.

代码语言:javascript
复制
set: shapes -> key: type -> bin(s): list of colors, list of sizes
set: colors -> key: color -> bin(s): list of shapes, list of sizes
set: sizes -> key: size -> bin(s): list of shapes, list of colors

还是有更好的方法来做这件事?如果我这样做,我需要3倍的存储空间。

我还希望每组都有数十亿个条目。顺便说一下,模型已被修改,以保护固有的代码;)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-06 22:46:56

NoSQL中的数据建模总是关于您计划如何检索数据、在什么吞吐量和在什么延迟时。

有几种方法可以对这些数据进行建模;最简单的方法是模拟每个字段都变成Bin的类结构。您可以在每个回收站上定义辅助索引,并使用聚合查询回答您的问题(上面)。

但这只是一种方法;您可能需要使用不同的数据模型来满足延迟和吞吐量的因素。

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32957002

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档