You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Hubert Chang <hu...@gmail.com> on 2010/03/06 10:23:01 UTC

How to model hierarchical structure?

Like Category, Taxonomy, or folder/file, there will be multiple level
hierarchical relationship.
 How to model it in Cassandra?
Serialize all the parent id and the item id together as the key?
How to model it when one child has many parents?

Re: How to model hierarchical structure?

Posted by Mark Robson <ma...@gmail.com>.
On 6 March 2010 09:23, Hubert Chang <hu...@gmail.com> wrote:

> Like Category, Taxonomy, or folder/file, there will be multiple level
> hierarchical relationship.
>  How to model it in Cassandra?
> Serialize all the parent id and the item id together as the key?
> How to model it when one child has many parents?
>

If you have parent/child data, there is a good chance that it's not big
enough to need to be stored in Cassandra.

Do you have > 1 billion items? If not, then put it in a conventional RDBMS.

If you have 1 billion items, but most of them are "leaf" nodes, it might be
a good idea to put only the "leaf" nodes in Cassandra, and put the parent
categories in a conventional database.

Cassandra is NOT a good general purpose database, it is for very specific
cases of high data volume and high write workload.

Mark

Re: How to model hierarchical structure?

Posted by Jean-Denis Greze <je...@6coders.com>.
This really depends on the operations you want to optimize for.  What's
important to you?  Aggregate queries?  Finding children/siblings/ancestors?
 Reorganizing the tree/hierarchy?

For Cassandra, you really need to spend time thinking about how you'll be
accessing things and design for that.

If it's a 2-3 level hierarchy, then straight forward approaches like what
Jeff suggested seem logical.

Otherwise, I'd say if you've got an arbitrary-level hierarchy, then you'll
have to think about how to efficiently adapt one of the usual suspects for
this stuff (adjacency lists, nested sets, materialized paths, etc.).  I, for
one, would be interested in knowing if anyone else's experienced with this
kind of stuff in Cassandra.

http://stackoverflow.com/questions/192220/what-is-the-most-efficient-elegant-way-to-parse-a-flat-table-into-a-tree/192462#192462


and the like might be good places to start.

On Sat, Mar 6, 2010 at 2:13 AM, Jeff Zhang <zj...@gmail.com> wrote:

> use the parent as column family and the child as the column under the
> column family if this is two-level.
> And you can use the super-column if there are more than two-levels
>
>
>
>
>
> On Sat, Mar 6, 2010 at 1:31 AM, HubertChang <hu...@gmail.com> wrote:
>
>>
>> For examples, like tags, many parents to many children.
>> --
>> View this message in context:
>> http://n2.nabble.com/How-to-model-hierarchical-structure-tp4685633p4685649.html
>> Sent from the cassandra-user@incubator.apache.org mailing list archive at
>> Nabble.com.
>>
>
>
>
> --
> Best Regards
>
> Jeff Zhang
>



-- 
jeandenis@6coders.com
(917) 951-0636

This email and any files transmitted with it are confidential and intended
solely for the use of the individual to whom they are addressed. If you have
received this email in error please notify the system manager. This message
contains confidential information and is intended only for the individual
named. If you are not the named addressee you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately by
e-mail if you have received this e-mail by mistake and delete this e-mail
from your system. If you are not the intended recipient you are notified
that disclosing, copying, distributing or taking any action in reliance on
the contents of this information is strictly prohibited.

Re: How to model hierarchical structure?

Posted by Jeff Zhang <zj...@gmail.com>.
use the parent as column family and the child as the column under the column
family if this is two-level.
And you can use the super-column if there are more than two-levels




On Sat, Mar 6, 2010 at 1:31 AM, HubertChang <hu...@gmail.com> wrote:

>
> For examples, like tags, many parents to many children.
> --
> View this message in context:
> http://n2.nabble.com/How-to-model-hierarchical-structure-tp4685633p4685649.html
> Sent from the cassandra-user@incubator.apache.org mailing list archive at
> Nabble.com.
>



-- 
Best Regards

Jeff Zhang

Re: How to model hierarchical structure?

Posted by HubertChang <hu...@gmail.com>.
For examples, like tags, many parents to many children.
-- 
View this message in context: http://n2.nabble.com/How-to-model-hierarchical-structure-tp4685633p4685649.html
Sent from the cassandra-user@incubator.apache.org mailing list archive at Nabble.com.