第8章データ管理
Tuple Relational Calculus and Domain Relational Calculusタプル関係計算とドメイン関係計算
In a relational database, a tuple is one row with a collection of values separated by a comma and enclosed in parenthesis. An example of a tuple in Python represents the employee Smith, his phone number, age, and zip code.
英語のヒント
関係データベースでは、タプルは一行を表し、コンマで区切って丸括弧で囲んだ値の集合からなる。次のPythonのタプルの例は、従業員Smithと、その電話番号、年齢、郵便番号を表す。
tuple = {'Smith', 8882355151, 50, 48505}Data inside a tuple can be of any type such as integer, string, float value, or a tuple type.
タプル内のデータには、整数、文字列、浮動小数点数、タプル型など、どのような型でも使える。
Tuple relational calculus uses tuple variables as key building blocks. A tuple variable refers to a tuple of a corresponding relation (also called range relation). A tuple relational calculus expression specifies a range relation for each tuple variable, a condition to select (combinations of) tuples, and a list of attribute types from which the values should be retrieved. As a result, a tuple relational calculus expression looks as follows:
英語のヒント
タプル関係計算では、タプル変数を主要な構成要素として使う。タプル変数は、対応する関係(範囲関係とも呼ぶ)のタプルを指す。タプル関係計算の式は、各タプル変数の範囲関係、タプルまたはその組み合わせを選ぶ条件、値を取得する属性型の一覧を指定する。そのため、式は次のような形になる。
{t(A_i) | Cond(t)}whereby t represents the tuple variable, Ai the attribute type of which the value needs to be retrieved, and Cond(t) the range relation and extra conditions to select relevant tuples. Consider the following example:
英語のヒント
ここでtはタプル変数、Aiは値を取得する属性型、Cond(t)は範囲関係と、該当するタプルを選ぶための追加条件を表す。次の例を考えよう。
{t.StudentID, t.StudentName | Student(t) AND t.StudentProgram = 3}A condition is specified using a well-formed (calculus) formula (wff), which can consist of various predicate calculus atoms combined using Boolean operators (and, or, not). The result of applying a formula to a tuple of a range relation can either be true, false, or unknown. If the result is true, the tuple will be selected in the result. Relational calculus also includes quantifiers such as the existential quantifier (∃or EXISTS) and universal quantifier (∀or FOR ALL). A formula with an existential quantifier (∃) evaluates to true if at least one tuple satisfies it. A formula with a universal quantifier (∀) evaluates to true if every tuple from the range relation satisfies the conditions stated.
英語のヒント
条件は、整形式の(論理計算の)論理式(wff)を使って指定する。これは、ブール演算子(and、or、not)で組み合わせた、さまざまな述語論理の原子式から構成できる。範囲関係のタプルに論理式を適用した結果は、真、偽、不明のいずれかになる。結果が真なら、そのタプルを結果として選ぶ。関係計算には、存在量化子(∃またはEXISTS)と全称量化子(∀またはFOR ALL)などの量化子もある。存在量化子(∃)を持つ論理式は、少なくとも一つのタプルがその式を満たせば、真と評価される。全称量化子(∀)を持つ論理式は、範囲関係のすべてのタプルが、記された条件を満たせば、真と評価される。
Instead of tuple variables, domain relational calculus defines domain variables that range over single values of domains of attribute types. A domain calculus expression for a relation of degree n looks as follows:
英語のヒント
ドメイン関係計算は、タプル変数の代わりに、属性型の定義域の個々の値を取る、ドメイン変数を定義する。次数nの関係についてのドメイン計算の式は、次のようになる。
1, v2, …vn, | COND(v1, v2, …vn) }{v1, v2, …vn, | COND(v1, v2, …vn) }where v1, v2, …vn represent the domain variables that range over domains of attribute types, and COND represents the extra conditions.
ここでv1、v2、…vnは、属性型の定義域の値を取るドメイン変数を表し、CONDは追加の条件を表す。
The earlier tuple relational calculus query selecting the student ID and student name of all students who study in program number 3 would now look as follows:
先ほどの、プログラム番号3で学ぶすべての学生の学生IDと氏名を選ぶ、タプル関係計算の問い合わせは、今度は次のようになる。
{ab| ∃(e) (Student(abcde) AND e = 3)}In this case, we defined five domain variables as a for the domain of StudentID, b for the domain of StudentName, c for the domain of StudentAddress, d for the domain of StudentCity, and e for the domain of StudentProgram. The condition e = 3 is a selection condition.
この場合、五つのドメイン変数を定義した。aはStudentIDの定義域、bはStudentNameの定義域、cはStudentAddressの定義域、dはStudentCityの定義域、eはStudentProgramの定義域に対応する。e = 3という条件は、選択条件である。
The existential quantifier (∃ or EXISTS) and universal quantifier (∀ or FOR ALL) are also supported in domain relational calculus.
存在量化子(∃またはEXISTS)と全称量化子(∀またはFOR ALL)は、ドメイン関係計算でも使える。
Query-by-Example (QBE) Language例示による問い合わせ(QBE)言語
The relational database language based on domain relational calculus is called query-by-example (QBE). QBE queries are expressed via a graphical query language, using visual tables where the user enters commands, example elements, and conditions. A parser converts the QBE graphical queries into statements expressed in a database manipulation language, such as SQL.
英語のヒント
ドメイン関係計算に基づく関係データベース言語を、例示による問い合わせ(QBE)という。QBEの問い合わせは、視覚的な表に利用者がコマンド、例となる要素、条件を入力する、グラフィカルな問い合わせ言語で表す。解析器は、QBEの図形式の問い合わせを、SQLなどのデータベース操作言語の文へ変換する。
Logical Design論理設計
The process of logical design involves designing a database based on a specific data model but independent of physical details. The logical design for a relational DBMS includes specifications for tables, relationships, and constraints. The logical design is performed in four steps: map conceptual model to logical model components, validate the logical model using normalization, validate logical model constraints, and validate the logical model against user requirements.
英語のヒント
論理設計では、特定のデータモデルに基づきつつ、物理的な細部には依存せず、データベースを設計する。関係DBMSの論理設計には、表、関連、制約の仕様が含まれる。論理設計は四つの段階で行う。概念モデルを論理モデルの構成要素へ対応させ、正規化を使って論理モデルを検証し、論理モデルの制約を検証し、利用者の要件に照らして論理モデルを検証する。
To determine the quality of relation schema design, we follow the informal design guidelines for relational schemas and use simple measures of quality such as making sure attribute semantics are clear, reducing redundant information, and reducing null values. Null values cause redundant work, which wastes storage space and increases the difficulty of performing operations.
英語のヒント
関係スキーマの設計品質を判断するには、関係スキーマの非形式的な設計指針に従い、単純な品質の尺度を使う。たとえば、属性の意味を明確にすること、冗長な情報を減らすこと、ヌル値を減らすことである。ヌル値は余分な作業を引き起こし、格納領域を浪費し、操作を難しくする。