CREATE TABLE dep
(
id integer NOT NULL,
city text NOT NULL,
name text NOT NULL,
CONSTRAINT dep_pk PRIMARY KEY (id)
);
-- продукты
CREATE TABLE prod
(
id integer NOT NULL,
price integer NOT NULL,
name text NOT NULL,
CONSTRAINT prod_pk PRIMARY KEY (id)
);
-- продажи
CREATE TABLE sales
(
time timestamp NOT NULL,
dep_id integer NOT NULL,
prod_id integer NOT NULL,
cost numeric(10, 2) NOT NULL,
CONSTRAINT sales_fk1 FOREIGN KEY (dep_id) REFERENCES dep (id),
CONSTRAINT sales_fk2 FOREIGN KEY (prod_id) REFERENCES prod (id)
);