
DROP TABLE "modules";
DROP SEQUENCE "modules_index_seq";

CREATE TABLE "modules"
   (
   "index"	SERIAL,
   "module"	VARCHAR UNIQUE NOT NULL,
   "time"	TIMESTAMP DEFAULT now() NOT NULL,
   "email"	BOOLEAN default false
   );

DROP TABLE "processing";

CREATE TABLE "processing"
   (
   "index"	INT4 REFERENCES "modules"("index") NOT NULL,
   "time"	TIMESTAMP DEFAULT now( ) NOT NULL
   );

DROP TABLE "archnames";
DROP SEQUENCE "archnames_index_seq";

CREATE TABLE "archnames"
   (
   "index"	SERIAL,
   "name"	VARCHAR UNIQUE NOT NULL
   );

DROP TABLE "osversions";
DROP SEQUENCE "osversions_index_seq";

CREATE TABLE "osversions"
   (
   "index"	SERIAL,
   "version"	VARCHAR UNIQUE NOT NULL
   );

DROP TABLE "grades";
DROP SEQUENCE "grades_index_seq";

CREATE TABLE "grades"
   (
   "index"	SERIAL,
   "grade"	VARCHAR UNIQUE NOT NULL
   );

DROP TABLE "testers";
DROP SEQUENCE "testers_index_seq";

CREATE TABLE "testers"
   (
   "index"	SERIAL,
   "email"	VARCHAR UNIQUE NOT NULL,
   "name"	VARCHAR
   );

DROP TABLE "tested";

CREATE TABLE "tested"
   (
   "tester_index"	INT4 REFERENCES "testers"("index"),
   "module_index"	INT4 REFERENCES "modules"("index") NOT  NULL,
   "archname_index"	INT4 REFERENCES "archnames"("index") NOT NULL,
   "osver_index"	INT4 REFERENCES "osversions"("index") NOT NULL,
   "grade_index"	INT4 REFERENCES "grades"("index") NOT NULL,
   "time"		TIMESTAMP DEFAULT now( ),
   UNIQUE( "tester_index", "module_index", "archname_index", "osver_index", "grade_index" )
   );
