MapR-DB JSON Tables

MapR-DB JSON tables are used to store OJAI documents.

When a OJAI document is added to a JSON table, it is put in a table row. The table row is part of one column family (although you can create more, as described in Column Families). The value in the row is a single OJAI document that is stored in a binary format. Binary format makes a number of optimizations to the document’s layout to make data access fast and efficient.

The OJAI documents that are in a table do not all have to have identical structures. It is possible to include in a single table any number of OJAI documents that have no common fields or that share a subset of fields.

For example, an online retailer might have documents the following three documents in a single JSON table. Only a subset of fields is common to all three documents. Each document has a different nested document in a field named specifications. Only two of the documents have arrays in the field features.

{
    "_id" : "4GGC859",
    "product_ID" : "4GGC859",
    "name" : "Thresher 1000",
    "brand" : "Careen",
    "category" : "Bicycle",
    "type" : "Road bicycle",
    "price" : 2949.99,

    "specifications" : {
        "size" : "55cm",
        "wheel_size" : "700c",
        "frameset" : {
            "frame" : "Carbon Enduro",
            "fork" : "Gabel 2"
         },
        "groupset" : {
            "chainset" : "Kette 230",
            "brake" : "Bremse FullStop"
	    },
        "wheelset" : {
	        "wheels" : "Rad Schnell 10",
	        "tyres" : "Reifen Pro"
        }
    }
}
{
    "_id" : "2DT3201",
    "product_ID" : "2DT3201",
    "name" : " Allegro SPD-SL 6800",
    "brand" : "Careen",
    "category" : "Pedals",
    "type" : "Components,
    "price" : 112.99,

    "features" : [
        "Low-profile design",
        "Floating SH11 cleats included"
    ],

    "specifications" : {
        "weight_per_pair" : "260g",
        "color" : "black"
    }
}
{
    "_id" : "3ML6758",
    "product_ID" : "3ML6758",
    "name" : "Trikot 24-LK",
    "brand" : "Careen",
    "category" : "Jersey",
    "type" : "Clothing",
    "price" : 76.99,

    "features" : [
        "Wicks away moisture.",
        "SPF-30",
        "Reflects light at night."
    ],

    "specifications" : {
        "sizes" : ["S","M","L","XL","XXL"],
        "colors" : [
            "white",
            "navy",
            "green"
        ]
     }
}

Table Paths

Tables are stored in the MapR file system. When providing the path to a table in the Java API, maprcli commands, or mapr dbshell, use these conventions.

  • For a path on the local cluster, start the path at the volume mount point. For example, for a table named test under a volume with a mount point at /volume1, specify the following path: /volume1/test
  • For a path on a remote cluster, you must also specify the cluster name in the path. For example, for a table named customer in volume1 in the sanfrancisco cluster, specify the following path: /mapr/sanfrancisco/volume1/customer

Tools for Working with JSON Tables

There are four tools that you can use for creating and administering JSON tables in MapR-DB.

MapR-DB Shell
This shell is a light-weight tool for manipulating JSON tables and documents. Learn more about it here: mapr dbshell
MapR-DB JSON API
Learn the basics of this API here: CRUD Operations for JSON Tables.
MapR-DB utilities
Learn more about these utilities here: Loading Documents into JSON Tables
maprcli commands
The maprcli table commands fully support JSON tables. See table.