Creating MariaDB table with a foreignkey to varchar
Creating MariaDB table with a foreignkey to varchar I am trying to create a table (yTable) which has a foreign key mapped to another table (xTable). I am using MariaDB. When I try to create it I get this error: Cannot find an index in the referenced table where the referenced columns appear as the first columns, or column types in the table and the referenced table do not match for constraint. When i dump existing table it gives me this description: CREATE TABLE `xTable` ( `id` varchar(25) NOT NULL, ... PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`), ... The query that I try to use to create another table is: Create table `yTable` ( `xTable_id` varchar(25) NOT NULL, Primary Key (`xTable_id`), Foreign Key (`xTable_id`) references `xTable` (`id`) on delete cascade on update cascade); In both pasted queries I have removed some columns. They don't affect anything. The problem is with connecting the xTable_id from yTable to xTable.id. For some reason it doesn't...