Take the following example table:
CREATE TABLE [dbo].[tbl_Example](
[PageID] [int] IDENTITY(1,1) NOT NULL,
[RequireLogin] [bit] NOT NULL,
[RequireAdmin] [bit] NOT NULL,
[HideIfLoggedIn] [bit] NOT NULL
)
How would one rewrite the above to include check constraints as follows:
- Force
[RequireAdmin]
to be False if[RequireLogin]
is False (i.e only allow[RequireAdmin]
to be True if[RequireLogin]
is True whilst allowing[RequireLogin]
to be True and[RequireAdmin]
to be False - Only allow
[HideIfLoggedIn]
to be True if[RequireLogin]
is False