I have a Database of City, State and Country. But I want to add Cities to my table and it does not always contain a State to be referenced.
However, every city is located in one country.
My question is: can I create a relationship in which a city that has not been, but which may be related to a country?
CREATE TABLE cidade
(
id_cidade integer NOT NULL,
id_estado integer NOT NULL,
nome character varying(120) NOT NULL,
CONSTRAINT cidade_pkey PRIMARY KEY (id_cidade),
CONSTRAINT fk_cidade_estado FOREIGN KEY (id_estado)
REFERENCES estado (id_estado) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)