tables
This commit is contained in:
43
banque.md
43
banque.md
@@ -30,51 +30,12 @@ Voir les adresses des serveurs [postgreSQL](https://sources.neotech.fr/Universit
|
||||
|
||||
Voir la syntaxe de [postgreSQL](syntaxe.md)
|
||||
|
||||
### 1. Titulaires
|
||||
|
||||
Création de la table `holder`.
|
||||
|
||||
```sql
|
||||
create table holder (
|
||||
"id" bigint primary key generated always as identity,
|
||||
"type" text,
|
||||
"created_at" timestamp
|
||||
);
|
||||
```
|
||||
|
||||
- entier sur 64 bits : `bigint`
|
||||
- clé primaire : `primary key`
|
||||
- incrément automatique : `generated always as identity`
|
||||
|
||||
Création de la table `person`.
|
||||
|
||||
```sql
|
||||
create table person (
|
||||
"id" bigint primary key references holder(id),
|
||||
"firstname" text,
|
||||
"lastname" text,
|
||||
"birthdate" date
|
||||
);
|
||||
```
|
||||
|
||||
- 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.
|
||||
|
||||
```sql
|
||||
create table company (
|
||||
"id" bigint primary key references holder(id),
|
||||
"name" text,
|
||||
"creation_date" date
|
||||
);
|
||||
```
|
||||
|
||||
```sql
|
||||
create table bank (
|
||||
"id" bigint primary key references holder(id),
|
||||
"name" text
|
||||
);
|
||||
```
|
||||
|
||||
```sql
|
||||
insert into holder (type) values ('BANK') returning holder;
|
||||
@@ -97,9 +58,7 @@ Il existe deux méthodes pour gérer le type.
|
||||
|
||||
2. utiliser une énumération `enum`.
|
||||
|
||||
```sql
|
||||
create type holder_type as enum ('BANK', 'PERSON', 'COMPANY');
|
||||
```
|
||||
|
||||
|
||||
#### 1.2 Vérifications
|
||||
|
||||
|
||||
Reference in New Issue
Block a user