I am compiling a table that will be used to send subsequent messages to specific queries for information. The request is sent to a group of people, and responses are tracked. If the person does not respond, zero or more subsequent actions may be sent. I created a table:
FollowupId int primary key, RequestId int foreign key (outside this example), Follows int foreign key (FollowupId), Message varchar
If the message should be the first subsequent message, Follows will be null. Otherwise, this is the identifier of some other continuation. I also added a unique restriction on Follows. That is, any message can contain no more than one message.
EDIT: I must also allocate a foreign key for subsequent actions. It refers to the FollowupId in this table. Therefore, if A-> B-> C, just deleting B makes the foreign key in C invalid. Likewise, it is not possible to simply update C to follow A, because B is already following A, and a unique restriction prohibits duplication.
The problem, of course, is that deleting subsequent entries is difficult if this message is followed by something else. It seems to me that it should be possible to disable the constraint check so that you can remove the average check, "move" after the next steps, and then set the check again. Is there a way to disable the restriction on transaction time only?
(In addition, I am aware of the possible data inconsistency that occurs when RequestId is in this table. It might be better to have Followups [FollowupId, Message], InitialFollowups [FollowupId, RequestId] and AfterFollowups [FollowupId, Follows] I think this is unnecessary complicates this example.)