Open alivxo opened 4 days ago
Query the Data
-- Fetch Users -- SELECT * FROM User;
-- Fetch Categories for a User -- SELECT * FROM Category WHERE user_id = 1;
-- Fetch Expenses for a User -- SELECT e.id, e.amount, e.description, e.date, c.name AS category FROM Expense e JOIN Category c ON e.category_id = c.id WHERE e.user_id = 1;
Insert test data to ensure the schema works as expected.
-- Insert for User -- INSERT INTO User (username, password, email) VALUES ('john_doe', 'securepassword123', 'john.doe@example.com');
-- Insert for Categories -- INSERT INTO Category (name, user_id) VALUES ('Food', 1), ('Transport', 1);
-- Insert for Expenses -- INSERT INTO Expense (amount, category_id, description, date, user_id) VALUES (15.75, 1, 'Lunch at cafe', '2024-11-20', 1), (50.00, 2, 'Bus pass', '2024-11-19', 1);