CREATE TABLE IF NOT EXISTS teams(team primary key);

CREATE TABLE IF NOT EXISTS users(
  user primary key, gecos, email, team,
  FOREIGN KEY(team) REFERENCES teams(team)
  	ON DELETE CASCADE ON UPDATE CASCADE);

CREATE TABLE IF NOT EXISTS skey(
  user, skey, expire,
  UNIQUE(user, skey),
  FOREIGN KEY(user) REFERENCES users(user)
  	ON DELETE CASCADE ON UPDATE CASCADE);

CREATE TABLE IF NOT EXISTS tmpkey(
  user, tmpkey, token, expire,
  UNIQUE(user, tmpkey),
  FOREIGN KEY(user) REFERENCES users(user)
  	ON DELETE CASCADE ON UPDATE CASCADE);
