I want to have some relation between my tables in MySQL. I use GORM ORM and go. I have 3 table with this name: singertbl, covertbl, singerscovertbl. my tables have id with autoincrement value. in singertbl and covertbl, I have this fields: ID and {some another field}. and in singerscovertbl I have this fields: ID, singer_id, cover_id. there is a relation between {ID.singertbl -> singer_id.singerscovertbl} and {ID.covertbl -> cover_id.singerscovertbl} when I want to apply this relation as a foreign key in MySQL workbench with this SQL query:
ALTER TABLE `mskm`.`albumscovers`
ADD INDEX `ID_idx` (`album_id` ASC) VISIBLE,
ADD INDEX `ID_idx1` (`cover_id` ASC) VISIBLE;
;
ALTER TABLE `mskm`.`albumscovers`
ADD CONSTRAINT `ID`
FOREIGN KEY (`album_id`)
REFERENCES `mskm`.`albumstbls` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
I get this error:
Operation failed: There was an error while applying the SQL script to the database.
Executing:
ALTER TABLE `mskm`.`albumscovers`
ADD INDEX `ID_idx` (`album_id` ASC) VISIBLE,
ADD INDEX `ID_idx1` (`cover_id` ASC) VISIBLE;
;
ALTER TABLE `mskm`.`albumscovers`
ADD CONSTRAINT `ID`
FOREIGN KEY (`album_id`)
REFERENCES `mskm`.`albumstbls` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ERROR 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 '
ADD INDEX `ID_idx1` (`cover_id` ASC) VISIBLE' at line 2
SQL Statement:
ALTER TABLE `mskm`.`albumscovers`
ADD INDEX `ID_idx` (`album_id` ASC) VISIBLE,
ADD INDEX `ID_idx1` (`cover_id` ASC) VISIBLE
how I can make this relationship between this tables?!