Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modelling of hierarchical entities in Cassandra

I am new to Cassandra and i did an online search about modelling of hierarchical entities in Cassandra but i couldn't find anything.

I tried classical relational db approach in which you store parent ids but that don't seem to work in nosql world.

So basically i have hierarchical entities (parent-child relationship), how should i create my tables for efficient querying on Cassandra?

I have packages and products. I put products in packages and i can also put packages in packages which contain products and packages and so on.

like image 300
A C S Avatar asked Oct 31 '22 05:10

A C S


1 Answers

To have a good understanding of how Cassandra modelling works, you should first see some tutorials on datastax academy or see some videos online.

In any case, what you need to think about is how your data will be accessed.

For example, let's say you only needs to have all the products and packages in a package, then you will only need a package table, with a column for the packages and one for the products.

Now if you want to see in which packages lies a product, the model above is wrong, and you need to make another table that will store every packages that contain a given product.

I think you see where I am going: it's impossible to find a good model if we don't know how it will be used.

Also, look at this more in-depth example: http://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling

like image 51
Whitefret Avatar answered Nov 15 '22 13:11

Whitefret