2018-08-07 11:36:36
概要複数のテーブルに対し、多対1でテーブルが関係付くときのテーブル設計のパターンについてまとめる。
データ設計以下のようなケースのデータ設計を例とする。
issues
id
title
pullrequests
id
title
comments
id
content
commentsがissues、pullrequestsのどちらに対しても多対一で関係付くようなケース。
ポリモーフィック関連
issues
id
title
pullrequests
id
title
comments
id
content
target_table
target_id...
データベース
ポリモーフィック
SQLアンチパターン