開発環境
Head First SQL ―頭とからだで覚えるSQLの基本 (Lynn Beighley(著)、 佐藤 直生 (監訳)、 松永 多苗子 (翻訳)、オライリージャパン)の7章(複数テーブルのデータベース設計: 現行テーブルからの脱却)、エクササイズ(p.337)を解いてみる。
エクササイズ(p.337)
| my_contacts |
| contact_id(主キー) |
| last_name |
| first_name |
| phone |
| email |
| gender |
| birthday |
| profession_id |
| zip_code |
| status_id |
| zip_code |
| zip_code(主キー) |
| city |
| state |
| status |
| status_id(主キー) |
| state |
| contact_interest |
| contact_id(複合キー) |
| interest_id(複合キー) |
| interests |
| interest_id(主キー) |
| interest |
| contact_seeking |
| contact_id(複合キー) |
| seeking_id(複合キー) |
| seeking |
| seeking_id(主キー) |
| seeking |
| profession |
| profession_id(主キー) |
| profession |
外部キー間の関係, 1対多関係, 多対多関係
- my_contactsとinterests, 多対多関係
- contact_id(my_contacts -> contact_interest), 1対多
- interest_id(interests -> contact_interest), 1対多
- my_contactsとseeking, 多対多
- contact_id(my_contacts -> contact_seeking), 1対多
- seeking_id(seeking -> contact_seeking), 1対多
- profession_id(profession -> my_contacts), 1対多
- zip_code(zip_code -> my_contacts), 1対多
- status_id(status -> my_contacts), 1対多
0 コメント:
コメントを投稿