В NetBeans7, когда я пытаюсь добавить «Классы сущностей из базы данных», возникает следующая проблема: некоторые таблицы слева выделены серым и отмечены "(без первичных ключей)" , поэтомуЯ не могу их добавить.На самом деле первичные ключи верны.Таблицы группы, группы, год, специализация окрашены в серый цвет, все остальные в порядке.
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
DROP SCHEMA IF EXISTS `mydb` ;
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`Faculty`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Faculty` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Faculty` (
`idFaculty` INT NOT NULL ,
`name` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idFaculty`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Specialization`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Specialization` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Specialization` (
`idSpecialization` INT NOT NULL ,
`Faculty_idFaculty` INT NOT NULL ,
`Name` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idSpecialization`) ,
CONSTRAINT `fk_Specialization_Faculty`
FOREIGN KEY (`Faculty_idFaculty` )
REFERENCES `mydb`.`Faculty` (`idFaculty` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_Specialization_Faculty` ON `mydb`.`Specialization` (`Faculty_idFaculty` ASC) ;
-- -----------------------------------------------------
-- Table `mydb`.`Student`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Student` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Student` (
`idStudent` INT NOT NULL ,
`Specialization_idSpecialization` INT NOT NULL ,
`Name` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idStudent`) ,
CONSTRAINT `fk_Student_Specialization1`
FOREIGN KEY (`Specialization_idSpecialization` )
REFERENCES `mydb`.`Specialization` (`idSpecialization` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_Student_Specialization1` ON `mydb`.`Student` (`Specialization_idSpecialization` ASC) ;
-- -----------------------------------------------------
-- Table `mydb`.`Discipline`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Discipline` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Discipline` (
`idDiscipline` INT NOT NULL ,
`Name` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idDiscipline`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Lecturer`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Lecturer` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Lecturer` (
`idLecturer` INT NOT NULL ,
`Name` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idLecturer`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`GroupsYear`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`GroupsYear` ;
CREATE TABLE IF NOT EXISTS `mydb`.`GroupsYear` (
`idGroupsYear` INT NOT NULL ,
`Discipline_idDiscipline` INT NOT NULL ,
`Lecturer_idLecturer` INT NOT NULL ,
`Year` YEAR NOT NULL ,
PRIMARY KEY (`idGroupsYear`) ,
CONSTRAINT `fk_Groups_Year_Discipline1`
FOREIGN KEY (`Discipline_idDiscipline` )
REFERENCES `mydb`.`Discipline` (`idDiscipline` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_GroupsYear_Lecturer1`
FOREIGN KEY (`Lecturer_idLecturer` )
REFERENCES `mydb`.`Lecturer` (`idLecturer` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_Groups_Year_Discipline1` ON `mydb`.`GroupsYear` (`Discipline_idDiscipline` ASC) ;
CREATE INDEX `fk_GroupsYear_Lecturer1` ON `mydb`.`GroupsYear` (`Lecturer_idLecturer` ASC) ;
-- -----------------------------------------------------
-- Table `mydb`.`Groups`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Groups` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Groups` (
`idGroups` INT NOT NULL ,
`GroupsYear_idGroupsYear` INT NOT NULL ,
`Lecturer_idLecturer` INT NOT NULL ,
PRIMARY KEY (`idGroups`) ,
CONSTRAINT `fk_Group_GroupsYear1`
FOREIGN KEY (`GroupsYear_idGroupsYear` )
REFERENCES `mydb`.`GroupsYear` (`idGroupsYear` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Group_Lecturer1`
FOREIGN KEY (`Lecturer_idLecturer` )
REFERENCES `mydb`.`Lecturer` (`idLecturer` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_Group_GroupsYear1` ON `mydb`.`Groups` (`GroupsYear_idGroupsYear` ASC) ;
CREATE INDEX `fk_Group_Lecturer1` ON `mydb`.`Groups` (`Lecturer_idLecturer` ASC) ;
-- -----------------------------------------------------
-- Table `mydb`.`Current_Group_has_Student`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Current_Group_has_Student` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Current_Group_has_Student` (
`Groups_idGroups` INT NOT NULL ,
`Student_idStudent` INT NOT NULL ,
PRIMARY KEY (`Groups_idGroups`, `Student_idStudent`) ,
CONSTRAINT `fk_Groups_has_Student_Groups1`
FOREIGN KEY (`Groups_idGroups` )
REFERENCES `mydb`.`Groups` (`idGroups` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Groups_has_Student_Student1`
FOREIGN KEY (`Student_idStudent` )
REFERENCES `mydb`.`Student` (`idStudent` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_Groups_has_Student_Student1` ON `mydb`.`Current_Group_has_Student` (`Student_idStudent` ASC) ;
CREATE INDEX `fk_Groups_has_Student_Groups1` ON `mydb`.`Current_Group_has_Student` (`Groups_idGroups` ASC) ;
-- -----------------------------------------------------
-- Table `mydb`.`LongTimeAgo_Group_has_Student`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`LongTimeAgo_Group_has_Student` ;
CREATE TABLE IF NOT EXISTS `mydb`.`LongTimeAgo_Group_has_Student` (
`Groups_idGroups` INT NOT NULL ,
`Student_idStudent` INT NOT NULL ,
PRIMARY KEY (`Groups_idGroups`, `Student_idStudent`) ,
CONSTRAINT `fk_Groups_has_Student_Groups2`
FOREIGN KEY (`Groups_idGroups` )
REFERENCES `mydb`.`Groups` (`idGroups` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Groups_has_Student_Student2`
FOREIGN KEY (`Student_idStudent` )
REFERENCES `mydb`.`Student` (`idStudent` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_Groups_has_Student_Student2` ON `mydb`.`LongTimeAgo_Group_has_Student` (`Student_idStudent` ASC) ;
CREATE INDEX `fk_Groups_has_Student_Groups2` ON `mydb`.`LongTimeAgo_Group_has_Student` (`Groups_idGroups` ASC) ;
-- -----------------------------------------------------
-- Table `mydb`.`Past_Group_has_Student`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Past_Group_has_Student` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Past_Group_has_Student` (
`Groups_idGroups` INT NOT NULL ,
`Student_idStudent` INT NOT NULL ,
PRIMARY KEY (`Groups_idGroups`, `Student_idStudent`) ,
CONSTRAINT `fk_Groups_has_Student_Groups3`
FOREIGN KEY (`Groups_idGroups` )
REFERENCES `mydb`.`Groups` (`idGroups` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Groups_has_Student_Student3`
FOREIGN KEY (`Student_idStudent` )
REFERENCES `mydb`.`Student` (`idStudent` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_Groups_has_Student_Student3` ON `mydb`.`Past_Group_has_Student` (`Student_idStudent` ASC) ;
CREATE INDEX `fk_Groups_has_Student_Groups3` ON `mydb`.`Past_Group_has_Student` (`Groups_idGroups` ASC) ;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Для лучшего понимания: http://i.stack.imgur.com/cGsjG.png
Я надеюсь, что кто-то найдет ошибкув схеме.