Foreign Key とは?
Foreign key は、ある table の column または column の集合で、別の table の primary key を参照し、それらの行間の関係を確立します。データベースは、すべての foreign key の値が既存の親行を指すことを強制します。この constraint は関連するデータを table 間で一貫した状態に保ちます。
なぜ重要か
Foreign key は、存在しないレコードを参照する孤立した行を防ぎます。アプリケーションコードに保守を依存する代わりに、schema 自体に関係をエンコードします。
関連ガイド
What Is Referential Integrity?Referential integrity is the guarantee that every foreign key value refers to an existing row, so relationshi…
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…