【发布时间】:2017-04-03 07:23:47
【问题描述】:
我在 SQL Server 2012 中创建一些表的查询如下:
create table Poll_Question_Table (
PollQuestionId int primary key,
PollQuestionTex varchar(max),
PollStatus int ,
PollStartDate date,
PollEndDate date,
PollCatagoryId int foreign key references Poll_Catagory_Table on update cascade on delete cascade
)
create table Poll_Catagory_Table(
PollCatagoryId int primary key,
PollCatagoryName varchar(100),
PollCatagoryDescription varchar(max)
)
create table Poll_Answer_Table(
PollAnswerId int primary key,
PollAnswerText varchar(max),
PollQuestionId int foreign key references Poll_Question_Table on update cascade on delete cascade
)
create table Poll_Vote_Table (
PollVoteId int primary key,
PollQuestionId int foreign key references Poll_Question_Table on update cascade on delete cascade ,
PollAnswerId int foreign key references Poll_Answer_Table on update cascade on delete cascade,
PollCount int
)
错误是
引入 FOREIGN KEY 约束 'FK__Poll_Vote__PollA__5A3A55A2' on 表 'Poll_Vote_Table' 可能会导致循环或多个级联路径。 指定 ON DELETE NO ACTION 或 ON UPDATE NO ACTION,或修改其他 外键约束。 我该如何解决这个问题
【问题讨论】:
-
标记您正在使用的 dbms。也添加其他两个表定义。
-
为什么要在删除了下表的记录后从主表中删除?
标签: sql sql-server