Need help, tests don't want to pass even though database is right

Each table should have a primary key
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

these 2 tests fail even though I’m certain i have both of those requirements

do you have other things that fail?
can you share your database dump?

i hope this is what you mean

--
-- PostgreSQL database dump
--

-- Dumped from database version 12.17 (Ubuntu 12.17-1.pgdg22.04+1)
-- Dumped by pg_dump version 12.17 (Ubuntu 12.17-1.pgdg22.04+1)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: galaxy; Type: TABLE; Schema: public; Owner: freecodecamp
--

CREATE TABLE public.galaxy (
    galaxy_id integer NOT NULL,
    name character varying(40) NOT NULL,
    type character varying(20) NOT NULL,
    discovered_year integer,
    planets_inside character varying(10)
);


ALTER TABLE public.galaxy OWNER TO freecodecamp;

--
-- Name: galaxy_galaxy_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--

CREATE SEQUENCE public.galaxy_galaxy_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.galaxy_galaxy_id_seq OWNER TO freecodecamp;

--
-- Name: galaxy_galaxy_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--

ALTER SEQUENCE public.galaxy_galaxy_id_seq OWNED BY public.galaxy.galaxy_id;


--
-- Name: moon; Type: TABLE; Schema: public; Owner: freecodecamp
--

CREATE TABLE public.moon (
    moon_id integer NOT NULL,
    name character varying(40) NOT NULL,
    planet_id integer,
    size numeric,
    gravity numeric
);


ALTER TABLE public.moon OWNER TO freecodecamp;

--
-- Name: moon_moon_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--

CREATE SEQUENCE public.moon_moon_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.moon_moon_id_seq OWNER TO freecodecamp;

--
-- Name: moon_moon_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--

ALTER SEQUENCE public.moon_moon_id_seq OWNED BY public.moon.moon_id;


--
-- Name: planet; Type: TABLE; Schema: public; Owner: freecodecamp
--

CREATE TABLE public.planet (
    planet_id integer NOT NULL,
    name character varying(40) NOT NULL,
    number_of_moons integer,
    mass numeric,
    description text,
    has_rings boolean,
    star_id integer
);


ALTER TABLE public.planet OWNER TO freecodecamp;

--
-- Name: planet_planet_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--

CREATE SEQUENCE public.planet_planet_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.planet_planet_id_seq OWNER TO freecodecamp;

--
-- Name: planet_planet_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--

ALTER SEQUENCE public.planet_planet_id_seq OWNED BY public.planet.planet_id;


--
-- Name: space_station; Type: TABLE; Schema: public; Owner: freecodecamp
--

CREATE TABLE public.space_station (
    name character varying(100) NOT NULL,
    location character varying(100),
    crew_size integer,
    distance_from_earth numeric,
    space_station_id integer NOT NULL
);


ALTER TABLE public.space_station OWNER TO freecodecamp;

--
-- Name: space_station_space_station_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--

CREATE SEQUENCE public.space_station_space_station_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.space_station_space_station_id_seq OWNER TO freecodecamp;

--
-- Name: space_station_space_station_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--

ALTER SEQUENCE public.space_station_space_station_id_seq OWNED BY public.space_station.space_station_id;


--
-- Name: star; Type: TABLE; Schema: public; Owner: freecodecamp
--

CREATE TABLE public.star (
    star_id integer NOT NULL,
    name character varying(40) NOT NULL,
    is_active boolean,
    galaxy_id integer,
    size numeric
);


ALTER TABLE public.star OWNER TO freecodecamp;

--
-- Name: star_star_id_seq; Type: SEQUENCE; Schema: public; Owner: freecodecamp
--

CREATE SEQUENCE public.star_star_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.star_star_id_seq OWNER TO freecodecamp;

--
-- Name: star_star_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: freecodecamp
--

ALTER SEQUENCE public.star_star_id_seq OWNED BY public.star.star_id;


--
-- Name: galaxy galaxy_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.galaxy ALTER COLUMN galaxy_id SET DEFAULT nextval('public.galaxy_galaxy_id_seq'::regclass);


--
-- Name: moon moon_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.moon ALTER COLUMN moon_id SET DEFAULT nextval('public.moon_moon_id_seq'::regclass);


--
-- Name: planet planet_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.planet ALTER COLUMN planet_id SET DEFAULT nextval('public.planet_planet_id_seq'::regclass);


--
-- Name: space_station space_station_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.space_station ALTER COLUMN space_station_id SET DEFAULT nextval('public.space_station_space_station_id_seq'::regclass);


--
-- Name: star star_id; Type: DEFAULT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.star ALTER COLUMN star_id SET DEFAULT nextval('public.star_star_id_seq'::regclass);


--
-- Data for Name: galaxy; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--

COPY public.galaxy (galaxy_id, name, type, discovered_year, planets_inside) FROM stdin;
1	Milky way	Barred spiral	1700	100B
2	Andromeda	Barred spiral	-961	trillions
3	Messier 87	Elliptical	1781	billions
4	Whirlpool	Spiral	1773	billions
5	Sombrero	Spiral	1781	800B
6	Triangulum	Spiral	1654	billions
\.


--
-- Data for Name: moon; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--

COPY public.moon (moon_id, name, planet_id, size, gravity) FROM stdin;
1	Luna	1	3474.2	1.62
2	Phobos	2	22.2	0.0057
3	Deimos	2	12.6	0.003
4	Io	3	3643.2	1.796
5	Europa	3	3121.6	1.315
6	Ganymede	3	5268.2	1.428
7	Callisto	3	4820.6	1.235
8	Titan	4	5149.5	1.352
9	Enceladus	4	504.2	0.113
10	Mimas	4	396.4	0.064
11	Rhea	4	1527.6	0.264
12	Iapetus	4	1468.6	0.223
13	Tethys	4	1062.2	0.146
14	Dione	4	1122.8	0.232
15	Hyperion	4	270.0	0.02
16	Betel-1	6	2345.6	1.24
17	Betel-2	6	1543.2	0.87
18	Arcturus Moon Prime	8	4567.8	2.1
19	Andromeda Minor	9	567.3	0.45
20	Sirius Moon Alpha	12	890.5	0.67
\.


--
-- Data for Name: planet; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--

COPY public.planet (planet_id, name, number_of_moons, mass, description, has_rings, star_id) FROM stdin;
1	Earth	1	5.97	Blue planet with abundant water and life	f	1
2	Mars	2	0.642	Red planet with thin atmosphere	f	1
3	Jupiter	79	1898	Largest planet in our solar system with a giant red spot	t	1
4	Saturn	82	568	Beautiful planet with prominent ring system	t	1
5	Proxima Centauri b	0	1.27	Potentially habitable exoplanet orbiting Proxima Centauri	f	1
6	Betelgeuse I	5	2543	Giant hot planet orbiting the red supergiant	f	2
7	Betelgeuse II	3	1125	Rocky world with extreme temperatures	f	2
8	Arcturus Prime	12	857	Gas giant with complex weather systems	t	3
9	Andromeda Major	8	1235	Distant exoplanet with methane atmosphere	t	4
10	Alcyone III	2	2.5	Small rocky world with unusual magnetic field	f	5
11	Sirius A-1	0	0.5	Hot terrestrial planet close to its star	f	6
12	Sirius A-2	4	15.3	Cool gas giant far from its star	t	6
\.


--
-- Data for Name: space_station; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--

COPY public.space_station (name, location, crew_size, distance_from_earth, space_station_id) FROM stdin;
International Space Station	Earth Orbit	7	408	1
New Horizons Station	Jupiter Orbit	15	778500000	2
Andromeda Research Base	Andromeda Galaxy	35	2537000000000000	3
\.


--
-- Data for Name: star; Type: TABLE DATA; Schema: public; Owner: freecodecamp
--

COPY public.star (star_id, name, is_active, galaxy_id, size) FROM stdin;
1	Alpha Centauri A	t	1	1.22
2	Betelgeuse	t	1	1000
3	Arcturus	t	1	25.4
4	Andromeda I	t	2	1.2
5	Alcyone	t	1	2.9
6	Sirius	t	1	1.71
\.


--
-- Name: galaxy_galaxy_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--

SELECT pg_catalog.setval('public.galaxy_galaxy_id_seq', 6, true);


--
-- Name: moon_moon_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--

SELECT pg_catalog.setval('public.moon_moon_id_seq', 20, true);


--
-- Name: planet_planet_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--

SELECT pg_catalog.setval('public.planet_planet_id_seq', 12, true);


--
-- Name: space_station_space_station_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--

SELECT pg_catalog.setval('public.space_station_space_station_id_seq', 3, true);


--
-- Name: star_star_id_seq; Type: SEQUENCE SET; Schema: public; Owner: freecodecamp
--

SELECT pg_catalog.setval('public.star_star_id_seq', 6, true);


--
-- Name: galaxy galaxy_id; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.galaxy
    ADD CONSTRAINT galaxy_id PRIMARY KEY (galaxy_id);


--
-- Name: moon moon_id; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.moon
    ADD CONSTRAINT moon_id PRIMARY KEY (moon_id);


--
-- Name: planet planet_id; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.planet
    ADD CONSTRAINT planet_id PRIMARY KEY (planet_id);


--
-- Name: space_station space_station_id; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.space_station
    ADD CONSTRAINT space_station_id PRIMARY KEY (space_station_id);


--
-- Name: star star_id; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.star
    ADD CONSTRAINT star_id PRIMARY KEY (star_id);


--
-- Name: moon unique_name; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.moon
    ADD CONSTRAINT unique_name UNIQUE (name);


--
-- Name: galaxy uniqueg_name; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.galaxy
    ADD CONSTRAINT uniqueg_name UNIQUE (name);


--
-- Name: planet uniquep_name; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.planet
    ADD CONSTRAINT uniquep_name UNIQUE (name);


--
-- Name: star uniques_name; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.star
    ADD CONSTRAINT uniques_name UNIQUE (name);


--
-- Name: space_station uniquess_name; Type: CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.space_station
    ADD CONSTRAINT uniquess_name UNIQUE (name);


--
-- Name: star galaxy_id; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.star
    ADD CONSTRAINT galaxy_id FOREIGN KEY (galaxy_id) REFERENCES public.galaxy(galaxy_id);


--
-- Name: moon planet_id; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.moon
    ADD CONSTRAINT planet_id FOREIGN KEY (planet_id) REFERENCES public.planet(planet_id);


--
-- Name: planet star_id; Type: FK CONSTRAINT; Schema: public; Owner: freecodecamp
--

ALTER TABLE ONLY public.planet
    ADD CONSTRAINT star_id FOREIGN KEY (star_id) REFERENCES public.star(star_id);


--
-- PostgreSQL database dump complete
--


Hi @juiokoli

EDIT:
You space_station table needs to fulfil all the requirements for a table.

Happy coding

you need to create a table more than those requested by name, that should not be an issue

Then, you should add tables named galaxy , star , planet , and moon

Your database should have at least five tables

Yeah, I get that but it does have 5 tables


the tests that are failing are specifically:

  • Each table should have a primary key
  • 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

and I know that all 5 tables have a primary key and that the name of it is matching, I just don’t see any issues in my database no matter how deep do i look

I am trying to recreate your database from the dump, give me some time, I am having small issues

If i can help somehow I’d gladly do

I’m not sure if i created the dump correctly, but i managed to recreate the database from the dump

I probably don’t have to tell you that but the command in bash is

psql -U postgres -d universe -f /workspace/project/universe.sql

ok, I managed
do you also see this failing?

Each table should have a primary key

yes, this and the one about the naming code
but every table does have a primary key, that’s why im confused
its even in the dumb

werid question, did you maybe change the default constraint names?

you have multiple constraints with the same name, the tests can’t deal with that

Are the tests set up to handle a table name with an underscore? That’s the only thing I can come up with…

Yeah i thought about it too, I’ve change the table name but it didn’t work. I guess i can try changing the column and key name, I’ll try it

you have multiple constraints with the same name, you may need to remove the constraints and add them back in

this is both PRIMARY KEY and FOREIGN KEY constraints
or if you know how to change the constraint names without doing that, do that

Nah. Don’t do that. I just looked at my code and my fifth table name had an underscore…passed just fine.

Yeah i figured as much, i’ve been scratching my chin at this for some time but it just doesn’t want to pass

wait, I’ll go check it out you might be onto something

Yeah that was it, I didn’t know that it could be a problem so I just ignored it
Thanks a lot for your time

it doesn’t seem to be a problem in general, you just caught one thing that the tests use to check if there are the constraints

wait actually now I want to ask for clarity
i created the new dump, created a github repo, uploaded the dump there but when i try to link the repo inside of the project on freecodecamp, it says “You have to complete the project first”
and I have already gotten the 100% pop-up on gitpod
am I missing a step ?