計算機科学のブログ

SQL - SQLite - Python - 複数テーブルのデータベース設計 - 現行テーブルからの脱却 - 外部キー, 主キー, 複合キー

Head First SQL ―頭とからだで覚えるSQLの基本Lynn Beighley(著)、 佐藤 直生(監訳)、 松永 多苗子(翻訳)、 オライリージャパンの 7章(複数テーブルのデータベース設計 - 現行テーブルからの脱却)、p.337(エクササイズ)の解答を求めてみる。

ER図

my_contacts.dio(VSCode, Draw.io Integration, SVG)

my_contacts
my_contacts
PK
PK
contact_id
contact_id
last_name
last_name
firstt_name
firstt_name
phone
phone
email
email
gender
gender
gender
gender
birthday
birthday
FK
FK
prof_id
prof_id
FK
FK
zip_code
zip_code
FK
FK
status_id
status_id
profession
profession
PK
PK
prof_id
prof_id
profession
profession
zip_code
zip_code
PK
PK
zip_code
zip_code
city
city
state
state
status
status
PK
PK
status_id
status_id
status
status
contact_interest
contact_interest
FK, CPK
FK, CPK
contact_id
contact_id
FK, CPK
FK, CPK
interst_id
interst_id
interest
interest
PK
PK
interest_id
interest_id
interest
interest
contact_seeking
contact_seeking
FK, CPK
FK, CPK
contact_id
contact_id
FK, CPK
FK, CPK
seeking_id
seeking_id
seeking
seeking
PK
PK
seeking_id
seeking_id
seeking
seeking
Text is not SVG - cannot display