-- ALTER TABLE BASEATTRIB_T DROP COLUMN BA_ROLE;
-- DROP TABLE ROLES_T;

-- Table ROLES_T
CREATE TABLE ROLES_T (
  ROLE_ID  NUMBER  NOT NULL,
  ROLE_NAME  VARCHAR2(50)  NOT NULL,
  CONSTRAINT ROLEID_PK
     PRIMARY KEY ( ROLE_ID )
);

INSERT INTO ROLES_T VALUES (20, 'NO_ROLE');
INSERT INTO ROLES_T VALUES (21, 'KEY');
INSERT INTO ROLES_T VALUES (22, 'LABEL');
INSERT INTO ROLES_T VALUES (23, 'PREDICTOR');

ALTER TABLE BASEATTRIB_T ADD 
  BA_ROLE NUMBER;
ALTER TABLE BASEATTRIB_T ADD 
  CONSTRAINT BA_ROLE_FK 
     FOREIGN KEY ( BA_ROLE )
     REFERENCES ROLES_T ( ROLE_ID );
     
UPDATE BASEATTRIB_T SET BA_ROLE = 20;

-- simplifying the conceptual data types:
UPDATE baseattrib_t SET ba_condtid = 1 WHERE ba_condtid IN (1,2,3,4);
UPDATE baseattrib_t SET ba_condtid = 7 WHERE ba_condtid IN (6,7,8,9);
UPDATE baseattrib_t SET ba_condtid = 10 WHERE ba_condtid IN (5,10);
