public
Description: The source code repository for twoorl.com
Homepage: http://twoorl.com
Clone URL: git://github.com/yariv/twoorl.git
twoorl / twoorl.sql
100644 53 lines (42 sloc) 1.457 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
drop table if exists usr;
create table usr (
       id integer unsigned auto_increment primary key,
       username varchar(30) not null,
       password char(20) not null,
       email varchar(50) not null,
       num_msgs integer unsigned not null default 0,
       num_replies integer unsigned not null default 0,
       created_on timestamp,
       unique(username, email)
) engine=innodb;
 
drop table if exists following;
create table following (
       usr_id1 integer unsigned not null,
       usr_id2 integer unsigned not null,
 
       # denormalized usernames to reduce lookups
       usr_username1 varchar(30) not null,
       usr_username2 varchar(30) not null,
 
       created_on timestamp,
       primary key(usr_id1, usr_id2)
) engine=innodb;
 
 
drop table if exists msg;
create table msg (
       id integer unsigned auto_increment primary key,
       usr_id integer unsigned not null,
 
       # denormalized username
       usr_username varchar(30) not null,
 
       # raw data entered by the user
       body_raw varchar(140) not null,
 
       # with pre-escaped html entities and links
       body varchar(140) not null,
 
       created_on timestamp,
       index(usr_id, created_on)
) engine=innodb;
 
drop table if exists reply;
create table reply (
       usr_id integer unsigned not null,
       msg_id integer unsigned not null,
       created_on timestamp,
       primary key(usr_id, msg_id),
       index(created_on)
) engine=innodb;