我正在为一个学校项目做这个,现在我们假设使用MySQL而不是我们想要的任何东西,我不知道为什么外键的WorksFor会产生1215个错误。
CREATE TABLE Employees(
employee_id INT (8),
last_name VARCHAR (30),
first_name VARCHAR (30),
status CHAR (7),
PRIMARY KEY (employee_id)
);
CREATE TABLE Departments(
department_name VARCHAR (25),
department_master_key CHAR (3),
PRIMARY KEY (department_name)
);
CREATE TABLE WorksFor(
department_name VARCHAR (25),
employee_id INT (8) ,
PRIMARY KEY (department_name, employee_id),
FOREIGN KEY (employee_id) REFERENCES Employees (employee_id),
FOREIGN KEY (department_name) REFERENCES Departments (department_name)
);