· 6 years ago · Dec 15, 2019, 09:38 AM
1-- MySQL dump 10.13 Distrib 5.7.12, for Win64 (x86_64)
2--
3-- Host: localhost Database: ddl
4-- ------------------------------------------------------
5-- Server version 5.7.14-log
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/*!40101 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 `cities`
20--
21
22DROP TABLE IF EXISTS `cities`;
23/*!40101 SET @saved_cs_client = @@character_set_client */;
24/*!40101 SET character_set_client = utf8 */;
25CREATE TABLE `cities` (
26 `id` int(11) NOT NULL,
27 `name` varchar(30) NOT NULL,
28 `country_name` varchar(80) NOT NULL,
29 PRIMARY KEY (`id`)
30) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31/*!40101 SET character_set_client = @saved_cs_client */;
32
33--
34-- Dumping data for table `cities`
35--
36
37LOCK TABLES `cities` WRITE;
38/*!40000 ALTER TABLE `cities` DISABLE KEYS */;
39/*!40000 ALTER TABLE `cities` ENABLE KEYS */;
40UNLOCK TABLES;
41
42--
43-- Table structure for table `info_plants`
44--
45
46DROP TABLE IF EXISTS `info_plants`;
47/*!40101 SET @saved_cs_client = @@character_set_client */;
48/*!40101 SET character_set_client = utf8 */;
49CREATE TABLE `info_plants` (
50 `id` int(11) NOT NULL,
51 `plant_id` int(11) NOT NULL,
52 `family` varchar(50) NOT NULL,
53 `genus` varchar(40) NOT NULL,
54 `purpose` varchar(60) DEFAULT NULL,
55 PRIMARY KEY (`id`),
56 KEY `plant_id_idx` (`plant_id`),
57 KEY `plants_id_idx` (`plant_id`),
58 CONSTRAINT `plants_id` FOREIGN KEY (`plant_id`) REFERENCES `plants` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
59) ENGINE=InnoDB DEFAULT CHARSET=utf8;
60/*!40101 SET character_set_client = @saved_cs_client */;
61
62--
63-- Dumping data for table `info_plants`
64--
65
66LOCK TABLES `info_plants` WRITE;
67/*!40000 ALTER TABLE `info_plants` DISABLE KEYS */;
68/*!40000 ALTER TABLE `info_plants` ENABLE KEYS */;
69UNLOCK TABLES;
70
71--
72-- Table structure for table `orders`
73--
74
75DROP TABLE IF EXISTS `orders`;
76/*!40101 SET @saved_cs_client = @@character_set_client */;
77/*!40101 SET character_set_client = utf8 */;
78CREATE TABLE `orders` (
79 `id` int(11) NOT NULL,
80 `user_id` int(11) NOT NULL,
81 `order_date` date NOT NULL,
82 `is_completed` tinyint(1) DEFAULT '0',
83 PRIMARY KEY (`id`),
84 KEY `user_id_idx` (`user_id`),
85 CONSTRAINT `user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
86) ENGINE=InnoDB DEFAULT CHARSET=utf8;
87/*!40101 SET character_set_client = @saved_cs_client */;
88
89--
90-- Dumping data for table `orders`
91--
92
93LOCK TABLES `orders` WRITE;
94/*!40000 ALTER TABLE `orders` DISABLE KEYS */;
95/*!40000 ALTER TABLE `orders` ENABLE KEYS */;
96UNLOCK TABLES;
97
98--
99-- Table structure for table `plants`
100--
101
102DROP TABLE IF EXISTS `plants`;
103/*!40101 SET @saved_cs_client = @@character_set_client */;
104/*!40101 SET character_set_client = utf8 */;
105CREATE TABLE `plants` (
106 `id` int(11) NOT NULL,
107 `name` varchar(50) NOT NULL,
108 `price` decimal(15,2) NOT NULL,
109 `color` varchar(50) DEFAULT NULL,
110 `quantity` int(11) DEFAULT '0',
111 PRIMARY KEY (`id`)
112) ENGINE=InnoDB DEFAULT CHARSET=utf8;
113/*!40101 SET character_set_client = @saved_cs_client */;
114
115--
116-- Dumping data for table `plants`
117--
118
119LOCK TABLES `plants` WRITE;
120/*!40000 ALTER TABLE `plants` DISABLE KEYS */;
121/*!40000 ALTER TABLE `plants` ENABLE KEYS */;
122UNLOCK TABLES;
123
124--
125-- Table structure for table `plants_orders`
126--
127
128DROP TABLE IF EXISTS `plants_orders`;
129/*!40101 SET @saved_cs_client = @@character_set_client */;
130/*!40101 SET character_set_client = utf8 */;
131CREATE TABLE `plants_orders` (
132 `plant_id` int(11) NOT NULL,
133 `order_id` int(11) NOT NULL,
134 PRIMARY KEY (`plant_id`,`order_id`),
135 KEY `plant_id_idx` (`plant_id`),
136 KEY `order_id_idx` (`order_id`),
137 CONSTRAINT `order_id` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
138 CONSTRAINT `plant_id` FOREIGN KEY (`plant_id`) REFERENCES `plants` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
139) ENGINE=InnoDB DEFAULT CHARSET=utf8;
140/*!40101 SET character_set_client = @saved_cs_client */;
141
142--
143-- Dumping data for table `plants_orders`
144--
145
146LOCK TABLES `plants_orders` WRITE;
147/*!40000 ALTER TABLE `plants_orders` DISABLE KEYS */;
148/*!40000 ALTER TABLE `plants_orders` ENABLE KEYS */;
149UNLOCK TABLES;
150
151--
152-- Table structure for table `users`
153--
154
155DROP TABLE IF EXISTS `users`;
156/*!40101 SET @saved_cs_client = @@character_set_client */;
157/*!40101 SET character_set_client = utf8 */;
158CREATE TABLE `users` (
159 `id` int(11) NOT NULL,
160 `username` varchar(50) NOT NULL,
161 `password` varchar(255) NOT NULL,
162 `first_name` varchar(50) NOT NULL,
163 `last_name` varchar(50) DEFAULT NULL,
164 `age` int(11) NOT NULL,
165 CHECK(age >= 18),
166 `money` decimal(15,2) NOT NULL,
167 `city_id` int(11) NOT NULL,
168 `register_date` date NOT NULL,
169 PRIMARY KEY (`id`),
170 UNIQUE KEY `username_UNIQUE` (`username`),
171 KEY `id_idx` (`city_id`),
172 CONSTRAINT `city_id` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
173) ENGINE=InnoDB DEFAULT CHARSET=utf8;
174/*!40101 SET character_set_client = @saved_cs_client */;
175
176--
177-- Dumping data for table `users`
178--
179
180LOCK TABLES `users` WRITE;
181/*!40000 ALTER TABLE `users` DISABLE KEYS */;
182/*!40000 ALTER TABLE `users` ENABLE KEYS */;
183UNLOCK TABLES;
184/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
185
186/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
187/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
188/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
189/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
190/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
191/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
192/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
193
194-- Dump completed on 2019-12-15 10:59:59