deathslayer999

oregonstate phpMyAdmin SQL Dump

Sep 25th, 2019
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.96 KB | None | 0 0
  1. -- phpMyAdmin SQL Dump
  2. -- version 4.7.0
  3. -- https://www.phpmyadmin.net/
  4. --
  5. -- Host: classmysql.engr.oregonstate.edu:3306
  6. -- Generation Time: Dec 07, 2017 at 10:16 PM
  7. -- Server version: 10.1.22-MariaDB
  8. -- PHP Version: 7.0.23
  9.  
  10. SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  11. SET AUTOCOMMIT = 0;
  12. START TRANSACTION;
  13. SET time_zone = "+00:00";
  14.  
  15.  
  16. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  17. /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  18. /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  19. /*!40101 SET NAMES utf8mb4 */;
  20.  
  21. --
  22. -- Database: `cs340_tusingz`
  23. --
  24.  
  25. DELIMITER $$
  26. --
  27. -- Procedures
  28. --
  29. CREATE DEFINER=`cs340_tusingz`@`%` PROCEDURE `updateAllCollegeStats` () NO SQL
  30. BEGIN
  31.  
  32. DECLARE appC INT;
  33. DECLARE done int default 0;
  34. DECLARE current_cName varchar(20);
  35. DECLARE cNamecur cursor for select cName from CollegeStats;
  36. DECLARE CONTINUE handler for not found set done = 1;
  37.  
  38. OPEN cNamecur;
  39.  
  40. REPEAT
  41.  
  42. FETCH cNamecur into current_cName;
  43.  
  44. UPDATE CollegeStats SET appCount = (SELECT COUNT(*) from Apply WHERE Apply.cName = current_cName)
  45.  
  46. where cName = current_cName;
  47.  
  48.  
  49. UNTIL done
  50. end repeat;
  51. close cNamecur;
  52.  
  53. END$$
  54.  
  55. CREATE DEFINER=`cs340_tusingz`@`%` PROCEDURE `updateCollegeStats` (IN `Name` VARCHAR(20)) NO SQL
  56. BEGIN
  57. DECLARE appC INT;
  58.  
  59. SELECT COUNT(*) INTO appC FROM Apply WHERE cName = Name;
  60.  
  61. UPDATE CollegeStats SET appCount = appC WHERE cName = Name;
  62.  
  63. END$$
  64.  
  65. DELIMITER ;
  66.  
  67. -- --------------------------------------------------------
  68.  
  69. --
  70. -- Table structure for table `Grocery_item`
  71. --
  72.  
  73. CREATE TABLE `Grocery_item` (
  74. `ItemID` int(11) NOT NULL,
  75. `Info` text NOT NULL,
  76. `Name` varchar(40) NOT NULL,
  77. `Calories` int(11) NOT NULL,
  78. `Price` decimal(4,2) NOT NULL,
  79. `Image` varchar(250) NOT NULL
  80. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  81.  
  82. --
  83. -- Dumping data for table `Grocery_item`
  84. --
  85.  
  86. INSERT INTO `Grocery_item` (`ItemID`, `Info`, `Name`, `Calories`, `Price`, `Image`) VALUES
  87. (1, 'Apples are the #1 fruit in America', 'Apple', 5, '0.99', 'https://www.organicfacts.net/wp-content/uploads/2013/05/Apple4.jpg'),
  88. (2, 'Banananananas', 'Bananas', 10, '0.89', 'https://img.purch.com/h/1000/aHR0cDovL3d3dy5saXZlc2NpZW5jZS5jb20vaW1hZ2VzL2kvMDAwLzA2NS8xNDkvb3JpZ2luYWwvYmFuYW5hcy5qcGc='),
  89. (3, 'Cantaloupe of the gods', 'Cantaloupe', 30, '3.99', 'http://www.specialtyproduce.com/sppics/788.png'),
  90. (4, 'Really good for your rabbits', 'Carrot', 2000, '7.00', 'http://media.mercola.com/assets/images/foodfacts/carrot-nutrition-facts.jpg'),
  91. (6, 'Mmmmm finger lickin\' good', 'Chicken Wings', 400, '6.99', 'https://st.depositphotos.com/1010305/1851/i/950/depositphotos_18513939-stock-photo-raw-chicken-legs-on-a.jpg'),
  92. (7, 'The coolest of Cool Aids', 'Cool Aid', 9001, '0.33', 'https://ih0.redbubble.net/image.426698105.1945/flat,800x800,075,f.u1.jpg'),
  93. (8, 'From the best pigs around!', 'Bacon', 600, '2.99', 'http://www.seriouseats.com/images/2016/10/20161018-best-way-to-bake-bacon-18.jpg'),
  94. (9, 'Best for Thanksgiving dinners!', 'Turkey', 7000, '14.99', 'https://scoobysfarm.com/wp-content/uploads/2016/08/whole-chicken.jpg');
  95.  
  96. -- --------------------------------------------------------
  97.  
  98. --
  99. -- Table structure for table `Orders`
  100. --
  101.  
  102. CREATE TABLE `Orders` (
  103. `OrderID` int(11) NOT NULL,
  104. `EmployeeID` int(11) DEFAULT NULL,
  105. `ShopperID` int(11) NOT NULL,
  106. `ShoppingID` int(11) NOT NULL,
  107. `Shopper_signature` int(11) NOT NULL DEFAULT '0',
  108. `Picker_signature` int(11) NOT NULL DEFAULT '0'
  109. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  110.  
  111. --
  112. -- Dumping data for table `Orders`
  113. --
  114.  
  115. INSERT INTO `Orders` (`OrderID`, `EmployeeID`, `ShopperID`, `ShoppingID`, `Shopper_signature`, `Picker_signature`) VALUES
  116. (1, 2, 2, 27, 0, 1),
  117. (2, NULL, 2, 28, 0, 0);
  118.  
  119. --
  120. -- Triggers `Orders`
  121. --
  122. DELIMITER $$
  123. CREATE TRIGGER `AddNewCart2` AFTER INSERT ON `Orders` FOR EACH ROW BEGIN
  124.  
  125. DECLARE storeInt INTEGER;
  126.  
  127. SET storeInt = (SELECT MAX(ShoppingID) FROM Shopping_cart) + 1;
  128.  
  129. INSERT INTO Shopping_cart (ShoppingID, Total, ShopperID) VALUES (storeInt, 0, new.ShopperID);
  130.  
  131. END
  132. $$
  133. DELIMITER ;
  134. DELIMITER $$
  135. CREATE TRIGGER `ifExists` BEFORE INSERT ON `Orders` FOR EACH ROW BEGIN
  136.  
  137. IF NOT EXISTS(select ShoppingID from Purchased_item where ShoppingID = new.ShoppingID) THEN
  138.  
  139. SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'There are no items in your shopping cart';
  140.  
  141. END IF;
  142.  
  143. END
  144. $$
  145. DELIMITER ;
  146.  
  147. -- --------------------------------------------------------
  148.  
  149. --
  150. -- Table structure for table `Picker_upper`
  151. --
  152.  
  153. CREATE TABLE `Picker_upper` (
  154. `EmployeeID` int(11) NOT NULL,
  155. `First_name` varchar(40) NOT NULL,
  156. `Last_name` varchar(40) NOT NULL,
  157. `Username` varchar(20) DEFAULT NULL,
  158. `Password` varchar(20) DEFAULT NULL,
  159. `Credit_card` int(11) NOT NULL,
  160. `Phone_number` int(11) NOT NULL,
  161. `Address` varchar(55) NOT NULL
  162. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  163.  
  164. --
  165. -- Dumping data for table `Picker_upper`
  166. --
  167.  
  168. INSERT INTO `Picker_upper` (`EmployeeID`, `First_name`, `Last_name`, `Username`, `Password`, `Credit_card`, `Phone_number`, `Address`) VALUES
  169. (1, 'new', 'new', 'newuser', 'n', 1, 1, '1'),
  170. (2, 'Zach', 'Tusing', 'Hello', 'h', 403, 503, '234');
  171.  
  172. -- --------------------------------------------------------
  173.  
  174. --
  175. -- Table structure for table `Purchased_item`
  176. --
  177.  
  178. CREATE TABLE `Purchased_item` (
  179. `ItemID` int(11) NOT NULL,
  180. `ShoppingID` int(11) NOT NULL,
  181. `Quantity` int(11) NOT NULL
  182. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  183.  
  184. --
  185. -- Dumping data for table `Purchased_item`
  186. --
  187.  
  188. INSERT INTO `Purchased_item` (`ItemID`, `ShoppingID`, `Quantity`) VALUES
  189. (1, 1, 2),
  190. (3, 4, 2),
  191. (2, 5, 3),
  192. (3, 6, 2),
  193. (1, 6, 5),
  194. (2, 9, 4),
  195. (1, 9, 3),
  196. (1, 13, 1),
  197. (2, 14, 1),
  198. (1, 15, 1),
  199. (1, 16, 1),
  200. (2, 17, 1),
  201. (1, 17, 1),
  202. (3, 18, 1),
  203. (2, 19, 1),
  204. (1, 20, 2),
  205. (2, 21, 1),
  206. (1, 22, 1),
  207. (1, 23, 1),
  208. (1, 24, 1),
  209. (2, 25, 1),
  210. (2, 26, 6),
  211. (3, 26, 4),
  212. (2, 27, 1),
  213. (1, 27, 1),
  214. (3, 27, 1),
  215. (7, 27, 10),
  216. (1, 28, 5),
  217. (3, 28, 4),
  218. (9, 28, 4);
  219.  
  220. --
  221. -- Triggers `Purchased_item`
  222. --
  223. DELIMITER $$
  224. CREATE TRIGGER `removeTotal` AFTER DELETE ON `Purchased_item` FOR EACH ROW BEGIN
  225.  
  226. declare storeInt decimal(13,2);
  227.  
  228. SELECT Price into storeInt FROM Grocery_item WHERE ItemID = old.ItemID;
  229.  
  230. UPDATE Shopping_cart SET total = total - (storeInt * old.Quantity) WHERE ShoppingID = old.ShoppingID;
  231.  
  232. END
  233. $$
  234. DELIMITER ;
  235. DELIMITER $$
  236. CREATE TRIGGER `updateTot` AFTER UPDATE ON `Purchased_item` FOR EACH ROW BEGIN
  237. declare storeInt decimal(13,2);
  238.  
  239. SELECT Price into storeInt FROM Grocery_item WHERE ItemID = new.ItemID;
  240.  
  241. UPDATE Shopping_cart SET total = total + storeInt WHERE ShoppingID = new.ShoppingID;
  242.  
  243. END
  244. $$
  245. DELIMITER ;
  246. DELIMITER $$
  247. CREATE TRIGGER `updateTotal` AFTER INSERT ON `Purchased_item` FOR EACH ROW BEGIN
  248.  
  249. declare storeInt decimal(13,2);
  250.  
  251. SELECT Price into storeInt FROM Grocery_item WHERE ItemID = new.ItemID;
  252.  
  253. UPDATE Shopping_cart SET total = total + storeInt WHERE ShoppingID = new.ShoppingID;
  254.  
  255. END
  256. $$
  257. DELIMITER ;
  258.  
  259. -- --------------------------------------------------------
  260.  
  261. --
  262. -- Table structure for table `Shopper`
  263. --
  264.  
  265. CREATE TABLE `Shopper` (
  266. `ShopperID` int(11) NOT NULL,
  267. `First_name` varchar(40) NOT NULL,
  268. `Last_name` varchar(40) NOT NULL,
  269. `UserName` varchar(20) NOT NULL,
  270. `Password` varchar(20) NOT NULL,
  271. `Credit_card` int(11) NOT NULL,
  272. `Phone_number` int(11) NOT NULL,
  273. `Address` varchar(55) NOT NULL
  274. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  275.  
  276. --
  277. -- Dumping data for table `Shopper`
  278. --
  279.  
  280. INSERT INTO `Shopper` (`ShopperID`, `First_name`, `Last_name`, `UserName`, `Password`, `Credit_card`, `Phone_number`, `Address`) VALUES
  281. (1, 'Zach', 'Tusing', 'Zach', 'z', 666000, 503, '6625'),
  282. (2, 'Cameron', 'Friel', 'Cam', 'c', 666999, 503, '902'),
  283. (3, 'test', 'test', 'new', 'test', 0, 0, 'test');
  284.  
  285. --
  286. -- Triggers `Shopper`
  287. --
  288. DELIMITER $$
  289. CREATE TRIGGER `addNewCart` AFTER INSERT ON `Shopper` FOR EACH ROW BEGIN
  290.  
  291. DECLARE storeInt INTEGER;
  292.  
  293. SET storeInt = (SELECT MAX(ShoppingID) FROM Shopping_cart) + 1;
  294.  
  295. INSERT INTO Shopping_cart (ShoppingID, Total, ShopperID) VALUES (storeInt, 0, new.ShopperID);
  296.  
  297. END
  298. $$
  299. DELIMITER ;
  300.  
  301. -- --------------------------------------------------------
  302.  
  303. --
  304. -- Table structure for table `Shopping_cart`
  305. --
  306.  
  307. CREATE TABLE `Shopping_cart` (
  308. `ShoppingID` int(11) NOT NULL,
  309. `Total` decimal(6,2) NOT NULL,
  310. `ShopperID` int(11) NOT NULL
  311. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  312.  
  313. --
  314. -- Dumping data for table `Shopping_cart`
  315. --
  316.  
  317. INSERT INTO `Shopping_cart` (`ShoppingID`, `Total`, `ShopperID`) VALUES
  318. (0, '0.00', 1),
  319. (1, '9.00', 2),
  320. (2, '-1.65', 3),
  321. (3, '0.00', 2),
  322. (4, '7.98', 2),
  323. (5, '2.67', 2),
  324. (6, '12.93', 2),
  325. (7, '0.00', 2),
  326. (8, '0.00', 2),
  327. (9, '6.53', 2),
  328. (10, '0.00', 2),
  329. (11, '0.00', 2),
  330. (12, '0.00', 2),
  331. (13, '0.99', 2),
  332. (14, '0.89', 2),
  333. (15, '0.99', 2),
  334. (16, '0.99', 2),
  335. (17, '1.88', 2),
  336. (18, '3.99', 2),
  337. (19, '0.89', 2),
  338. (20, '1.98', 2),
  339. (21, '0.89', 2),
  340. (22, '0.99', 2),
  341. (23, '0.99', 2),
  342. (24, '0.99', 2),
  343. (25, '0.89', 2),
  344. (26, '21.30', 2),
  345. (27, '9.17', 2),
  346. (28, '80.87', 2),
  347. (29, '0.00', 2);
  348.  
  349. --
  350. -- Indexes for dumped tables
  351. --
  352.  
  353. --
  354. -- Indexes for table `Grocery_item`
  355. --
  356. ALTER TABLE `Grocery_item`
  357. ADD PRIMARY KEY (`ItemID`);
  358.  
  359. --
  360. -- Indexes for table `Orders`
  361. --
  362. ALTER TABLE `Orders`
  363. ADD PRIMARY KEY (`OrderID`),
  364. ADD KEY `EmployeeID` (`EmployeeID`),
  365. ADD KEY `ShopperID` (`ShopperID`),
  366. ADD KEY `ShoppingID` (`ShoppingID`);
  367.  
  368. --
  369. -- Indexes for table `Picker_upper`
  370. --
  371. ALTER TABLE `Picker_upper`
  372. ADD PRIMARY KEY (`EmployeeID`);
  373.  
  374. --
  375. -- Indexes for table `Purchased_item`
  376. --
  377. ALTER TABLE `Purchased_item`
  378. ADD KEY `ItemID` (`ItemID`),
  379. ADD KEY `ShoppingID` (`ShoppingID`);
  380.  
  381. --
  382. -- Indexes for table `Shopper`
  383. --
  384. ALTER TABLE `Shopper`
  385. ADD PRIMARY KEY (`ShopperID`);
  386.  
  387. --
  388. -- Indexes for table `Shopping_cart`
  389. --
  390. ALTER TABLE `Shopping_cart`
  391. ADD PRIMARY KEY (`ShoppingID`),
  392. ADD KEY `ShopperID` (`ShopperID`);
  393.  
  394. --
  395. -- Constraints for dumped tables
  396. --
  397.  
  398. --
  399. -- Constraints for table `Orders`
  400. --
  401. ALTER TABLE `Orders`
  402. ADD CONSTRAINT `Orders_ibfk_1` FOREIGN KEY (`EmployeeID`) REFERENCES `Picker_upper` (`EmployeeID`),
  403. ADD CONSTRAINT `Orders_ibfk_2` FOREIGN KEY (`ShopperID`) REFERENCES `Shopper` (`ShopperID`),
  404. ADD CONSTRAINT `Orders_ibfk_3` FOREIGN KEY (`ShoppingID`) REFERENCES `Shopping_cart` (`ShoppingID`) ON UPDATE CASCADE;
  405.  
  406. --
  407. -- Constraints for table `Purchased_item`
  408. --
  409. ALTER TABLE `Purchased_item`
  410. ADD CONSTRAINT `Purchased_item_ibfk_1` FOREIGN KEY (`ItemID`) REFERENCES `Grocery_item` (`ItemID`),
  411. ADD CONSTRAINT `Purchased_item_ibfk_2` FOREIGN KEY (`ShoppingID`) REFERENCES `Shopping_cart` (`ShoppingID`) ON UPDATE CASCADE;
  412.  
  413. --
  414. -- Constraints for table `Shopping_cart`
  415. --
  416. ALTER TABLE `Shopping_cart`
  417. ADD CONSTRAINT `Shopping_cart_ibfk_1` FOREIGN KEY (`ShopperID`) REFERENCES `Shopper` (`ShopperID`) ON UPDATE CASCADE;
  418. COMMIT;
  419.  
  420. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  421. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  422. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Add Comment
Please, Sign In to add comment