Five types of database storage models (rows, columns, key values, documents, graphs)

Five types of database storage models (rows, columns, key values, documents, graphs)

Row storage

Definition: The relational model uses records (rows or tuples) for storage. The records are stored in tables, which are defined by the schema. Each column in the table has a name and type, and all records in the table must conform to the definition of the table. SQL is a special query language that provides corresponding syntax to find records that meet conditions, such as table join (Join). Table join can query records between multiple tables based on the relationship between the tables.

Storage format: A row database stores the data values ​​in a row together, and then stores the data in the next row, and so on.

For example, the following table:

EmpID LastName FirstName Salary
1 Smith Joe 40000
2 Jones Mary 50000
3 Johnson Cathy 44000

Features: According to the bank-related storage architecture for space allocation, it is mainly suitable for small batch data processing, and is often used for online transactional data processing. The latter three requirements cannot be met: high concurrent read and write requirements for the database, high-efficiency storage and access requirements for massive data, and high scalability and high availability for the database. One sentence is not suitable for distributed, high concurrency and mass.

Column store

Definition: What is a columnar database? A columnar database is a database with column-related storage architecture for data storage. Columnar storage stores all data in columns in a stream, and is mainly suitable for batch data processing and ad hoc queries.

Storage format:

Columnar databases string together the data values ​​in one column and store them together, and then store the data in the next column, and so on.

1,2,3;Smith,Jones,Johnson;Joe,Mary,Cathy;40000,50000,44000;

Features: including fast query, because the query needs to read fewer blocks; the data compression ratio is high, precisely because the same type of columns are stored together. Load is fast. Simplify the complexity of data modeling. However, the insert update is slow, and it is not suitable for the data to always change. It is stored in columns. At this time you know that it is suitable for DSS (decision support system), an excellent choice for BI, data mart, data warehouse, it is not suitable for OLTP.

Examples are Sybase IQ, C-Store, Vertica, VectorWise,MonetDB, ParAccel, and Infobright.

Please refer to: http://en.wikipedia.org/wiki/Column-oriented_DBMS .

Key-value store

Namely Key-Value storage, KV storage for short. It is a way of NoSQL storage. Its data is organized, indexed and stored in the form of key-value pairs. KV storage is very suitable for business data that does not involve too many data relationships and business relationships. At the same time, it can effectively reduce the number of times to read and write to disk, and has better read and write performance than SQL database storage.

A typical example of Sorted String Table is SSTable. In fact, map and hash_map in STL library, and hash_table and hash_map in Java are key-value storage. But their value only supports memory operations, and the query efficiency of map is too low. The key is that they are just simple data structures and cannot achieve large-scale storage and distribution, and the efficiency of data modification is relatively low. SSTalbe solves these problems.

Key-value storage is actually a kind of distributed table system.

The implementation mechanism can also refer to

LevelDB/Sstable: http://blog.chinaunix.NET/uid-26111972-id-3342215.html.

LevelDB :http://www.samecity.com/blog/Index.asp?SortID=12

Document storage

Document storage supports access to structured data. Unlike the relational model, document storage has no mandatory architecture.

In fact, document storage is stored in the form of packaged key-value pairs. In this case, the application adopts some conventions on the packets to be retrieved, or uses the storage engine's ability to divide different documents into different sets to manage data.

Unlike the relational model, the document storage model supports a nested structure. For example, the document storage model supports XML and JSON documents, and the "value" of a field can be nested to store other documents. The document storage model also supports arrays and column value keys.

Unlike key-value storage, document storage cares about the internal structure of the document. This allows the storage engine to directly support secondary indexes, allowing efficient queries on any field. The ability to support nested storage of documents makes the query language capable of searching nested objects. XQuery is an example. MongoDB achieves similar functions by supporting specifying the JSON field path in the query.

MongoDB is a more comprehensive database that supports SQL and ACID. However, it is more about the collection and storage of logs, the distributed storage of small files, and data storage similar to Internet microblog applications.

Comparison of MongoDB and Cassandra:
http://www.csdn.net/article/2013-08-23/2816679-time-series-data-mongdb-vs-cassandra

Graphic data

The graph database stores vertex and edge information, and some supports adding comments.

Graph databases can be used to model things, such as social graphs and various objects in the real world. The content of the IMDB (Internet MovieDatabase) site constitutes a complex image, with actors and movies intertwined with each other.

The query language of the graph database is generally used to find the path of the graph interruption point, or the attributes of the path between the end points. Neo4j is a typical graph database.

Guess you like

Origin blog.csdn.net/killingbow/article/details/53809379