|
create table dept (
code int not null,
dep_code int null,
name char (50) not null,
constraint PK_DEPT primary key (code)
)
go
alter table dept
add constraint FK_DEPT_RELATIONS_DEPT foreign key (dep_code)
references dept (code)
go
------------------
code is the primary key of the department table, and dept_code is a special foreign key, which is a reference to its own primary key (code), which means that dept has a one-to-many relationship with itself. |
|