-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Aug 15, 2025 at 11:51 AM
-- 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: `vivin`
--

-- --------------------------------------------------------

--
-- Table structure for table `addresses`
--

CREATE TABLE `addresses` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `address_title` varchar(100) NOT NULL,
  `recipient_name` varchar(100) NOT NULL,
  `street_address` varchar(255) NOT NULL,
  `city` varchar(100) NOT NULL,
  `state` varchar(100) NOT NULL,
  `postal_code` varchar(20) NOT NULL,
  `country` varchar(100) NOT NULL,
  `phone_number` varchar(20) NOT NULL,
  `is_default` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `cart`
--

CREATE TABLE `cart` (
  `id` varchar(20) NOT NULL,
  `user_id` varchar(50) NOT NULL,
  `product_id` varchar(50) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `qty` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `image` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`id`, `name`, `image`) VALUES
(1, 'Mobile', 'mobile.jpg'),
(2, 'Appliances', 'Appliances.jpg'),
(3, 'Toys', 'Toys.jpg'),
(4, 'Fashion', 'Fashion.jpg'),
(5, 'Sports', 'Sports.jpg'),
(6, 'Furniture', 'Furniture.jpg'),
(7, 'Beauty', 'Beauty.jpg'),
(8, 'Smart gadgets', 'Smart gadgets.png'),
(9, 'Grocery', 'Grocery.JPEG'),
(10, 'Electronics', 'Electronics.webp');

-- --------------------------------------------------------

--
-- Table structure for table `message`
--

CREATE TABLE `message` (
  `id` varchar(20) NOT NULL,
  `user_id` varchar(20) NOT NULL,
  `name` varchar(50) NOT NULL,
  `email` varchar(100) NOT NULL,
  `subject` varchar(200) NOT NULL,
  `message` varchar(500) NOT NULL,
  `seller_id` varchar(20) DEFAULT NULL,
  `seen` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `notifications`
--

CREATE TABLE `notifications` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `message` text NOT NULL,
  `type` varchar(50) DEFAULT NULL,
  `is_read` tinyint(1) DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `orders`
--

CREATE TABLE `orders` (
  `id` int(11) NOT NULL,
  `user_id` varchar(20) NOT NULL,
  `seller_id` varchar(20) NOT NULL,
  `name` varchar(50) NOT NULL,
  `number` varchar(20) NOT NULL,
  `email` varchar(50) NOT NULL,
  `address` varchar(200) NOT NULL,
  `address_type` varchar(10) NOT NULL,
  `method` varchar(50) NOT NULL,
  `product_id` varchar(20) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `qty` tinyint(4) NOT NULL,
  `date` date NOT NULL DEFAULT current_timestamp(),
  `status` varchar(50) NOT NULL DEFAULT 'in progress',
  `payment_status` varchar(200) NOT NULL DEFAULT 'pending',
  `tracking_number` varchar(50) DEFAULT NULL,
  `carrier` varchar(50) DEFAULT NULL,
  `estimated_delivery` date DEFAULT NULL,
  `delivery_date` date DEFAULT NULL,
  `return_requested` tinyint(1) DEFAULT 0,
  `return_reason` varchar(255) DEFAULT NULL,
  `return_status` varchar(50) DEFAULT NULL,
  `refund_amount` decimal(10,2) DEFAULT NULL,
  `refund_date` date DEFAULT NULL,
  `address_id` int(11) DEFAULT NULL,
  `payment_method_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `order_items`
--

CREATE TABLE `order_items` (
  `id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `product_id` varchar(20) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `qty` tinyint(4) NOT NULL,
  `subtotal` decimal(10,2) NOT NULL,
  `status` varchar(50) NOT NULL DEFAULT 'pending'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `order_status_history`
--

CREATE TABLE `order_status_history` (
  `id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `status` varchar(50) NOT NULL,
  `changed_by` varchar(50) NOT NULL COMMENT 'user_id or seller_id',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `order_totals`
--

CREATE TABLE `order_totals` (
  `id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `subtotal` decimal(10,2) NOT NULL,
  `shipping` decimal(10,2) NOT NULL DEFAULT 0.00,
  `tax` decimal(10,2) NOT NULL DEFAULT 0.00,
  `discount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `total` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `payment_methods`
--

CREATE TABLE `payment_methods` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `type` enum('credit_card','paypal','bank_transfer') NOT NULL,
  `card_number` varchar(20) DEFAULT NULL,
  `expiry_month` varchar(2) DEFAULT NULL,
  `expiry_year` varchar(4) DEFAULT NULL,
  `cardholder_name` varchar(100) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `bank_name` varchar(100) DEFAULT NULL,
  `account_number` varchar(20) DEFAULT NULL,
  `routing_number` varchar(20) DEFAULT NULL,
  `account_holder` varchar(100) DEFAULT NULL,
  `is_default` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` bigint(20) NOT NULL,
  `seller_id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `image` varchar(255) NOT NULL,
  `stock` int(11) NOT NULL DEFAULT 0,
  `product_detail` text NOT NULL,
  `status` enum('active','deactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `content` text NOT NULL,
  `description` text NOT NULL,
  `image_01` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `products`
--

INSERT INTO `products` (`id`, `seller_id`, `category_id`, `name`, `price`, `image`, `stock`, `product_detail`, `status`, `created_at`, `content`, `description`, `image_01`) VALUES
(1, 2, 1, 'Redmi Note 14 5G', 16999.00, 'Redmi Note 14 5G.webp', 50, 'The Redmi Note 14 5G is a mid-range smartphone featuring a 6.67-inch AMOLED 120Hz display, MediaTek Dimensity 7025-Ultra processor, up to 12GB RAM and 256GB storage, a 108MP main camera with OIS, 5110mAh battery with 45W fast charging, and HyperOS 1.0 (Android 14). It offers smooth performance, vibrant visuals, strong camera capabilities, and long-lasting battery life at an affordable price.', 'active', '2025-08-15 09:01:19', '', '', NULL),
(2, 2, 1, 'OnePlus', 20999.00, 'OnePlus.webp', 50, 'The Redmi Note 14 5G is a mid-range smartphone featuring a 6.67-inch AMOLED 120Hz display, MediaTek Dimensity 7025-Ultra processor, up to 12GB RAM and 256GB storage, a 108MP main camera with OIS, 5110mAh battery with 45W fast charging, and HyperOS 1.0 (Android 14). It offers smooth performance, vibrant visuals, strong camera capabilities, and long-lasting battery life at an affordable price.', 'active', '2025-08-15 09:07:41', '', '', NULL),
(3, 2, 1, 'Realme 15 Pro 5G', 38998.00, 'Realme 15 Pro 5G.avif', 5, 'Display: 6.8-inch AMOLED, 1.5K resolution (1280 × 2800), 144Hz refresh rate, 6,500 nits peak brightness, protected by Corning Gorilla Glass 7i.', 'active', '2025-08-15 09:11:32', '', '', NULL),
(4, 2, 2, 'Air Fryer', 18998.00, 'Air Fryer.avif', 15, 'An Air Fryer is a kitchen appliance that cooks food by circulating hot air around it, producing a crispy, fried-like texture without the need for large amounts of oil. It’s popular for making healthier versions of fried foods like French fries, chicken, and snacks. Most models come with adjustable temperature and timer settings, making them versatile for baking, grilling, and roasting as well.', 'active', '2025-08-15 09:13:26', '', '', NULL),
(77, 3, 7, 'Stunning Beauty Face Cream', 100.00, 'Stunning Beauty Face Cream.jpg', 100, 'A nourishing beauty product that hydrates, brightens, and revitalizes your skin, giving a radiant and youthful glow.', 'active', '2025-08-15 09:36:12', '', '', NULL),
(756, 2, 2, 'purple retro refrigerator', 10998.00, 'purple retro refrigerator.avif', 15, 'A purple retro refrigerator is a stylish, vintage-inspired fridge with a bold purple finish, combining nostalgic 1950s design elements with modern cooling technology. It’s both a functional appliance and a statement piece for kitchens or retro-themed spaces.', 'active', '2025-08-15 09:15:16', '', '', NULL),
(763, 4, 3, 'Toy Teddy Bear', 500.00, 'Toy Teddy Bear.jpg', 10, 'A soft and huggable teddy bear perfect for children of all ages. It provides comfort, companionship, and a lovable friend for playtime or bedtime.', 'active', '2025-08-15 09:48:13', '', '', NULL),
(48798, 2, 10, 'Ultra Wireless S50 Headphones', 5998.00, 'Ultra Wireless S50 Headphones.jpg', 15, 'The Ultra Wireless S50 Headphones are sleek, over-ear wireless headphones offering high-quality sound, deep bass, and up to 30 hours of battery life. They feature Bluetooth connectivity, comfortable cushioning, and built-in controls for music and calls, making them ideal for everyday use and travel.', 'active', '2025-08-15 09:19:30', '', '', NULL),
(48799, 2, 8, 'Boat Black Headset', 999.00, 'boat.webp', 150, 'The Boat Black Headset is a stylish and durable audio accessory designed for clear sound and comfortable wear. It typically features wired or wireless connectivity, noise isolation, and built-in controls for music and calls, making it ideal for everyday use, gaming, or travel.', 'active', '2025-08-15 09:25:01', '', '', NULL),
(48800, 3, 7, 'Beauty Products', 1999.00, 'Beauty Products.avif', 100, 'Products used to enhance appearance and personal grooming.', 'active', '2025-08-15 09:33:12', '', '', NULL),
(48801, 3, 4, 'Royal Charm', 19999.00, 'dress.jpg', 5, 'A premium, stylish dress crafted for elegance and comfort, designed to make you stand out on any occasion with its perfect fit and timeless appeal.', 'active', '2025-08-15 09:42:20', '', 'A premium, stylish dress crafted for elegance and comfort, designed to make you stand out on any occasion with its perfect fit and timeless appeal.', NULL),
(48802, 4, 3, 'Shumee Rainbow Wooden Stacker', 50.00, 'Shumee Rainbow Wooden Stacker.webp', 100, 'A colorful, wooden stacking toy that encourages creativity, fine motor skills, and hand-eye coordination in children. Its vibrant rainbow pieces can be stacked, sorted, and balanced for endless fun and learning.', 'active', '2025-08-15 09:47:13', '', '', NULL),
(48803, 4, 5, 'Nike Pegasus', 5000.00, 'Nike Pegasus.avif', 10, 'A high-performance running shoe designed for comfort, support, and speed. It features responsive cushioning, durable materials, and a sleek design, making it ideal for daily runs and athletic activities.', 'active', '2025-08-15 09:50:09', '', '', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `sellers`
--

CREATE TABLE `sellers` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `role` enum('admin','seller') NOT NULL DEFAULT 'seller',
  `password` varchar(255) NOT NULL,
  `image` varchar(100) NOT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `status` enum('active','inactive') NOT NULL DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `sellers`
--

INSERT INTO `sellers` (`id`, `name`, `email`, `role`, `password`, `image`, `phone`, `address`, `created_at`, `status`) VALUES
(1, 'Admin User', 'admin@gmail.com', 'admin', 'admin123', 'default.png', NULL, NULL, '2025-08-15 07:26:20', 'active'),
(2, 'vivin', 'vivin@gmail.com', 'seller', '1', '2F3IAxkyiYIRIErfoaV3.avif', NULL, NULL, '2025-08-15 07:32:40', 'active'),
(3, 'beauty', 'beauty@gmail.com', 'seller', '1', 'scnnLceWU27JWSBDEhHj.gif', NULL, NULL, '2025-08-15 09:29:44', 'active'),
(4, 'cute', 'cute@gmail.com', 'seller', '1', 'K8jsJwseuJ1kNiunlMHV.png', NULL, NULL, '2025-08-15 09:46:07', 'active');

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` varchar(20) NOT NULL,
  `name` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `password` varchar(50) NOT NULL,
  `image` varchar(100) NOT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `address` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `name`, `email`, `password`, `image`, `phone`, `address`) VALUES
('nAsK9A3LnDvfjTt0Qkpx', 'vivin', 'test@gmail.com', '1', 'ROyOiD2a4BUPibhIV1V9.jpeg', NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `wishlist`
--

CREATE TABLE `wishlist` (
  `id` varchar(20) NOT NULL,
  `user_id` varchar(20) NOT NULL,
  `product_id` varchar(50) NOT NULL,
  `price` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `wishlist`
--

INSERT INTO `wishlist` (`id`, `user_id`, `product_id`, `price`) VALUES
('689efe684b563', 'nAsK9A3LnDvfjTt0Qkpx', '4', 18998.00);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `addresses`
--
ALTER TABLE `addresses`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `name` (`name`);

--
-- Indexes for table `message`
--
ALTER TABLE `message`
  ADD PRIMARY KEY (`id`),
  ADD KEY `seller_id` (`seller_id`),
  ADD KEY `seen` (`seen`);

--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
  ADD PRIMARY KEY (`id`),
  ADD KEY `seller_id` (`seller_id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `status` (`status`),
  ADD KEY `payment_status` (`payment_status`),
  ADD KEY `date` (`date`),
  ADD KEY `seller_id_2` (`seller_id`),
  ADD KEY `fk_address` (`address_id`),
  ADD KEY `fk_payment_method` (`payment_method_id`);

--
-- Indexes for table `order_items`
--
ALTER TABLE `order_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_id` (`order_id`);

--
-- Indexes for table `order_status_history`
--
ALTER TABLE `order_status_history`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_id` (`order_id`);

--
-- Indexes for table `order_totals`
--
ALTER TABLE `order_totals`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_id` (`order_id`);

--
-- Indexes for table `payment_methods`
--
ALTER TABLE `payment_methods`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `products`
--
ALTER TABLE `products`
  ADD PRIMARY KEY (`id`),
  ADD KEY `category_id` (`category_id`),
  ADD KEY `seller_id` (`seller_id`);

--
-- Indexes for table `sellers`
--
ALTER TABLE `sellers`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `wishlist`
--
ALTER TABLE `wishlist`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `addresses`
--
ALTER TABLE `addresses`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `notifications`
--
ALTER TABLE `notifications`
  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 `order_items`
--
ALTER TABLE `order_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `order_status_history`
--
ALTER TABLE `order_status_history`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `order_totals`
--
ALTER TABLE `order_totals`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `payment_methods`
--
ALTER TABLE `payment_methods`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=48804;

--
-- AUTO_INCREMENT for table `sellers`
--
ALTER TABLE `sellers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
  ADD CONSTRAINT `fk_address` FOREIGN KEY (`address_id`) REFERENCES `addresses` (`id`),
  ADD CONSTRAINT `fk_payment_method` FOREIGN KEY (`payment_method_id`) REFERENCES `payment_methods` (`id`);

--
-- Constraints for table `order_items`
--
ALTER TABLE `order_items`
  ADD CONSTRAINT `order_items_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `order_status_history`
--
ALTER TABLE `order_status_history`
  ADD CONSTRAINT `order_status_history_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `order_totals`
--
ALTER TABLE `order_totals`
  ADD CONSTRAINT `order_totals_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `products`
--
ALTER TABLE `products`
  ADD CONSTRAINT `products_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`),
  ADD CONSTRAINT `products_ibfk_2` FOREIGN KEY (`seller_id`) REFERENCES `sellers` (`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 */;
