Problem with Mario Database

Thats my code and the result :

mario_database=> ALTER TABLE more_info ADD COLUMN character_id INT REFERENCES characters(character_id);
ERROR: there is no unique constraint matching given keys for referenced table “characters”

My bet is that there is no primary key on the characters table. You can run the following command in the terminal to see if there is one:

\d characters

It should say that the character_id column is a PRIMARY KEY. If it doesn’t, you’ll need to run an ALTER TABLE and add a constraint that signals to Postgres that the character_id column is the primary key of the table characters.

Foreign keys require that the referenced column is a primary key.