-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Open
Description
Descripción
Crear un script SQL que defina el esquema inicial de la base de datos para un sistema de finanzas personales. Este sistema permitirá registrar transacciones, presupuestos, metas de ahorro y (opcionalmente) usuarios y cuentas. El esquema debe ser compatible con MySQL y cubrir el MVP de la aplicación.
Tablas requeridas:
transactions
: registro de ingresos/gastos, categorías y descripción.budgets
: presupuestos por categoría y periodo.savings_goals
: metas de ahorro con estado.- (Opcional:
accounts
para soportar varias cuentas o wallets)
Debe incluir claves primarias, tipos de datos adecuados y referencias entre tablas donde aplique.
Why
- Permite que el backend almacene y consulte los datos financieros de forma estructurada.
- Facilita la generación de reportes “fin de mes”, seguimiento de objetivos y visualización de gastos/ingresos.
- Es fundamental para el funcionamiento de toda la app y para poder avanzar hacia la integración con frontend y generación de reportes.
Possible Implementation & Open Questions
Script SQL sugerido:
CREATE TABLE accounts (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
currency VARCHAR(10) DEFAULT 'MXN',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE transactions (
id INT AUTO_INCREMENT PRIMARY KEY,
account_id INT DEFAULT NULL,
type ENUM('income','expense') NOT NULL,
amount DECIMAL(12,2) NOT NULL,
category VARCHAR(100),
description TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(account_id) REFERENCES accounts(id) ON DELETE SET NULL
);
CREATE TABLE budgets (
id INT AUTO_INCREMENT PRIMARY KEY,
account_id INT DEFAULT NULL,
category VARCHAR(100) NOT NULL,
limit_amount DECIMAL(12,2) NOT NULL,
period ENUM('monthly','weekly','yearly') NOT NULL DEFAULT 'monthly',
start_date DATE DEFAULT NULL,
end_date DATE DEFAULT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(account_id) REFERENCES accounts(id) ON DELETE SET NULL
);
CREATE TABLE savings_goals (
id INT AUTO_INCREMENT PRIMARY KEY,
account_id INT DEFAULT NULL,
name VARCHAR(100) NOT NULL,
target_amount DECIMAL(12,2) NOT NULL,
saved_amount DECIMAL(12,2) DEFAULT 0.0,
icon VARCHAR(50),
target_date DATE DEFAULT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(account_id) REFERENCES accounts(id) ON DELETE SET NULL
);
Preguntas abiertas:
- ¿Es necesario soportar múltiples usuarios o es solo para uso personal? (si sí, agregar tabla users y relación con cuentas)
- ¿Se requiere historial de modificaciones (audit trail)?
- ¿Se usarán categorías predefinidas o personalizables?
Is this something you're interested in working on?
- YES
- NO
Metadata
Metadata
Assignees
Labels
No labels