I want to develop a hierarchical database to store directory structure in the filesystem.
Just like
Root -dir -subdir -subdir -subdir -subdir -subdir -subdir -subdir
can i use Apache Cassandra for this
a java example will be better to understand.
You could store the data, type and parent of a path in a column family,
paths { #colum family
"/some/path" { # key
"type" : "file|directory" #column, either file or directory, if this is a file or a directory
"data" : "??" # if this is a file, the data for the file. you don't want to be storing very large files in cassandra in one column
}
}
With cassandra, you need to denormalize to serve the queries you are going to perform. You probably want to query the children of a directory, so have a structure like,
children { #column family
"/some/path" { # key
"child-path-1" : null #column, one for each child of /some/path
"child-path-2" : null
}
}
Add more column families to support the other queries you wish to do.
Hi this is what i would do for a relational dbms schema.
product{
id int,
parent_id int,
name varchar2(30)
}
Sample data:
product
--------------------
id | parent_id | name
0 | 0 | root
1 | 0 | laptop
2 | 0 | pc
3 | 1 | Dell Latitude E4310
4 | 1 | Dell Vostro E3300
5 | 2 | Compaq Desktop 3
6 | 2 | Compaq Presario 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With