PostgreSQL
Tables:
- user - id, balance, username
- transactions - id, crypto_code, unit_price, crypto_amount, local_currency_amount, is_purchase, timestamp, user_id
- holdings - id, crypto_code, crypto_amount, user_id
Functions:
- User Management
- Holdings
- Transaction info (all, but short)
- Transaction info (one, but detailed)
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: