deposit
This commit is contained in:
@@ -2,15 +2,12 @@
|
||||
|
||||
## 1. Les titulaires
|
||||
|
||||
|
||||
`person` : informations propres aux personnes physiques
|
||||
- prénom, nom, date de naissance
|
||||
|
||||
`company` : informations propres aux entreprises
|
||||
- raison sociale, numéro d’immatriculation, date de création
|
||||
|
||||
|
||||
|
||||
### 1.6 Contôle de l'âge
|
||||
|
||||
Contrainte déclarative
|
||||
|
||||
22
banque.sql
22
banque.sql
@@ -1,5 +1,6 @@
|
||||
drop schema bank cascade;
|
||||
drop schema if exists bank cascade;
|
||||
create schema bank;
|
||||
set search_path TO bank;
|
||||
|
||||
/*
|
||||
* Holder : table commune à tous les titulaires
|
||||
@@ -71,12 +72,12 @@ insert into holder(type) values ('PERSON') returning id;
|
||||
insert into person(id, firstname, lastname, birthdate)
|
||||
values (3, 'Lucas', 'Zanetti', '2002-05-09');
|
||||
|
||||
select * from person;
|
||||
select * from holders_list;
|
||||
|
||||
delete from holder where id = 3;
|
||||
|
||||
-- La suppresion du titulaire entraine la suppression de l'individu
|
||||
select * from person;
|
||||
select * from holders_list;
|
||||
|
||||
-- Contrainte sur l'âge du titulaire
|
||||
alter table person
|
||||
@@ -170,7 +171,7 @@ begin;
|
||||
insert into holder(type) values ('PERSON') returning id;
|
||||
|
||||
insert into person(id, firstname, lastname, birthdate)
|
||||
values (6, 'Justin', 'Hébrard', '1993-03-11');
|
||||
values (6, 'Mattéo', 'Zanetti', '2012-12-12');
|
||||
|
||||
commit;
|
||||
|
||||
@@ -309,9 +310,9 @@ end;
|
||||
$$;
|
||||
|
||||
CREATE TABLE transaction (
|
||||
id SERIAL PRIMARY KEY,
|
||||
id bigint primary key generated always as identity,
|
||||
account_id INT NOT NULL REFERENCES account(id),
|
||||
amount NUMERIC(12, 2) NOT NULL CHECK (amount <> 0),
|
||||
amount NUMERIC(18, 6) NOT NULL CHECK (amount <> 0),
|
||||
operation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
@@ -368,4 +369,13 @@ BEGIN
|
||||
END;
|
||||
$$;
|
||||
|
||||
CALL deposit(1, 500);
|
||||
CALL withdraw(1, 200);
|
||||
CALL withdraw(1, 1000); -- Doit échouer
|
||||
|
||||
create table entry (
|
||||
id bigint primary key generated always as identity,
|
||||
transaction_id bigint,
|
||||
amount NUMERIC(18, 6) NOT NULL CHECK (amount <> 0),
|
||||
sens
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user