· 5 years ago · Oct 13, 2020, 11:24 PM
1-- MySQL dump 10.13 Distrib 8.0.21, for Win64 (x86_64)
2--
3-- Host: 127.0.0.1 Database: sql_store
4-- ------------------------------------------------------
5-- Server version 8.0.21
6
7/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10/*!50503 SET NAMES utf8 */;
11/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
12/*!40103 SET TIME_ZONE='+00:00' */;
13/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17
18--
19-- Table structure for table `customers`
20--
21
22DROP TABLE IF EXISTS `customers`;
23/*!40101 SET @saved_cs_client = @@character_set_client */;
24/*!50503 SET character_set_client = utf8mb4 */;
25CREATE TABLE `customers` (
26 `customer_id` int NOT NULL AUTO_INCREMENT,
27 `first_name` varchar(50) NOT NULL,
28 `last_name` varchar(50) NOT NULL,
29 `birth_date` date DEFAULT NULL,
30 `phone` varchar(50) DEFAULT NULL,
31 `address` varchar(50) NOT NULL,
32 `city` varchar(50) NOT NULL,
33 `state` char(2) NOT NULL,
34 `points` int NOT NULL DEFAULT '0',
35 PRIMARY KEY (`customer_id`)
36) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
37/*!40101 SET character_set_client = @saved_cs_client */;
38
39--
40-- Table structure for table `order_item_notes`
41--
42
43DROP TABLE IF EXISTS `order_item_notes`;
44/*!40101 SET @saved_cs_client = @@character_set_client */;
45/*!50503 SET character_set_client = utf8mb4 */;
46CREATE TABLE `order_item_notes` (
47 `note_id` int NOT NULL,
48 `order_Id` int NOT NULL,
49 `product_id` int NOT NULL,
50 `note` varchar(255) NOT NULL,
51 PRIMARY KEY (`note_id`)
52) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
53/*!40101 SET character_set_client = @saved_cs_client */;
54
55--
56-- Table structure for table `order_items`
57--
58
59DROP TABLE IF EXISTS `order_items`;
60/*!40101 SET @saved_cs_client = @@character_set_client */;
61/*!50503 SET character_set_client = utf8mb4 */;
62CREATE TABLE `order_items` (
63 `order_id` int NOT NULL AUTO_INCREMENT,
64 `product_id` int NOT NULL,
65 `quantity` int NOT NULL,
66 `unit_price` decimal(4,2) NOT NULL,
67 PRIMARY KEY (`order_id`,`product_id`),
68 KEY `fk_order_items_products_idx` (`product_id`),
69 CONSTRAINT `fk_order_items_orders` FOREIGN KEY (`order_id`) REFERENCES `orders` (`order_id`) ON UPDATE CASCADE,
70 CONSTRAINT `fk_order_items_products` FOREIGN KEY (`product_id`) REFERENCES `products` (`product_id`) ON UPDATE CASCADE
71) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
72/*!40101 SET character_set_client = @saved_cs_client */;
73
74--
75-- Table structure for table `order_statuses`
76--
77
78DROP TABLE IF EXISTS `order_statuses`;
79/*!40101 SET @saved_cs_client = @@character_set_client */;
80/*!50503 SET character_set_client = utf8mb4 */;
81CREATE TABLE `order_statuses` (
82 `order_status_id` tinyint NOT NULL,
83 `name` varchar(50) NOT NULL,
84 PRIMARY KEY (`order_status_id`)
85) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
86/*!40101 SET character_set_client = @saved_cs_client */;
87
88--
89-- Table structure for table `orders`
90--
91
92DROP TABLE IF EXISTS `orders`;
93/*!40101 SET @saved_cs_client = @@character_set_client */;
94/*!50503 SET character_set_client = utf8mb4 */;
95CREATE TABLE `orders` (
96 `order_id` int NOT NULL AUTO_INCREMENT,
97 `customer_id` int NOT NULL,
98 `order_date` date NOT NULL,
99 `status` tinyint NOT NULL DEFAULT '1',
100 `comments` varchar(2000) DEFAULT NULL,
101 `shipped_date` date DEFAULT NULL,
102 `shipper_id` smallint DEFAULT NULL,
103 PRIMARY KEY (`order_id`),
104 KEY `fk_orders_customers_idx` (`customer_id`),
105 KEY `fk_orders_shippers_idx` (`shipper_id`),
106 KEY `fk_orders_order_statuses_idx` (`status`),
107 CONSTRAINT `fk_orders_customers` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`customer_id`) ON UPDATE CASCADE,
108 CONSTRAINT `fk_orders_order_statuses` FOREIGN KEY (`status`) REFERENCES `order_statuses` (`order_status_id`) ON UPDATE CASCADE,
109 CONSTRAINT `fk_orders_shippers` FOREIGN KEY (`shipper_id`) REFERENCES `shippers` (`shipper_id`) ON UPDATE CASCADE
110) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
111/*!40101 SET character_set_client = @saved_cs_client */;
112
113--
114-- Table structure for table `products`
115--
116
117DROP TABLE IF EXISTS `products`;
118/*!40101 SET @saved_cs_client = @@character_set_client */;
119/*!50503 SET character_set_client = utf8mb4 */;
120CREATE TABLE `products` (
121 `product_id` int NOT NULL AUTO_INCREMENT,
122 `name` varchar(50) NOT NULL,
123 `quantity_in_stock` int NOT NULL,
124 `unit_price` decimal(4,2) NOT NULL,
125 PRIMARY KEY (`product_id`)
126) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
127/*!40101 SET character_set_client = @saved_cs_client */;
128
129--
130-- Table structure for table `shippers`
131--
132
133DROP TABLE IF EXISTS `shippers`;
134/*!40101 SET @saved_cs_client = @@character_set_client */;
135/*!50503 SET character_set_client = utf8mb4 */;
136CREATE TABLE `shippers` (
137 `shipper_id` smallint NOT NULL AUTO_INCREMENT,
138 `name` varchar(50) NOT NULL,
139 PRIMARY KEY (`shipper_id`)
140) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
141/*!40101 SET character_set_client = @saved_cs_client */;
142/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
143
144/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
145/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
146/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
147/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
148/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
149/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
150/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
151
152-- Dump completed on 2020-10-14 0:05:08
153