NOSQL (ii) aggregated data model

Source: Internet
Author: User

"NoSQL essence" Reading notes, reproduced please indicate the source "Jiq Technical Blog"

Anosql data model

The data model of a relational database is "relational" and "tuple", a relationship corresponds to a table, and a tuple corresponds to a row, where the tuple consists of a series of values and cannot be nested.

The biggest shift in NoSQL databases is the abandonment of relational models. But each NoSQL solution model is different, in general, the NoSQL data model can be divided into four categories: "Key value", "Document", "Column Family", "figure", the first three types of models have a common feature, called "Aggregation model."

Second, the aggregation model

2.1 What is aggregation?

Aggregation is the concept of "domain driven design", and usually we want to manipulate a set of interrelated objects as a whole unit, which is aggregation.

For example, there is a shopping site, need to manage user information, product information, delivery address information, order information, payment methods, etc., if the relationship model to describe, will be divided into user table, order form, commodity table, payment Method table, there is a relationship between the table and the table. If you use the idea of aggregation, a way is divided into two aggregations, an aggregation is the user, by the user's basic information and receiving address information, such as composition, an aggregation is the order, by the commodity list, payment method and other information composition; Another way to put all the orders below the user in the user aggregation.

There is no standard answer to how you divide aggregations, which depends entirely on how you manipulate your data. If you want to access all of the users ' orders at once, put them into a large aggregation, and if you want to deal with a specific order, divide it into two aggregations for the user and the order is better.

2.2 Why is the aggregation model chosen?

Choosing an aggregation-oriented model is a decisive factor in that it is ideal for running in a cluster.

By designing aggregations based on scenarios, you can minimize the number of nodes required to collect data. By explicitly including the aggregation structure in the database, you can use this information to know what data needs to be manipulated together, and that data should be placed on the same node. in summary, the aggregation is central when running on a cluster, because the database must ensure that the data within the aggregation is placed on the same node. aggregation is the smallest unit of data for an update operation, and it is appropriate for the control of things to be aggregated as an operating unit.

2.3 What are the effects of aggregation on transaction processing?

The relational database has the concept of a transaction, which can be manipulated in an acid transaction with arbitrary tables, with atomicity, consistency, isolation, and persistence, the core of which is atomic in nature.

An aggregation-oriented database does not support acid transactions that span multiple aggregates, instead of atomic operations on only one aggregation structure, but most atomic operations in real-world applications can be confined within the aggregation structure, and this is one of the key considerations when dividing aggregations.

Three, several different styles of oriented aggregation data model

3.1 Key-value data model and document Data model

Common denominator: both contain a large number of aggregations, each of which has a key or ID used to get the data.

difference: The key-value database aggregates the aggregation as an opaque whole, a chunk of information that does not make much sense, and can only be traced by the key to the entire aggregation. Aggregations in the document database are transparent to the database, and you can query for and get a small subset of the data. The advantage of opacity is that arbitrary data can be stored, while the document database restricts what is stored in it, defines the allowable structure and data types, and provides the benefit of flexible access to the data.

You might think that an ID field in the document database is used as a "key-valued query", which is the same as the key-value database, but the difference is that the key-value database is the key to search for content, and the document database submits query keywords that are often based on the internal structure of the document, possibly a key, or something else.

3.2 Column Family data model

Most databases store data in behavioral units, particularly if you need to improve write performance. In some cases, however, there are few write operations, but it is often necessary to read many columns in one row at a time, in which case a set of columns for all rows is best for the base data storage unit. This is where the Columnstore database comes in.

BigTable and its successors follow the concept of "storing in a set of columns (column families)."

the best way to understand the column family model is to think of it as a "level two aggregation structure." For example, a column family model describes the user information structure, each row represents a user, contains the basic information column family (with name, address, age and other information), order list family (including all order lists), such as the first level aggregation is "row aggregation", is a row key to a row of data mapping, contains some useful data blocks ( Basic information, order information) of the column family. The second-level aggregation is the column family aggregation, where each column family defines a record type, such as customer information.

NOSQL (ii) aggregated data model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.