-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jan 01, 2026 at 01:12 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: `pos_db`
--

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

--
-- Table structure for table `advance_pay`
--

CREATE TABLE `advance_pay` (
  `advance_id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `advance_date` date NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `note` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `advance_pay`
--

INSERT INTO `advance_pay` (`advance_id`, `employee_id`, `advance_date`, `amount`, `note`, `created_at`) VALUES
(2, 2, '2025-12-25', 1000.00, '', '2025-12-25 07:35:07'),
(3, 3, '2025-12-26', 5000.00, '', '2025-12-26 15:02:35'),
(4, 4, '2026-01-01', 5000.00, '', '2025-12-26 15:09:58');

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

--
-- Table structure for table `bonus_pay`
--

CREATE TABLE `bonus_pay` (
  `bonus_id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `bonus_type` varchar(100) NOT NULL,
  `bonus_amount` decimal(10,2) NOT NULL,
  `bonus_date` date NOT NULL,
  `note` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `bonus_pay`
--

INSERT INTO `bonus_pay` (`bonus_id`, `employee_id`, `bonus_type`, `bonus_amount`, `bonus_date`, `note`, `created_at`) VALUES
(1, 1, 'Eid Bonus', 2000.00, '2025-12-25', '', '2025-12-25 17:57:17'),
(3, 4, 'Eid Bonus', 5000.00, '2025-12-26', '', '2025-12-26 15:11:29');

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

--
-- Table structure for table `customers`
--

CREATE TABLE `customers` (
  `customer_id` int(11) NOT NULL,
  `customer_name` varchar(255) NOT NULL,
  `customer_phone` varchar(50) DEFAULT NULL,
  `customer_email` varchar(100) DEFAULT NULL,
  `customer_address` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `customers`
--

INSERT INTO `customers` (`customer_id`, `customer_name`, `customer_phone`, `customer_email`, `customer_address`, `created_at`) VALUES
(1, 'Kapsul Ray', '017324234', 'example@gmail.com', 'Lalmonirhat Sadar', '2025-09-14 21:07:52'),
(2, 'Badhon', '0177330000', '', 'Rangpur', '2025-09-14 21:07:52');

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

--
-- Table structure for table `designation`
--

CREATE TABLE `designation` (
  `designation_id` int(11) NOT NULL,
  `title` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `designation`
--

INSERT INTO `designation` (`designation_id`, `title`, `description`, `created_at`) VALUES
(3, 'Manager', '', '2025-11-25 11:28:28'),
(4, 'Computer Operator', '', '2025-11-25 11:36:49'),
(5, 'Marketing Manager', '', '2025-11-25 11:37:36'),
(7, 'CEO', '', '2025-12-26 15:07:29');

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

--
-- Table structure for table `due_collection`
--

CREATE TABLE `due_collection` (
  `collection_id` int(11) NOT NULL,
  `sale_id` int(11) NOT NULL,
  `collected_amount` decimal(10,2) NOT NULL,
  `collection_date` date NOT NULL,
  `note` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `due_collection`
--

INSERT INTO `due_collection` (`collection_id`, `sale_id`, `collected_amount`, `collection_date`, `note`, `created_at`) VALUES
(1, 1, 50.00, '2025-09-14', '', '2025-09-14 21:35:04'),
(2, 1, 20.00, '2025-09-14', '', '2025-09-14 21:50:35'),
(3, 2, 20000.00, '2025-09-16', '', '2025-09-16 13:26:50'),
(4, 7, 155.00, '2025-10-10', '', '2025-10-10 19:39:44'),
(5, 1, 30.00, '2025-10-10', '', '2025-10-10 19:41:02');

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

--
-- Table structure for table `due_payments`
--

CREATE TABLE `due_payments` (
  `due_payment_id` int(11) NOT NULL,
  `purchase_id` int(11) NOT NULL,
  `supplier_id` int(11) NOT NULL,
  `invoice_no` char(6) NOT NULL,
  `payment_date` date NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `method` enum('Cash','Card','Bank','Mobile Banking') NOT NULL DEFAULT 'Cash',
  `note` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `due_payments`
--

INSERT INTO `due_payments` (`due_payment_id`, `purchase_id`, `supplier_id`, `invoice_no`, `payment_date`, `amount`, `method`, `note`, `created_at`) VALUES
(9, 7, 4, '', '2025-10-18', 500.00, 'Cash', '', '2025-10-18 19:34:45'),
(10, 11, 4, '', '2025-11-13', 2000.00, 'Cash', '', '2025-11-13 17:36:30');

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

--
-- Table structure for table `employees`
--

CREATE TABLE `employees` (
  `employee_id` int(11) NOT NULL,
  `employee_name` varchar(191) NOT NULL,
  `designation_id` int(11) NOT NULL,
  `father_name` varchar(191) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `family_phone` varchar(50) DEFAULT NULL,
  `email` varchar(191) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `join_date` date DEFAULT NULL,
  `gender` varchar(20) DEFAULT NULL,
  `blood_group` varchar(10) DEFAULT NULL,
  `nid` varchar(100) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  `base_salary` decimal(12,2) DEFAULT 0.00,
  `status` enum('Active','Inactive') DEFAULT 'Active',
  `photo` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `employees`
--

INSERT INTO `employees` (`employee_id`, `employee_name`, `designation_id`, `father_name`, `phone`, `family_phone`, `email`, `address`, `join_date`, `gender`, `blood_group`, `nid`, `dob`, `base_salary`, `status`, `photo`, `created_at`) VALUES
(1, 'Kapsul Chandro Ray', 5, 'Subol ray', '0177330005', '01234234234', 'kapsulray2@gmail.com', 'Lalmonirhat', '2025-11-05', 'Male', 'AB+', '123456789', '2025-11-25', 21000.00, 'Active', 'emp_1764069919_e43cba8fab97.jpg', '2025-11-25 11:24:36'),
(2, 'Sojib Ray', 4, 'test', '0177330005', '', '', '', '0000-00-00', '', '', '', '0000-00-00', 15000.00, 'Active', NULL, '2025-12-25 06:56:22'),
(4, 'Badhon Ray', 7, 'test', '0177330000', '', '', 'test', '0000-00-00', 'Male', '', '', '0000-00-00', 25000.00, 'Active', 'emp_1766761731_cbb2e9baa94c.jpg', '2025-12-26 15:08:51');

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

--
-- Table structure for table `expenses`
--

CREATE TABLE `expenses` (
  `expense_id` int(11) NOT NULL,
  `expense_name` varchar(150) NOT NULL,
  `category_id` int(11) NOT NULL,
  `transaction_method` enum('Cash','Bkash','Nagad','Rocket','Bank','Other') NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `note` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `expenses`
--

INSERT INTO `expenses` (`expense_id`, `expense_name`, `category_id`, `transaction_method`, `amount`, `note`, `created_at`) VALUES
(1, 'Gest Launch 2', 2, 'Cash', 400.00, 'gest bill', '2025-09-10 09:25:11');

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

--
-- Table structure for table `expense_categories`
--

CREATE TABLE `expense_categories` (
  `category_id` int(11) NOT NULL,
  `category_name` varchar(100) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `expense_categories`
--

INSERT INTO `expense_categories` (`category_id`, `category_name`, `created_at`) VALUES
(1, 'Nasta Bil', '2025-09-08 19:49:20'),
(2, 'Dokan', '2025-09-08 19:50:28'),
(3, 'test', '2025-09-08 19:51:03');

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

--
-- Table structure for table `purchases`
--

CREATE TABLE `purchases` (
  `purchase_id` int(11) NOT NULL,
  `supplier_id` int(11) NOT NULL,
  `invoice_no` char(6) NOT NULL,
  `purchase_date` date NOT NULL,
  `total` decimal(12,2) NOT NULL DEFAULT 0.00,
  `paid` decimal(12,2) NOT NULL DEFAULT 0.00,
  `due` decimal(12,2) NOT NULL DEFAULT 0.00,
  `note` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `purchases`
--

INSERT INTO `purchases` (`purchase_id`, `supplier_id`, `invoice_no`, `purchase_date`, `total`, `paid`, `due`, `note`, `created_at`) VALUES
(7, 4, '906001', '2025-09-26', 2000.00, 2000.00, 0.00, NULL, '2025-09-25 20:19:37'),
(9, 4, '607781', '2025-10-11', 50000.00, 40000.00, 10000.00, NULL, '2025-10-10 20:04:57'),
(11, 4, '216705', '2025-11-13', 5000.00, 4000.00, 1000.00, NULL, '2025-11-13 17:35:22');

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

--
-- Table structure for table `purchase_items`
--

CREATE TABLE `purchase_items` (
  `purchase_item_id` int(11) NOT NULL,
  `purchase_id` int(11) NOT NULL,
  `product` varchar(255) NOT NULL,
  `size` varchar(50) DEFAULT NULL,
  `rate` decimal(12,2) NOT NULL,
  `qty` int(11) NOT NULL,
  `subtotal` decimal(12,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `purchase_items`
--

INSERT INTO `purchase_items` (`purchase_item_id`, `purchase_id`, `product`, `size`, `rate`, `qty`, `subtotal`) VALUES
(7, 7, 'Home pc 1', '2kg', 200.00, 10, 2000.00),
(9, 9, 'test 1', 'test', 100.00, 100, 10000.00),
(10, 9, 'test 2', 'test 2', 200.00, 200, 40000.00),
(12, 11, 'test product', '22 inch', 100.00, 50, 5000.00);

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

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `role_id` int(11) NOT NULL,
  `role_name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` (`role_id`, `role_name`) VALUES
(1, 'admin'),
(3, 'cashier'),
(2, 'manager');

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

--
-- Table structure for table `salary_pay`
--

CREATE TABLE `salary_pay` (
  `salary_id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `salary_month` varchar(20) NOT NULL,
  `paid_amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `base_salary` decimal(10,2) NOT NULL,
  `advance_deduct` decimal(10,2) DEFAULT 0.00,
  `net_salary` decimal(10,2) NOT NULL,
  `pay_date` date NOT NULL,
  `note` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `salary_pay`
--

INSERT INTO `salary_pay` (`salary_id`, `employee_id`, `salary_month`, `paid_amount`, `base_salary`, `advance_deduct`, `net_salary`, `pay_date`, `note`, `created_at`) VALUES
(2, 1, '2025-12', 15000.00, 21000.00, 0.00, 15000.00, '2025-12-25', '', '2025-12-25 07:32:15'),
(5, 1, '2025-12', 6000.00, 21000.00, 0.00, 6000.00, '2025-12-25', '', '2025-12-25 14:07:29'),
(6, 2, '2025-12', 12000.00, 15000.00, 1000.00, 12000.00, '2025-12-25', '', '2025-12-25 16:32:43'),
(7, 2, '2025-12', 2000.00, 15000.00, 1000.00, 2000.00, '2025-12-26', '', '2025-12-25 16:33:03'),
(8, 3, '2025-12', 20000.00, 25000.00, 5000.00, 20000.00, '2025-12-26', '', '2025-12-26 15:03:45'),
(9, 4, '2026-01', 20000.00, 25000.00, 5000.00, 20000.00, '2025-12-26', '', '2025-12-26 15:10:56');

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

--
-- Table structure for table `sales`
--

CREATE TABLE `sales` (
  `sale_id` int(11) NOT NULL,
  `customer_id` int(11) NOT NULL,
  `sale_date` date NOT NULL,
  `total` decimal(10,2) NOT NULL,
  `paid` decimal(10,2) NOT NULL,
  `due` decimal(10,2) NOT NULL,
  `invoice_no` varchar(50) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `payment_due_date` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `sales`
--

INSERT INTO `sales` (`sale_id`, `customer_id`, `sale_date`, `total`, `paid`, `due`, `invoice_no`, `created_at`, `payment_due_date`) VALUES
(1, 2, '2025-09-15', 200.00, 200.00, 0.00, 'INV000001', '2025-09-14 21:08:32', NULL),
(2, 1, '2025-09-16', 25000.00, 20000.00, 5000.00, 'INV000002', '2025-09-16 13:25:38', NULL),
(3, 1, '2025-08-12', 2000.00, 1500.00, 500.00, 'INV000003', '2025-09-19 08:06:10', NULL),
(4, 2, '2025-09-19', 2400.00, 2000.00, 400.00, 'INV000004', '2025-09-19 13:30:21', NULL),
(7, 2, '2025-10-11', 1155.00, 1155.00, 0.00, 'INV000005', '2025-10-10 19:38:34', NULL),
(8, 2, '2025-10-11', 1440.00, 2000.00, 0.00, 'INV000006', '2025-10-10 20:00:14', NULL),
(10, 1, '2025-10-13', 3750.00, 2000.00, 1750.00, 'INV000007', '2025-10-13 07:19:00', '2025-10-18'),
(11, 1, '2025-10-13', 1155.00, 500.00, 655.00, 'INV000008', '2025-10-13 07:46:14', '2025-10-18'),
(12, 2, '2025-10-13', 1995.00, 1000.00, 995.00, 'INV000009', '2025-10-13 07:47:48', '2025-10-13'),
(15, 1, '2025-11-13', 2640.00, 2000.00, 640.00, 'INV000010', '2025-11-13 17:38:15', '2025-11-13');

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

--
-- Table structure for table `sale_items`
--

CREATE TABLE `sale_items` (
  `sale_item_id` int(11) NOT NULL,
  `sale_id` int(11) NOT NULL,
  `product` varchar(255) NOT NULL,
  `size` varchar(50) DEFAULT NULL,
  `rate` decimal(10,2) NOT NULL,
  `qty` int(11) NOT NULL,
  `subtotal` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `sale_items`
--

INSERT INTO `sale_items` (`sale_item_id`, `sale_id`, `product`, `size`, `rate`, `qty`, `subtotal`) VALUES
(1, 1, 'Home pc 2', '2kg', 200.00, 1, 200.00),
(2, 2, 'T shirt', 'xl', 500.00, 50, 25000.00),
(3, 3, 'T shirt print', 'M', 50.00, 40, 2000.00),
(4, 4, 'T shirt print', 'M', 120.00, 20, 2400.00),
(8, 7, 'test', '22 x 150', 0.35, 1, 1155.00),
(9, 8, 'test', '24 x 150', 0.40, 1, 1440.00),
(12, 10, 'test 1', '22', 0.35, 2, 15.40),
(13, 10, 'pc 1', '24', 0.40, 1, 9.60),
(14, 11, 'Home pc 1', '22Ã—150', 0.35, 1, 1155.00),
(15, 12, 'laptop', '22Ã—150', 0.35, 1, 1155.00),
(16, 12, 'Home pc 1', '24Ã—100', 0.35, 1, 840.00),
(17, 15, 'test 2 product', '22 Ã— 12', 10.00, 1, 2640.00);

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

--
-- Table structure for table `suppliers`
--

CREATE TABLE `suppliers` (
  `supplier_id` int(11) NOT NULL,
  `supplier_name` varchar(255) NOT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `suppliers`
--

INSERT INTO `suppliers` (`supplier_id`, `supplier_name`, `phone`, `address`, `created_at`) VALUES
(4, 'Kapsul Ray', '0177330001', '', '2025-09-14 21:23:25');

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

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

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(50) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `role` enum('admin','manager','staff') NOT NULL DEFAULT 'admin'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

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

INSERT INTO `users` (`id`, `username`, `password`, `created_at`, `role`) VALUES
(1, 'admin', '21232f297a57a5a743894a0e4a801fc3', '2025-08-31 16:01:32', 'admin'),
(4, 'staff', '81dc9bdb52d04dc20036dbd8313ed055', '2025-10-03 14:14:57', 'staff'),
(12, 'manager', '81dc9bdb52d04dc20036dbd8313ed055', '2025-10-03 17:06:09', 'manager');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `advance_pay`
--
ALTER TABLE `advance_pay`
  ADD PRIMARY KEY (`advance_id`),
  ADD KEY `employee_id` (`employee_id`);

--
-- Indexes for table `bonus_pay`
--
ALTER TABLE `bonus_pay`
  ADD PRIMARY KEY (`bonus_id`),
  ADD KEY `employee_id` (`employee_id`);

--
-- Indexes for table `customers`
--
ALTER TABLE `customers`
  ADD PRIMARY KEY (`customer_id`);

--
-- Indexes for table `designation`
--
ALTER TABLE `designation`
  ADD PRIMARY KEY (`designation_id`);

--
-- Indexes for table `due_collection`
--
ALTER TABLE `due_collection`
  ADD PRIMARY KEY (`collection_id`),
  ADD KEY `sale_id` (`sale_id`);

--
-- Indexes for table `due_payments`
--
ALTER TABLE `due_payments`
  ADD PRIMARY KEY (`due_payment_id`),
  ADD KEY `purchase_id` (`purchase_id`),
  ADD KEY `supplier_id` (`supplier_id`);

--
-- Indexes for table `employees`
--
ALTER TABLE `employees`
  ADD PRIMARY KEY (`employee_id`),
  ADD KEY `designation_id` (`designation_id`);

--
-- Indexes for table `expenses`
--
ALTER TABLE `expenses`
  ADD PRIMARY KEY (`expense_id`),
  ADD KEY `category_id` (`category_id`);

--
-- Indexes for table `expense_categories`
--
ALTER TABLE `expense_categories`
  ADD PRIMARY KEY (`category_id`);

--
-- Indexes for table `purchases`
--
ALTER TABLE `purchases`
  ADD PRIMARY KEY (`purchase_id`),
  ADD UNIQUE KEY `invoice_no` (`invoice_no`),
  ADD KEY `supplier_id` (`supplier_id`),
  ADD KEY `idx_purchases_invoice` (`invoice_no`);

--
-- Indexes for table `purchase_items`
--
ALTER TABLE `purchase_items`
  ADD PRIMARY KEY (`purchase_item_id`),
  ADD KEY `purchase_id` (`purchase_id`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`role_id`),
  ADD UNIQUE KEY `role_name` (`role_name`);

--
-- Indexes for table `salary_pay`
--
ALTER TABLE `salary_pay`
  ADD PRIMARY KEY (`salary_id`);

--
-- Indexes for table `sales`
--
ALTER TABLE `sales`
  ADD PRIMARY KEY (`sale_id`),
  ADD KEY `customer_id` (`customer_id`);

--
-- Indexes for table `sale_items`
--
ALTER TABLE `sale_items`
  ADD PRIMARY KEY (`sale_item_id`),
  ADD KEY `sale_id` (`sale_id`);

--
-- Indexes for table `suppliers`
--
ALTER TABLE `suppliers`
  ADD PRIMARY KEY (`supplier_id`);

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

--
-- AUTO_INCREMENT for dumped tables
--

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

--
-- AUTO_INCREMENT for table `bonus_pay`
--
ALTER TABLE `bonus_pay`
  MODIFY `bonus_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
  MODIFY `customer_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `designation`
--
ALTER TABLE `designation`
  MODIFY `designation_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `due_collection`
--
ALTER TABLE `due_collection`
  MODIFY `collection_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

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

--
-- AUTO_INCREMENT for table `employees`
--
ALTER TABLE `employees`
  MODIFY `employee_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

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

--
-- AUTO_INCREMENT for table `expense_categories`
--
ALTER TABLE `expense_categories`
  MODIFY `category_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `purchases`
--
ALTER TABLE `purchases`
  MODIFY `purchase_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

--
-- AUTO_INCREMENT for table `purchase_items`
--
ALTER TABLE `purchase_items`
  MODIFY `purchase_item_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;

--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
  MODIFY `role_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `salary_pay`
--
ALTER TABLE `salary_pay`
  MODIFY `salary_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

--
-- AUTO_INCREMENT for table `sales`
--
ALTER TABLE `sales`
  MODIFY `sale_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

--
-- AUTO_INCREMENT for table `sale_items`
--
ALTER TABLE `sale_items`
  MODIFY `sale_item_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;

--
-- AUTO_INCREMENT for table `suppliers`
--
ALTER TABLE `suppliers`
  MODIFY `supplier_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `bonus_pay`
--
ALTER TABLE `bonus_pay`
  ADD CONSTRAINT `fk_bonus_employee` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`employee_id`) ON DELETE CASCADE;

--
-- Constraints for table `due_collection`
--
ALTER TABLE `due_collection`
  ADD CONSTRAINT `due_collection_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `sales` (`sale_id`) ON DELETE CASCADE;

--
-- Constraints for table `due_payments`
--
ALTER TABLE `due_payments`
  ADD CONSTRAINT `due_payments_ibfk_1` FOREIGN KEY (`purchase_id`) REFERENCES `purchases` (`purchase_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `due_payments_ibfk_2` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`supplier_id`) ON DELETE CASCADE;

--
-- Constraints for table `employees`
--
ALTER TABLE `employees`
  ADD CONSTRAINT `fk_employee_designation` FOREIGN KEY (`designation_id`) REFERENCES `designation` (`designation_id`) ON UPDATE CASCADE;

--
-- Constraints for table `expenses`
--
ALTER TABLE `expenses`
  ADD CONSTRAINT `expenses_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `expense_categories` (`category_id`) ON DELETE CASCADE;

--
-- Constraints for table `purchases`
--
ALTER TABLE `purchases`
  ADD CONSTRAINT `purchases_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`supplier_id`) ON DELETE CASCADE;

--
-- Constraints for table `purchase_items`
--
ALTER TABLE `purchase_items`
  ADD CONSTRAINT `purchase_items_ibfk_1` FOREIGN KEY (`purchase_id`) REFERENCES `purchases` (`purchase_id`) ON DELETE CASCADE;

--
-- Constraints for table `sales`
--
ALTER TABLE `sales`
  ADD CONSTRAINT `sales_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`customer_id`) ON DELETE CASCADE;

--
-- Constraints for table `sale_items`
--
ALTER TABLE `sale_items`
  ADD CONSTRAINT `sale_items_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `sales` (`sale_id`) ON DELETE CASCADE;
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 */;
