0

I previously asked a question about this (How to store a Tree Of Life in MySQL? (Phylum, Class, Order, Family, etc)) and I was using MySQL but after someone suggested using MongoDB, I decided to look around and install Couchbase. (Funny thing, geraldss suggested Couchbase in the comment of my previous question after I installed it).

I will store the Kingdom, Phylum, Class, etc for each fish in a document. But I would also like to have document(s) to help with a multilevel dropdown.

I want the first dropdown to be the 5 Kingdom, and then the next dropdown will populate with the Phylum available for this kingdom., Then the third dropdown will be populate with a list of this Phylum's class, and so on.

Right now I'm trying to find the best practical way to store this.

Should I create 1 single huge document called taxonomy or should I create multiple documents about, let say, each Phylum (still huge documents), or something else?

Little PHP array example to help me create the document(s):

  "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

                ),
              ),
            ),
          ),

What should I do? Would it be a good approach to create one single document? How would you store this?

(Please don't close this question, I'm trying very hard to switch my mind from relational to document-based DB and I'm struggling with this)

Community
  • 1
  • 1
Jayd
  • 183
  • 3
  • 15
  • You should keep in mind that Couchbase does not support partial updates for documents. So if you only use one document updating it will take really long and will block other update operations in the meantime. So I would go for distinct documents. – Robin Ellerkmann Feb 07 '17 at 13:20
  • Thank you Robin. I'll try multiple documents approach for this, but I heard it's best to avoid JOIN-like query in NoSQL, it poses an issue because a doc could have 13 parents (levels) I need to get, I should create multiple requests to get the full hierarchy. – Jayd Feb 08 '17 at 04:34
  • You are right that joins are often expensive in noSQL. In Couchbase you can control on which cluster node specific document types you want to join are stored. So you only have to do a join on one node, not across the whole cluster. – Robin Ellerkmann Feb 08 '17 at 15:08

0 Answers0