wiki:WikiStart/DB

Version 3 (modified by 203206, 2 months ago) ( diff )

db1

Релациона шема

DLL код

create table account(
    id serial primary key,
	username varchar(255) not null,
	password varchar(255) not null,
	balance decimal(15, 2) not null 
);

create table "transaction"(
    id serial primary key,
	amount decimal(15, 2) not null,
	type varchar(50) not null,
	timestamp timestamp default current_timestamp,
	account_id int not null,
	foreign key (account_id) references account(id)
);

create table transfer(
    id serial primary key,
    s_id int not null,
    r_id int not null, 
    foreign key(s_id) references account(id),
    foreign key(r_id) references
    account(id)

);

create table deposit(
    id serial primary key,
	account_id int not null,
	amount decimal(15,2) not null,
	timestamp timestamp default current_timestamp,
	foreign key(account_id) references account(id)
);

create table withdraw(
    id serial primary key,
	account_id int not null,
	amount decimal(15,2) not null,
	timestamp timestamp default current_timestamp,
	foreign key(account_id) references account(id)
);

create table transferred_money(
	id serial primary key, 
	s_account_id int not null, 
	r_account_id int not null, 
	t_id int not null, 
	currency varchar(50) not null, 
	foreign key (s_account_id) references account(id),
	foreign key (r_account_id) references account(id),
	foreign key (t_id) references transaction(id)
);


Note: See TracWiki for help on using the wiki.