-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Foreign Key
constraints
#18209
Comments
I think a lot of users coming from MySQL think of DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
id INT NOT NULL PRIMARY KEY auto_increment,
a CHAR(32) NOT NULL
);
CREATE TABLE t2 (
id INT NOT NULL PRIMARY KEY auto_increment,
t1_id INT NOT NULL,
b CHAR(32) NOT NULL,
FOREIGN KEY (t1_id) REFERENCES t1(id)
);
INSERT INTO t1 VALUES (1, 'aa');
INSERT INTO t2 VALUES (1, 1, 'bbb'); Currently TiDB treats the first two statements as equal, but with EXPLAIN SELECT * FROM t2;
EXPLAIN SELECT t2.* FROM t2 LEFT JOIN t1 ON t2.t1_id = t1.id;
EXPLAIN SELECT t2.* FROM t2 INNER JOIN t1 ON t2.t1_id = t1.id; |
Also consider adding foreign keys as a good way to ensure cascade delete's happen when needed |
What's the status on this? Is anyone working on this? |
Hello @Anutrix, This is still something that we would like to implement, but is also a complex feature to implement. I don't know where this is on our roadmap currently. Is there a specific issue for which you need foreign keys? |
Not a specific issue but we were thinking to migrate from one of our old large DB to a modern distributed DB system at some point. |
I will work on this now. |
hi @crazycs520 thx for taking this. could you share some rough timeline on this feature? |
Looks like this issue can be closed:
From https://docs.pingcap.com/zh/tidb/v6.6/foreign-key with Google Translate (I can't read Chinese!) Good work team |
The information is available in English on https://docs.pingcap.com/tidb/v6.6/foreign-key |
Thanks for the team! We can close this issue now. |
Feature Request
Is your feature request related to a problem? Please describe:
No
Describe the feature you'd like:
Most of RDBMS support
Foreign Key
and a lot of applications rely on this feature (such as Zabbix).Describe alternatives you've considered:
Teachability, Documentation, Adoption, Migration Strategy:
The text was updated successfully, but these errors were encountered: