プリンキピア

第8章データ管理

8.3 Relational Database Management Systems8.3 関係データベース管理システム

Learning Objectives学習目標
By the end of this section, you will be able to:
この節を終えると、次のことができるようになる。
• Discuss the relational model
• 関係モデルを論じる。
• Describe the theoretical and practical aspects of the structured query language (SQL)
• 構造化照会言語(SQL)の理論面と実践面を述べる。
• Explain how to create a logical relational database design
• 関係データベースの論理設計を作成する方法を説明する。
• Demonstrate how to create a physical relational database design
• 関係データベースの物理設計を作成する方法を示す。
• Discuss application programming interfaces and techniques used to program relational database applications
• 関係データベースアプリケーションをプログラムするための、APIと技法を論じる。
• Identify the various components of a relational database management system
• 関係データベース管理システムの、さまざまな構成要素を見分ける。
A relational database management system (RDBMS) is one type of DBMS that stores related data elements in a row-based table structure. An RDBMS transaction is a single logical unit of work that accesses and possibly modifies the contents of a database using read-and-write operations. Multiple SQL commands may be performed as part of a single RDBMS transaction as a single logical unit of work. For example, a student may register for multiple courses using a university’s registration system. To maintain consistency in a RDBMS, transactions satisfy properties known as atomicity, consistency, isolation, and durability (ACID). These properties are necessary for maintaining data consistency, integrity, and reliability while performing transactions via a RDMBS. Atomicity ensures that multiple SQL commands that are part of the same transaction are executed atomically (i.e., as a unit). In the example mentioned earlier, once the registration transaction is complete, the student will be registered for all three courses. If that is not possible because one of the courses is full, the transaction will not complete successfully. Consistency ensures that only valid data are written in the database. In the student registration example, it simply means that the registration information stored in the database will be consistent with the registration transaction that was completed. Isolation guarantees that multiple users that access the RDBMS concurrently will not be affected by the transactions performed by others. In the course registration example, multiple students can register concurrently without any of them noticing any side effects that result from the RDBMS being accessed by multiple students concurrently. Finally, durability guarantees that once information has been stored in the database, it will be stay there permanently. In the course registration example, if one student registers successfully, the registration information will not change unless they decide to go back and perform another drop/add transaction. While ACID transaction properties ensure that stored data are reliable and accurate, they also come at a cost. For example, guaranteeing full isolation in a RDBMS requires significant additional processing time.
英語のヒント
関係データベース管理システム(RDBMS)は、関連するデータ要素を、行を中心とする表構造に保存するDBMSの一種である。RDBMSのトランザクションは、読み書きの操作でデータベースの内容にアクセスし、場合によっては変更する、一つの論理的な作業単位である。一つの論理的な作業単位として、一回のRDBMSトランザクションの中で、複数のSQLコマンドを実行する場合がある。たとえば学生が、大学の履修登録システムを使って、複数の科目へ登録する場合である。RDBMS内の一貫性を維持するため、トランザクションは、原子性、一貫性、分離性、永続性という、ACIDとして知られる性質を満たす。これらは、RDBMSでトランザクションを実行しながら、データの一貫性、整合性、信頼性を保つために必要である。原子性は、同じトランザクションに含まれる複数のSQLコマンドを、分割せず一つの単位として実行することを保証する。先ほどの例では、登録トランザクションが完了すると、学生は三つの科目すべてに登録される。一つの科目が定員に達していて、それが不可能なら、トランザクションは正常には完了しない。一貫性は、有効なデータだけがデータベースへ書き込まれることを保証する。履修登録の例では、保存された登録情報が、完了した登録トランザクションと一致することを意味する。分離性は、RDBMSへ並行してアクセスする複数の利用者が、ほかの利用者のトランザクションの影響を受けないことを保証する。履修登録の例では、複数の学生が並行して登録でき、誰も、複数の学生による同時のRDBMSアクセスに起因する副作用に気付かずに済む。最後に、永続性は、一度データベースへ保存した情報が、永続的に残ることを保証する。履修登録の例では、一人の学生が正常に登録を終えれば、もう一度戻り、履修の取り消しや追加のトランザクションを実行すると決めない限り、登録情報は変わらない。ACIDの性質は、保存データの信頼性と正確性を保証するが、そのための費用も伴う。たとえばRDBMSで完全な分離性を保証するには、相当の追加処理時間が必要になる。
Due to the use of database logical schemas that constrain the row-based table structure and require each field to abide to specific type constraints, RDBMS are not good at storing unstructured or semistructured data. The rigid schema also makes RDBMS more expensive to set up, maintain, and grow. RDBMS requires users to have specific use cases in advance, and any changes to the schema are usually difficult and time-consuming. In addition, traditional RDBMS were designed to run on a single computer node, which means their speed is significantly slower when processing large volumes of data. Sharding RDBMS is a partitioning method that splits the database into smaller components, which makes the management process faster, but using it while maintaining ACID compliance is challenging.
英語のヒント
RDBMSは、行を中心とする表構造を制約し、各フィールドに特定の型制約を守らせる、データベースの論理スキーマを使う。そのため、非構造化データや半構造化データの格納には向いていない。厳格なスキーマは、RDBMSの導入・保守・拡大を、より高価にもする。RDBMSは、利用者が事前に具体的な用途を定めることを求め、スキーマの変更は、通常、難しく時間もかかる。さらに、従来のRDBMSは、一台のコンピューターノードで動くように設計されていた。そのため、大量のデータを処理するときは、速度が大幅に遅くなる。RDBMSのシャーディングは、データベースを小さな構成部分に分割し、管理処理を速める方法である。しかし、ACIDへの適合を維持しながら使うことは難しい。

Relational Model関係モデル

The relational model of data is based on the concept of a relation. A relation is a mathematical concept based on the ideas of sets. The model was first proposed by Dr. Edgar F. Codd of IBM Research in 1970. A relation typically contains a set of rows. The data elements in each row represent certain facts that correspond to a real-world entity or relationship. In the formal model, rows are called tuples, each column has a column header that indicates the meaning of the data items in that column, and the column header is referred to as an attribute name or just as an attribute. Multiple attributes may be selected to form superkeys that uniquely identify individual tuples. Minimal superkeys are referred to as candidate keys. Candidate keys are considered minimal because they should only include a minimum number of attributes to uniquely identify individual tuples. For example, a car database may use the vehicle identification number (VIN) and the make of the vehicle attributes as a candidate key. Another possible candidate key could be obtained by using the license plate and state of the vehicle. Either one of the candidate keys can be selected as a primary key, which then provides a unique identifier for each table record (Table 8.2). A constraint on the primary key is called a key constraint and provides a unique value, assigns a default value to a column if none is specified, and checks for predefined conditions before inserting the data.
英語のヒント
データの関係モデルは、関係という概念に基づく。関係は、集合の考え方に基づく数学的な概念である。このモデルは、1970年にIBM Researchのエドガー・F・コッド博士が初めて提案した。関係は、通常、行の集合を含む。各行のデータ要素は、現実世界の実体や関連に対応する、特定の事実を表す。形式的なモデルでは、行をタプルという。各列には、その列のデータ項目の意味を示す列見出しがあり、属性名、または単に属性と呼ぶ。個々のタプルを一意に識別するスーパーキーを作るために、複数の属性を選ぶ場合がある。極小のスーパーキーを候補キーと呼ぶ。候補キーを極小とするのは、各タプルを一意に識別するのに必要な最小限の属性だけを含むべきだからである。たとえば車のデータベースでは、車両識別番号(VIN)とメーカーという属性を、候補キーとして使う場合がある。ナンバープレートと車両の州を使って、別の候補キーを得ることもできる。候補キーのいずれか一つを主キーとして選べば、表の各レコードに一意の識別子を与えられる(表8.2)。主キーに課す制約をキー制約という。一意の値を与え、値の指定がない列には既定値を割り当て、データを挿入する前に、あらかじめ定めた条件を確認する。
License_number
License_number(登録番号)
Engine_serial_number
Engine_serial_number(エンジン製造番号)
Make
Make(メーカー)
Model
Model(車種)
Year
Year(年)
Texas ABC-739
A69352
Ford
Mustang
02
Florida TVP-347
B43696
Oldsmobile
Cutlass
05
New York MPO-22
X83554
Oldsmobile
Delta
01
California 432-TFY
C43742
Mercedes
190-D
99
California RSK-629
Y82935
Toyota
Camry
04
Texas RPN-624
U028365
Jaguar
XJS
04
Table 8.2 Primary Key Example in a Car Table for a RDBMS The primary key in a table is typically underlined.
表8.2 RDBMSの車両表における主キーの例。表の主キーには、通常、下線が引かれる。