Created
October 15, 2020 21:55
-
-
Save dieissonmartins/1d31f4fc1ede2275da7ac822fa6a7163 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table if not exists banco ( | |
numero integer not NULL, | |
nome varchar(50), | |
ativo boolean not null default TRUE, | |
data_criacao timestamp not null default current_timestamp, | |
primary key (numero) | |
); | |
create table if not exists agencia ( | |
banco_numero integer not null, | |
numero integer not null, | |
nome varchar(89) not null, | |
ativo boolean not null default TRUE, | |
data_criacao timestamp not null default current_timestamp, | |
primary key (banco_numero,numero), | |
foreign key (banco_numero) references banco (numero) | |
); | |
create table if not exists cliente ( | |
numero bigserial primary key, | |
nome varchar(120) not null, | |
email varchar(120) not null, | |
ativo boolean not null default TRUE, | |
data_criacao timestamp not null default current_timestamp | |
); | |
create table if not exists conta_corrente ( | |
banco_numero integer not null, | |
agencia_numero integer not null, | |
numero bigint not null, | |
digito smallint not null, | |
cliente_numero bigint not null, | |
ativo boolean not null default TRUE, | |
data_criacao timestamp not null default current_timestamp, | |
primary key (banco_numero,agencia_numero,numero,digito,cliente_numero), | |
foreign key (banco_numero,agencia_numero) references agencia (banco_numero,numero), | |
foreign key (cliente_numero) references cliente (numero) | |
); | |
create table tipo_transacao ( | |
id smallserial primary key, | |
nome varchar(50) not null, | |
agencia_numero integer not null, | |
data_criacao timestamp not null default current_timestamp | |
); | |
create table cliente_transacoes ( | |
id smallserial primary key, | |
banco_numero integer not null, | |
agencia_numero integer not null, | |
conta_corrente_numero bigint not null, | |
conta_corrente_digito smallint not null, | |
cliente_numero bigint not null, | |
tipo_transacao_id smallint not null, | |
valor numeric(15,2), | |
data_criacao timestamp not null default current_timestamp, | |
foreign key (banco_numero,agencia_numero,conta_corrente_numero,conta_corrente_digito,cliente_numero) | |
references conta_corrente (banco_numero,agencia_numero,numero,digito,cliente_numero) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment