0

問題を検索しましたが、解決策が見つかりません。

1対1の関係であり、スタッフへのFKを持つ他のテーブルでも同じ問題があります

私は取得し続けます

  error 1005 error no 105

テーブル構造

CREATE TABLE `staff` (
  `StaffNumber` varchar(5) NOT NULL,
  `Firstname` varchar(45) DEFAULT NULL,
  `Lastname` varchar(45) DEFAULT NULL,
  `Insertion` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`StaffNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8


CREATE TABLE `airmarshall` (
  `weaponNumber` int(11) NOT NULL,
  `Nationality` varchar(45) NOT NULL,
  `Snumber` varchar(5) NOT NULL,
  `SnumberA` varchar(5) NOT NULL,
  PRIMARY KEY (`Snumber`,`SnumberA`),
  CONSTRAINT `staff_ibfk_1` FOREIGN KEY (`Snumber`) REFERENCES `staff` (`StaffNumber`)     
  ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
4

1 に答える 1

0
 In Mysql Server version: 5.1.60   


mysql> CREATE TABLE `staff` (   `StaffNumber` varchar(5) NOT NULL,   `Firstname` varchar(45) DEFAULT NULL,   `Lastname` varchar(45) DEFAULT NULL,   `Insertion` varchar(45) DEFAULT NULL,   PRIMARY KEY (`StaffNumber`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    Query OK, 0 rows affected (0.15 sec)


    mysql> CREATE TABLE `airmarshall` (
        ->   `weaponNumber` int(11) NOT NULL,
        ->   `Nationality` varchar(45) NOT NULL,
        ->   `Snumber` varchar(5) NOT NULL,
        ->   `SnumberA` varchar(5) NOT NULL,
        ->   PRIMARY KEY (`Snumber`,`SnumberA`),
        ->   CONSTRAINT `staff_ibfk_1` FOREIGN KEY (`Snumber`) REFERENCES `staff` (`StaffNumber`)     
        ->   ON DELETE CASCADE ON UPDATE CASCADE
        ->  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    Query OK, 0 rows affected (0.16 sec)

    mysql> show create table airmarshall;
    -----------------------------------+
    | airmarshall | CREATE TABLE `airmarshall` (
      `weaponNumber` int(11) NOT NULL,
      `Nationality` varchar(45) NOT NULL,
      `Snumber` varchar(5) NOT NULL,
      `SnumberA` varchar(5) NOT NULL,
      PRIMARY KEY (`Snumber`,`SnumberA`),
      CONSTRAINT `staff_ibfk_1` FOREIGN KEY (`Snumber`) REFERENCES `staff` (`StaffNumber`) ON DELETE CASCADE ON UPDATE CASCADE
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
于 2012-10-09T12:22:20.740 に答える