CREATE TABLE connection ( id serial PRIMARY KEY, ip inet, port INT, timestamp TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE login_attempt ( id serial PRIMARY KEY, username text NOT NULL, password text NOT NULL, connection int references connection(id), timestamp TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP );