CREATE TABLE contests (
	id INT NOT NULL AUTO_INCREMENT, 
	fromgid INT NOT NULL,
	togid INT NOT NULL,
	game INT NOT NULL,
	type TINYINT NOT NULL,
	PRIMARY KEY(id)
);

CREATE TABLE games (
	id INT NOT NULL AUTO_INCREMENT,
	name CHAR(45),
	PRIMARY KEY(id)
);

CREATE TABLE groups (
	gid INT NOT NULL AUTO_INCREMENT,
	gname CHAR(30),
	PRIMARY KEY(gid)
);

CREATE TABLE messages (
	id INT NOT NULL AUTO_INCREMENT,
	uid INT NOT NULL, 
	gid INT NOT NULL, 
	postdate BIGINT,
	subject VARCHAR(128),
	body TEXT, 
	PRIMARY KEY(id)
);

CREATE TABLE scores (
	id INT NOT NULL,
	uid INT NOT NULL, 
	score INT NOT NULL
);

CREATE TABLE users (
	uid INT NOT NULL AUTO_INCREMENT,
	gid INT NOT NULL,
	fname CHAR(30) NOT NULL,
	lname CHAR(30) NOT NULL,
	user CHAR(30) NOT NULL,
	pass CHAR(30) NOT NULL,
	points INT NOT NULL DEFAULT 50,
	PRIMARY KEY(uid)
);

CREATE TABLE votes (
	id INT NOT NULL,
	uid INT NOT NULL, 
	gid INT NOT NULL,
	points INT NOT NULL
);
