テーブルを連携させる
2つのテーブルの連携を考える。
peapleテーブル(personの複数形)
id | INT,プライマリキー,AutoIncrement |
name | Text, Not Null, Unique |
password | Text, Not Null |
comment | Text, Null |
boardsテーブル
id | Int,プライマリキー,AutoIncrement |
person_id | Not Null |
title | Text |
content | Text |
person_idは外部キーということになる。
テーブルの結合
3つのJOIN
- LEFT JOIN
- RIGHT JOIN
- INNER JOIN
わかりやすい解説があった。
A Visual Explanation of SQL Joins
このリンクを読んだ後以下を読むと意味がわかる。
qiita.com