Я бы снял ограничения, но вот, пожалуйста.
CREATE TABLE DEPARTMENTS (
Department_Id varchar(5) Primary Key,
Department_Name char(20) NOT NULL,
Manager_Id varchar(5),
Location_Id varchar(5)
)
GO
CREATE TABLE EMPLOYEES (
Employee_Id varchar(5) Primary Key,
First_Name char(20) NOT NULL,
Last_Name char(20) NOT NULL,
Email varchar(60) NULL,
PhoneNumber varchar(13) NULL,
Hire_Date date NOT NULL,
Manager_ID varchar(5),
Department_Id varchar(5)
)
GO
CREATE TABLE LOCATIONS (
Location_ID varchar(5) Primary Key,
Postal_Code varchar(5),
City varchar(60),
State_Province varchar(20),
Country varchar(60)
)
GO
ALTER TABLE DEPARTMENTS WITH CHECK ADD CONSTRAINT [FK_DepartmentManager] FOREIGN KEY([Manager_Id])
REFERENCES EMPLOYEES ([Employee_Id])
GO
ALTER TABLE DEPARTMENTS WITH CHECK ADD CONSTRAINT [FK_UserLocation] FOREIGN KEY([Location_Id])
REFERENCES LOCATIONS ([Location_Id])
GO
ALTER TABLE EMPLOYEES WITH CHECK ADD CONSTRAINT [FK_EmployeeManager] FOREIGN KEY([Manager_Id])
REFERENCES EMPLOYEES ([Employee_Id])
GO
ALTER TABLE EMPLOYEES WITH CHECK ADD CONSTRAINT [FK_EmployeeDepartment] FOREIGN KEY([Department_Id])
REFERENCES DEPARTMENTS ([Department_Id])
GO