Can we have sth like this in MariaDB?
ALTER TABLE `files` ADD
CONSTRAINT `fk_persons_cover`
FOREIGN KEY (`foreign_key`, `model`)
REFERENCES `persons` (`uuid`, "persons_cover")
ON DELETE NO ACTION
ON UPDATE NO ACTION;
I want refrence from files to persons table when files.uuid=persons.uuid
and files.model="persons_cover"
Now with this code MariaDB said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"persons_cover")
ON DELETE NO ACTION
ON UPDATE NO ACTION' at line 4
Is there a solution?
Edit:
I know can use filelable
super/interface table like this solution
Or use some auto generated fields in files table like this solution
but they ar not good solution I think.
At first solution we can't find file 1 (row 1) is associated to what? or can't find list of persons 1 (person row with pk = 1) files
At second solution we should add nullable foreign key field per new association!