Problems with the Last Problem on the Celestial Bodies database

I’m having trouble validating the last task on the Celestial Bodies database task. As you can see in the image I’ve created 3 foreign keys that reference the tables, but for some reason it’s not passing.
Any help or insight would be appreciated - including any other approaches that you might take at a task like this. Thanks!

Here’s the link to the full code on GitHub

You mean this test?

Each foreign key column should have the same name as the column it is referencing

EDIT: Spotted your GitHub link… I’ll take a look.

Well, I got your database to pass… I’m not exactly sure why it wasn’t passing.
Somebody who knows more about psql than me probably knows why my solution fixed it though…

I added a system_id column to your galaxy table, as a foreign key referencing system(system_id). That didn’t help the test to pass. However, I noticed that the name of the constraint is galaxy_system_id_fkey. It has the names of both tables.

Your moon table’s foreign key constraint is fk_planet_id (i.e. it doesn’t also contain the name ‘moon’). So I dropped the constraint and readded it again, which changed the name to moon_planet_id_fkey, as per this image.

Then, seemingly at random, the final test passed and the project is complete!

I don’t know firstly why the constraint names varied in the first place (method of adding them?) and secondly why dropping and reapplying that one key allowed the project to pass. Thirdly, the name of the constraint may be irrelevant, as your other tables’ foreign keys are still named as your moon table one was.

Still, try doing exactly what I did and see if it works for you!

1 Like

Interesting, but that worked! Obviously I’m newer to this and tried to build it all without looking anything up elsewhere, so it’s a tad messy…but I’m glad your solution fixed it.
Thank you for your time!

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