Hi I am trying to complete this database, however I have one requirement to go I have to make one column in every table unique. I decided to make the ID column unique for every table. however after setting 5 unique columns I cannot get a green check what am I doing wrong? below are the details for each table.
universe=> \d
List of relations
+--------+----------------------+----------+--------------+
| 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 | why | table | freecodecamp |
| public | why_why_id_seq | sequence | freecodecamp |
+--------+----------------------+----------+--------------+
(10 rows)
universe=> \d galaxy
Table "public.galaxy"
+-----------+-----------------------+-----------+----------+-------------------------------------------+
| Column | Type | Collation | Nullable | Default |
+-----------+-----------------------+-----------+----------+-------------------------------------------+
| galaxy_id | integer | | not null | nextval('galaxy_galaxy_id_seq'::regclass) |
| name | character varying(30) | | not null | |
| x | integer | | | |
| y | integer | | | |
| z | integer | | | |
+-----------+-----------------------+-----------+----------+-------------------------------------------+
Indexes:
"galaxy_pkey" PRIMARY KEY, btree (galaxy_id)
"galaxyid" UNIQUE, btree (galaxy_id)
Referenced by:
TABLE "star" CONSTRAINT "galaxy_id" FOREIGN KEY (galaxy_id) REFERENCES galaxy(galaxy_id) ON DELETE CASCADE
universe=> \d star
Table "public.star"
+-----------+-----------------------+-----------+----------+---------------------------------------+
| Column | Type | Collation | Nullable | Default |
+-----------+-----------------------+-----------+----------+---------------------------------------+
| star_id | integer | | not null | nextval('star_star_id_seq'::regclass) |
| mass | integer | | | |
| radius | numeric | | | |
| name | character varying(30) | | | |
| galaxy_id | integer | | not null | |
+-----------+-----------------------+-----------+----------+---------------------------------------+
Indexes:
"star_pkey" PRIMARY KEY, btree (star_id)
"starid" UNIQUE, btree (star_id)
Foreign-key constraints:
"galaxy_id" FOREIGN KEY (galaxy_id) REFERENCES galaxy(galaxy_id) ON DELETE CASCADE
Referenced by:
TABLE "planet" CONSTRAINT "star_id" FOREIGN KEY (star_id) REFERENCES star(star_id) ON DELETE CASCADE
universe=> \d planet
Table "public.planet"
+-----------+-----------------------+-----------+----------+-------------------------------------------+
| Column | Type | Collation | Nullable | Default |
+-----------+-----------------------+-----------+----------+-------------------------------------------+
| planet_id | integer | | not null | nextval('planet_planet_id_seq'::regclass) |
| mass | integer | | | |
| radius | numeric | | | |
| life | boolean | | | |
| star_id | integer | | not null | |
| name | character varying(30) | | | |
+-----------+-----------------------+-----------+----------+-------------------------------------------+
Indexes:
"planet_pkey" PRIMARY KEY, btree (planet_id)
"planetid" UNIQUE, btree (planet_id)
Foreign-key constraints:
"star_id" FOREIGN KEY (star_id) REFERENCES star(star_id) ON DELETE CASCADE
Referenced by:
TABLE "moon" CONSTRAINT "planet_id" FOREIGN KEY (planet_id) REFERENCES planet(planet_id) ON DELETE CASCADE
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(30) | | | |
| mass | integer | | | |
| radius | numeric | | | |
| life | boolean | | | |
| planet_id | integer | | not null | |
+-----------+-----------------------+-----------+----------+---------------------------------------+
Indexes:
"moon_pkey" PRIMARY KEY, btree (moon_id)
"moonid" UNIQUE, btree (moon_id)
Foreign-key constraints:
"planet_id" FOREIGN KEY (planet_id) REFERENCES planet(planet_id) ON DELETE CASCADE
universe=> \d why
Table "public.why"
+--------+-----------------------+-----------+----------+-------------------------------------+
| Column | Type | Collation | Nullable | Default |
+--------+-----------------------+-----------+----------+-------------------------------------+
| why_id | integer | | not null | nextval('why_why_id_seq'::regclass) |
| name | character varying(20) | | | |
| title | text | | | |
| idk | boolean | | not null | |
+--------+-----------------------+-----------+----------+-------------------------------------+
Indexes:
"why_pkey" PRIMARY KEY, btree (why_id)
"whyid" UNIQUE, btree (why_id)