使用Couchebase存储分类标准(生命之树),最佳实践

时间:2017-02-06 02:43:01

标签: data-structures tree couchbase multi-level nosql

我之前曾问过这个问题(How to store a Tree Of Life in MySQL? (Phylum, Class, Order, Family, etc))我正在使用MySQL但是在有人建议使用MongoDB后,我决定环顾四周并安装Couchbase。 (有趣的是,geraldss在我安装之后在我上一个问题的评论中建议使用Couchbase。)

我会在文件中为每条鱼存储王国,门,等等。但我也希望有文档来帮助进行多级下拉。

我希望第一个下拉列表是5个王国,然后下一个下拉列表将填充此王国的Phylum。然后第三个下拉列表将填充此Phylum类的列表,依此类推。< / p>

现在我正在努力寻找最好的实用方法来存储它。

我应该创建一个名为分类法的单个巨大文档,还是应该创建多个文档,比如每个Phylum(仍然是大文档)或其他什么?

帮助我创建文档的小PHP数组示例:

  "Fungi" => array(
    "type"=>"kingdom",
    "origin" => "Latin, derived from Greek - sp(h)onges, sponges",
    "description" => "Obtain food through absorption, excrete enzymes for digestion",
    "example" => "molds, mushrooms, lichens",
    "Phylum" => array(),
  ),
  "Plantae" => array(
    "type"=>"kingdom",
    "origin" => "Latin - plant",
    "description" => "Multicellular organisms that are autotrophic",
    "example" => "mosses, ferns, grasses, flowers, trees.",
    "Phylum" => array(),
  ),
  "Animalia" => array(
    "type"=>"kingdom",
    "origin" => "Latin - breath, soul",
    "description" => "Multicellular organisms that develop from the fertilization of an egg by a sperm",
    "example" => "sponges, worms, insects, fish, birds, humans",
    "Phylum" => array( //32 total, 12 here
      "Porifera" => array(
        "name" => "Porifera",
        "type" => "Phylum",
        "origin" => "Latin - to bear pores",
        "description" => "Sponges",
      ),
      "Cnidaria" => array(
        "name" => "Cnidaria",
        "type" => "Phylum",
        "origin" => "Greek - nettle",
        "description" => "",
        "Class" => array(
          "Hydrozoa" => array(
            "name" => "Hydrozoa",
            "description" => "Hydras",
            "Order" => array( //Multiple Order
              "Family" => array( //Multiple Family for each Order
                "Genus" => array( //Multiple Genus for each Family

                ),
              ),
            ),
          ),

我该怎么办?创建一个单独的文档会是一个好方法吗?你会怎么存储这个?

(请不要关闭这个问题,我正在努力将我的思路从关系转向基于文档的数据库,而我正在努力解决这个问题)

0 个答案:

没有答案