第8章データ管理
Tuple and Document Storesタプルストアとドキュメントストア
A tuple and document store database stores data in XML or JSON format with the document name as key and the contents of the document as value.
タプルストアやドキュメントストアのデータベースは、文書名をキー、文書の内容を値として、XML形式またはJSON形式でデータを格納する。

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典
Figure 8.17 The same code written in (a) XML and (b) JSON shows the differences between the formats. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図8.17 同じコードを(a)XMLと(b)JSONで記述し、形式の違いを示している。(出典:著作権 Rice University、OpenStax、CC BY 4.0ライセンス)
Documents can contain many different value types and can be nested, making them particularly well-suited to manage semistructured data across distributed systems. For example, MongoDB and Couchbase are document-oriented databases that store data in flexible, schemaless documents, which allows for a high degree of flexibility in how data are stored and queried. However, MongoDB uses a flexible document model that allows for complex nested structures and hierarchical data, while Couchbase uses a key-value data model with JSON documents. This makes MongoDB more suited for complex data structures and Couchbase more suited for simpler data structures.
英語のヒント
文書は、さまざまな型の値を含められ、入れ子にもできるため、分散システムにまたがる半構造化データの管理に特に適している。たとえば、MongoDBとCouchbaseは、柔軟でスキーマを持たない文書へデータを格納するドキュメント指向データベースであり、格納方法や問い合わせ方法の自由度が高い。ただし、MongoDBは複雑な入れ子構造や階層データを扱える柔軟な文書モデルを使い、CouchbaseはJSON文書を持つキーバリューモデルを使う。そのため、MongoDBは複雑なデータ構造に、Couchbaseは単純なデータ構造に、より適している。
Column-Oriented Databases列指向データベース
A column-oriented database stores data in column families or tables and are built to manage petabytes of data across a massive distributed system (e.g., Cassandra and Hbase). Both Cassandra and HBase use a column-family data model to store and manage data and are both NoSQL databases that are designed to handle large volumes of data. However, Cassandra uses a partitioned row-store data model, while HBase uses a column-oriented data model. This means that Cassandra is optimized for high-speed reads and writes of individual rows, while HBase is optimized for scanning large tables of data.
英語のヒント
列指向データベースは、列ファミリーや表にデータを格納し、巨大な分散システムにまたがるペタバイト単位のデータを管理するよう作られている。CassandraやHBaseなどがその例である。どちらも列ファミリーのデータモデルを使ってデータを格納・管理し、大量のデータを扱うためのNoSQLデータベースである。ただし、Cassandraは分割された行ストアのデータモデルを使い、HBaseは列指向のデータモデルを使う。このため、Cassandraは個々の行の高速な読み書きに適し、HBaseは大きなデータ表の走査に適している。
Graph-Based Databasesグラフに基づくデータベース
A graph-based database represents data as a network of related nodes or objects to facilitate data visualizations and graph analytics. The graph may represent any relationship such as 1:1, 1:N, and N:M. It is useful for analyzing the relationships between heterogeneous data points, such as in fraud prevention or Facebook’s friend graph.
英語のヒント
グラフに基づくデータベースは、関連するノードやオブジェクトのネットワークとしてデータを表し、データの可視化とグラフ分析を容易にする。グラフは、1対1、1対多、多対多など、さまざまな関連を表せる。不正防止やFacebookの友人グラフのように、性質の異なるデータ点どうしの関連を分析するのに役立つ。
Other NoSQL DatabasesそのほかのNoSQLデータベース
There are many NoSQL databases such as XML databases, OO databases, database systems to deal with time series and streaming events, and database systems to store and query geospatial data (Spatial data refer to data that are associated with a specific location or geographic area. Spatial data can be managed and analyzed using a geographical information system.). There are also database systems such as BayesDB. BayesDB is a probabilistic programming platform that is based on a Bayesian approach to modeling data relationships. The structure of BayesDB can be broken down into several key components, including data tables and models that lets users query the probable implication of their data.
英語のヒント
NoSQLデータベースには、XMLデータベース、オブジェクト指向データベース、時系列やストリーミング事象を扱うシステム、地理空間データを格納・検索するシステムなど、多くの種類がある。空間データは、特定の位置や地理的範囲に結び付いたデータを指し、地理情報システムを使って管理・分析できる。BayesDBのようなデータベースシステムもある。BayesDBは、データ間の関連をベイズ的な方法でモデル化する、確率的プログラミングのプラットフォームである。その構造は、データ表やモデルなど、いくつかの主要な構成要素に分けられる。これらにより、利用者はデータが確率的に何を意味するかを問い合わせられる。
Transaction Management and Concurrency in NoSQL DatabasesNoSQLデータベースのトランザクション管理と並行性
With the increasing amount of data, the number of parallel transactions has increased. In this case, the capacity can be increased by extending the system capabilities (vertical scaling) or arranging multiple servers in a cluster (horizontal scaling). NoSQL databases distribute data over a cluster of database nodes for the sake of performance and availability.
英語のヒント
データ量の増加に伴い、並列に実行されるトランザクションの数も増えた。その場合、システムの能力を拡張する垂直スケーリングか、複数のサーバーをクラスターとして配置する水平スケーリングによって、処理能力を増やせる。NoSQLデータベースは、性能と可用性のために、データベースノードのクラスター全体へデータを分散する。
In many NoSQL implementations (e.g., Cassandra, Google’s BigTable, Amazon’s DynamoDB). all nodes implement the same functionality and are able to perform the role of request coordinator using a membership protocol. The membership protocol checks the availability of each node, which makes it easier to apply index between them but does not guarantee that every node is aware of every other node at all times. Hashing is the process of transforming a key to another value to implement a hash table. Consistent hashing avoids mapping each key to a new node in case nodes are added or deleted. Consistent hashing uses a modulo operator (%) to distribute keys over servers. The syntax is (H(key) = key % N) where N is the number of servers. Eventual consistency means the data and their replicas become consistent at some point in time after each transaction. NoSQL databases are categorized as eventual consistency because it guarantees up-to-date information; therefore, many NoSQL databases guarantee so-called eventual consistency based on the CAP theorem. The CAP theorem states that a distributed computer system cannot attain the following three properties concurrently: consistency (all nodes see the same data at the same time), availability (guarantees that every request receives a response, indicating a success or failure result), and partition tolerance (the system continues to work even if nodes go down or are added).
英語のヒント
Cassandra、GoogleのBigTable、AmazonのDynamoDBなど、多くのNoSQLの実装では、すべてのノードが同じ機能を持ち、メンバーシッププロトコルを使って要求の調整役を担える。このプロトコルは各ノードが利用可能かを確認する。これによってノード間へ索引を適用しやすくなるが、すべてのノードが常にほかのすべてのノードを把握しているとは限らない。ハッシュ化は、ハッシュ表を実装するために、キーを別の値へ変換する処理である。コンシステントハッシュ法は、ノードを追加・削除したときに、すべてのキーを新しいノードへ対応付け直すことを避ける。キーをサーバーへ分散するのに剰余演算子(%)を使い、その構文は(H(key) = key % N)となる。ここでNはサーバー数である。結果整合性は、各トランザクションの後、ある時点でデータとその複製の一貫性が得られることを意味する。最新の情報を保証するため、NoSQLデータベースは結果整合性の区分に入る。このように、多くのNoSQLデータベースはCAP定理に基づき、いわゆる結果整合性を保証する。CAP定理は、分散コンピューターシステムが次の三つの性質を同時には達成できないとする。一貫性は、すべてのノードが同じ時刻に同じデータを見ること。可用性は、すべての要求に対し、成功または失敗を示す応答を返すこと。分断耐性は、ノードが停止したり追加されたりしても、システムが動き続けることである。