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

START TRANSACTION;



--
-- Database: `stockmicro`
--

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

--
-- Table structure for table `company`
--

CREATE TABLE `company` (
  `companyId` int(11) NOT NULL,
  `companyName` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `company`
--

INSERT INTO `company` (`companyId`, `companyName`) VALUES
(1, 'Chiang Mai'),
(2, 'Nakhonpathom'),
(3, 'Lopburi'),
(4, 'บ้านหมี่');

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

--
-- Table structure for table `log`
--

CREATE TABLE `log` (
  `id` int(11) NOT NULL,
  `stockId` int(11) NOT NULL,
  `productId` int(11) NOT NULL,
  `userId` int(11) NOT NULL,
  `companyId` int(11) NOT NULL,
  `date` varchar(40) NOT NULL,
  `time` varchar(30) NOT NULL,
  `qty` int(11) NOT NULL,
  `status` varchar(10) NOT NULL,
  `stockTotal` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `log`
--

INSERT INTO `log` (`id`, `stockId`, `productId`, `userId`, `companyId`, `date`, `time`, `qty`, `status`, `stockTotal`) VALUES
(69, 27, 9, 9, 1, '2025-02-17', '22:10:32', 4, 'up', '4'),
(70, 27, 9, 9, 1, '2025-02-17', '22:13:10', 1, 'up', '5'),
(71, 27, 9, 9, 1, '2025-02-17', '22:13:13', 1, 'down', '4'),
(72, 27, 9, 9, 1, '2025-02-17', '23:45:52', 100, 'up', '104'),
(73, 28, 10, 9, 1, '2025-02-17', '23:46:02', 200, 'up', '200'),
(74, 29, 11, 9, 1, '2025-02-17', '23:46:09', 150, 'up', '150'),
(75, 27, 9, 9, 1, '2025-02-17', '23:49:34', 50, 'up', '154'),
(78, 28, 10, 13, 1, '2025-02-18', '09:09:40', 1, 'down', '199'),
(79, 28, 10, 9, 1, '2025-02-18', '09:11:54', 1, 'down', '198');

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

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

CREATE TABLE `product` (
  `id` int(11) NOT NULL,
  `productName` varchar(100) NOT NULL,
  `description` varchar(200) DEFAULT NULL,
  `price` int(11) NOT NULL,
  `Totalprice` int(11) NOT NULL,
  `companyId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `product` (`id`, `productName`, `description`, `price`, `Totalprice`, `companyId`) VALUES
(9, 'Power Subply', '800w', 1000, 0, 1),
(10, 'Ram DDR4(3200) ', '8GB BLACKBERRY 8 CHIP', 430, 0, 1),
(11, 'Notebook Asus Vivobook', '16X K3605ZU-N1506W (Indie Black)', 28990, 0, 1),
(12, 'USB MOUSE HP ', 'M160 WHITE', 120, 0, 1),
(13, 'คอมพิวเตอร์', '', 20000, 0, 1);

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

--
-- Table structure for table `status`
--

CREATE TABLE `status` (
  `statusId` int(11) NOT NULL,
  `statusName` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `status`
--

INSERT INTO `status` (`statusId`, `statusName`) VALUES
(1, 'user'),
(5, 'admin'),
(9, 'superAdmin');

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

--
-- Table structure for table `stock`
--

CREATE TABLE `stock` (
  `id` int(11) NOT NULL,
  `productId` int(11) NOT NULL,
  `qty` int(11) NOT NULL,
  `companyId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `stock`
--

INSERT INTO `stock` (`id`, `productId`, `qty`, `companyId`) VALUES
(27, 9, 0, 1),
(28, 10, 198, 1),
(29, 11, 150, 1);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `company`
--
ALTER TABLE `company`
  ADD PRIMARY KEY (`companyId`);

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

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

--
-- Indexes for table `status`
--
ALTER TABLE `status`
  ADD PRIMARY KEY (`statusId`);

--
-- Indexes for table `stock`
--
ALTER TABLE `stock`
  ADD PRIMARY KEY (`id`),
  ADD KEY `productId` (`productId`),
  ADD KEY `companyId` (`companyId`);

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

--
-- Constraints for table `stock`
--
ALTER TABLE `stock`
  ADD CONSTRAINT `stock_ibfk_1` FOREIGN KEY (`productId`) REFERENCES `product` (`Id`),
  ADD CONSTRAINT `stock_ibfk_2` FOREIGN KEY (`companyId`) REFERENCES `company` (`companyId`);
COMMIT;

