Why do I get the message: each star should have a foreign key that references one of the rows in galaxy. ?
I thought that the following code met the requirement:
Table "public.galaxy"
+-----------------+-----------------------+-----------+----------+-------------------------------------------+
| Column | Type | Collation | Nullable | Default |
+-----------------+-----------------------+-----------+----------+-------------------------------------------+
| galaxy_id | integer | | not null | nextval('galaxy_galaxy_id_seq'::regclass) |
| name | character varying(80) | | not null | |
| number_of_stars | integer | | | |
| stellar_mass | numeric | | | |
| spiral_galaxy | boolean | | | false |
| active_galaxy | boolean | | | false |
| notes | text | | | |
+-----------------+-----------------------+-----------+----------+-------------------------------------------+
Indexes:
"galaxy_pkey" PRIMARY KEY, btree (galaxy_id)
"galaxy_id" UNIQUE CONSTRAINT, btree (galaxy_id)
Referenced by:
TABLE "star" CONSTRAINT "star_galaxy_id_fkey" FOREIGN KEY (galaxy_id) REFERENCES galaxy(galaxy_id)
Table "public.star"
+---------------------+-----------------------+-----------+----------+---------------------------------------+
| Column | Type | Collation | Nullable | Default |
+---------------------+-----------------------+-----------+----------+---------------------------------------+
| star_id | integer | | not null | nextval('star_star_id_seq'::regclass) |
| name | character varying(80) | | not null | |
| star_mass | numeric | | | |
| star_age | integer | | | |
| variable_brightness | boolean | | | false |
| pulsar | boolean | | | false |
| galaxy_id | integer | | | |
| notes | text | | | |
+---------------------+-----------------------+-----------+----------+---------------------------------------+
Indexes:
"star_pkey" PRIMARY KEY, btree (star_id)
"star_id" UNIQUE CONSTRAINT, 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 "asteroid" CONSTRAINT "asteroid_star_id_fkey" FOREIGN KEY (star_id) REFERENCES star(star_id)
TABLE "planet" CONSTRAINT "planet_star_id_fkey" FOREIGN KEY (star_id) REFERENCES star(star_id)