Hi,
I was wondering if it’s possible to have many-to-one foreign keys in MySQL (or even at all). I have 3 tables:
CREATE TABLE table_1 (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
value_1 DECIMAL (10, 4) NOT NULL
) ENGINE=INNODB;
CREATE TABLE table_3 (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
value_2 DECIMAL (10, 4) NOT NULL
) ENGINE=INNODB;
CREATE TABLE table_3 (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
value_3 DECIMAL (10, 4) NOT NULL
) ENGINE=INNODB;
And a fourth table, which has a foreign key that could be the value of either of the three tables:
CREATE TABLE table_4 (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
value_x DECIMAL (10, 4) NOT NULL
) ENGINE=INNODB;
value_x is an FK for either tables 1, 2, or 3. Is it possible to have a single FK in table_4 that can have either of the values 1, 2, or 3? OR will three FKs need to be created for each of the values? Only one value is required. Any comments will be greatly appreciated.
Thanks in advance.