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.