第8章データ管理
THINK IT THROUGH考えてみよう
The Relational Model and Constructors関係モデルと構成子
The relational model uses two types of constructors. One is “aggregate of,” which enables the creation of tables by aggregating various columns that contain data of different types. The other is “set of,” which enables the gathering of multiple records within a table.
英語のヒント
関係モデルは、二つの種類の構成子を使う。一つは「aggregate of」で、異なる型のデータを含むさまざまな列を集約し、表を作れるようにする。もう一つは「set of」で、一つの表の中に複数のレコードを集められるようにする。
Is there a limitation with this approach?
この方法には限界があるだろうか。
RDBMS APIs and Programming TechniquesRDBMSのAPIとプログラミング技法
A database architecture is a representation of the design that helps design, develop, implement, and maintain the DBMS. This section covers RDBMS architectures, database APIs, object persistence and object-relational mappings (ORMs), and sample RDBMS applications.
英語のヒント
データベースアーキテクチャーは、DBMSの設計・開発・実装・保守に役立つ、設計の表現である。この部分では、RDBMSのアーキテクチャー、データベースAPI、オブジェクトの永続化とオブジェクト関係マッピング(ORM)、RDBMSのアプリケーション例を扱う。
RDBMS ArchitecturesRDBMSのアーキテクチャー
A relational database management system (RDBMS) architecture is categorized as a centralized system architecture and a tiered system architecture. In centralized system architecture, the DBMS’s responsibilities are handled by one centralized entity—the mainframe database, which has become rare, expensive, and difficult to maintain. The tiered system architectures aim to decouple the centralized setup by combining the computing capabilities of powerful central computers with the flexibility of personal computers (PCs).
英語のヒント
関係データベース管理システム(RDBMS)のアーキテクチャーは、集中型システムと階層型システムに分類される。集中型システムでは、一つの集中した主体であるメインフレームのデータベースが、DBMSの責務を担う。これは、現在では珍しく、高価で、保守が難しいものとなっている。階層型システムのアーキテクチャーは、強力な中央コンピューターの計算能力と、パーソナルコンピューター(PC)の柔軟性を組み合わせ、集中した構成を分離することを目指す。
There are multiple variants of the tiered system architecture such as two-tier architecture or client-server architecture. The fat client variant is where presentation logic and application logic are handled by the client and is common in cases where it makes sense to couple an application’s workflow with its look and feel; in that case, the DBMS now fully runs on the database server. A thin client variant is one where only the presentation logic is handled by the client and applications and database commands are executed on the server; it is common when application logic and database logic are tightly coupled or similar. Three-tier architecture decouples application logic from the DBMS and puts it in a separate layer (i.e., application server). Note: application server or database server may consist of multiple physical, distributed machines.
英語のヒント
階層型システムのアーキテクチャーには、2層型やクライアントサーバー型など、複数の種類がある。ファットクライアント方式では、表示のロジックとアプリケーションのロジックを、クライアントが処理する。アプリケーションの仕事の流れと、見た目や操作感を結び付けるのが妥当な場合によく使われる。この場合、DBMSはすべてデータベースサーバー上で動く。シンクライアント方式では、クライアントが処理するのは表示のロジックだけで、アプリケーションとデータベースのコマンドはサーバーで実行する。これは、アプリケーションのロジックとデータベースのロジックが、密接に結び付く、または似ている場合によく使われる。3層型では、アプリケーションのロジックをDBMSから切り離し、別の層、すなわちアプリケーションサーバーへ置く。なお、アプリケーションサーバーやデータベースサーバーは、複数の、物理的に分散したマシンで構成される場合がある。
Database APIsデータベースAPI
In a tiered DBMS system architecture, client applications can query database servers and receive results. It is possible to use in-process DBMSs (e.g., SQLite) or access stand-alone DBMS servers (e.g., Postgres). Client applications that wish to utilize the services provided by a DBMS use a specific API provided by the DBMS. This database API exposes an interface through which client applications can access and query a DBMS. The database server receives calls made by clients and executes the relevant operations before returning the results. In many cases, the client and server interfaces are implemented to work over a computer network using network sockets. The main goal of a database API is to expose an interface through which other parties can utilize the services provided by the DBMS. Most DBMS vendors provide a proprietary, DBMS-specific API (the disadvantage is that client applications must be aware of the DBMS that will be utilized on the server side). Alternatively, generic, vendor-agnostic universal APIs have been proposed, and they allow to easily port applications to multiple DBMSs.
英語のヒント
階層型DBMSシステムのアーキテクチャーでは、クライアントアプリケーションがデータベースサーバーへ問い合わせ、結果を受け取れる。プロセス内で動くDBMS(SQLiteなど)を使うことも、独立したDBMSサーバー(Postgresなど)へアクセスすることもできる。DBMSのサービスを利用したいクライアントアプリケーションは、そのDBMSが提供する特定のAPIを使う。このデータベースAPIは、クライアントアプリケーションがDBMSにアクセスし、問い合わせるためのインターフェースを公開する。データベースサーバーは、クライアントからの呼び出しを受け、該当する操作を実行してから、結果を返す。多くの場合、クライアントとサーバーのインターフェースは、ネットワークソケットを使い、コンピューターネットワーク越しに動くよう実装される。データベースAPIの主な目標は、ほかの主体がDBMSのサービスを使うためのインターフェースを公開することである。多くのDBMS提供企業は、独自の、DBMS固有のAPIを提供する。欠点は、クライアントアプリケーションが、サーバー側でどのDBMSを使うかを把握しなければならないことである。代わりに、提供企業に依存しない、汎用的で共通のAPIも提案されており、アプリケーションを複数のDBMSへ容易に移植できるようにする。
APIs can be embedded or call-level. Embedded API embeds SQL statements in the host programming language, meaning that SQL statements are part of the source code. (Before the program is compiled, a SQL precompiler parses the SQL-related instructions and replaces them with source code instructions native to the host programming language used. Converted source code is then sent to the actual compiler.) Call-level APIs (SQL/CLI) work by passing SQL instructions to the DBMS by means of direct calls to a series of procedures, functions, or methods as provided by the API to perform the necessary actions (e.g., ODBC/JDBC).
英語のヒント
APIには、埋め込み型と呼び出しレベル型がある。埋め込みAPIは、SQL文をホストのプログラミング言語へ埋め込む。つまり、SQL文がソースコードの一部になる。プログラムをコンパイルする前に、SQLプリコンパイラーがSQL関連の命令を解析し、使っているホスト言語本来のソースコード命令へ置き換える。変換後のソースコードを、実際のコンパイラーへ渡す。呼び出しレベルAPI(SQL/CLI)は、必要な操作を行うためにAPIが提供する、一連の手続き、関数、メソッドを直接呼び出し、SQLの命令をDBMSへ渡すことで動く。ODBCやJDBCなどが例である。
Object Persistence and Object-Relational Mappings (ORMs)オブジェクトの永続化とオブジェクト関係マッピング(ORM)
API technologies such as JDBC and ADO.NET represent database-related entities (e.g., tables, records) in an object-oriented (OO) way. As plain domain entities such as Book and Author are represented as objects using a programming language’s representational capabilities and syntax, object persistence ensures that the corresponding object data are persisted behind the scenes to a database or other data source. Language-integrated query technologies apply similar ideas while object persistence APIs go a step further as they also describe the full business domain (i.e., the definition of data entities) within the host language. They allow for efficient querying of objects; such entities are frequently mapped to a relational database model using an object relational mapper (ORM). It is not strictly necessary to utilize an ORM to enable object persistence, though most APIs tightly couple both concepts.
英語のヒント
JDBCやADO.NETなどのAPI技術は、表やレコードなどのデータベース関連の実体を、オブジェクト指向(OO)の形で表現する。BookやAuthorなどの通常の対象領域の実体を、プログラミング言語の表現能力と構文でオブジェクトとして表すとき、オブジェクトの永続化は、対応するオブジェクトのデータが、裏側でデータベースやほかのデータ源に保存され続けるようにする。言語統合問い合わせの技術も、同様の考え方を使う。オブジェクト永続化APIは、さらに一歩進み、業務領域全体、すなわちデータ実体の定義も、ホスト言語内で記述する。オブジェクトを効率よく問い合わせることができ、それらの実体は、オブジェクト関係マッパー(ORM)を使って、関係データベースモデルへ対応付けられることが多い。オブジェクトの永続化を可能にするために、ORMが必須というわけではない。ただし、多くのAPIは、この二つの概念を密接に結び付けている。