create table adherent (
  id int primary key,
  nom text,
  prenom text,
  genre text,
  naissance date,
  pays text
);

\COPY adherent FROM '/tmp/adherent.csv' (FORMAT CSV, header, ENCODING 'UTF8');

create table famille (
  famille text primary key,
  intitule text,
  type int,
  unite int
);

\COPY famille FROM '/tmp/famille.csv' (FORMAT CSV, header, ENCODING 'UTF8');

create table article (
  code text primary key,
  article text,
  famille text, -- references famille(famille)
  factpoids int,
  unitevente int,
  prix decimal,
  unitepoids int,
  publie int,
  suivistock int,
  sommeil int
);

\COPY article FROM '/tmp/article.csv' (FORMAT CSV, header, ENCODING 'UTF8');

create table ticket (
  id int primary key,
  date_ticket timestamp,
  client_id int,
  mode_rglt int
);

\COPY ticket FROM '/tmp/ticket.csv' (FORMAT CSV, header, ENCODING 'UTF8');

create table ligne (
  id int primary key,
  ticket_id int, --references ticket (id),
  article text, -- references article (code)
  prix_unitaire decimal,
  quantite decimal
);

\COPY ligne FROM '/tmp/ligne.csv' (FORMAT CSV, header, ENCODING 'UTF8');
