express-backend-uni/sql/create_db.sql
2024-06-01 14:47:24 +02:00

26 lines
697 B
SQL

CREATE TABLE accounts (
number integer NOT NULL,
name text NOT NULL,
qualifiedName text NOT NULL UNIQUE,
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_name text NOT NULL,
amount float,
label text,
FOREIGN KEY (transaction_id) REFERENCES transactions (transaction_id) FOREIGN KEY (account_name) REFERENCES account (account_qualifiedName) PRIMARY KEY (transaction_id, account_id)
);