How do you get a double-column unique key as a foreign key?
How do you get a double-column unique key as foreign key?
233
31-Jul-2023
Updated on 01-Aug-2023
Aryan Kumar
01-Aug-2023To get a double column unique key as foreign key, you can use the following SQL statement:
SQL
For example, if you have the following two tables:
SQL
Then you can use the following SQL statement to create a foreign key constraint on the
iso_639_1andmain_flagcolumns in theteststable:SQL
This will ensure that the
iso_639_1andmain_flagcolumns in theteststable reference a valid row in thelanguagestable.Here are some things to keep in mind when creating a foreign key constraint on a double column unique key: