I have two tables in SQL Server, one named Users
and the other named Connections
and connections is simply a connection between user and another user so my tables are like:
CREATE TABLE Users(
UserUID int IDENTITY NOT NULL,
UserUN NVARCHAR(100) NOT NULL,
UserPassword NVARCHAR(100) NOT NULL,
PRIMARY KEY(UserUID)
)
CREATE TABLE Connections(
_CID int IDENTITY NOT NULL,
_UID1 int not null,
_UID2 int not null,
_ConDate datetime null DEFAULT GETDATE(),
PRIMARY KEY(_CID),
FOREIGN KEY(_UID1) REFERENCES Users(UserUID) ON DELETE CASCADE,
FOREIGN KEY(_UID2) REFERENCES Users(UserUID) ON DELETE CASCADE
)
But every time I run the query it throws error:
Introducing FOREIGN KEY constraint 'FK_Connectio__UID2__69B1A35C' on table 'Connections' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
I tried searching in google and i found an answer that says I should do a trigger, but I don't know what is that. I hope I can find some answers and thanks a lot.