SQL对数据子集的独特约束
我有一个 SQL Server 表 tbl_Submissions,其中包含任何给定 CaseID 的许多记录。每个提交都有一个 AuthorizedStatus 字段,可以是“授权”、“拒绝”、“撤销”。一个 CaseID 可能有多个被拒绝或撤销的提交,但只能有一个授权记录。
是否可以添加约束或索引来强制执行此操作?
I have a SQL Server table tbl_Submissions which contains a number of records for any given CaseID. Each Submission has an AuthorisedStatus field which can be "Authorised", "Rejected", "Rescinded". There could be multiple rejected or rescinded submissions for a CaseID, but there can only ever be one authorised record.
Is it possible to add a constraint or index to enforce this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它可以使用 过滤索引:
It could be implemeneted using filtered index: