How to have two not null constraints at the same time - Mailing list pgsql-novice

From A B
Subject How to have two not null constraints at the same time
Date
Msg-id AANLkTikZm8HNYzDozuMbGtzYVoNopbY-Q_LHKWYbmc_+@mail.gmail.com
Whole thread Raw
Responses Re: How to have two not null constraints at the same time
List pgsql-novice
Hi.
If I have a table

country (id int Primary key, president bigint references people);

and a table
people (id bigint, country_id int not null references country );

and now I want to enforce that there is a president in each country by
adding a not null constraint on the  column presient in the country
table.

Is there a way to do that? just adding the not null, will that not
get me into a chicken-egg situation where I can not add a country
without adding a president to the people table, which requires a
country... and so on.

So how would you insert the rows?


Or are there other ways to do this without creating a new table to
contain the presidents?

pgsql-novice by date:

Previous
From: Nima Ghorbany
Date:
Subject: Integrity Error
Next
From: Andreas
Date:
Subject: Re: How to have two not null constraints at the same time