简体   繁体   中英

can't add foreign key for table that has files

I'm building a project with angular and php, I added to my database table "file" that I can send files to him and retrieve all files information. now I'm trying to add a foreign key("Customer_id") from "Customers" table to connect the customer to specific file.

But when I try to add a relation it says:

error relational features are disabled

Can any one please help?can it be that the problem because the table has files?

This is my table :

CREATE TABLE `file` (
    `id`        Int Unsigned Not Null Auto_Increment,
    `name`      VarChar(255) Not Null Default 'Untitled.txt',
    `mime`      VarChar(50) Not Null Default 'text/plain',
    `size`      BigInt Unsigned Not Null Default 0,
    `data`      MediumBlob Not Null,
    `created`   DateTime Not Null,
    PRIMARY KEY (`id`)
)

Verify that the engines used in both of the tables are innoDB .

As you mentioned in chat, your files table was MyISAM , hence the Foreign Constraints were disabled!!.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM