Aeroseismic modeling and querying

Let's say I have the following model in JAVA

class Shape {
    String type;
    String color;
    String size;
}

And I will say that I have the following data based on the above model.

Triangle, Blue, Small
Triangle, Red, Large
Circle, Blue, Small
Circle, Blue, Medium
Square, Green, Medium
Star, Blue, Large

I would like to answer the following questions.

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

I am wondering if I should model it like this ...

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

Or is there a better way to do this? If I do this, I need 3 times as much storage.

I also expect to have billions of records for each set. Btw model has been edited to protect inoncent code;)

+4
source share
1 answer

NoSQL data modeling is always related to how you plan to retrieve data, at what bandwidth and at what delay.

; , . (. ).

; .

+7

Source: https://habr.com/ru/post/1610325/


All Articles