drop table if exists RESULT_UNIT_ASSOCIATION;
drop table if exists RESULT_EVENT_ASSOCIATION;

CREATE TABLE RESULT_UNIT_ASSOCIATION (
  ID_INTERNAL int(11) NOT NULL auto_increment,
  KEY_RESULT int(11) NOT NULL default '0',
  KEY_UNIT int(11) NOT NULL default '0',
  KEY_ROOT_DOMAIN_OBJECT int not null,
  ROLE varchar(100),
  PRIMARY KEY  (ID_INTERNAL),
  KEY KEY_RESULT (KEY_RESULT),
  KEY KEY_UNIT (KEY_UNIT),
  UNIQUE (KEY_RESULT, KEY_UNIT, ROLE)
) ENGINE=InnoDB;

CREATE TABLE RESULT_EVENT_ASSOCIATION (
  ID_INTERNAL int(11) NOT NULL auto_increment,
  KEY_RESULT int(11) NOT NULL,
  KEY_EVENT int(11) NOT NULL,
  KEY_ROOT_DOMAIN_OBJECT int not null,
  ROLE varchar(100),
  PRIMARY KEY (ID_INTERNAL),
  KEY KEY_RESULT (KEY_RESULT),
  KEY KEY_EVENT (KEY_EVENT),
  UNIQUE (KEY_RESULT, KEY_EVENT, ROLE)
) Type=InnoDB;

