Build A Menu For Bytes Of China: step 9 duplicate key error

Hello all! I’m having a bit of trouble with the Bytes of China project, when populating the database with data i get this error code:
ERROR: duplicate key value violates unique constraint “review_restaurant_id_key”
DETAIL: Key (restaurant_id)=(1) already exists.
ERROR: duplicate key value violates unique constraint “review_restaurant_id_key”
DETAIL: Key (restaurant_id)=(1) already exists.

I’ve tried to follow the directions to the letter and have gone back over it but I’m not sure what i’ve done wrong, any help would be greatly appreciated, ill leave the link and my current code down below!

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-22-designing-relational-databases/modules/wdcp-22-how-do-i-make-and-populate-my-own-database/projects/restaurant-database-project-with-postgresql

I am also having an issue posting the code, for some reason i get a 403 error!

Hello @tunelessshelf ,

Thank you for including the link.

Unfortunately, I don’t have seem to access to this lesson but I will try to help you as best I can.

If you do a SELECT * from the table, you should see all the records that exist in there. The error message indicates that you are inserting a row with a restaurant_id = 1 which already exists. If it is your own table, you can just delete the records and reinsert them.

Thanks so much for the help!
I did as you suggested and realised that I had been trying to create 2 unique rows when only one was needed.

1 Like