currency
This commit is contained in:
47
banque.md
47
banque.md
@@ -428,8 +428,6 @@ create table person (
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
|
||||
- Créer un compte individuel pour _Françoise Zanetti_, née le 12 avril 1995.
|
||||
- Créer une entreprise nommée _Boulangerie de Valorgue_, créée le 19 août 2014, numéro d’immatriculation FR19803269968.
|
||||
- Ajouter un nouveau titulaire : _Justin Hébrard_ né le 11/03/1993.
|
||||
@@ -498,6 +496,15 @@ Cette procédure doit :
|
||||
|
||||
### 2. Les comptes
|
||||
|
||||
```sql
|
||||
create table account (
|
||||
"id" bigint primary key generated always as identity,
|
||||
"creation_date" date default current_date,
|
||||
"balance" decimal check (balance >= 0),
|
||||
"currency_code" text references currency (code)
|
||||
);
|
||||
```
|
||||
|
||||
- Le solde des comptes ne peuvent être négatifs.
|
||||
- Créez un compte joint à 50/50 pour Françoise et Justin.
|
||||
|
||||
@@ -586,7 +593,41 @@ Doit refuser la création avec une erreur claire :
|
||||
```
|
||||
ERROR: La somme des parts (1.1000) doit être égale à 1.0000
|
||||
```
|
||||
### 3. Monnaies et taux de change
|
||||
|
||||
### 3. Les opérations et transactions
|
||||
```sql
|
||||
create table currency (
|
||||
code text primary key
|
||||
);
|
||||
```
|
||||
|
||||
```sql
|
||||
create table exchange_rate (
|
||||
"currency_code" text references currency(code) on delete cascade,
|
||||
"date" date ,
|
||||
"rate" decimal not null,
|
||||
primary key (currency_code, date)
|
||||
);
|
||||
```
|
||||
|
||||
### 4. Les opérations et transactions
|
||||
|
||||
Implémenter les transactions et opérations.
|
||||
|
||||
```sql
|
||||
create table transaction (
|
||||
"id" bigint primary key generated always as identity,
|
||||
"transaction_date" timestamp default current_timestamp,
|
||||
amount decimal check (amount > 0)
|
||||
);
|
||||
```
|
||||
|
||||
```sql
|
||||
create table operation (
|
||||
"id" bigint primary key generated always as identity,
|
||||
"transaction_id" bigint references transaction(id),
|
||||
"account_id" bigint references account(id),
|
||||
amount decimal check (amount > 0),
|
||||
direction text check (direction in ('DEBIT', 'CREDIT'))
|
||||
);
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user