MySQL Forums
Forum List  »  Newbie

Re: Foreign Key question
Posted by: Peter Brawley
Date: September 22, 2017 08:45AM

> A single foreign key can only point to a single parent table (AFAIK).

Obviously a FK declaration allows just one, but the poster seems to have been asking about one column used in FKs referring to different tables, eg ...

drop tables if exists c,b,a;
create table a(i int primary key);
create table b like a;
create table c(
  j int primary key, 
  i int, 
  foreign key x (i) references a(i), 
  foreign key y (i) references b(i)
);

which is possible but impractical.

Options: ReplyQuote


Subject
Written By
Posted
September 16, 2017 02:52PM
September 16, 2017 03:49PM
September 20, 2017 11:46AM
September 20, 2017 12:44PM
September 21, 2017 04:11AM
Re: Foreign Key question
September 22, 2017 08:45AM
September 20, 2017 12:35PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.