express-backend-uni/sql/create_db.sql
2024-04-18 16:53:26 +02:00

27 lines
731 B
SQL

CREATE TABLE accounts (
account_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
qualifiedName TEXT NOT NULL,
description TEXT NOT NULL,
type TEXT NOT NULL,
balance FLOAT NOT NULL,
localBalance FLOAT NOT NULL
);
CREATE TABLE transactions (
transaction_id INTEGER PRIMARY KEY,
postingDate TEXT NOT NULL,
valueDate TEXT,
title TEXT NOT NULL
);
CREATE TABLE transaction_entries (
transaction_id INT,
account_id INT,
amount FLOAT,
label TEXT,
FOREIGN KEY (transaction_id) REFERENCES transactions(transaction_id)
FOREIGN KEY (account_id) REFERENCES account(account_id)
PRIMARY KEY (transaction_id, account_id)
);