it is requested to have tables with a primary key named table_id
i created all tables and pkeys
table5 : “table5_id” PRIMARY KEY, btree (id)
moon : moon_id" PRIMARY KEY, btree (id)
planet : planet_id" PRIMARY KEY, btree (id)
star : star_id" PRIMARY KEY, btree (id)
galaxy : galaxy_id" PRIMARY KEY, btree (id)
and still complaining
same for foreign keys : name should be referencing column
Foreign-key constraints:
“id” FOREIGN KEY (planet_id) REFERENCES planet(id)
is this not correct ?
best regards, Guy
The name of the column has to be exactly the same as the name of the foreign key
id = id
or should it be the name of the column in the dependent table : eg planet_id pointing to id in parent table
If you have a planet table for eg and it has a column called planet_id and you want to link that with another table as the foreign key (say another table called moon), then the moon table should use planet_id too
i do not agree with that
I have planet table with a column id
the moon table has a column id and a column planet_id
the moon.planet_id column has a foreign key to panel.id
so : should the name be id / planet_id to be checked as correct ?
They should both be planet_id
Edit: to be clear, the foreign key should be called planet_id
changed the names of FK and still task is not done flagged ok
cat universe.sql |grep -i FOREIGN
ADD CONSTRAINT galaxy_id FOREIGN KEY (galaxy_id) REFERENCES public.galaxy(id);
ADD CONSTRAINT planet_id FOREIGN KEY (planet_id) REFERENCES public.planet(id);
ADD CONSTRAINT star_id FOREIGN KEY (star_id) REFERENCES public.star(id);
same problem with PK :
cat universe.sql |grep -i PRIMARY
ADD CONSTRAINT galaxy_id PRIMARY KEY (id);
ADD CONSTRAINT moon_id PRIMARY KEY (id);
ADD CONSTRAINT planet_id PRIMARY KEY (id);
ADD CONSTRAINT star_id PRIMARY KEY (id);
ADD CONSTRAINT universe_id PRIMARY KEY (id);
cat universe.sql |grep -i ‘CREATE TABLE’
CREATE TABLE public.galaxy (
CREATE TABLE public.moon (
CREATE TABLE public.planet (
CREATE TABLE public.star (
CREATE TABLE public.universe (
it does not appear that you have followed this request
Each primary key column should follow the naming convention
table_name_id
. For example, themoon
table should have a primary key column namedmoon_id
It appears all your primary keys are called id?
the name of the pk is galaxy_id for table galaxy on column id
The constraint name is not the issue. It is the column name that needs to be changed.
this I do not understand at all
the task indicates : the pk should be named tablename_id
there is no indication about the column on which the pk is based.
When I read the instruction it says “the primary key column”. So a column is not a constraint.
yes, reading each word is important. thks for all help
completed the task
best regards, Guy
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.