I am currently working through the Build A Periodic Table course and am trying to get a green check by the " Your properties
table should have a type_id
foreign key column that references the type_id
column from the types
table. It should be an INT
with the NOT NULL
constraint"
My understanding is that I start by adding the column and then add the foreign key constraint. However, starting here:
ALTER TABLE properties ADD COLUMN type_id INT NOT NULL;
I am continuously receiving an error:
ERROR: column "type_id" contains null values
I tried resetting the course and starting with this step and continue to get the error.
The error seems to be telling me that there is data but when I list the table’s columns there is no type_id column:
Table "public.properties"
Column | Type | Collation | Nullable | Default
---------------+-----------------------+-----------+----------+---------
atomic_number | integer | | not null |
type | character varying(30) | | |
weight | numeric(9,6) | | not null |
melting_point | numeric | | |
boiling_point | numeric | | |
Indexes:
"properties_pkey" PRIMARY KEY, btree (atomic_number)
"properties_atomic_number_key" UNIQUE CONSTRAINT, btree (atomic_number)
I’m scratching my head. Any thoughts or insight here would be greatly appreciated.
Thank you,
Richard