Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.17 KB | None | 0 0
  1. create table user(
  2. usr_id INT NOT NULL AUTO_INCREMENT,
  3. email varchar(70) NOT NULL UNIQUE,
  4. password blob NOT NULL,
  5. display_name varchar(4000),
  6. birth_date char(10) NOT NULL,
  7. gitlab_API_key varchar(20),
  8. img_ref varchar(100),
  9. personal_quote TEXT,
  10. PRIMARY KEY(usr_id)
  11. );
  12.  
  13.  
  14. create table conversation(
  15. conv_id INT NOT NULL AUTO_INCREMENT,
  16. title varchar(200),
  17. usr1_id INT NOT NULL,
  18. usr2_id INT NOT NULL,
  19. PRIMARY KEY(conv_id),
  20. FOREIGN KEY(usr1_id) REFERENCES user(usr_id),
  21. FOREIGN KEY(usr2_id) REFERENCES user(usr_id)
  22. );
  23.  
  24. create table user_conversation(
  25. usr_id INT NOT NULL,
  26. conv_id INT NOT NULL,
  27. FOREIGN KEY(usr_id) REFERENCES user(usr_id),
  28. FOREIGN KEY(conv_id) REFERENCES conversation(conv_id),
  29. PRIMARY KEY(usr_id, conv_id)
  30. );
  31.  
  32. create table message(
  33. msg_id INT NOT NULL AUTO_INCREMENT,
  34. conv_id INT NOT NULL,
  35. from_id INT NOT NULL,
  36. create_date char(10) NOT NULL,
  37. content_txt TEXT NOT NULL,
  38. PRIMARY KEY(msg_id),
  39. FOREIGN KEY(conv_id) REFERENCES conversation(conv_id),
  40. FOREIGN KEY(from_id) REFERENCES user(usr_id)
  41. );
  42.  
  43. create table post(
  44. post_id INT NOT NULL AUTO_INCREMENT,
  45. usr_id INT NOT NULL,
  46. create_date char(10) NOT NULL,
  47. content_txt TEXT NOT NULL,
  48. PRIMARY KEY(post_id),
  49. FOREIGN KEY(usr_id) REFERENCES user(usr_id)
  50. );
  51.  
  52. create table post_fav(
  53. usr_id INT NOT NULL,
  54. post_id INT NOT NULL,
  55. PRIMARY KEY(usr_id, post_id),
  56. FOREIGN KEY(usr_id) REFERENCES user(usr_id),
  57. FOREIGN KEY(post_id) REFERENCES post(post_id)
  58. );
  59.  
  60. create table repo(
  61. repo_id INT NOT NULL,
  62. name_change_date char(10),
  63. PRIMARY KEY(repo_id)
  64. );
  65.  
  66. create table repo_fav(
  67. usr_id INT NOT NULL,
  68. repo_id INT NOT NULL,
  69. PRIMARY KEY(usr_id, repo_id),
  70. FOREIGN KEY(usr_id) REFERENCES user(usr_id),
  71. FOREIGN KEY(repo_id) REFERENCES repo(repo_id)
  72. );
  73.  
  74. create table user_follow(
  75. stalker_id INT NOT NULL,
  76. subject_id INT NOT NULL,
  77. PRIMARY KEY(stalker_id, subject_id),
  78. FOREIGN KEY(stalker_id) REFERENCES user(usr_id),
  79. FOREIGN KEY(subject_id) REFERENCES user(usr_id)
  80. );
  81.  
  82. create table login(
  83. ssh_key varchar(512) NOT NULL,
  84. usr_id INT NOT NULL,
  85. create_date char(10) NOT NULL,
  86. expire_date char(10)
  87. );
  88.  
  89. alter table user modify display_name NOT NULL varchar(4000) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement