CREATE TABLE Performances (
DT Datetime NOT NULL,
Name varchar(20) NOT NULL,
Start_Time time NULL,
Min_price integer NOT NULL,
Max_price integer NOT NULL,
Location Varchar (20) NOT NULL,
PRIMARY KEY (DT, Name),
create Table [TYPE OF SHOWS] (
Name Varchar (20) NOT NULL ,
Type_of_show Varchar (20),
PRIMARY KEY (Name),
CONSTRAINT fk_PerformanceName FOREIGN KEY (Name)
REFERENCES Performances (Name),
)
我无法仅将外键设置为“名称”,该如何实施呢?
答案 0 :(得分:1)
我怀疑您实际上是想要这种关系,Performances
引用了Type of Shows
,例如:
create Table [TYPE OF SHOWS] (
Name Varchar (20) NOT NULL ,
Type_of_show Varchar (20),
PRIMARY KEY (Name)
);
CREATE TABLE Performances (
DT Datetime NOT NULL,
Name varchar(20) NOT NULL,
Start_Time time NULL,
Min_price integer NOT NULL,
Max_price integer NOT NULL,
Location Varchar (20) NOT NULL,
PRIMARY KEY (DT, Name),
CONSTRAINT fk_PerformanceName FOREIGN KEY (Name) REFERENCES [TYPE OF SHOWS](Name)
);