我想开发一个分层数据库来将目录结构存储在文件系统中。我如何使用Apache Cassandra构建分层数据库
就像
Root -dir -subdir -subdir -subdir -subdir -subdir -subdir -subdir
我可以使用Apache Cassandra的这个
java的例子会更好理解。
我想开发一个分层数据库来将目录结构存储在文件系统中。我如何使用Apache Cassandra构建分层数据库
就像
Root -dir -subdir -subdir -subdir -subdir -subdir -subdir -subdir
我可以使用Apache Cassandra的这个
java的例子会更好理解。
你可以存储在一个列族的路径的数据,类型和家长,
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
}
}
随着卡桑德拉,你需要进行非规范化服务您要执行的查询。你可能想查询目录的孩子,所以有一个结构是怎样的,
children { #column family
"/some/path" { # key
"child-path-1" : null #column, one for each child of /some/path
"child-path-2" : null
}
}
添加多个列的家庭支持你希望做的其他查询。
+1解释。谢谢。 – JOHN
嗨,这是我会为关系型dbms架构做什么。
product{
id int,
parent_id int,
name varchar2(30)
}
的样本数据:
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
从技术上讲,这是可能的。每行可以有一个名为“parent”的列。然而,遍历树(就像cassandra中的几乎所有迭代操作一样)将非常慢并且效率低下。 –
谢谢。你能举一个例子来说明一下吗? – JOHN
+1我正在寻找确切的术语来调用这种父类的数据库关系,不知道它叫做分层数据库结构。 –