-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
36 lines (32 loc) · 974 Bytes
/
schema.sql
File metadata and controls
36 lines (32 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
create database folha_pagamento
create table DEPARTAMENTO(
id serial primary key,
nome varchar (40) not null
);
create table FUNCIONARIO(
id serial primary key,
cpf varchar (11) not null unique,
nome varchar (30) not null,
data_nascimento date not null,
salario_bruto numeric (10,2) not null,
id_departamento int not null,
foreign key (id_departamento) references DEPARTAMENTO (id)
);
create table DEPENDENTE(
id serial primary key,
cpf varchar (11) unique not null,
nome varchar (30) not null,
data_nascimento date not null,
parentesco varchar(30),
cpf_funcionario varchar (11) not null,
foreign key (cpf_funcionario) references FUNCIONARIO (cpf)
);
create table FOLHA_PAGAMENTO(
id serial primary key,
cpf_funcionario varchar(11) unique not null,
data_pagamento date not null,
inss numeric (10,2) not null,
ir numeric (10,2) not null,
liquido numeric (10,2) not null,
foreign key (cpf_funcionario) references FUNCIONARIO (cpf)
);