Tell us what’s happening:
Describe your issue in detail here.
cannot pass the following
-
Each “star” should have a foreign key that references one of the rows in
galaxy
-
Each “planet” should have a foreign key that references one of the rows in
star
-
Each “moon” should have a foreign key that references one of the rows in
planet
Your code so far
please tell me what am I doing wrong here?
why the above checks are not getting passsed?
upon describing my tables in the universe DB
with \d
universe=> \d star
Table "public.star"
+---------------------+------------------------+-----------+----------+---------------------------------------+
| Column | Type | Collation | Nullable | Default |
+---------------------+------------------------+-----------+----------+---------------------------------------+
| star_id | integer | | not null | nextval('star_star_id_seq'::regclass) |
| name | character varying(100) | | not null | |
| spectral_type | character varying(50) | | | |
| luminosity | numeric(5,2) | | | |
| mass | numeric(5,2) | | | |
| distance_from_earth | numeric(5,2) | | | |
| is_active | boolean | | | |
| temperature | numeric(5,2) | | | |
| 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)
universe=> \d planet
Table "public.planet"
+--------------------+-----------------------+-----------+----------+-------------------------------------------+
| Column | Type | Collation | Nullable | Default |
+--------------------+-----------------------+-----------+----------+-------------------------------------------+
| planet_id | integer | | not null | nextval('planet_planet_id_seq'::regclass) |
| name | character varying(50) | | not null | |
| type | character varying(50) | | | |
| size | numeric(5,2) | | | |
| mass | numeric(5,2) | | | |
| distance_from_star | numeric(5,2) | | | |
| orbital_period | numeric(5,2) | | | |
| is_habitable | boolean | | | |
| star_id | integer | | | |
| planet_position | integer | | not null | |
| random_number | integer | | | |
+--------------------+-----------------------+-----------+----------+-------------------------------------------+
Indexes:
"planet_pkey" PRIMARY KEY, btree (planet_id)
"planet_name_key" UNIQUE CONSTRAINT, btree (name)
Foreign-key constraints:
"planet_star_id_fkey" FOREIGN KEY (star_id) REFERENCES star(star_id)
Referenced by:
TABLE "moon" CONSTRAINT "moon_planet_id_fkey" FOREIGN KEY (planet_id) REFERENCES planet(planet_id)
universe=> \d moon
Table "public.moon"
+----------------------+-----------------------+-----------+----------+-----------------------------------------+
| Column | Type | Collation | Nullable | Default |
+----------------------+-----------------------+-----------+----------+-----------------------------------------+
| moon_id | integer | | not null | nextval('moon_moon_id_seq'::regclass) |
| name | character varying(50) | | not null | |
| size | numeric(5,2) | | | |
| mass | numeric(5,2) | | | |
| distance_from_planet | numeric(5,2) | | | |
| orbital_period | numeric(5,2) | | | |
| is_satellite | boolean | | | |
| planet_id | integer | | not null | nextval('moon_planet_id_seq'::regclass) |
+----------------------+-----------------------+-----------+----------+-----------------------------------------+
Indexes:
"moon_pkey" PRIMARY KEY, btree (moon_id)
"moon_name_key" UNIQUE CONSTRAINT, btree (name)
Foreign-key constraints:
"moon_planet_id_fkey" FOREIGN KEY (planet_id) REFERENCES planet(planet_id)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Challenge: Celestial Bodies Database - Build a Celestial Bodies Database
Link to the challenge: