参照整合性とは?
参照整合性は、ある table から別の table へのすべての参照が実際に存在する行を指すというデータベースの性質です。宙に浮いた参照を残すような insert や delete を拒否する foreign key constraint によって強制されます。これを維持することで、データ内の関係を信頼できるものに保ちます。
なぜ重要か
参照整合性がないと、クエリは削除された親を参照する行を返し、混乱したり壊れたりした結果を生みます。schema で強制することで、一連の整合性チェックをアプリケーションコードから卸します。
関連ガイド
What Is a Foreign Key?A foreign key is a column whose values must match a key in another table, linking rows across tables and enfo…
What Is a Surrogate Key?A surrogate key is an artificial identifier, such as an auto-incrementing number or UUID, used as a primary k…
What Is a Natural Key?A natural key is a primary key drawn from meaningful business data that is already unique, such as an email a…