Advertisement
Guest User

Untitled

a guest
Jun 12th, 2013
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.72 KB | None | 0 0
  1. CREATE extension hstore;
  2.  
  3. CREATE TABLE users {
  4.     id          serial PRIMARY KEY,
  5.     username    text NOT NULL,
  6.     email       text NOT NULL,
  7.     password    BINARY,
  8.     attributes  hstore
  9. };
  10.  
  11. CREATE TABLE forums {
  12.     id          serial PRIMARY KEY,
  13.     name        text,
  14.     attributes  hstore
  15. };
  16.  
  17. CREATE TABLE threads {
  18.     id          serial PRIMARY KEY,
  19.     forumid     INTEGER REFERENCES forums(id) NOT NULL,
  20.     userid      INTEGER REFERENCES users(id) NOT NULL,
  21.     subject     text NOT NULL,
  22.     TIME        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  23.     attributes  hstore
  24. };
  25.  
  26. CREATE TABLE posts {
  27.     id          serial PRIMARY KEY,
  28.     threadid    INTEGER REFERENCES threads(id) NOT NULL,
  29.     userid      INTEGER REFERENCES users(id) NOT NULL,
  30.     TIME        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  31.     text        text NOT NULL,
  32.     attributes  hstore
  33. };
  34.  
  35. CREATE TABLE messages {
  36.     id          serial PRIMARY KEY,
  37.     fromid      INTEGER REFERENCES users(id) NOT NULL,
  38.     toid        INTEGER REFERENCES users(id) NOT NULL,
  39.     TIME        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  40.     subject     text NOT NULL,
  41.     text        text NOT NULL,
  42.     viewed      BOOLEAN,
  43.     attributes  hstore
  44. };
  45.  
  46. CREATE TABLE thread_subscription {
  47.     id          serial PRIMARY KEY,
  48.     threadid    INTEGER REFERENCES threads(id) NOT NULL,
  49.     userid      INTEGER REFERENCES users(id) NOT NULL,
  50.     lastseenid  INTEGER REFERENCES posts(id) NOT NULL,
  51.     attributes  hstore
  52. };
  53.  
  54. CREATE TABLE forum_subscription {
  55.     id          serial PRIMARY KEY,
  56.     forumid     INTEGER REFERENCES forums(id) NOT NULL,
  57.     lastseenid  INTEGER REFERENCES forums(id) NOT NULL,
  58.     attributes  hstore
  59. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement