CREATE SCHEMA "MYSCHEMA";

CREATE TABLE "MYSCHEMA"."AFTERSALES" (
    "SONUM"    CHAR(5) NOT NULL,    
    "CUSTOMER" CHAR(5),    
    "YEAR"     CHAR(4),    
    "MONTH"    CHAR(2),    
    "DAY"      CHAR(2)    
);

CREATE TABLE "MYSCHEMA"."BEFORESALES" (
    "SONUM"    CHAR(5) NOT NULL,
    "CUSTOMER" CHAR(5),
    "GENDATE"  DATE
);

CREATE TABLE "MYSCHEMA"."CODEMASTER" (
    "BEFORECODE" CHAR(5) NOT NULL,
    "AFTERCODE"  CHAR(5)
);

ALTER TABLE "MYSCHEMA"."AFTERSALES"
  ADD CONSTRAINT "AFTERSALES_PK" PRIMARY KEY ("SONUM");

ALTER TABLE "MYSCHEMA"."BEFORESALES"
  ADD CONSTRAINT "BEFORESALES_PK" PRIMARY KEY ("SONUM");

ALTER TABLE "MYSCHEMA"."CODEMASTER"
  ADD CONSTRAINT "CODEMASTER_PK" PRIMARY KEY ("BEFORECODE");
