· 5 years ago · Jun 14, 2020, 06:14 PM
1CREATE DATABASE IF NOT EXISTS `dotnet-shop` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
2USE `dotnet-shop`;
3-- MySQL dump 10.17 Distrib 10.3.22-MariaDB, for debian-linux-gnu (x86_64)
4--
5-- Host: 127.0.0.1 Database: dotnet-shop
6-- ------------------------------------------------------
7-- Server version 10.3.22-MariaDB-1ubuntu1
8
9/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
10/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
11/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
12/*!40101 SET NAMES utf8 */;
13/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
14/*!40103 SET TIME_ZONE='+00:00' */;
15/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
16/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
17/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
18/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
19
20--
21-- Table structure for table `category`
22--
23
24DROP TABLE IF EXISTS `category`;
25/*!40101 SET @saved_cs_client = @@character_set_client */;
26/*!40101 SET character_set_client = utf8 */;
27CREATE TABLE `category` (
28 `title` varchar(20) NOT NULL,
29 PRIMARY KEY (`title`)
30) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
31/*!40101 SET character_set_client = @saved_cs_client */;
32
33--
34-- Table structure for table `category_product`
35--
36
37DROP TABLE IF EXISTS `category_product`;
38/*!40101 SET @saved_cs_client = @@character_set_client */;
39/*!40101 SET character_set_client = utf8 */;
40CREATE TABLE `category_product` (
41 `product_title` varchar(50) NOT NULL,
42 `product_vendor_name` varchar(50) NOT NULL,
43 `category_title` varchar(20) NOT NULL,
44 PRIMARY KEY (`product_title`,`product_vendor_name`,`category_title`),
45 KEY `fk_category_product_category_title` (`category_title`),
46 CONSTRAINT `fk_category_product_category_title` FOREIGN KEY (`category_title`) REFERENCES `category` (`title`) ON DELETE CASCADE ON UPDATE CASCADE,
47 CONSTRAINT `fk_category_product_product_title_vendor_name` FOREIGN KEY (`product_title`, `product_vendor_name`) REFERENCES `product` (`title`, `vendor_name`) ON DELETE CASCADE ON UPDATE CASCADE
48) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
49/*!40101 SET character_set_client = @saved_cs_client */;
50
51--
52-- Table structure for table `customer`
53--
54
55DROP TABLE IF EXISTS `customer`;
56/*!40101 SET @saved_cs_client = @@character_set_client */;
57/*!40101 SET character_set_client = utf8 */;
58CREATE TABLE `customer` (
59 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
60 `first_name` varchar(50) NOT NULL,
61 `last_name` varchar(50) NOT NULL,
62 PRIMARY KEY (`id`)
63) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
64/*!40101 SET character_set_client = @saved_cs_client */;
65
66--
67-- Table structure for table `order`
68--
69
70DROP TABLE IF EXISTS `order`;
71/*!40101 SET @saved_cs_client = @@character_set_client */;
72/*!40101 SET character_set_client = utf8 */;
73CREATE TABLE `order` (
74 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
75 `customer_id` int(10) unsigned NOT NULL,
76 PRIMARY KEY (`id`,`customer_id`),
77 KEY `fk_order_customer_id` (`customer_id`),
78 CONSTRAINT `fk_order_customer_id` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
79) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
80/*!40101 SET character_set_client = @saved_cs_client */;
81
82--
83-- Table structure for table `order_product`
84--
85
86DROP TABLE IF EXISTS `order_product`;
87/*!40101 SET @saved_cs_client = @@character_set_client */;
88/*!40101 SET character_set_client = utf8 */;
89CREATE TABLE `order_product` (
90 `order_id` int(10) unsigned NOT NULL,
91 `order_customer_id` int(10) unsigned NOT NULL,
92 `product_title` varchar(50) NOT NULL,
93 `product_vendor_name` varchar(50) NOT NULL,
94 `amount` int(10) unsigned NOT NULL,
95 PRIMARY KEY (`order_id`,`order_customer_id`,`product_title`,`product_vendor_name`),
96 KEY `fk_order_product_product_title_vendor_name` (`product_title`,`product_vendor_name`),
97 CONSTRAINT `fk_order_product_order_id_customer_id` FOREIGN KEY (`order_id`, `order_customer_id`) REFERENCES `order` (`id`, `customer_id`) ON DELETE CASCADE ON UPDATE CASCADE,
98 CONSTRAINT `fk_order_product_product_title_vendor_name` FOREIGN KEY (`product_title`, `product_vendor_name`) REFERENCES `product` (`title`, `vendor_name`) ON DELETE CASCADE ON UPDATE CASCADE
99) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
100/*!40101 SET character_set_client = @saved_cs_client */;
101
102--
103-- Table structure for table `product`
104--
105
106DROP TABLE IF EXISTS `product`;
107/*!40101 SET @saved_cs_client = @@character_set_client */;
108/*!40101 SET character_set_client = utf8 */;
109CREATE TABLE `product` (
110 `title` varchar(50) NOT NULL,
111 `vendor_name` varchar(50) NOT NULL,
112 `price` decimal(10,2) unsigned NOT NULL,
113 PRIMARY KEY (`title`,`vendor_name`),
114 KEY `fk_product_vendor_name` (`vendor_name`),
115 CONSTRAINT `fk_product_vendor_name` FOREIGN KEY (`vendor_name`) REFERENCES `vendor` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
116) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
117/*!40101 SET character_set_client = @saved_cs_client */;
118
119--
120-- Table structure for table `vendor`
121--
122
123DROP TABLE IF EXISTS `vendor`;
124/*!40101 SET @saved_cs_client = @@character_set_client */;
125/*!40101 SET character_set_client = utf8 */;
126CREATE TABLE `vendor` (
127 `name` varchar(50) NOT NULL,
128 PRIMARY KEY (`name`)
129) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
130/*!40101 SET character_set_client = @saved_cs_client */;
131
132--
133-- Dumping events for database 'dotnet-shop'
134--
135
136--
137-- Dumping routines for database 'dotnet-shop'
138--
139/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
140
141/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
142/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
143/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
144/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
145/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
146/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
147/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
148
149-- Dump completed on 2020-06-14 20:08:56