CREATE TABLE CATEGORIES(
 ID NUMBER(7) NOT NULL,
 NOM VARCHAR2(50) NOT NULL,
 CONSTRAINT PK_CAT PRIMARY KEY (ID)
) TABLESPACE ACME_APP;

create sequence categories_id_seq;
create trigger trg_emp_id
  before insert on CATEGORIES
  for each row
begin
  select categories_id_seq.nextval
    into :new.ID
    from dual;
end;
/

CREATE TABLE PRODUITS(
ID NUMBER(8) NOT NULL,
ID_CATEGORIE NUMBER(8),
NOM VARCHAR2(150),
CONSTRAINT PK_PROD PRIMARY KEY (ID),
CONSTRAINT FK_PROD_CAT FOREIGN KEY (ID_CATEGORIE) REFERENCES CATEGORIES(ID)
) TABLESPACE ACME_APP;

create sequence produits_id_seq;
create trigger trg_produits_id
  before insert on PRODUITS
  for each row
begin
  select produits_id_seq.nextval
    into :new.ID
    from dual;
end;
/

REM -- ADMIN tablespace

CREATE TABLE CLIENTS(
ID NUMBER(8) NOT NULL,
NOM VARCHAR2(50) NOT NULL,
CONSTRAINT PK_CLIENTS PRIMARY KEY (ID)
) TABLESPACE ACME_ADMIN;

create sequence clients_id_seq;
create trigger trg_clients_id
  before insert on PRODUITS
  for each row
begin
  select clients_id_seq.nextval
    into :new.ID
    from dual;
end;
/

CREATE TABLE BACKUPLOGS(
ID NUMBER(8) NOT NULL,
LOG_DATE DATE NOT NULL,
CONSTRAINT PK_LOGS PRIMARY KEY (ID)
) TABLESPACE ACME_ADMIN;

create sequence backuplogs_id_seq;
create trigger trg_backuplogs_id
  before insert on BACKUPLOGS
  for each row
begin
  select backuplogs_id_seq.nextval
    into :new.ID
    from dual;
end;
/