     ON UPDATE CASCADE)
 ENGINE = InnoDB;
 
+
+-- -----------------------------------------------------
+-- Table `ledita-web-app`.`composes`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `ledita-web-app`.`composes` ;
+
+CREATE  TABLE IF NOT EXISTS `ledita-web-app`.`composes` (
+  `id` INT NOT NULL ,
+  `ld_id` INT NOT NULL ,
+  `activity_id` INT NULL ,
+  `ld_part_id` INT NULL ,
+  `activity_group_id` INT NULL ,
+  `order` INT UNSIGNED NULL ,
+  INDEX `fk_activity_has_ld_ld1_idx` (`ld_id` ASC) ,
+  INDEX `fk_activity_has_ld_activity1_idx` (`activity_id` ASC) ,
+  INDEX `fk_composes_activity_group1_idx` (`activity_group_id` ASC) ,
+  INDEX `fk_ld_is_part_of_ld1_idx` (`ld_part_id` ASC) ,
+  PRIMARY KEY (`id`) ,
+  CONSTRAINT `fk_activity_has_ld_activity1`
+    FOREIGN KEY (`activity_id` )
+    REFERENCES `ledita-web-app`.`activity` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION,
+  CONSTRAINT `fk_activity_has_ld_ld1`
+    FOREIGN KEY (`ld_id` )
+    REFERENCES `ledita-web-app`.`ld` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION,
+  CONSTRAINT `fk_composes_activity_group1`
+    FOREIGN KEY (`activity_group_id` )
+    REFERENCES `ledita-web-app`.`activity_group` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION,
+  CONSTRAINT `fk_ld_is_part_of_ld1`
+    FOREIGN KEY (`ld_part_id` )
+    REFERENCES `ledita-web-app`.`ld` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `ledita-web-app`.`participates`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `ledita-web-app`.`participates` ;
+
+CREATE  TABLE IF NOT EXISTS `ledita-web-app`.`participates` (
+  `id` INT NOT NULL ,
+  `activity_group_id` INT NOT NULL ,
+  `activity_id` INT NULL ,
+  `ld_is_part_id` INT NULL ,
+  PRIMARY KEY (`id`) ,
+  INDEX `fk_activity_has_activity_group_activity_group1_idx` (`activity_group_id` ASC) ,
+  INDEX `fk_activity_has_activity_group_activity1_idx` (`activity_id` ASC) ,
+  INDEX `fk_ld_has_acitivty_group_idx` (`ld_is_part_id` ASC) ,
+  CONSTRAINT `fk_activity_has_activity_group_activity1`
+    FOREIGN KEY (`activity_id` )
+    REFERENCES `ledita-web-app`.`activity` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION,
+  CONSTRAINT `fk_activity_has_activity_group_activity_group1`
+    FOREIGN KEY (`activity_group_id` )
+    REFERENCES `ledita-web-app`.`activity_group` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION,
+  CONSTRAINT `fk_ld_has_acitivty_group`
+    FOREIGN KEY (`ld_is_part_id` )
+    REFERENCES `ledita-web-app`.`ld` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `ledita-web-app`.`supports`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `ledita-web-app`.`supports` ;
+
+CREATE  TABLE IF NOT EXISTS `ledita-web-app`.`supports` (
+  `technology_id` INT NOT NULL ,
+  `activity_id` INT NOT NULL ,
+  PRIMARY KEY (`technology_id`, `activity_id`) ,
+  INDEX `fk_technology_has_activity_activity1_idx` (`activity_id` ASC) ,
+  INDEX `fk_technology_has_activity_technology1_idx` (`technology_id` ASC) ,
+  CONSTRAINT `fk_technology_has_activity_technology1`
+    FOREIGN KEY (`technology_id` )
+    REFERENCES `ledita-web-app`.`technology` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION,
+  CONSTRAINT `fk_technology_has_activity_activity1`
+    FOREIGN KEY (`activity_id` )
+    REFERENCES `ledita-web-app`.`activity` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `ledita-web-app`.`describes`
+-- -----------------------------------------------------
+DROP TABLE IF EXISTS `ledita-web-app`.`describes` ;
+
+CREATE  TABLE IF NOT EXISTS `ledita-web-app`.`describes` (
+  `id` INT NOT NULL AUTO_INCREMENT ,
+  `tag_id` INT NOT NULL ,
+  `comment_id` INT NULL ,
+  `activity_id` INT NULL ,
+  PRIMARY KEY (`id`) ,
+  INDEX `fk_activity_has_tag_tag1_idx` (`tag_id` ASC) ,
+  INDEX `fk_describes_comment1_idx` (`comment_id` ASC) ,
+  INDEX `fk_describes_activity1_idx` (`activity_id` ASC) ,
+  CONSTRAINT `fk_activity_has_tag_tag1`
+    FOREIGN KEY (`tag_id` )
+    REFERENCES `ledita-web-app`.`tag` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION,
+  CONSTRAINT `fk_describes_comment1`
+    FOREIGN KEY (`comment_id` )
+    REFERENCES `ledita-web-app`.`comment` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION,
+  CONSTRAINT `fk_describes_activity1`
+    FOREIGN KEY (`activity_id` )
+    REFERENCES `ledita-web-app`.`activity` (`id` )
+    ON DELETE NO ACTION
+    ON UPDATE NO ACTION)
+ENGINE = InnoDB;
+
 USE `ledita-web-app` ;
 
 



-- -----------------------------------------------------
-- Table `ledita-web-app`.`needs`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `ledita-web-app`.`needs` ;

  `id` INT NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(100) NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `ledita-web-app`.`comment`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `ledita-web-app`.`comment` ;

CREATE  TABLE IF NOT EXISTS `ledita-web-app`.`comment` (
  `id` INT NOT NULL AUTO_INCREMENT ,
  `user_id` INT NOT NULL ,
  `comment_father_id` INT NOT NULL DEFAULT 0 ,
  `ld_id` INT NOT NULL ,
  `content` VARCHAR(2000) NOT NULL ,
  `creation_date` DATETIME NOT NULL ,
  `last_edit_date` TIMESTAMP NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_comment_user1_idx` (`user_id` ASC) ,
  INDEX `fk_comment_comment1_idx` (`comment_father_id` ASC) ,
  INDEX `fk_comment_ld1_idx` (`ld_id` ASC) ,
  CONSTRAINT `fk_comment_user1`
    FOREIGN KEY (`user_id` )
    REFERENCES `ledita-web-app`.`user` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_comment_comment1`
    FOREIGN KEY (`comment_father_id` )
    REFERENCES `ledita-web-app`.`comment` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_comment_ld1`
    FOREIGN KEY (`ld_id` )
    REFERENCES `ledita-web-app`.`ld` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `ledita-web-app`.`activity_group`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `ledita-web-app`.`activity_group` ;

CREATE  TABLE IF NOT EXISTS `ledita-web-app`.`activity_group` (
  `id` INT NOT NULL AUTO_INCREMENT ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `ledita-web-app`.`tag`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `ledita-web-app`.`tag` ;

CREATE  TABLE IF NOT EXISTS `ledita-web-app`.`tag` (
  `id` INT NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(255) NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `ledita-web-app`.`likes`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `ledita-web-app`.`likes` ;

CREATE  TABLE IF NOT EXISTS `ledita-web-app`.`likes` (
  `user_id` INT NOT NULL ,
  `ld_id` INT NOT NULL ,
  INDEX `fk_ld_has_user_user1_idx` (`user_id` ASC) ,
  INDEX `fk_ld_has_user_ld1_idx` (`ld_id` ASC) ,
  PRIMARY KEY (`user_id`, `ld_id`) ,
  CONSTRAINT `fk_ld_has_user_ld1`
    FOREIGN KEY (`ld_id` )
    REFERENCES `ledita-web-app`.`ld` (`user_id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ld_has_user_user1`
    FOREIGN KEY (`user_id` )
    REFERENCES `ledita-web-app`.`user` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


