Can't pass foreign key step (star to galaxy) Databases

Here is my star table information. It looks to me like I have setup a foreign key from star table to galaxy table. However, I can’t pass the test "Each star should have a foreign key that references one row in galaxy table.

Any thoughts?

Gerry

±---------
-----------±----------------------±----------±---------±--------------------------------------+
| Column | Type | Collation | Nullable | Default |
±--------------------±----------------------±----------±---------±--------------------------------------+
| star_id | integer | | not null | nextval(‘star_star_id_seq’::regclass) |
| name | character varying(40) | | | |
| distance_from_earth | integer | | | |
| diameter | integer | | | |
| gravity_pull | numeric | | | |
| is_spherical | boolean | | | |
| has_life | boolean | | | |
| galaxy_id | integer | | | |
±--------------------±----------------------±----------±---------±--------------------------------------+
Indexes:
“star_pkey” PRIMARY KEY, btree (star_id)
“star_galaxy_id_key” UNIQUE CONSTRAINT, btree (galaxy_id)
Foreign-key constraints:
“star_galaxy_id_fkey” FOREIGN KEY (galaxy_id) REFERENCES galaxy(galaxy_id)

If I’m looking at the test correctly, I think you need to have at least one row in the stars table with a foreign key to a galaxy, and that all the rows in the stars table need to have it. That may be what you are missing. If that doesn’t work, can you share a dump of your database using the command in the instructions, and I will take a look.

so do I, I can’t pass that command even i’m trying over and over.

I haven’t actually created any rows in any tables yet

You need to put data in those tables, including the relevant foreign keys to the correct tables before the check marks get passed successfully.

1 Like