-- https://www.phpmyadmin.net/
--

START TRANSACTION;



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

--
-- Table structure for table `product`
--

CREATE TABLE `product` (
  `productId` varchar(100) NOT NULL,
  `productName` varchar(100) NOT NULL,
  `brand` varchar(100) NOT NULL,
  `department` varchar(100) NOT NULL,
  `type` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `product`
--

INSERT INTO `product` (`productId`, `productName`, `brand`, `department`, `type`) VALUES
('1000-405-3322-1456/12', 'Printer', 'Broter', '2', 'Printer'),
('1111-444-5555-1234/14', 'UPS', 'APC ', '3', 'UPS'),
('1234-567-8910-1112/01', 'Computer', 'Asus', '1', 'PC'),
('1345-543-1345-3421/01', 'UPS', 'APC ', '3', 'UPS');

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

--
-- Table structure for table `repair`
--

CREATE TABLE `repair` (
  `repairId` varchar(100) NOT NULL,
  `empId` varchar(100) NOT NULL,
  `productId` varchar(100) NOT NULL,
  `description` varchar(200) NOT NULL,
  `date` varchar(50) NOT NULL,
  `dateEnd` varchar(50) DEFAULT NULL,
  `state` varchar(1) NOT NULL,
  `email` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `repair`
--

INSERT INTO `repair` (`repairId`, `empId`, `productId`, `description`, `date`, `dateEnd`, `state`, `email`) VALUES
('N0001', 'E001', '1234-567-8910-1112/01', 'เปิดไม่ติด', '2025-02-17', '2025-02-17', '2', 'ppcllaearg@gmail.com'),
('N002', 'E002', '1234-567-8910-1112/01', 'เปิดไม่ติด', '2025-02-17', '2025-02-17', '2', 'ppcllaearg@gmail.com'),
('N003', 'E003', '1234-567-8910-1112/01', 'เปิดไม่ติด', '2025-02-18', '2025-02-18', '2', 'ppcllaearg@gmail.com'),
('N004', 'E005', '1000-405-3322-1456/12', 'กระดาษติด', '2025-02-18', '2025-02-18', '2', 'ppcllaearg@gmail.com'),
('N005', 'E007', '1234-567-8910-1112/01', 'เปิดไม่ติด', '2025-02-18', '2025-02-18', '2', 'ppcllaearg@gmail.com'),
('N006', 'E009', '1111-444-5555-1234/14', 'เปิดไม่ติด', '2025-02-18', NULL, '1', 'ppcllaearg@gmail.com');

--
-- Indexes for table `product`
--
ALTER TABLE `product`
  ADD PRIMARY KEY (`productId`);

--
-- Indexes for table `repair`
--
ALTER TABLE `repair`
  ADD PRIMARY KEY (`repairId`),
  ADD KEY `productKey` (`productId`),
  ADD KEY `repair_ibfk_1` (`empId`);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `repair`
--
ALTER TABLE `repair`
  ADD CONSTRAINT `productKey` FOREIGN KEY (`productId`) REFERENCES `product` (`productId`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `repair_ibfk_1` FOREIGN KEY (`empId`) REFERENCES `employee` (`empId`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

