Skip to content

Instantly share code, notes, and snippets.

@Mau5trakt
Created November 20, 2023 20:20
Show Gist options
  • Save Mau5trakt/557bfb6f9a2512a53befd39de7203ed6 to your computer and use it in GitHub Desktop.
Save Mau5trakt/557bfb6f9a2512a53befd39de7203ed6 to your computer and use it in GitHub Desktop.
finance database
CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
username TEXT,
hash TEXT,
cash REAL DEFAULT 10000
);
CREATE TABLE IF NOT EXISTS transactions (
transaction_id INTEGER PRIMARY KEY AUTOINCREMENT,
symbol TEXT,
qty INTEGER,
price REAL,
user_id INTEGER, -- Agrega la columna user_id como clave externa
timestamp TEXT,
FOREIGN KEY(user_id) REFERENCES users(id)
);
CREATE TABLE IF NOT EXISTS records (
record_id INTEGER PRIMARY KEY AUTOINCREMENT,
symbol text,
action text,
qty integer,
price real,
timestamp TEXT,
user_id INTEGER,
transaction_id INTEGER,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (transaction_id) REFERENCES transactions(transaction_id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment