File manager - Edit - /home/webapp69.cm.in.th/u69319090015/Shop/schema.sql
Back
-- Database Schema for Online Clothing Ordering System -- Target Database: shop69319090015 -- 1. Table products CREATE TABLE IF NOT EXISTS `products` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `description` TEXT, `price` DECIMAL(10,2) NOT NULL, `size` VARCHAR(10) NOT NULL, -- S, M, L, XL, etc. `stock` INT NOT NULL DEFAULT 0, `image_url` VARCHAR(255) DEFAULT NULL, `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- 2. Table orders CREATE TABLE IF NOT EXISTS `orders` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `customer_name` VARCHAR(255) NOT NULL, `phone` VARCHAR(20) NOT NULL, `address` TEXT NOT NULL, `total_price` DECIMAL(10,2) NOT NULL, `payment_status` VARCHAR(50) NOT NULL DEFAULT 'pending', -- pending, paid, cancelled `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- 3. Table order_details CREATE TABLE IF NOT EXISTS `order_details` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `order_id` INT NOT NULL, `product_id` INT NOT NULL, `quantity` INT NOT NULL, FOREIGN KEY (`order_id`) REFERENCES `orders`(`id`) ON DELETE CASCADE, FOREIGN KEY (`product_id`) REFERENCES `products`(`id`) ON DELETE RESTRICT ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- 4. Table users CREATE TABLE IF NOT EXISTS `users` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `email` VARCHAR(255) NOT NULL UNIQUE, `password` VARCHAR(255) NOT NULL, `phone` VARCHAR(20) DEFAULT NULL, `address` TEXT DEFAULT NULL, `role` VARCHAR(20) DEFAULT 'customer', -- 'customer' or 'seller' `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Seed Sample Data for Products INSERT INTO `products` (`name`, `description`, `price`, `size`, `stock`, `image_url`) VALUES ('Minimalist Oversized Tee', '100% premium organic cotton. Features a relaxed silhouette, dropped shoulders, and a clean crew neck.', 590.00, 'S', 15, 'https://images.unsplash.com/photo-1521572267360-ee0c2909d518?w=500&auto=format&fit=crop&q=80'), ('Minimalist Oversized Tee', '100% premium organic cotton. Features a relaxed silhouette, dropped shoulders, and a clean crew neck.', 590.00, 'M', 25, 'https://images.unsplash.com/photo-1521572267360-ee0c2909d518?w=500&auto=format&fit=crop&q=80'), ('Minimalist Oversized Tee', '100% premium organic cotton. Features a relaxed silhouette, dropped shoulders, and a clean crew neck.', 590.00, 'L', 8, 'https://images.unsplash.com/photo-1521572267360-ee0c2909d518?w=500&auto=format&fit=crop&q=80'), ('Premium Linen Trouser', 'Breathable linen blend. Designed with a tailored straight leg, elasticated drawstring waistband, and side pockets.', 1290.00, 'M', 10, 'https://images.unsplash.com/photo-1594633312681-425c7b97ccd1?w=500&auto=format&fit=crop&q=80'), ('Premium Linen Trouser', 'Breathable linen blend. Designed with a tailored straight leg, elasticated drawstring waistband, and side pockets.', 1290.00, 'L', 5, 'https://images.unsplash.com/photo-1594633312681-425c7b97ccd1?w=500&auto=format&fit=crop&q=80'), ('Structured Denim Jacket', 'Heavyweight classic denim. Features dual chest pockets, silver-tone hardware, and a slightly cropped length.', 1890.00, 'M', 12, 'https://images.unsplash.com/photo-1576995853123-5a10305d93c0?w=500&auto=format&fit=crop&q=80'), ('Structured Denim Jacket', 'Heavyweight classic denim. Features dual chest pockets, silver-tone hardware, and a slightly cropped length.', 1890.00, 'L', 15, 'https://images.unsplash.com/photo-1576995853123-5a10305d93c0?w=500&auto=format&fit=crop&q=80'), ('Classic Knit Cardigan', 'Soft merino wool knitwear with tortoise shell buttons, ribbed cuffs, and a cozy loose-fit silhouette.', 1490.00, 'S', 7, 'https://images.unsplash.com/photo-1614975058789-41316d0e2e9c?w=500&auto=format&fit=crop&q=80'), ('Classic Knit Cardigan', 'Soft merino wool knitwear with tortoise shell buttons, ribbed cuffs, and a cozy loose-fit silhouette.', 1490.00, 'M', 14, 'https://images.unsplash.com/photo-1614975058789-41316d0e2e9c?w=500&auto=format&fit=crop&q=80');
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings