假设我有 2 张桌子
CREATE TABLE [dbo].[People](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Nom] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_People] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
和
CREATE TABLE [dbo].[Transactions](
[ID] [int] IDENTITY(1,1) NOT NULL,
[BUYER_ID] [int] NOT NULL,
[SELLER_ID] [int] NOT NULL,
[DateTransaction] [datetime] NOT NULL,
CONSTRAINT [PK_Transactions] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
逻辑是事务表需要来自人员表的 2 条记录,买家和卖家。
我想要做的是在 BUYER_ID 和 SELLER_ID 列上实现级联删除。
但是,我可以毫不费力地添加一个(任何一个),但是如果我尝试添加第二个,当我去保存时,我会收到一条错误消息......
Unable to create relationship 'FK_Transactions_Buyer'.
Introducing FOREIGN KEY constraint 'FK_Transactions_Buyer' on table 'Transactions' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
有没有办法在不使用触发器的情况下执行此操作,或者触发器是执行此操作的最佳方法