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

START TRANSACTION;



--
-- Database: `financial_tracker`
--

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

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

CREATE TABLE `categories` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `type` enum('income','expense') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `categories` (`id`, `name`, `type`) VALUES
(1, 'Cash Received ', 'income'),
(2, 'Bank Received ', 'income'),
(3, 'BKash Received ', 'income'),
(4, 'Cash Payment ', 'expense'),
(5, 'BKash Payment', 'expense'),
(6, 'Bank Transfer ', 'expense');

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

--
-- Table structure for table `expense`
--

CREATE TABLE `expense` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `date` date NOT NULL,
  `notes` 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 `expense`
--

INSERT INTO `expense` (`id`, `user_id`, `category_id`, `amount`, `date`, `notes`, `created_at`) VALUES
(1, 1, 6, 50000.00, '2025-12-05', 'Bkash Transfers ', '2025-12-05 03:11:01'),
(2, 1, 4, 50000.00, '2025-12-05', 'Bkash Transfers ', '2025-12-05 12:50:58'),
(3, 1, 5, 50000.00, '2025-12-05', '0181900000', '2025-12-05 13:14:21'),
(4, 1, 6, 50000.00, '2025-12-06', 'Client AC 098989988 Exim Bank Pahartoli Br', '2025-12-06 02:36:56');

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

--
-- Table structure for table `income`
--

CREATE TABLE `income` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `date` date NOT NULL,
  `notes` 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 `income`
--

INSERT INTO `income` (`id`, `user_id`, `category_id`, `amount`, `date`, `notes`, `created_at`) VALUES
(4, 1, 1, 20000.00, '2025-12-05', 'Mr. X', '2025-12-05 13:11:49'),
(5, 1, 2, 50000.00, '2025-12-05', 'AC No: 08185112233', '2025-12-05 13:12:13'),
(6, 1, 3, 20000.00, '2025-12-05', '0181900000', '2025-12-05 13:13:29'),
(7, 1, 1, 100000.00, '2025-12-04', 'Mr. X', '2025-12-05 13:22:31'),
(8, 1, 2, 200000.00, '2025-12-04', 'Bkash Received', '2025-12-05 13:23:04'),
(9, 1, 2, 50000.00, '2025-12-06', 'AC No: 08185112233 Sonali Bank CUET Br', '2025-12-06 02:35:34'),
(10, 1, 2, 5000.00, '2025-12-06', 'AC:', '2025-12-06 16:14:48'),
(11, 1, 2, 5000.00, '2025-12-06', 'Bank', '2025-12-06 16:15:12');

--
-- Indexes for dumped tables
--

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

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

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `expense`
--
ALTER TABLE `expense`
  ADD CONSTRAINT `expense_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `expense_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `income`
--
ALTER TABLE `income`
  ADD CONSTRAINT `income_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `income_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE;
COMMIT;

