Changes between Initial Version and Version 1 of WikiStart/Optimization/vtora_verzija


Ignore:
Timestamp:
04/01/25 21:49:55 (2 months ago)
Author:
203206
Comment:

db2

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart/Optimization/vtora_verzija

    v1 v1  
     1== Оптимизиран SQL-код, кој работи поедноставно и побрзо
     2
     3
     4=== DDL код
     5{{{
     6create table account(
     7    id serial primary key,
     8    username varchar(255) not null,
     9    email varchar(255) not null,
     10    password varchar(255) not null,
     11    balance decimal(15, 2) not null
     12);
     13
     14create table "transaction"(
     15    id serial primary key,
     16    amount decimal(15, 2) not null,
     17    currency varchar(255) not null,
     18    type varchar(50) not null,
     19    timestamp timestamp default current_timestamp,
     20    account_id int not null,
     21    foreign key (account_id) references account(id)
     22);
     23
     24create table transfer(
     25    id serial primary key,
     26    s_id int not null,
     27    r_id int not null,
     28    foreign key(s_id) references account(id),
     29    foreign key(r_id) references
     30    account(id)
     31
     32);
     33
     34create table deposit(
     35    id serial primary key,
     36    account_id int not null,
     37    amount decimal(15,2) not null,
     38    timestamp timestamp default current_timestamp,
     39    foreign key(account_id) references account(id)
     40);
     41
     42create table withdraw(
     43    id serial primary key,
     44    account_id int not null,
     45    amount decimal(15,2) not null,
     46    timestamp timestamp default current_timestamp,
     47    foreign key(account_id) references account(id)
     48);
     49
     50create table transferred_money(
     51    id serial primary key,
     52    s_account_id int not null,
     53    r_account_id int not null,
     54    t_id int not null,
     55    currency varchar(50) not null,
     56    foreign key (s_account_id) references account(id),
     57    foreign key (r_account_id) references account(id),
     58    foreign key (t_id) references transaction(id)
     59);
     60
     61}}}