Skip to content

Commit

Permalink
mark the support of foreign key as experimental (pingcap#15290)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiancai authored Nov 9, 2023
1 parent b3ecd3c commit 2cd14da
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion basic-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ You can try out TiDB features on [TiDB Playground](https://play.tidbcloud.com/?u
| [Clustered index on integer `PRIMARY KEY`](/clustered-indexes.md) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| [Clustered index on composite or non-integer key](/clustered-indexes.md) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | N |
| [Multi-valued indexes](/sql-statements/sql-statement-create-index.md#multi-valued-indexes) | Y | Y | Y | Y | N | N | N | N | N | N | N | N |
| [Foreign key](/constraints.md#foreign-key) | Y | Y | Y | Y | N | N | N | N | N | N | N | N |
| [Foreign key](/constraints.md#foreign-key) | E | E | E | E | N | N | N | N | N | N | N | N |
| [TiFlash late materialization](/tiflash/tiflash-late-materialization.md) | Y | Y | Y | Y | N | N | N | N | N | N | N | N |

## SQL statements
Expand Down
2 changes: 1 addition & 1 deletion constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ For more details about the primary key of the `CLUSTERED` type, refer to [cluste

> **Note:**
>
> Starting from v6.6.0, TiDB supports the [FOREIGN KEY constraints](/foreign-key.md) feature. Before v6.6.0, TiDB supports creating and deleting foreign key constraints, but the constraints are not actually effective. After upgrading TiDB to v6.6.0, you can delete the invalid foreign key and create a new one to make the foreign key constraints effective.
> Starting from v6.6.0, TiDB supports the [FOREIGN KEY constraints](/foreign-key.md) as an experimental feature. Before v6.6.0, TiDB supports creating and deleting foreign key constraints, but the constraints are not actually effective. After upgrading TiDB to v6.6.0, you can delete the invalid foreign key and create a new one to make the foreign key constraints effective.
TiDB supports creating `FOREIGN KEY` constraints in DDL commands.

Expand Down
12 changes: 7 additions & 5 deletions develop/dev-guide-sample-application-nodejs-prisma.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,15 @@ For more information, refer to [Delete data](/develop/dev-guide-delete-data.md).

### Foreign key constraints vs Prisma relation mode

For TiDB v6.6.0 or later, it's recommended to use [Foreign key constraints](https://docs.pingcap.com/tidb/stable/foreign-key) instead of [Prisma relation mode](https://www.prisma.io/docs/concepts/components/prisma-schema/relations/relation-mode) for [referential integrity](https://en.wikipedia.org/wiki/Referential_integrity?useskin=vector) checking.
To check [referential integrity](https://en.wikipedia.org/wiki/Referential_integrity?useskin=vector), you can use foreign key constraints or Prisma relation mode:

Relation mode is the emulation of referential integrity in Prisma Client side. However, it should be noted that there are performance implications, as it requires additional database queries to maintain referential integrity.
- [Foreign key](https://docs.pingcap.com/tidb/stable/foreign-key) is an experimental feature supported starting from TiDB v6.6.0, which allows cross-table referencing of related data, and foreign key constraints to maintain data consistency.

> **Note**
>
> **Foreign keys are suitable for small and medium-volumes data scenarios.** Using foreign keys in large data volumes might lead to serious performance issues and could have unpredictable effects on the system. If you plan to use foreign keys, conduct thorough validation first and use them with caution.
> **Warning:**
>
> **Foreign keys are suitable for small and medium-volumes data scenarios.** Using foreign keys in large data volumes might lead to serious performance issues and could have unpredictable effects on the system. If you plan to use foreign keys, conduct thorough validation first and use them with caution.
- [Prisma relation mode](https://www.prisma.io/docs/concepts/components/prisma-schema/relations/relation-mode) is the emulation of referential integrity in Prisma Client side. However, it should be noted that there are performance implications, as it requires additional database queries to maintain referential integrity.

## Next steps

Expand Down
2 changes: 1 addition & 1 deletion develop/dev-guide-sample-application-nodejs-typeorm.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ For more information, refer to [TypeORM: DataSource API](https://typeorm.io/data

### Foreign key constraints

Using foreign key constraints ensures the [referential integrity](https://en.wikipedia.org/wiki/Referential_integrity) of data by adding checks on the database side. However, this might lead to serious performance issues in scenarios with large data volumes.
Using [foreign key constraints](https://docs.pingcap.com/tidb/stable/foreign-key) (experimental) ensures the [referential integrity](https://en.wikipedia.org/wiki/Referential_integrity) of data by adding checks on the database side. However, this might lead to serious performance issues in scenarios with large data volumes.

You can control whether foreign key constraints are created when constructing relationships between entities by using the `createForeignKeyConstraints` option (default value is `true`).

Expand Down
5 changes: 3 additions & 2 deletions foreign-key.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ summary: An overview of the usage of FOREIGN KEY constraints for the TiDB databa

Starting from v6.6.0, TiDB supports the foreign key feature, which allows cross-table referencing of related data, and foreign key constraints to maintain data consistency.

> **Note:**
> **Warning:**
>
> The foreign key feature is usually used for providing integrity and consistency constraint checks for data in small or medium volumes. However, for large data volumes in a distributed database system, the use of foreign keys might lead to serious performance issues and could have unpredictable effects on the system. If you plan to use foreign keys, conduct thorough validation first and use them with caution.
> - Currently, the foreign key feature is experimental. It is not recommended that you use it in production environments. This feature might be changed or removed without prior notice. If you find a bug, you can report an [issue](https://github.com/pingcap/tidb/issues) on GitHub.
> - The foreign key feature is usually used for providing integrity and consistency constraint checks for data in small or medium volumes. However, for large data volumes in a distributed database system, the use of foreign keys might lead to serious performance issues and could have unpredictable effects on the system. If you plan to use foreign keys, conduct thorough validation first and use them with caution.
The foreign key is defined in the child table. The syntax is as follows:

Expand Down
6 changes: 3 additions & 3 deletions releases/release-6.6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In v6.6.0-DMR, the key new features and improvements are as follows:
</tr>
<tr>
<td rowspan="2">SQL functionalities<br /></td>
<td><a href="https://docs.pingcap.com/tidb/v6.6/foreign-key" target="_blank">Foreign key</a></td>
<td><a href="https://docs.pingcap.com/tidb/v6.6/foreign-key" target="_blank">Foreign key</a> (experimental)</td>
<td>Support MySQL-compatible foreign key constraints to maintain data consistency and improve data quality.</td>
</tr>
<tr>
Expand Down Expand Up @@ -176,7 +176,7 @@ In v6.6.0-DMR, the key new features and improvements are as follows:

### SQL

* Support MySQL-compatible foreign key constraints [#18209](https://github.com/pingcap/tidb/issues/18209) @[crazycs520](https://github.com/crazycs520)
* Support MySQL-compatible foreign key constraints (experimental) [#18209](https://github.com/pingcap/tidb/issues/18209) @[crazycs520](https://github.com/crazycs520)

TiDB v6.6.0 introduces the foreign key constraints feature, which is compatible with MySQL. This feature supports referencing within a table or between tables, constraints validation, and cascade operations. This feature helps to migrate applications to TiDB, maintain data consistency, improve data quality, and facilitate data modeling.

Expand Down Expand Up @@ -337,7 +337,7 @@ In v6.6.0-DMR, the key new features and improvements are as follows:

### MySQL compatibility

* Support MySQL-compatible foreign key constraints [#18209](https://github.com/pingcap/tidb/issues/18209) @[crazycs520](https://github.com/crazycs520)
* Support MySQL-compatible foreign key constraints (experimental) [#18209](https://github.com/pingcap/tidb/issues/18209) @[crazycs520](https://github.com/crazycs520)

For more information, see the [SQL](#sql) section in this document and [documentation](/foreign-key.md).

Expand Down

0 comments on commit 2cd14da

Please sign in to comment.