# Foreign Key

__*FOREIGN KEY*__

+ TiDB supports foreign key syntax to avoid syntax errors when migrating data from other databases to TiDB
+ TiDB does not perform constraint checks on foreign keys
```10
tidb> CREATE TABLE test.p (id INT PRIMARY KEY, name CHAR(30));
tidb> CREATE TABLE test.c (id INT PRIMARY KEY, pid INT NOT NULL, ~!@FOREIGN KEY (pid) REFERENCES test.p (id)@!~);
tidb> INSERT INTO test.p VALUES (~!@1@!~,'A');
tidb> INSERT INTO test.c VALUES (1,~!@100@!~);

SELECT ~!@'p', id@!~ FROM test.p 
UNION ALL 
SELECT ~!@'c', pid@!~ FROM test.c;
+------+------+
| p    | id   |
+------+------+
| c    |  100 |
| p    |    1 |
+------+------+
```
------------------------------------------------------------
[no notes]