PostgreSQL

Tables:

Functions:

Transactions:

Querries:

Create tables: (outdated)

create table users (
id bigint generated always as identity primary key,
username varchar(50) not null,
balance decimal(15, 3)
);

create table holdings(
id bigint generated always as identityprimary key,
crypto_code varchar(10) not null,
unit_price numeric(38, 18) not null,
crypto_amount numeric(38, 18) not null,
local_currency_amount numeric(15, 3) not null,
is_purchase boolean not null,
trade_timestamp timestamptz not null default current_timestamp,
user_id int not null,
foreign key (user_id) references users(id)
);

create table portfolio(
id bigint generated always as identityprimary key,
crypto_code varchar(10) not null,
crypto_amount numeric(38, 18) not null,
user_id int not null,
foreign key (user_id) references users(id)
);

Functions: