0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

外部キー

Posted at

外部キーとは

The relationship between customers table and orders table is one-to-many. And this relationship is established by the foreign key in the orders table specified by the customerNumber column.

出典

https://www.mysqltutorial.org/mysql-foreign-key/#:~:text=The%20relationship%20between%20customers%20table%20and%20orders%20table%20is%20one%2Dto%2Dmany.%20And%20this%20relationship%20is%20established%20by%20the%20foreign%20key%20in%20the%20orders%20table%20specified%20by%20the%20customerNumber%20column.

顧客テーブルと受注テーブルの関係は、一対多である。そして、この関係は、customerNumber列で指定されたordersテーブルの外部キーによって確立されている。
出典 deepL

MySQL supports foreign keys, which permit cross-referencing related data across tables, and foreign key constraints, which help keep the related data consistent.
A foreign key relationship involves a parent table that holds the initial column values, and a child table with column values that reference the parent column values. A foreign key constraint is defined on the child table.

出典

https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html#:~:text=MySQL%20supports%20foreign%20keys,on%20the%20child%20table.

MySQL は、テーブル間で関連するデータの相互参照を可能にする外部キーと、関連するデータの一貫性を保つための外部キー制約をサポートしています。

外部キー関係には、最初のカラム値を保持する親テーブルと、親カラム値を参照するカラム値を保持する子テーブルが含まれます。子テーブルには、外部キー制約が定義されています。
出典 deepL

感想

関係を確立させるために外部キーを設定するのか。
何となく知っていたけど、改めて理解した気がする。
まだ自信がない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?