Celestial bodies

Each primary key column should follow the naming convention table_name_id . For example, the moon table should have a primary key column named moon_id

dont know why it isnt checked anymore

"galaxy_pkey" PRIMARY KEY, btree (galaxy_id)
  "star_pkey" PRIMARY KEY, btree (star_id)
 "planet_pkey" PRIMARY KEY, btree (planet_id)
 "moon_pkey" PRIMARY KEY, btree (moon_id)

do you have other tables?

Hi @GavinEscanilla

Can you show the contents of the tables using SELECT *?

Happy coding

+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
| galaxy_id | the_amount_of_stars | the_amount_of_planets | the_amount_of_moons | age_in_millions |       name        |                                                                                                    description                                                                                                    | is_spherical |
+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
|         1 |                   1 |                     2 |                   3 |             100 | Milky Way         | The Milky Way is a huge collection of stars, dust, and gas. It's called a spiral galaxy because if you could view it from the top or bottom, it would look like a spinning pinwheel.                              | t            |
|         2 |                   1 |                     2 |                   3 |             100 | Andromeda Galaxy  | The Andromeda Galaxy is the closest spiral galaxy to the Milky Way and is on a collision course with the Milky Way. It is a spiral galaxy, which means it has a central bulge, spiral arms, and is not spherical. | f            |
|         3 |                   1 |                     2 |                   3 |             100 | Triangulum Galaxy | The Triangulum Galaxy is a smaller spiral galaxy located near the Andromeda Galaxy. It contains many star-forming regions and nebulae. It is not spherical and has a relatively flat structure.                   | f            |
+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
(3 rows)
  Table "public.galaxy"
+-----------------------+-----------------------+-----------+----------+-------------------------------------------+
|        Column         |         Type          | Collation | Nullable |                  Default                  |
+-----------------------+-----------------------+-----------+----------+-------------------------------------------+
| galaxy_id             | integer               |           | not null | nextval('galaxy_galaxy_id_seq'::regclass) |
| the_amount_of_stars   | integer               |           | not null |                                           |
| the_amount_of_planets | integer               |           | not null |                                           |
| the_amount_of_moons   | integer               |           | not null |                                           |
| age_in_millions       | numeric               |           | not null |                                           |
| name                  | character varying(40) |           | not null |                                           |
| description           | text                  |           | not null |                                           |
| is_spherical          | boolean               |           |          |                                           |
+-----------------------+-----------------------+-----------+----------+-------------------------------------------+
Indexes:
    "galaxy_id_pkey" PRIMARY KEY, btree (galaxy_id)
    "galaxy_name_key" UNIQUE CONSTRAINT, btree (name)
Referenced by:
    TABLE "star" CONSTRAINT "galaxy_id" FOREIGN KEY (galaxy_id) REFERENCES galaxy(galaxy_id)
+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
| galaxy_id | the_amount_of_stars | the_amount_of_planets | the_amount_of_moons | age_in_millions |       name        |                                                                                                    description                                                                                                    | is_spherical |
+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
|         1 |                   1 |                     2 |                   3 |             100 | Milky Way         | The Milky Way is a huge collection of stars, dust, and gas. It's called a spiral galaxy because if you could view it from the top or bottom, it would look like a spinning pinwheel.                              | t            |
|         2 |                   1 |                     2 |                   3 |             100 | Andromeda Galaxy  | The Andromeda Galaxy is the closest spiral galaxy to the Milky Way and is on a collision course with the Milky Way. It is a spiral galaxy, which means it has a central bulge, spiral arms, and is not spherical. | f            |
|         3 |                   1 |                     2 |                   3 |             100 | Triangulum Galaxy | The Triangulum Galaxy is a smaller spiral galaxy located near the Andromeda Galaxy. It contains many star-forming regions and nebulae. It is not spherical and has a relatively flat structure.                   | f            |
+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
(3 rows)
  Table "public.galaxy"
+-----------------------+-----------------------+-----------+----------+-------------------------------------------+
|        Column         |         Type          | Collation | Nullable |                  Default                  |
+-----------------------+-----------------------+-----------+----------+-------------------------------------------+
| galaxy_id             | integer               |           | not null | nextval('galaxy_galaxy_id_seq'::regclass) |
| the_amount_of_stars   | integer               |           | not null |                                           |
| the_amount_of_planets | integer               |           | not null |                                           |
| the_amount_of_moons   | integer               |           | not null |                                           |
| age_in_millions       | numeric               |           | not null |                                           |
| name                  | character varying(40) |           | not null |                                           |
| description           | text                  |           | not null |                                           |
| is_spherical          | boolean               |           |          |                                           |
+-----------------------+-----------------------+-----------+----------+-------------------------------------------+
Indexes:
    "galaxy_id_pkey" PRIMARY KEY, btree (galaxy_id)
    "galaxy_name_key" UNIQUE CONSTRAINT, btree (name)
Referenced by:
    TABLE "star" CONSTRAINT "galaxy_id" FOREIGN KEY (galaxy_id) REFERENCES galaxy(galaxy_id)
+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
| galaxy_id | the_amount_of_stars | the_amount_of_planets | the_amount_of_moons | age_in_millions |       name        |                                                                                                    description                                                                                                    | is_spherical |
+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
|         1 |                   1 |                     2 |                   3 |             100 | Milky Way         | The Milky Way is a huge collection of stars, dust, and gas. It's called a spiral galaxy because if you could view it from the top or bottom, it would look like a spinning pinwheel.                              | t            |
|         2 |                   1 |                     2 |                   3 |             100 | Andromeda Galaxy  | The Andromeda Galaxy is the closest spiral galaxy to the Milky Way and is on a collision course with the Milky Way. It is a spiral galaxy, which means it has a central bulge, spiral arms, and is not spherical. | f            |
|         3 |                   1 |                     2 |                   3 |             100 | Triangulum Galaxy | The Triangulum Galaxy is a smaller spiral galaxy located near the Andromeda Galaxy. It contains many star-forming regions and nebulae. It is not spherical and has a relatively flat structure.                   | f            |
+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
(3 rows)
  Table "public.galaxy"
+-----------------------+-----------------------+-----------+----------+-------------------------------------------+
|        Column         |         Type          | Collation | Nullable |                  Default                  |
+-----------------------+-----------------------+-----------+----------+-------------------------------------------+
| galaxy_id             | integer               |           | not null | nextval('galaxy_galaxy_id_seq'::regclass) |
| the_amount_of_stars   | integer               |           | not null |                                           |
| the_amount_of_planets | integer               |           | not null |                                           |
| the_amount_of_moons   | integer               |           | not null |                                           |
| age_in_millions       | numeric               |           | not null |                                           |
| name                  | character varying(40) |           | not null |                                           |
| description           | text                  |           | not null |                                           |
| is_spherical          | boolean               |           |          |                                           |
+-----------------------+-----------------------+-----------+----------+-------------------------------------------+
Indexes:
    "galaxy_id_pkey" PRIMARY KEY, btree (galaxy_id)
    "galaxy_name_key" UNIQUE CONSTRAINT, btree (name)
Referenced by:
    TABLE "star" CONSTRAINT "galaxy_id" FOREIGN KEY (galaxy_id) REFERENCES galaxy(galaxy_id)

.

please show ther esult of running \d command

1 Like
+--------+------------------------------+----------+--------------+
| Schema |             Name             |   Type   |    Owner     |
+--------+------------------------------+----------+--------------+
| public | galaxy                       | table    | freecodecamp |
| public | galaxy_galaxy_id_seq         | sequence | freecodecamp |
| public | moon                         | table    | freecodecamp |
| public | moon_moon_id_seq             | sequence | freecodecamp |
| public | planet                       | table    | freecodecamp |
| public | planet_planet_id_seq         | sequence | freecodecamp |
| public | star                         | table    | freecodecamp |
| public | star_star_id_seq             | sequence | freecodecamp |
| public | types_of_galaxys             | table    | freecodecamp |
| public | types_of_galaxys_type_id_seq | sequence | freecodecamp |

found the issue types of galaxy id was type_id instead of types_of_galaxys_id

dont know why star id is 4 instead of 1

universe=> SELECT * FROM star ORDER BY star_id;
+---------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-----------+
| star_id |    name    |                                                                                                                                                                 description                                                                                                                                                                  |     types_of_suns     | galaxy_id |
+---------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-----------+
|       4 | Betelgeuse | Betelgeuse is one of the brightest stars in the night sky, located in the constellation Orion. It is a red supergiant nearing the end of its life and is expected to explode as a supernova within the next 100,000 years. Due to its enormous size and brightness, Betelgeuse is visible to the naked eye and has been studied extensively. | Red Supergiant(M-type |         1 |
+---------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-----------+
(1 row)
+---------------+-----------------------+-----------+----------+---------------------------------------+
|    Column     |         Type          | Collation | Nullable |                Default                |
+---------------+-----------------------+-----------+----------+---------------------------------------+
| star_id       | integer               |           | not null | nextval('star_star_id_seq'::regclass) |
| name          | character varying(40) |           | not null |                                       |
| description   | text                  |           | not null |                                       |
| types_of_suns | text                  |           | not null |                                       |
| galaxy_id     | integer               |           | not null |                                       |
+---------------+-----------------------+-----------+----------+---------------------------------------+
Indexes:
    "star_id_pkey" PRIMARY KEY, btree (star_id)
    "star_name_key" UNIQUE CONSTRAINT, btree (name)
Foreign-key constraints:
    "galaxy_id" FOREIGN KEY (galaxy_id) REFERENCES galaxy(galaxy_id)
Referenced by:
    TABLE "planet" CONSTRAINT "star_id" FOREIGN KEY (star_id) REFERENCES star(star_id)

did you maybe added and deleted rows previously?

I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.

Thanks.

1 Like
+---------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-----------+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
| star_id |    name    |                                                                                                                                                                 description                                                                                                                                                                  |     types_of_suns     | galaxy_id | galaxy_id | the_amount_of_stars | the_amount_of_planets | the_amount_of_moons | age_in_millions |       name        |                                                                                                    description                                                                                                    | is_spherical |
+---------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-----------+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
|       4 | Betelgeuse | Betelgeuse is one of the brightest stars in the night sky, located in the constellation Orion. It is a red supergiant nearing the end of its life and is expected to explode as a supernova within the next 100,000 years. Due to its enormous size and brightness, Betelgeuse is visible to the naked eye and has been studied extensively. | Red Supergiant(M-type |         1 |         1 |                   1 |                     2 |                   3 |             100 | Milky Way         | The Milky Way is a huge collection of stars, dust, and gas. It's called a spiral galaxy because if you could view it from the top or bottom, it would look like a spinning pinwheel.                              | t            |
|         |            |                                                                                                                                                                                                                                                                                                                                              |                       |           |         2 |                   1 |                     2 |                   3 |             100 | Andromeda Galaxy  | The Andromeda Galaxy is the closest spiral galaxy to the Milky Way and is on a collision course with the Milky Way. It is a spiral galaxy, which means it has a central bulge, spiral arms, and is not spherical. | f            |
|         |            |                                                                                                                                                                                                                                                                                                                                              |                       |           |         3 |                   1 |                     2 |                   3 |             100 | Triangulum Galaxy | The Triangulum Galaxy is a smaller spiral galaxy located near the Andromeda Galaxy. It contains many star-forming regions and nebulae. It is not spherical and has a relatively flat structure.                   | f            |
+---------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-----------+-----------+---------------------+-----------------------+---------------------+-----------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+
``` honsetly not sure i kept changing the column names and adding pkey n fkeys that i lost track

oh didnt know i could do that bc i already checked the solution box

1 Like

how do i submit it https://github.com/GavinEscanilla/relational-database/blob/main/Universe.sql
i tried lowercasing the u aswell

what happens when you try?

you must complete project first

you need to do that then

i did and put universe.sql in public repo, it passed all the tests

did you reload the page on freecodecamp to check? do you see a checkmark on the freecodecamp page?