千里之行,始于足下.
老子
学習目標¶
- リレーションの概念を理解する.
- 直積,濃度,次数の概念を理解し,計算できる.
- リレーションスキーマとインスタンスの違いを理解する.
- 第1正規形の概念を理解し,非第1正規形リレーションを正規化できる.
データモデルの要素¶
- 構造記述:データベースの構成要素の記述
- 意味記述:データベースの一貫性制約の記述
- 操作記述:データベース操作言語
A data model is a combination of at least three components:
- A collection of data structure types (the database building, blocks);
- A collection of operators or rules of inference, which can be applied to any valid instances of the data types listed in (1), to retrieve, derive, or modify data from any parts of those structures in any combinations desired;
- A collection of general integrity rules, which implicitly or explicitly define the set of consistent database states or changes of state or both--these rules are general in the sense that they apply to any database using this model (incidentally, they may sometimes be expressed as insert-update-delete rules).
E. F. Codd. 1982. Relational database: a practical foundation for productivity. Commun. ACM 25, 2 (Feb 1982), 109–117. Codd (1982)
リレーションとは¶
ドメイン¶
直積¶
リレーション¶
濃度と次数¶
テーブルとリレーション¶
リレーションをテーブル(table)として表すことができる.テーブルの行はリレーションのタプルであり,テーブルの列はリレーションのドメインに対応する.
リレーションスキーマとインスタンス¶
属性名(attribute name)はテーブルの列の名前であり,リレーション名(relation name)はテーブルの名前である.
ドメイン関数を用いたリレーションの定義¶
リレーションスキーマとインスタンス¶
第1正規形¶
非第1正規形¶
ドメインを複数のドメインの直積として定義する入れ子型リレーションは非第1正規形である.
べき集合(power set)として定義されるドメインも非第1正規形である.
練習問題¶
問題1:非第1正規形からの正規化¶
以下のようなリレーションがある:
| 注文ID | 顧客名 | 商品一覧 |
|---|---|---|
| 1001 | 佐藤 | {りんご, バナナ, オレンジ} |
| 1002 | 鈴木 | {バナナ, パイナップル} |
- 上記リレーションが 非第1正規形 である理由を説明せよ。
- このリレーションを 第1正規形 に正規化せよ。
- 正規化後のリレーションに対し、リレーションスキーマを明記し、そのインスタンスをテーブル形式で記述せよ。
問題2:リレーションスキーマとインスタンス¶
リレーションスキーマ について、各属性は以下のように定義される。
- :学籍番号
- :氏名
- :年齢
- :所属(学部名)
以下の問いに答えよ。
- の具体的なインスタンスを 3件分、テーブル形式で作成せよ。
- そのインスタンスをリレーション として 集合表記 で表せ。
- の 濃度 と 次数 を求めよ。
- (所属)の ドメイン を定義せよ。
- Codd, E. F. (1982). Relational database: a practical foundation for productivity. Communications of the ACM, 25(2), 109–117. 10.1145/358396.358400