├── LICENSE ├── README.md ├── shop.mwb ├── shop.sql ├── tutorials24x7-mysql-online-shopping-cart-database-design.png └── tutorials24x7-mysql-online-shopping-cart-database-design.svg /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Tutorisl24x7 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shopping Cart Database 2 | The Shopping Cart Database in MySQL as the starting point to develop the online shopping cart websites and applications. 3 | 4 | ## Details 5 | The complete details to design the database for the online Shopping Cart is available at [Guide To Design Database For Shopping Cart In MySQL](https://mysql.tutorials24x7.com/blog/guide-to-design-database-for-shopping-cart-in-mysql). 6 | 7 | ## Database Schema 8 | The visual database design of the Shopping Cart Database is shown below. 9 | 10 | ![Shopping Cart Database](https://github.com/tutorials24x7/shopping-cart-database-mysql/blob/master/tutorials24x7-mysql-online-shopping-cart-database-design.png "Shopping Cart Database") 11 | -------------------------------------------------------------------------------- /shop.mwb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutorials24x7/shopping-cart-database-mysql/cc2ced28ee9617857c58531aad87b337ffdc7b4a/shop.mwb -------------------------------------------------------------------------------- /shop.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 8.0.14, for Win64 (x86_64) 2 | -- 3 | -- Host: 127.0.0.1 Database: shop 4 | -- ------------------------------------------------------ 5 | -- Server version 8.0.14 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 | 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 `cart` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `cart`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | SET character_set_client = utf8mb4 ; 25 | CREATE TABLE `cart` ( 26 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 27 | `userId` bigint(20) DEFAULT NULL, 28 | `sessionId` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 29 | `token` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 30 | `status` smallint(6) NOT NULL DEFAULT '0', 31 | `firstName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 32 | `middleName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 33 | `lastName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 34 | `mobile` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 35 | `email` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 36 | `line1` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 37 | `line2` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 38 | `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 39 | `province` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 40 | `country` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 41 | `createdAt` datetime NOT NULL, 42 | `updatedAt` datetime DEFAULT NULL, 43 | `content` text COLLATE utf8mb4_unicode_ci, 44 | PRIMARY KEY (`id`), 45 | KEY `idx_cart_user` (`userId`), 46 | CONSTRAINT `fk_cart_user` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) 47 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 48 | /*!40101 SET character_set_client = @saved_cs_client */; 49 | 50 | -- 51 | -- Dumping data for table `cart` 52 | -- 53 | 54 | LOCK TABLES `cart` WRITE; 55 | /*!40000 ALTER TABLE `cart` DISABLE KEYS */; 56 | /*!40000 ALTER TABLE `cart` ENABLE KEYS */; 57 | UNLOCK TABLES; 58 | 59 | -- 60 | -- Table structure for table `cart_item` 61 | -- 62 | 63 | DROP TABLE IF EXISTS `cart_item`; 64 | /*!40101 SET @saved_cs_client = @@character_set_client */; 65 | SET character_set_client = utf8mb4 ; 66 | CREATE TABLE `cart_item` ( 67 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 68 | `productId` bigint(20) NOT NULL, 69 | `cartId` bigint(20) NOT NULL, 70 | `sku` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 71 | `price` float NOT NULL DEFAULT '0', 72 | `discount` float NOT NULL DEFAULT '0', 73 | `quantity` smallint(6) NOT NULL DEFAULT '0', 74 | `active` tinyint(1) NOT NULL DEFAULT '0', 75 | `createdAt` datetime NOT NULL, 76 | `updatedAt` datetime DEFAULT NULL, 77 | `content` text COLLATE utf8mb4_unicode_ci, 78 | PRIMARY KEY (`id`), 79 | KEY `idx_cart_item_product` (`productId`), 80 | KEY `idx_cart_item_cart` (`cartId`), 81 | CONSTRAINT `fk_cart_item_cart` FOREIGN KEY (`cartId`) REFERENCES `cart` (`id`), 82 | CONSTRAINT `fk_cart_item_product` FOREIGN KEY (`productId`) REFERENCES `product` (`id`) 83 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 84 | /*!40101 SET character_set_client = @saved_cs_client */; 85 | 86 | -- 87 | -- Dumping data for table `cart_item` 88 | -- 89 | 90 | LOCK TABLES `cart_item` WRITE; 91 | /*!40000 ALTER TABLE `cart_item` DISABLE KEYS */; 92 | /*!40000 ALTER TABLE `cart_item` ENABLE KEYS */; 93 | UNLOCK TABLES; 94 | 95 | -- 96 | -- Table structure for table `category` 97 | -- 98 | 99 | DROP TABLE IF EXISTS `category`; 100 | /*!40101 SET @saved_cs_client = @@character_set_client */; 101 | SET character_set_client = utf8mb4 ; 102 | CREATE TABLE `category` ( 103 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 104 | `parentId` bigint(20) DEFAULT NULL, 105 | `title` varchar(75) COLLATE utf8mb4_unicode_ci NOT NULL, 106 | `metaTitle` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 107 | `slug` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 108 | `content` text COLLATE utf8mb4_unicode_ci, 109 | PRIMARY KEY (`id`), 110 | KEY `idx_category_parent` (`parentId`), 111 | CONSTRAINT `fk_category_parent` FOREIGN KEY (`parentId`) REFERENCES `category` (`id`) 112 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 113 | /*!40101 SET character_set_client = @saved_cs_client */; 114 | 115 | -- 116 | -- Dumping data for table `category` 117 | -- 118 | 119 | LOCK TABLES `category` WRITE; 120 | /*!40000 ALTER TABLE `category` DISABLE KEYS */; 121 | /*!40000 ALTER TABLE `category` ENABLE KEYS */; 122 | UNLOCK TABLES; 123 | 124 | -- 125 | -- Table structure for table `order` 126 | -- 127 | 128 | DROP TABLE IF EXISTS `order`; 129 | /*!40101 SET @saved_cs_client = @@character_set_client */; 130 | SET character_set_client = utf8mb4 ; 131 | CREATE TABLE `order` ( 132 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 133 | `userId` bigint(20) DEFAULT NULL, 134 | `sessionId` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 135 | `token` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 136 | `status` smallint(6) NOT NULL DEFAULT '0', 137 | `subTotal` float NOT NULL DEFAULT '0', 138 | `itemDiscount` float NOT NULL DEFAULT '0', 139 | `tax` float NOT NULL DEFAULT '0', 140 | `shipping` float NOT NULL DEFAULT '0', 141 | `total` float NOT NULL DEFAULT '0', 142 | `promo` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 143 | `discount` float NOT NULL DEFAULT '0', 144 | `grandTotal` float NOT NULL DEFAULT '0', 145 | `firstName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 146 | `middleName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 147 | `lastName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 148 | `mobile` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 149 | `email` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 150 | `line1` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 151 | `line2` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 152 | `city` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 153 | `province` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 154 | `country` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 155 | `createdAt` datetime NOT NULL, 156 | `updatedAt` datetime DEFAULT NULL, 157 | `content` text COLLATE utf8mb4_unicode_ci, 158 | PRIMARY KEY (`id`), 159 | KEY `idx_order_user` (`userId`), 160 | CONSTRAINT `fk_order_user` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) 161 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 162 | /*!40101 SET character_set_client = @saved_cs_client */; 163 | 164 | -- 165 | -- Dumping data for table `order` 166 | -- 167 | 168 | LOCK TABLES `order` WRITE; 169 | /*!40000 ALTER TABLE `order` DISABLE KEYS */; 170 | /*!40000 ALTER TABLE `order` ENABLE KEYS */; 171 | UNLOCK TABLES; 172 | 173 | -- 174 | -- Table structure for table `order_item` 175 | -- 176 | 177 | DROP TABLE IF EXISTS `order_item`; 178 | /*!40101 SET @saved_cs_client = @@character_set_client */; 179 | SET character_set_client = utf8mb4 ; 180 | CREATE TABLE `order_item` ( 181 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 182 | `productId` bigint(20) NOT NULL, 183 | `orderId` bigint(20) NOT NULL, 184 | `sku` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 185 | `price` float NOT NULL DEFAULT '0', 186 | `discount` float NOT NULL DEFAULT '0', 187 | `quantity` smallint(6) NOT NULL DEFAULT '0', 188 | `createdAt` datetime NOT NULL, 189 | `updatedAt` datetime DEFAULT NULL, 190 | `content` text COLLATE utf8mb4_unicode_ci, 191 | PRIMARY KEY (`id`), 192 | KEY `idx_order_item_product` (`productId`), 193 | KEY `idx_order_item_order` (`orderId`), 194 | CONSTRAINT `fk_order_item_order` FOREIGN KEY (`orderId`) REFERENCES `order` (`id`), 195 | CONSTRAINT `fk_order_item_product` FOREIGN KEY (`productId`) REFERENCES `product` (`id`) 196 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 197 | /*!40101 SET character_set_client = @saved_cs_client */; 198 | 199 | -- 200 | -- Dumping data for table `order_item` 201 | -- 202 | 203 | LOCK TABLES `order_item` WRITE; 204 | /*!40000 ALTER TABLE `order_item` DISABLE KEYS */; 205 | /*!40000 ALTER TABLE `order_item` ENABLE KEYS */; 206 | UNLOCK TABLES; 207 | 208 | -- 209 | -- Table structure for table `product` 210 | -- 211 | 212 | DROP TABLE IF EXISTS `product`; 213 | /*!40101 SET @saved_cs_client = @@character_set_client */; 214 | SET character_set_client = utf8mb4 ; 215 | CREATE TABLE `product` ( 216 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 217 | `userId` bigint(20) NOT NULL, 218 | `title` varchar(75) COLLATE utf8mb4_unicode_ci NOT NULL, 219 | `metaTitle` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 220 | `slug` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 221 | `summary` tinytext COLLATE utf8mb4_unicode_ci, 222 | `type` smallint(6) NOT NULL DEFAULT '0', 223 | `sku` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 224 | `price` float NOT NULL DEFAULT '0', 225 | `discount` float NOT NULL DEFAULT '0', 226 | `quantity` smallint(6) NOT NULL DEFAULT '0', 227 | `shop` tinyint(1) NOT NULL DEFAULT '0', 228 | `createdAt` datetime NOT NULL, 229 | `updatedAt` datetime DEFAULT NULL, 230 | `publishedAt` datetime DEFAULT NULL, 231 | `startsAt` datetime DEFAULT NULL, 232 | `endsAt` datetime DEFAULT NULL, 233 | `content` text COLLATE utf8mb4_unicode_ci, 234 | PRIMARY KEY (`id`), 235 | UNIQUE KEY `uq_slug` (`slug`), 236 | KEY `idx_product_user` (`userId`), 237 | CONSTRAINT `fk_product_user` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) 238 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 239 | /*!40101 SET character_set_client = @saved_cs_client */; 240 | 241 | -- 242 | -- Dumping data for table `product` 243 | -- 244 | 245 | LOCK TABLES `product` WRITE; 246 | /*!40000 ALTER TABLE `product` DISABLE KEYS */; 247 | /*!40000 ALTER TABLE `product` ENABLE KEYS */; 248 | UNLOCK TABLES; 249 | 250 | -- 251 | -- Table structure for table `product_category` 252 | -- 253 | 254 | DROP TABLE IF EXISTS `product_category`; 255 | /*!40101 SET @saved_cs_client = @@character_set_client */; 256 | SET character_set_client = utf8mb4 ; 257 | CREATE TABLE `product_category` ( 258 | `productId` bigint(20) NOT NULL, 259 | `categoryId` bigint(20) NOT NULL, 260 | PRIMARY KEY (`productId`,`categoryId`), 261 | KEY `idx_pc_category` (`categoryId`), 262 | KEY `idx_pc_product` (`productId`), 263 | CONSTRAINT `fk_pc_category` FOREIGN KEY (`categoryId`) REFERENCES `category` (`id`), 264 | CONSTRAINT `fk_pc_product` FOREIGN KEY (`productId`) REFERENCES `product` (`id`) 265 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 266 | /*!40101 SET character_set_client = @saved_cs_client */; 267 | 268 | -- 269 | -- Dumping data for table `product_category` 270 | -- 271 | 272 | LOCK TABLES `product_category` WRITE; 273 | /*!40000 ALTER TABLE `product_category` DISABLE KEYS */; 274 | /*!40000 ALTER TABLE `product_category` ENABLE KEYS */; 275 | UNLOCK TABLES; 276 | 277 | -- 278 | -- Table structure for table `product_meta` 279 | -- 280 | 281 | DROP TABLE IF EXISTS `product_meta`; 282 | /*!40101 SET @saved_cs_client = @@character_set_client */; 283 | SET character_set_client = utf8mb4 ; 284 | CREATE TABLE `product_meta` ( 285 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 286 | `productId` bigint(20) NOT NULL, 287 | `key` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, 288 | `content` text COLLATE utf8mb4_unicode_ci, 289 | PRIMARY KEY (`id`), 290 | UNIQUE KEY `uq_product_meta` (`productId`,`key`), 291 | KEY `idx_meta_product` (`productId`), 292 | CONSTRAINT `fk_meta_product` FOREIGN KEY (`productId`) REFERENCES `product` (`id`) 293 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 294 | /*!40101 SET character_set_client = @saved_cs_client */; 295 | 296 | -- 297 | -- Dumping data for table `product_meta` 298 | -- 299 | 300 | LOCK TABLES `product_meta` WRITE; 301 | /*!40000 ALTER TABLE `product_meta` DISABLE KEYS */; 302 | /*!40000 ALTER TABLE `product_meta` ENABLE KEYS */; 303 | UNLOCK TABLES; 304 | 305 | -- 306 | -- Table structure for table `product_review` 307 | -- 308 | 309 | DROP TABLE IF EXISTS `product_review`; 310 | /*!40101 SET @saved_cs_client = @@character_set_client */; 311 | SET character_set_client = utf8mb4 ; 312 | CREATE TABLE `product_review` ( 313 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 314 | `productId` bigint(20) NOT NULL, 315 | `parentId` bigint(20) DEFAULT NULL, 316 | `title` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 317 | `rating` smallint(6) NOT NULL DEFAULT '0', 318 | `published` tinyint(1) NOT NULL DEFAULT '0', 319 | `createdAt` datetime NOT NULL, 320 | `publishedAt` datetime DEFAULT NULL, 321 | `content` text COLLATE utf8mb4_unicode_ci, 322 | PRIMARY KEY (`id`), 323 | KEY `idx_review_product` (`productId`), 324 | KEY `idx_review_parent` (`parentId`), 325 | CONSTRAINT `fk_review_parent` FOREIGN KEY (`parentId`) REFERENCES `product_review` (`id`), 326 | CONSTRAINT `fk_review_product` FOREIGN KEY (`productId`) REFERENCES `product` (`id`) 327 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 328 | /*!40101 SET character_set_client = @saved_cs_client */; 329 | 330 | -- 331 | -- Dumping data for table `product_review` 332 | -- 333 | 334 | LOCK TABLES `product_review` WRITE; 335 | /*!40000 ALTER TABLE `product_review` DISABLE KEYS */; 336 | /*!40000 ALTER TABLE `product_review` ENABLE KEYS */; 337 | UNLOCK TABLES; 338 | 339 | -- 340 | -- Table structure for table `product_tag` 341 | -- 342 | 343 | DROP TABLE IF EXISTS `product_tag`; 344 | /*!40101 SET @saved_cs_client = @@character_set_client */; 345 | SET character_set_client = utf8mb4 ; 346 | CREATE TABLE `product_tag` ( 347 | `productId` bigint(20) NOT NULL, 348 | `tagId` bigint(20) NOT NULL, 349 | PRIMARY KEY (`productId`,`tagId`), 350 | KEY `idx_pt_tag` (`tagId`), 351 | KEY `idx_pt_product` (`productId`), 352 | CONSTRAINT `fk_pt_product` FOREIGN KEY (`productId`) REFERENCES `product` (`id`), 353 | CONSTRAINT `fk_pt_tag` FOREIGN KEY (`tagId`) REFERENCES `tag` (`id`) 354 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 355 | /*!40101 SET character_set_client = @saved_cs_client */; 356 | 357 | -- 358 | -- Dumping data for table `product_tag` 359 | -- 360 | 361 | LOCK TABLES `product_tag` WRITE; 362 | /*!40000 ALTER TABLE `product_tag` DISABLE KEYS */; 363 | /*!40000 ALTER TABLE `product_tag` ENABLE KEYS */; 364 | UNLOCK TABLES; 365 | 366 | -- 367 | -- Table structure for table `tag` 368 | -- 369 | 370 | DROP TABLE IF EXISTS `tag`; 371 | /*!40101 SET @saved_cs_client = @@character_set_client */; 372 | SET character_set_client = utf8mb4 ; 373 | CREATE TABLE `tag` ( 374 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 375 | `title` varchar(75) COLLATE utf8mb4_unicode_ci NOT NULL, 376 | `metaTitle` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 377 | `slug` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 378 | `content` text COLLATE utf8mb4_unicode_ci, 379 | PRIMARY KEY (`id`) 380 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 381 | /*!40101 SET character_set_client = @saved_cs_client */; 382 | 383 | -- 384 | -- Dumping data for table `tag` 385 | -- 386 | 387 | LOCK TABLES `tag` WRITE; 388 | /*!40000 ALTER TABLE `tag` DISABLE KEYS */; 389 | /*!40000 ALTER TABLE `tag` ENABLE KEYS */; 390 | UNLOCK TABLES; 391 | 392 | -- 393 | -- Table structure for table `transaction` 394 | -- 395 | 396 | DROP TABLE IF EXISTS `transaction`; 397 | /*!40101 SET @saved_cs_client = @@character_set_client */; 398 | SET character_set_client = utf8mb4 ; 399 | CREATE TABLE `transaction` ( 400 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 401 | `userId` bigint(20) NOT NULL, 402 | `orderId` bigint(20) NOT NULL, 403 | `code` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 404 | `type` smallint(6) NOT NULL DEFAULT '0', 405 | `mode` smallint(6) NOT NULL DEFAULT '0', 406 | `status` smallint(6) NOT NULL DEFAULT '0', 407 | `createdAt` datetime NOT NULL, 408 | `updatedAt` datetime DEFAULT NULL, 409 | `content` text COLLATE utf8mb4_unicode_ci, 410 | PRIMARY KEY (`id`), 411 | KEY `idx_transaction_user` (`userId`), 412 | KEY `idx_transaction_order` (`orderId`), 413 | CONSTRAINT `fk_transaction_order` FOREIGN KEY (`orderId`) REFERENCES `order` (`id`), 414 | CONSTRAINT `fk_transaction_user` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) 415 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 416 | /*!40101 SET character_set_client = @saved_cs_client */; 417 | 418 | -- 419 | -- Dumping data for table `transaction` 420 | -- 421 | 422 | LOCK TABLES `transaction` WRITE; 423 | /*!40000 ALTER TABLE `transaction` DISABLE KEYS */; 424 | /*!40000 ALTER TABLE `transaction` ENABLE KEYS */; 425 | UNLOCK TABLES; 426 | 427 | -- 428 | -- Table structure for table `user` 429 | -- 430 | 431 | DROP TABLE IF EXISTS `user`; 432 | /*!40101 SET @saved_cs_client = @@character_set_client */; 433 | SET character_set_client = utf8mb4 ; 434 | CREATE TABLE `user` ( 435 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 436 | `firstName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 437 | `middleName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 438 | `lastName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 439 | `mobile` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 440 | `email` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 441 | `passwordHash` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL, 442 | `admin` tinyint(1) NOT NULL DEFAULT '0', 443 | `vendor` tinyint(1) NOT NULL DEFAULT '0', 444 | `registeredAt` datetime NOT NULL, 445 | `lastLogin` datetime DEFAULT NULL, 446 | `intro` tinytext COLLATE utf8mb4_unicode_ci, 447 | `profile` text COLLATE utf8mb4_unicode_ci, 448 | PRIMARY KEY (`id`), 449 | UNIQUE KEY `uq_mobile` (`mobile`), 450 | UNIQUE KEY `uq_email` (`email`) 451 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 452 | /*!40101 SET character_set_client = @saved_cs_client */; 453 | 454 | -- 455 | -- Dumping data for table `user` 456 | -- 457 | 458 | LOCK TABLES `user` WRITE; 459 | /*!40000 ALTER TABLE `user` DISABLE KEYS */; 460 | /*!40000 ALTER TABLE `user` ENABLE KEYS */; 461 | UNLOCK TABLES; 462 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 463 | 464 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 465 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 466 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 467 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 468 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 469 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 470 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 471 | 472 | -- Dump completed on 2020-04-27 6:46:35 473 | -------------------------------------------------------------------------------- /tutorials24x7-mysql-online-shopping-cart-database-design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutorials24x7/shopping-cart-database-mysql/cc2ced28ee9617857c58531aad87b337ffdc7b4a/tutorials24x7-mysql-online-shopping-cart-database-design.png --------------------------------------------------------------------------------