Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 如何使用apache Cassandra构建分层数据库_Database_Cassandra - Fatal编程技术网

Database 如何使用apache Cassandra构建分层数据库

Database 如何使用apache Cassandra构建分层数据库,database,cassandra,Database,Cassandra,我想开发一个分层数据库,在文件系统中存储目录结构 就像 Root -dir -subdir -subdir -subdir -subdir -subdir -subdir -subdir 根 -迪尔 -细分 -细分 -细分 -细分 -细分 -细分 -细分 我可以用Apache Cassandra来做这个吗 java示例更容易理解。嗨,这是我对关系dbms模式所做的 product{

我想开发一个分层数据库,在文件系统中存储目录结构

就像

Root -dir -subdir -subdir -subdir -subdir -subdir -subdir -subdir 根 -迪尔 -细分 -细分 -细分 -细分 -细分 -细分 -细分 我可以用Apache Cassandra来做这个吗


java示例更容易理解。

嗨,这是我对关系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

可以在列族中存储路径的数据、类型和父级

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
    }
}
使用cassandra,您需要进行非规范化以服务于将要执行的查询。您可能希望查询目录的子目录,因此具有如下结构:

children { #column family 
    "/some/path" { # key
         "child-path-1" : null #column, one for each child of /some/path
         "child-path-2" : null 
    }
}

添加更多列族以支持您希望执行的其他查询。

从技术角度讲,是的,这是可能的。每行可以有一个名为“parent”的列。然而,遍历树(就像cassandra中几乎所有的迭代操作一样)会非常缓慢和低效。谢谢。你能举个例子让它更清楚些吗?+1我在搜索称之为父类数据库关系的确切术语,不知道它被称为分层数据库结构。参考,给定的方法在存储数据方面已经足够好了。但是在检索方面相当慢Wikipedia也提供了一个很好的概述(另请参见指向嵌套间隔等备选方案的链接).1为例。实际上,这是在RDBMS中实现分层数据的好主意。但我认为需要通过编程来实现这种结构。假设我们删除根,那么我们必须编写代码来删除所有子体。如果我错了,请更正。您如何知道项是文件还是目录?