--- trunk/schema.sql	2005/05/13 21:17:58	1
+++ trunk/schema.sql	2005/05/14 11:44:05	4
@@ -2,31 +2,58 @@
 	id	serial,
 	email	text not null,
 	full_name text not null,
-	date	timestamp default now(),
+	date	timestamp not null default now(),
+	active	boolean not null default true,
+	bounce_count int not null default 0,
+	ext_id	text,
 	primary key(id)
 );
 
 create table lists (
 	id	serial,
 	name	text not null,
-	date	timestamp default now(),
+	bounce_limit int not null default 3,
+	date	timestamp not null default now(),
 	primary key(id)
 );
 
 create table user_list (
-	user_id	int not null references users(id),
-	list_id int not null references lists(id),
-	date	timestamp default now(),
+	user_id	int not null references users(id) on update cascade on delete cascade,
+	list_id int not null references lists(id) on update cascade on delete cascade,
+	date	timestamp not null default now(),
 	primary key (user_id, list_id)
 );
 
 create table messages (
 	id	serial,
+	from	text not null,
 	message text not null,
-	date	timestamp default now(),
+	date	timestamp not null default now(),
 	primary key(id)
 );
 
+create table message_list (
+	message_id int not null references messages(id) on update cascade on delete cascade,
+	list_id int not null references lists(id) on update cascade on delete cascade,
+	date	timestamp not null default now(),
+	primary key(message_id, list_id)
+);
+
+create table sent (
+	message_id int not null references messages(id) on update cascade on delete cascade,
+	user_id	int not null references users(id) on update cascade on delete cascade,
+	date	timestamp not null default now(),
+	primary key(message_id, user_id)
+);
+
+create table received (
+	user_id	not null references users(id) on update cascade on delete cascade,
+	message	text not null,
+	bounced	boolean not null default false,
+	date	timestamp not null default now(),
+);
+
+
 insert into users (email, full_name) values ('dpavlin@rot13.org', 'DbP');
 insert into users (email, full_name) values ('dpavlin@gmail.com', 'DbP');
 insert into users (email, full_name) values ('xxx_doesnt_exist_xxx@gmail.com', 'fake');
