Original Bottom-up of the basic data model of Cassandra

Source: Internet
Author: User
Tags cassandra

A Brief introduction

  For those who are accustomed to the relational database, learning Cassandra has some difficulties. Cassandra has a lot of new terminology, and the terms in relational db are similar but inherently different. Here we mainly learn the Cassandra data model from two angles: bottom-up and top-down.

Two-bottom-up understanding of the data model of Cassandra

  Cassandra is categorized as a NoSQL database because its design does not need to be predicted to define attribute columns like the relational db. Cassandra is stored in columns, and we can usually imagine the following model:

  

However, after using this data model to store the data, if the data is not placed in a fixed position, we need to look at the value of the individual values at the time of the query, and if you always place a value in a fixed position in this model, you must add a point character to maintain the relative position if there is no value. The root of these problems is that this data model, which can be called an array, is too simple to have enough semantics.

Therefore, we consider adding a dimension on top of some models to add semantics: the name of value. After giving each value a name, a mapping structure is given as shown.

  

This greatly increases the semantics, and we know the name of each value corresponding to its purpose.

Although the above model solves the problem of data storage and parsing (mainly solves the problem of correct parsing), this model can only store data of one instance, if there are multiple instances, they want to store the same data, what should we do?

Cassandra to solve this problem, add a name to the above data model and call it the row Key. Note that the row key here is essentially a name that differs from the row key in the relational db, but acts similarly, and is used to uniquely identify a set of data. After adding this row key, get the data model as shown:

  

After getting the concept of row, there is a new problem, how do we store multiple rows of data? Cassandra introduced the concept of a family of columns, used as a logical grouping, to associate similar data. Therefore, the column races can be compared to the table in the relational db.

By combining the concepts mentioned above, we get the basic data structure of Cassandra: columns, that is, Name/value pairs (the client also provides a timestamp for the most recent update); The column family is the container that is prepared for rows that have similar but different columns of collections.

Finally, I'll mention a little bit about the nesting problems that can occur from column to row evolution, which is called the Super column in Cassandra, and its essence is to use the row in row to encapsulate another layer. It is worth noting that only one layer of nesting is allowed in Cassandra.

Summary of three

  While it is not an initiative to compare the concepts in Cassandra with the concepts in the relational db, we can quickly understand the role of each concept and the source from which it is introduced by analogy. column, which is Name/value, and the column family is the equivalent of table, which is introduced for storing rows consisting of columns. As for the outer layer of the column family, that is the next article "[Original]cassandra basic data model of the top-down" described in the.

If there is a mistake, please leave a message!

Original Bottom-up of the basic data model of Cassandra

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.