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? Utpal Vishwas 403 31 Jul 2023 How do you get a double-column unique key as a foreign key?
To 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: