DROP TABLE IF EXISTS SHIFT_DISTRIBUTION;
CREATE TABLE SHIFT_DISTRIBUTION (
 	ID_INTERNAL int(11) NOT NULL auto_increment,
 	KEY_EXECUTION_YEAR int(11) NOT NULL,
  	KEY_ROOT_DOMAIN_OBJECT int(11) NOT NULL default '1',
	PRIMARY KEY (ID_INTERNAL),
	UNIQUE (KEY_EXECUTION_YEAR),
	KEY (KEY_EXECUTION_YEAR),
	KEY (KEY_ROOT_DOMAIN_OBJECT)
)TYPE=InnoDB;

DROP TABLE IF EXISTS SHIFT_DISTRIBUTION_ENTRY;
CREATE TABLE SHIFT_DISTRIBUTION_ENTRY (
 	ID_INTERNAL int(11) NOT NULL auto_increment,
 	ABSTRACT_STUDENT_NUMBER int(11) NOT NULL,
 	KEY_SHIFT_DISTRIBUTION int(11) NOT NULL,
 	KEY_SHIFT varchar(50) NOT NULL,
 	KEY_EXECUTION_DEGREE int(11) NOT NULL,
  	KEY_ROOT_DOMAIN_OBJECT int(11) NOT NULL default '1',
  	DISTRIBUTED bit default '0',
	PRIMARY KEY (ID_INTERNAL),
	UNIQUE (KEY_EXECUTION_DEGREE, KEY_SHIFT, ABSTRACT_STUDENT_NUMBER),
	KEY (KEY_EXECUTION_DEGREE),
	KEY (KEY_ROOT_DOMAIN_OBJECT)
)TYPE=InnoDB;
