diff --git a/banque.md b/banque.md index 679c3b1..38ea3e4 100644 --- a/banque.md +++ b/banque.md @@ -81,16 +81,16 @@ erDiagram text registration_numer date creation_date } - + holder { bigint id PK int person_id FK } - %% Relations + %% Relations - person ||--o{ holder : "is held by" - company ||--o{ holder : "is held by" + person ||--|| holder + company ||--|| holder ``` ## 2. Les comptes @@ -122,6 +122,66 @@ begin; commit; ``` +```mermaid +erDiagram + person { + bigint id PK + text firstname + text lastname + date birthdate + } + + company { + bigint id PK + text registration_numer + date creation_date + } + + bank { + bigint id PK + } + + holder { + bigint id PK + date creation_date + } + + account { + bigint id PK + date creation_date + decimal balance >0 + text currency_code FK + } + + account_holder { + bigint account_id FK + bigint holder_id FK + } + + transaction { + bigint id PK + date transaction_date + decimal amount + } + + currency { + text code PK + } + + currency { + text code PK + } + + %% Relations + + person ||--|| holder + company ||--|| holder + bank ||--|| holder + holder }|--|{ account_holder + account_holder }|--|{ account + +``` + ## 4. Procédure stockée Pour fiabiliser le process et être sûr que l'execution s'effectue toujours dans une transaction, diff --git a/banque.sql b/banque.sql index 1ac2ff4..d593176 100644 --- a/banque.sql +++ b/banque.sql @@ -98,7 +98,6 @@ create table account ( id bigint primary key generated always as identity, number text unique not null, opened_at date not null default current_date, - closed_at date, balance numeric(18,6) not null default 0 check (balance >= 0) );