Files
2025-06-23 20:53:26 +08:00

283 lines
8.8 KiB
SQL

-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 15, 2025 at 03:32 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.0.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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: `unimarket`
--
-- --------------------------------------------------------
--
-- Table structure for table `cart`
--
CREATE TABLE `cart` (
`cart_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `cart`
--
INSERT INTO `cart` (`cart_id`, `user_id`, `created_at`) VALUES
(1, 1, '2025-05-09 10:11:49'),
(2, 3, '2025-05-10 04:31:57'),
(3, 4, '2025-06-14 16:11:43'),
(4, 5, '2025-06-15 05:11:09');
-- --------------------------------------------------------
--
-- Table structure for table `cart_items`
--
CREATE TABLE `cart_items` (
`cart_item_id` int(11) NOT NULL,
`cart_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL DEFAULT 1,
`added_at` timestamp NOT NULL DEFAULT current_timestamp(),
`size` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`order_id` int(11) NOT NULL,
`customer_id` int(11) NOT NULL,
`status` enum('pending','processing','ready','completed','cancelled') NOT NULL DEFAULT 'pending',
`order_date` datetime NOT NULL DEFAULT current_timestamp(),
`notification_read` tinyint(1) NOT NULL DEFAULT 0,
`total_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
`pickup_schedule` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `order_items`
--
CREATE TABLE `order_items` (
`item_id` int(11) NOT NULL,
`order_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
`price` decimal(10,2) NOT NULL,
`size` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`product_id` int(11) NOT NULL,
`owner_id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`description` text DEFAULT NULL,
`price` decimal(10,2) NOT NULL,
`category` varchar(50) DEFAULT NULL,
`stock_quantity` int(11) NOT NULL DEFAULT 0,
`image_path` varchar(255) DEFAULT NULL,
`size_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`size_data`)),
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`Sub_Cat` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`product_id`, `owner_id`, `name`, `description`, `price`, `category`, `stock_quantity`, `image_path`, `size_data`, `created_at`, `updated_at`, `Sub_Cat`) VALUES
(4, 5, 'University Uniform(Male)', 'Official Uniform of PLSP', 1200.00, 'clothes', 15, '684eba8744c23.png', '{\"S\":5,\"M\":5,\"L\":5}', '2025-06-15 12:14:31', '2025-06-15 12:20:23', 'university_uniform'),
(5, 5, 'University ID Lace', 'Official ID Lace of PLSP', 100.00, 'others', 20, '684ebab524fdf.png', NULL, '2025-06-15 12:21:09', '2025-06-15 12:21:09', 'university_lace'),
(6, 2, 'University Uniform(Female)', 'Brand new(wrong size)', 1000.00, 'clothes', 1, '684ebdf851717.png', '{\"S\":1}', '2025-06-15 12:35:04', '2025-06-15 12:35:04', 'university_uniform');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`user_id` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(100) NOT NULL,
`role` enum('customer','owner','admin') DEFAULT NULL,
`first_name` varchar(50) NOT NULL,
`last_name` varchar(50) NOT NULL,
`phone` varchar(20) DEFAULT NULL,
`university_id` varchar(20) DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`user_id`, `username`, `password`, `email`, `role`, `first_name`, `last_name`, `phone`, `university_id`, `created_at`) VALUES
(1, 'crischarles', '$2y$10$8ANjJj59KNpM1ToMniyamuWskxnnAj45nXZJSjhL8kKmsnHZDWXue', 'crischarlesgarcia345@gmail.com', 'customer', 'Cris Charles', 'Garcia', '09914970689', '23-10824', '2025-05-09 10:11:49'),
(2, 'crischarlesvendor', '$2y$10$f0ObqNbNpxNI2D1.xy/nguRjFlrnQyjS9pTzzLORL3TSmC2h4rXs.', 'crischarlesgarcia3456@gmail.com', 'owner', 'Cris Charles', 'Garcia', '09914970689', '23-10824', '2025-05-09 11:50:03'),
(3, 'mizzy', '$2y$10$8QvFr6JJfS5KK6aGLuma0uMWQnzfOSB0Tw.6ISRpZbZb3yrMB1JUG', 'joyjoy@gmail.com', 'customer', 'Mizzy Joy', 'Babiano', '0912345670', '23-091234', '2025-05-10 04:31:57'),
(4, 'cheskaley', '$2y$10$i3MpnKPriVJ681dErx1tC.rZmUwCwt26XED5IK2kvK50j6mPce14u', 'francheskasuliguin@gmail.com', 'customer', 'francheska lei', 'joyosa', '098474738', '23-0123', '2025-06-14 16:11:43'),
(5, 'admin', '$2y$10$BAx4QpbOmxqlAMQGpCNnguMPIVVG3l14qJVvUM8.oE22b/gFxQIIK', 'admin@gmail.com', 'admin', 'ADMIN', '123', '09123123123123', '23-12345', '2025-06-15 05:11:09');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `cart`
--
ALTER TABLE `cart`
ADD PRIMARY KEY (`cart_id`),
ADD UNIQUE KEY `user_id` (`user_id`);
--
-- Indexes for table `cart_items`
--
ALTER TABLE `cart_items`
ADD PRIMARY KEY (`cart_item_id`),
ADD UNIQUE KEY `cart_id` (`cart_id`,`product_id`),
ADD KEY `product_id` (`product_id`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`order_id`),
ADD KEY `customer_id` (`customer_id`);
--
-- Indexes for table `order_items`
--
ALTER TABLE `order_items`
ADD PRIMARY KEY (`item_id`),
ADD KEY `order_id` (`order_id`),
ADD KEY `product_id` (`product_id`);
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`product_id`),
ADD KEY `owner_id` (`owner_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`user_id`),
ADD UNIQUE KEY `username` (`username`),
ADD UNIQUE KEY `email` (`email`),
ADD KEY `role` (`role`),
ADD KEY `role_2` (`role`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `cart`
--
ALTER TABLE `cart`
MODIFY `cart_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `cart_items`
--
ALTER TABLE `cart_items`
MODIFY `cart_item_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=46;
--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
MODIFY `order_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `order_items`
--
ALTER TABLE `order_items`
MODIFY `item_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `product_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `cart`
--
ALTER TABLE `cart`
ADD CONSTRAINT `cart_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`);
--
-- Constraints for table `cart_items`
--
ALTER TABLE `cart_items`
ADD CONSTRAINT `cart_items_ibfk_1` FOREIGN KEY (`cart_id`) REFERENCES `cart` (`cart_id`),
ADD CONSTRAINT `cart_items_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`product_id`);
--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
ADD CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE;
--
-- Constraints for table `order_items`
--
ALTER TABLE `order_items`
ADD CONSTRAINT `order_items_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`order_id`) ON DELETE CASCADE,
ADD CONSTRAINT `order_items_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`product_id`) ON DELETE CASCADE;
--
-- Constraints for table `products`
--
ALTER TABLE `products`
ADD CONSTRAINT `products_ibfk_1` FOREIGN KEY (`owner_id`) REFERENCES `users` (`user_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 */;