Insert or Update violates foreign key constraints

Hi!

I recently changed my database from Google Sheets to Postgres.

I have a ITEM and a CATEGORY table where Item table has a Category column (wich is a foreign key).

Now, everytime I need to add a new Item wich I need to also add a new category:

thiago_tcr_2-1662993025804.png

I get a violate message:

thiago_tcr_3-1662994930535.png

I understand the behavior, trying to add an Item with a Category ID that does not exist in Category table.

Is there any work around this issue?

 

 

 

 

0 8 2,322
8 REPLIES 8