Celestial bodies foreign keys not being accepted

All the foreign key tasks on the checklist are not being accepted here is one example. What did i do wrong? I made galaxy id the foreign key to star or is it supposed to be the other way around.

+--------------------+-----------------------+-----------+----------+---------------------------------------+
|       Column       |         Type          | Collation | Nullable |                Default                |
+--------------------+-----------------------+-----------+----------+---------------------------------------+
| star_id            | integer               |           | not null | nextval('star_star_id_seq'::regclass) |
| name               | character varying(30) |           | not null |                                       |
| type               | character varying(20) |           |          |                                       |
| asterism           | character varying(20) |           |          |                                       |
| constellation      | character varying(20) |           |          |                                       |
| apparent_magnitude | integer               |           |          |                                       |
| color              | character varying(20) |           |          |                                       |
| galaxy_id          | integer               |           |          |                                       |
+--------------------+-----------------------+-----------+----------+---------------------------------------+
Indexes:
    "star_pkey" PRIMARY KEY, btree (star_id)
    "star_name_key" UNIQUE CONSTRAINT, btree (name)
Foreign-key constraints:
    "star_galaxy_id_fkey" FOREIGN KEY (galaxy_id) REFERENCES galaxy(galaxy_id)
Referenced by:
    TABLE "planet" CONSTRAINT "planet_star_id_fkey" FOREIGN KEY (star_id) REFERENCES star(star_id)```

If the schema you showed belongs to the star table then the star_id column should not be a foreign key at all.
Instead the galaxy_id should be the foreign key and it should like to the primary key of the same name in the galaxy table.

yes, galaxy_id is the foreign key of this star table and it’s the primary key of the galaxy table

Please share the schemas of all the tables you created. Also make sure your foreign keys are all set to not null.

(And add 3 rows to each table)






Ok here you go

Make sure all the foreign keys are not null (star_id in planet table seems to be missing that).

Also the test will not pass without some data added to the tables. So make sure you have data in each table.

Also can you clarify which specific test(s) is failing? (All the foreign key ones or a one in particular?)

ok i have corrected that. Yeah, i was expecting all the foreign key tests to pass by now but I don’t have any rows of data yet in any table.

The test requires that you have the rows filled in the tables.