I tried
CREATE TABLE `valorant`.`abilities` (
`PlayerId` INT NOT NULL,
`AgentName` VARCHAR(45) NOT NULL,
`AbilityName` VARCHAR(45) NOT NULL,
`KeyBind` VARCHAR(45) NULL,
`Cost` INT NULL,
PRIMARY KEY (`PlayerId`, `AgentName`, `AbilityName`));
CREATE TABLE `valorant`.`abilitystats` (
`PlayerId` INT NOT NULL,
`AgentName` VARCHAR(45) NOT NULL,
`AbilityName` VARCHAR(45) NOT NULL,
`EnemiesAffected` INT NULL,
`AlliesAffected` INT NULL,
CONSTRAINT `FK_abilitystats_abilities`
FOREIGN KEY (`AbilityName`, `AgentName`)
REFERENCES `abilities` ( `AgentName`, `AbilityName`),
PRIMARY KEY (`PlayerId`)
);
This is the error i got
Error Code: 1822. Failed to add the foreign key constraint. Missing index for constraint 'FK_abilitystats_abilities' in the referenced table 'abilities'
I have no idea what is wrong with this. i follow a tutorial for FOREIGN KEY