CREATE TABLE dav_password (
  uid SERIAL PRIMARY KEY,
  username VARCHAR(16) NOT NULL UNIQUE,
  password VARCHAR(34) NOT NULL,
  firstname VARCHAR(64),
  lastname VARCHAR(64)
);

CREATE TABLE dav_group (
  gid SERIAL PRIMARY KEY,
  username VARCHAR(16) NOT NULL REFERENCES dav_password(username),
  groupname VARCHAR(32) NOT NULL,
  UNIQUE(username, groupname)
);

CREATE TABLE dav_log (
  logid SERIAL PRIMARY KEY,
  username VARCHAR(16),
  reqdate VARCHAR(20),
  uri TEXT,
  ipaddr VARCHAR(16)
);

INSERT INTO dav_password (username, password) VALUES ('admin', md5('secret'));
INSERT INTO dav_group (username, groupname) VALUES ('admin', 'davadmin');
