Mario Database Course Incorrect SQL example

I got stuck on the following step:

You want to use character_id as a foreign key again. This will be a “one-to-many” relationship because one character will have many sounds, but no sound will have more than one character. Here’s the example again:

ALTER TABLE table_name ADD COLUMN column_name DATATYPE CONSTRAINT REFERENCES referenced_table_name(referenced_column_name);

Add a column to sounds named character_id. Give it the properties INT, NOT NULL, and set it as a foreign key that references character_id from characters.

The command example generates a syntax error. By removing the CONSTRAINT so it just says references, my command work. The earlier example does not have the CONSTRAINT keyword.

you should be replacing CONSTRAINT by constraints like not null unique it self it is not keyword.

Wow that’s embarrassing. I apologize. That flew right over my head. Thank you for the clarification.

no worries,it all happens to us some times.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.