SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `vn2008`.`department`;

CREATE TABLE `vn2008`.`department` (
  `department_id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
  `lft` int(11) NOT NULL,
  `rgt` int(11) NOT NULL,
  `Id_Trabajador` int(11) DEFAULT NULL COMMENT 'Id_Trabajador es el jefe del departamento',
  `company_id` int(11) NOT NULL,
  `father_id` int(11) DEFAULT NULL,
  `boss_id` int(11) DEFAULT NULL,
  `x` int(11) DEFAULT NULL,
  `y` int(11) DEFAULT NULL,
  `production` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`department_id`),
  UNIQUE KEY `lft_UNIQUE` (`lft`),
  UNIQUE KEY `rgt_UNIQUE` (`rgt`),
  UNIQUE KEY `name_UNIQUE` (`name`),
  KEY `fk_department_Trabajadores1_idx` (`Id_Trabajador`),
  KEY `dep_org_ibfk_3_idx` (`company_id`),
  KEY `fk_department_department1_idx` (`father_id`),
  KEY `fk_department_department1_idx_idx` (`father_id`),
  CONSTRAINT `fk_department_Trabajadores1` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE,
  CONSTRAINT `fk_department_department1_idx` FOREIGN KEY (`father_id`) REFERENCES `department` (`department_id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


SET FOREIGN_KEY_CHECKS=1;