Advertisement
Guest User

Untitled

a guest
May 30th, 2017
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. create table users(
  2. id serial PRIMARY KEY,
  3. email text NOT NULL,
  4. screen_name text NOT NULL,
  5. first_name text,
  6. last_name text);
  7.  
  8. create table post(
  9. id serial Primary key,
  10. title text NOT NULL,
  11. content text NOT NULL,
  12. users_id integer references users(id),
  13. timePosted timestamp default current_timestamp
  14. );
  15.  
  16. create table tags(
  17. id serial PRIMARY KEY,
  18. tag_text text NOT NULL);
  19.  
  20. create table comments(
  21. id serial Primary key,
  22. user_id integer references users(id),
  23. post_id integer references post(id),
  24. commentText text NOT NULL
  25. );
  26.  
  27. Create table post_comments(
  28. post_id integer references post(id),
  29. comment_id integer references comments(id),
  30. Ref_comment_id integer references comments(id)
  31. );
  32.  
  33. Create table post_tags(
  34. post_id integer references post(id),
  35. tags_id integer references tags(id)
  36. );
  37.  
  38.  
  39. INSERT INTO users (email, screen_name, first_name) VALUES ('pikachu@gmail.com', 'Pikachu', 'Bob');
  40. INSERT INTO users (email, screen_name, first_name) VALUES ('evie@gmail.com', 'Evie', 'Bobby');
  41. INSERT INTO users (email, screen_name, first_name) VALUES ('squirtle@gmail.com', 'Squirtle', 'Robert');
  42. insert into post (title, content, users_id) VALUES ('Crispy chicken', 'I burnt some chicken today. It was delicious.', 1);
  43. insert into post (title, content, users_id) VALUES ('Waterfalls', 'Saw the most beautiful waterfall yesterday. Can''t wait to go back.', 2);
  44. insert into post (title, content, users_id) VALUES ('Water Slides', 'OMG these are the beeeeeeeeest.', 3);
  45.  
  46. insert into comments (user_id, post_id, commenttext) VALUES (3, 2, 'Take me with you next time.');
  47. insert into comments (user_id, post_id, commenttext) VALUES (1, 2, 'I don''t really like water');
  48. insert into comments (user_id, post_id, commenttext) VALUES (1, 3, 'No really, I don''t like water at all.');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement