> i am getting following error in sql
> server express while defining foreign
> key could any body resolve my problem
>
> > 'tbl_branch' table saved successfully
> > 'tbl_students' table
> > - Unable to create relationship 'FK_tbl_students_tbl_branch'.
> > Introducing FOREIGN KEY constraint
> > 'FK_tbl_students_tbl_branch' on table
> > 'tbl_students' may cause cycles or
> > multiple cascade paths. Specify ON
> > DELETE NO ACTION or ON UPDATE NO
> > ACTION, or modify other FOREIGN KEY
> > constraints. Could not create
> > constraint. See previous errors.
> >
> > > Blockquote
答案 0 :(得分:1)
我很确定这是警告您有外键的“循环引用”;即tbl_branch有一个指向tbl_students的外键,而tbl_students有一个指向tbl_branch的外键。
具体问题是您已启用级联删除或更新。这意味着当您删除tbl_branch中的行时,它将尝试删除tbl_students中的关联记录,这将尝试删除tbl_branch中的关联记录等。换句话说,您可能会导致循环级联删除。
关闭级联删除/更新,或删除“循环”外键。