Only one key from composite primary key as foreign key
In this database, key1 & key2 make up the composite primary key of table4 , but i'm able to add a foreign key to table3 that comprise just key1 . Why MySQL allows this? Does the above database design make no sense at all? TL;DR It's not standard SQL. MySQL documentation itself advises not doing it. In SQL a FOREIGN KEY declaration must reference a column list declared PRIMARY KEY or UNIQUE NOT NULL. (PRIMARY KEY creates a UNIQUE NOT NULL constraint.) (The constraint has to be explicit, even though any set of NOT NULL columns containing a set that is UNIQUE has to be unique.) The MySQL