BEGIN;

CREATE TABLE client (
	client SERIAL PRIMARY KEY NOT NULL,
	name   TEXT NOT NULL UNIQUE
	);

CREATE TABLE site (
	site	SERIAL PRIMARY KEY NOT NULL,
	name	TEXT NOT NULL CHECK (name <> '')
	);

CREATE TABLE host (
	host	SERIAL PRIMARY KEY NOT NULL,
	ip	TEXT NOT NULL CHECK (ip <> ''),
	site	INTEGER REFERENCES site NOT NULL,
	client  INTEGER REFERENCES client NOT NULL
	);

CREATE TABLE info (
	info	SERIAL PRIMARY KEY NOT NULL,
	host	INTEGER REFERENCES host NOT NULL,
	message TEXT NOT NULL CHECK (message <> '')
	);

COMMIT;
