text: -- phpMyAdmin SQL Dump
  -- version 4.9.0.1
  -- https://www.phpmyadmin.net/
  --
  -- Host: 127.0.0.1
  -- Generation Time: Oct 17, 2019 at 09:43 AM
  -- Server version: 10.4.6-MariaDB
  -- PHP Version: 7.3.8
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  SET AUTOCOMMIT = 0;
  START TRANSACTION;
  SET time_zone = "+00:00";
  
  
  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  /*!40101 SET NAMES utf8mb4 */;
  
  --
  -- Database: `lezada`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `account`
  --
  
  CREATE TABLE `account` (
    `id` int(11) NOT NULL,
    `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
    `email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
    `phone` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
    `password` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
    `address` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
    `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `status` tinyint(1) DEFAULT 0 COMMENT '0 là khách hàng, 1 là quản trị, 2 bị khóa'
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `banner`
  --
  
  CREATE TABLE `banner` (
    `id` int(11) NOT NULL,
    `name` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
    `image` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
    `content` text COLLATE utf8_unicode_ci DEFAULT NULL,
    `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `ordering` tinyint(4) DEFAULT 0 COMMENT 'Sắp xếp vị trí',
    `status` tinyint(1) DEFAULT 1 COMMENT '0 là ẩn, 1 là hiển thị'
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `blog`
  --
  
  CREATE TABLE `blog` (
    `id` int(11) NOT NULL,
    `name` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
    `slug` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
    `image` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
    `content` text COLLATE utf8_unicode_ci DEFAULT NULL,
    `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `status` tinyint(1) DEFAULT 1 COMMENT '0 là ẩn, 1 là hiển thị'
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `category`
  --
  
  CREATE TABLE `category` (
    `id` int(11) NOT NULL,
    `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
    `slug` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
    `parent_id` int(11) DEFAULT 0 COMMENT '0 là danh mục cha',
    `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `status` tinyint(1) DEFAULT 1 COMMENT '0 là ẩn, 1 là hiển thị'
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `comment`
  --
  
  CREATE TABLE `comment` (
    `id` int(11) NOT NULL,
    `parent_id` int(11) DEFAULT NULL,
    `product_id` int(11) NOT NULL,
    `account_id` int(11) NOT NULL,
    `comment` text COLLATE utf8_unicode_ci NOT NULL COMMENT '0 là ẩn, 1 là hiện',
    `status` tinyint(1) DEFAULT NULL,
    `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `updated_at` timestamp NOT NULL DEFAULT current_timestamp()
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `orders`
  --
  
  CREATE TABLE `orders` (
    `id` int(11) NOT NULL,
    `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
    `email` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
    `phone` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
    `address` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
    `status` tinyint(1) DEFAULT 0 COMMENT '0 là mới, chưa duyệt, 1 là đã duyệt, 2 đã giao hàng, 3 hủy',
    `account_id` int(11) DEFAULT 0,
    `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `created_at` timestamp NOT NULL DEFAULT current_timestamp()
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `order_detail`
  --
  
  CREATE TABLE `order_detail` (
    `order_id` int(11) NOT NULL,
    `product_id` int(11) NOT NULL,
    `quantity` int(11) NOT NULL COMMENT 'Số lượng mua',
    `price` int(11) NOT NULL COMMENT 'Giá tại thời điểm đặt hàng'
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `product`
  --
  
  CREATE TABLE `product` (
    `id` int(11) NOT NULL,
    `name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
    `slug` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
    `image` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
    `price` int(10) UNSIGNED NOT NULL,
    `description` text COLLATE utf8_unicode_ci DEFAULT NULL,
    `sale_price` int(10) UNSIGNED DEFAULT 0,
    `category_id` int(11) NOT NULL,
    `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `status` tinyint(1) DEFAULT 1 COMMENT '0 là ẩn, 1 là hiển thị, 2 là is stock'
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `product_image`
  --
  
  CREATE TABLE `product_image` (
    `id` int(11) NOT NULL,
    `link` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
    `product_id` int(11) NOT NULL,
    `status` tinyint(1) DEFAULT 1 COMMENT '0 là ẩn, 1 là hiển thị, 2 là is stock'
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `wishlist`
  --
  
  CREATE TABLE `wishlist` (
    `account_id` int(11) NOT NULL,
    `product_id` int(11) NOT NULL,
    `Created_at` timestamp NOT NULL DEFAULT current_timestamp(),
    `Updated_at` timestamp NOT NULL DEFAULT current_timestamp()
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `account`
  --
  ALTER TABLE `account`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `email` (`email`);
  
  --
  -- Indexes for table `banner`
  --
  ALTER TABLE `banner`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `blog`
  --
  ALTER TABLE `blog`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `category`
  --
  ALTER TABLE `category`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `name` (`name`),
    ADD UNIQUE KEY `slug` (`slug`);
  
  --
  -- Indexes for table `comment`
  --
  ALTER TABLE `comment`
    ADD PRIMARY KEY (`id`),
    ADD KEY `FK_com_account` (`account_id`),
    ADD KEY `FK_com_product` (`product_id`);
  
  --
  -- Indexes for table `orders`
  --
  ALTER TABLE `orders`
    ADD PRIMARY KEY (`id`),
    ADD KEY `FK_order_account` (`account_id`);
  
  --
  -- Indexes for table `order_detail`
  --
  ALTER TABLE `order_detail`
    ADD PRIMARY KEY (`order_id`,`product_id`),
    ADD KEY `product_id` (`product_id`);
  
  --
  -- Indexes for table `product`
  --
  ALTER TABLE `product`
    ADD PRIMARY KEY (`id`),
    ADD KEY `category_id` (`category_id`);
  
  --
  -- Indexes for table `product_image`
  --
  ALTER TABLE `product_image`
    ADD PRIMARY KEY (`id`),
    ADD KEY `product_id` (`product_id`);
  
  --
  -- Indexes for table `wishlist`
  --
  ALTER TABLE `wishlist`
    ADD KEY `FK_wish_account` (`account_id`),
    ADD KEY `FK_wish_pro` (`product_id`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `account`
  --
  ALTER TABLE `account`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `banner`
  --
  ALTER TABLE `banner`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `blog`
  --
  ALTER TABLE `blog`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `category`
  --
  ALTER TABLE `category`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `comment`
  --
  ALTER TABLE `comment`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `orders`
  --
  ALTER TABLE `orders`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `product`
  --
  ALTER TABLE `product`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `product_image`
  --
  ALTER TABLE `product_image`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `comment`
  --
  ALTER TABLE `comment`
    ADD CONSTRAINT `FK_com_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`id`),
    ADD CONSTRAINT `FK_com_product` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`);
  
  --
  -- Constraints for table `orders`
  --
  ALTER TABLE `orders`
    ADD CONSTRAINT `FK_order_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`id`);
  
  --
  -- Constraints for table `order_detail`
  --
  ALTER TABLE `order_detail`
    ADD CONSTRAINT `order_detail_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`),
    ADD CONSTRAINT `order_detail_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`);
  
  --
  -- Constraints for table `product`
  --
  ALTER TABLE `product`
    ADD CONSTRAINT `product_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`);
  
  --
  -- Constraints for table `product_image`
  --
  ALTER TABLE `product_image`
    ADD CONSTRAINT `product_image_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`);
  
  --
  -- Constraints for table `wishlist`
  --
  ALTER TABLE `wishlist`
    ADD CONSTRAINT `FK_wish_account` FOREIGN KEY (`account_id`) REFERENCES `account` (`id`),
    ADD CONSTRAINT `FK_wish_pro` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`);
  COMMIT;
  
  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  