概要複数のテーブルに対し、多対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 commentsにtarget_tableとtarget_idというカラムを追加し、issuesとpullrequestsのどちらに結びつくか判断させようとするテーブル設計。 SQLアンチパターンではアンチパターンの一つとして取り上げられて
![bmf-tech.com - 複数のテーブルに多対1で紐づく時のテーブル設計のアプローチについて](https://cdn-ak-scissors.b.st-hatena.com/image/square/5996e4a659e179a95617005ca0b3a183da527172/height=288;version=1;width=512/http%3A%2F%2Fbmf-tech.com%2Fvendor%2Fbmftech%2Fimg%2Fheader.jpg)