Top 60 Oracle Blogs

Recent comments

Major and Minor keys in Oracle NoSQL Database

Oracle NoSQL Database uses Major and Minor key values to achieve user-controllable record co-location. Records are stored based on the hash of the major key, so all of the records with the same major key will be co-located on the same server.

A JSON document could be divided into sub-parts, with each sub-part having a different minor key. For example, customer meta data could be stored in the main customer record, transactions in a different record, recommendations in a third, friends and associates in yet another, etc. Atomic multi-record operations are supported as long as all of the records share the same major key. For example, “Get all of the sales records for UserID 123” (where UserID is the Major Key) would return a transactionally consistent data set. You could also write multiple records and get transactional behavior. For example, “Write the following 6 records for UserID 123” or “Delete record type X, add record type Y, and update record type Z for UserID 123” could be done as an atomic transaction.

No other NoSQL database vendor offers a similar feature. So, based on the examples in the September 2011 white paper that announced Oracle NoSQL Database, I believe that the Oracle NoSQL Database developers confused the “value” in “key-value” with the value in the infamous “Entity-Attribute-Value” model:

“Applications can take advantage of subkey capabilities to achieve data locality. A key is the concatenation of a Major Key Path and a Minor Key Path, both of which are specified by the application. All records sharing a Major Key Path are co-located to achieve data locality. Within a co-located collection of Major Key Paths, the full key, comprised of both the Major and Minor Key Paths, provides fast, indexed lookup. For example, an application storing user profiles might use the profile-name as a Major Key Path and then have several Minor Key Paths for different components of that profile such as email address, name, phone number, etc. [emphasis added]”

The disadvantage of Major/Minor keys is that, if you have a highly variable number of minor keys per major key, you can end up with an uneven record distribution. For example a Major/Minor key of UserID/MessageID will potentially put all the records for a highly active user into a single partition.

P.S. Oracle NoSQL Database has started using the terms “Primary Key” and “Sharding Key.” The sharding key is what Oracle NoSQL Database previously called the major key while the primary key is the combination of the major and minor keys. Refer to