Advertisement
xhaosmaster

Untitled

Dec 5th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.35 KB | None | 0 0
  1. -- phpMyAdmin SQL Dump
  2. -- version 4.6.4
  3. -- https://www.phpmyadmin.net/
  4. --
  5. -- Host: localhost:8889
  6. -- Generation Time: Dec 05, 2016 at 02:31 PM
  7. -- Server version: 5.6.33
  8. -- PHP Version: 7.0.12
  9.  
  10. SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  11. SET time_zone = "+00:00";
  12.  
  13. --
  14. -- Database: `evolve`
  15. --
  16.  
  17. -- --------------------------------------------------------
  18.  
  19. --
  20. -- Table structure for table `comments`
  21. --
  22.  
  23. CREATE TABLE `comments` (
  24. `comment_id` int(11) NOT NULL,
  25. `post_id` int(11) NOT NULL,
  26. `user_id` int(11) NOT NULL,
  27. `comment_body` text NOT NULL,
  28. `comment_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  29. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  30.  
  31. --
  32. -- Dumping data for table `comments`
  33. --
  34.  
  35. INSERT INTO `comments` (`comment_id`, `post_id`, `user_id`, `comment_body`, `comment_timestamp`) VALUES
  36. (1, 1, 1, 'This is a comment that came from an SQL Database.', '2016-12-05 12:35:41');
  37.  
  38. -- --------------------------------------------------------
  39.  
  40. --
  41. -- Table structure for table `likes`
  42. --
  43.  
  44. CREATE TABLE `likes` (
  45. `like_id` int(11) NOT NULL,
  46. `comment_id` int(11) NOT NULL,
  47. `user_id` int(11) NOT NULL,
  48. `hasLiked` int(1) NOT NULL
  49. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  50.  
  51. -- --------------------------------------------------------
  52.  
  53. --
  54. -- Table structure for table `posts`
  55. --
  56.  
  57. CREATE TABLE `posts` (
  58. `post_id` int(11) NOT NULL,
  59. `user_id` int(11) NOT NULL,
  60. `post_body` text NOT NULL,
  61. `post_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  62. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  63.  
  64. --
  65. -- Dumping data for table `posts`
  66. --
  67.  
  68. INSERT INTO `posts` (`post_id`, `user_id`, `post_body`, `post_timestamp`) VALUES
  69. (1, 1, 'Hey there, this is sample text that came from a SQL Database.', '2016-12-05 12:34:44');
  70.  
  71. -- --------------------------------------------------------
  72.  
  73. --
  74. -- Table structure for table `users`
  75. --
  76.  
  77. CREATE TABLE `users` (
  78. `user_id` int(10) NOT NULL,
  79. `user_login` varchar(20) NOT NULL,
  80. `user_password` varchar(20) NOT NULL,
  81. `user_email` varchar(30) NOT NULL,
  82. `display_name` varchar(30) NOT NULL,
  83. `user_reg_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  84. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  85.  
  86. --
  87. -- Dumping data for table `users`
  88. --
  89.  
  90. INSERT INTO `users` (`user_id`, `user_login`, `user_password`, `user_email`, `display_name`, `user_reg_date`) VALUES
  91. (1, 'admin', '1234', 'admin@evolve.com', 'Administrator', '2016-12-05 12:33:29');
  92.  
  93. -- --------------------------------------------------------
  94.  
  95. --
  96. -- Table structure for table `votes`
  97. --
  98.  
  99. CREATE TABLE `votes` (
  100. `vote_id` int(11) NOT NULL,
  101. `post_id` int(11) NOT NULL,
  102. `user_id` int(11) NOT NULL,
  103. `hasVoted` int(1) NOT NULL
  104. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  105.  
  106. --
  107. -- Indexes for dumped tables
  108. --
  109.  
  110. --
  111. -- Indexes for table `comments`
  112. --
  113. ALTER TABLE `comments`
  114. ADD PRIMARY KEY (`comment_id`),
  115. ADD KEY `post_id` (`post_id`),
  116. ADD KEY `user_id` (`user_id`);
  117.  
  118. --
  119. -- Indexes for table `likes`
  120. --
  121. ALTER TABLE `likes`
  122. ADD PRIMARY KEY (`like_id`),
  123. ADD KEY `comment_id` (`comment_id`),
  124. ADD KEY `user_id` (`user_id`);
  125.  
  126. --
  127. -- Indexes for table `posts`
  128. --
  129. ALTER TABLE `posts`
  130. ADD PRIMARY KEY (`post_id`),
  131. ADD KEY `user_id` (`user_id`);
  132.  
  133. --
  134. -- Indexes for table `users`
  135. --
  136. ALTER TABLE `users`
  137. ADD PRIMARY KEY (`user_id`);
  138.  
  139. --
  140. -- Indexes for table `votes`
  141. --
  142. ALTER TABLE `votes`
  143. ADD PRIMARY KEY (`vote_id`),
  144. ADD KEY `post_id` (`post_id`),
  145. ADD KEY `user_id` (`user_id`);
  146.  
  147. --
  148. -- AUTO_INCREMENT for dumped tables
  149. --
  150.  
  151. --
  152. -- AUTO_INCREMENT for table `comments`
  153. --
  154. ALTER TABLE `comments`
  155. MODIFY `comment_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  156. --
  157. -- AUTO_INCREMENT for table `likes`
  158. --
  159. ALTER TABLE `likes`
  160. MODIFY `like_id` int(11) NOT NULL AUTO_INCREMENT;
  161. --
  162. -- AUTO_INCREMENT for table `posts`
  163. --
  164. ALTER TABLE `posts`
  165. MODIFY `post_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  166. --
  167. -- AUTO_INCREMENT for table `users`
  168. --
  169. ALTER TABLE `users`
  170. MODIFY `user_id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  171. --
  172. -- AUTO_INCREMENT for table `votes`
  173. --
  174. ALTER TABLE `votes`
  175. MODIFY `vote_id` int(11) NOT NULL AUTO_INCREMENT;
  176. --
  177. -- Constraints for dumped tables
  178. --
  179.  
  180. --
  181. -- Constraints for table `comments`
  182. --
  183. ALTER TABLE `comments`
  184. ADD CONSTRAINT `comments_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`),
  185. ADD CONSTRAINT `comments_ibfk_2` FOREIGN KEY (`post_id`) REFERENCES `posts` (`post_id`);
  186.  
  187. --
  188. -- Constraints for table `likes`
  189. --
  190. ALTER TABLE `likes`
  191. ADD CONSTRAINT `likes_ibfk_1` FOREIGN KEY (`comment_id`) REFERENCES `comments` (`comment_id`),
  192. ADD CONSTRAINT `likes_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`);
  193.  
  194. --
  195. -- Constraints for table `posts`
  196. --
  197. ALTER TABLE `posts`
  198. ADD CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`);
  199.  
  200. --
  201. -- Constraints for table `votes`
  202. --
  203. ALTER TABLE `votes`
  204. ADD CONSTRAINT `votes_ibfk_1` FOREIGN KEY (`post_id`) REFERENCES `posts` (`post_id`),
  205. ADD CONSTRAINT `votes_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`);
  206.  
  207. -- create the users and grant priveleges to those users
  208. GRANT SELECT, INSERT, DELETE, UPDATE
  209. ON evolve.*
  210. TO admin@localhost
  211. IDENTIFIED BY '1234';
  212.  
  213. GRANT SELECT
  214. ON users
  215. TO admin@localhost
  216. IDENTIFIED BY '1234';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement