---
# System prepended metadata

title: Untitled

---


CREATE SEQUENCE mavariable_seq;

CREATE TABLE (
    macleprimaire montype PRIMARY KEY DEFAULT NEXTVAL('macleprimaire_seq')
    ,....
)
CREATE SEQUENCE escale_seq;


CREATE SEQUENCE bateau_seq;
CREATE SEQUENCE conteneur_seq;

CREATE SEQUENCE proprietaire_seq;


CREATE TABLE bateau(
    num_bateau INT PRIMARY KEY DEFAULT NEXTVAL('bateau_seq')
    ,nom TEXT
    )

CREATE TABLE escale(
    num_escale INT PRIMARY KEY DEFAULT NEXTVAL('escale_seq')
    ,num_bateau INT REFERENCES bateau
    ,date_arrivee DATE
    ,date_depart DATE
    CHECK (date_depart <= date_arrivee)
    )

CREATE TABLE proprietaire
(
num_proprietaire INT PRIMARY KEY DEFAULT NEXTVAL('proprietaire_seq')
,nom TEXT
,prenom TEXT
)

CREATE TYPE mon_type AS ENUM ('machaine1', 'machaine2');
CREATE TYPE taille_conteneur AS ENUM ('standard','demi');


CREATE TABLE conteneur(
      num_conteneur INT PRIMARY KEY DEFAULT NEXTVAL ('conteneur_seq')
      , taille taille_conteneur
      , num_proprietaire INT REFERENCES proprietaire
      )
      


CREATE TABLE mouvement
(
 num_escale INT REFERENCES escale 
,num_conteneur INT REFERENCES conteneur
,poids REAL
,pays TEXT
,est_chargement BOOL
,date_mouvement DATE
,PRIMARY KEY(num_escale, num_conteneur)
)