Advertisement
Guest User

script

a guest
Oct 18th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. use socialnetwork;
  2.  
  3. create table users
  4. (
  5. id int auto_increment
  6. primary key,
  7. first_name varchar(50) null,
  8. last_name varchar(50) null,
  9. email varchar(50) null,
  10. password varchar(255) null,
  11. gender varchar(50) null,
  12. enabled boolean null,
  13. constraint users_email_uindex
  14. unique (email)
  15. );
  16.  
  17. create table authorities
  18. (
  19. authority varchar(50) null,
  20. username varchar(50) null,
  21. constraint authorities_users_username_fk
  22. foreign key (username) references users (email)
  23. );
  24.  
  25. create table connections
  26. (
  27. user_one_id int auto_increment
  28. primary key,
  29. user_two_id int null,
  30. status varchar(50) null,
  31. constraint connections_users_id_fk
  32. foreign key (user_one_id) references users (id),
  33. constraint connections_users_id_fk_2
  34. foreign key (user_two_id) references users (id)
  35. );
  36.  
  37. create table photos
  38. (
  39. id int auto_increment
  40. primary key,
  41. is_public boolean null,
  42. user_id int null,
  43. constraint photo_user_fk
  44. foreign key (user_id) references users (id)
  45. );
  46.  
  47. create table posts
  48. (
  49. id int auto_increment
  50. primary key,
  51. content text null,
  52. likes int null,
  53. is_public boolean null,
  54. post_date datetime null,
  55. user_id int null,
  56. unique (user_id),
  57. constraint post_user_fk
  58. foreign key (user_id) references users (id)
  59. );
  60.  
  61. create table comments
  62. (
  63. id int auto_increment
  64. primary key,
  65. content text null,
  66. likes int null,
  67. comment_date datetime null,
  68. user_id int null,
  69. post_id int null,
  70. constraint comment_post_fk
  71. foreign key (post_id) references posts (id),
  72. constraint comment_user_fk
  73. foreign key (user_id) references users (id)
  74. );
  75.  
  76. create table user_additional_info
  77. (
  78. id int null,
  79. image_path varchar(255) null,
  80. city varchar(50) null,
  81. country int null,
  82. about text null,
  83. constraint user_additional_info_users_id_fk
  84. foreign key (id) references users (id)
  85. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement