CREATE TABLE IF NOT EXISTS `budgets` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `user_id` INT NOT NULL, `category` VARCHAR(100) NOT NULL, `amount` DECIMAL(10, 2) NOT NULL, `budget_month` DATE NOT NULL, -- Stores the first day of the month, e.g., 2025-10-01 `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE, UNIQUE KEY `user_category_month` (`user_id`, `category`, `budget_month`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;