With this kind of thing, it's a little awkward: you have to define the values somewhere and re-use these same values elsewhere. I decided to define them in an enum and re-use the defined values in the database.
ActionRight.ActionRightID isn't an identity field btw:
CREATE TABLE [ActionRight] (
[ActionRightID] [int] NOT NULL ,
[ActionRightDescription] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[AppliesToForum] [bit] NOT NULL ,
[AppliesToSystem] [bit] NOT NULL ,
CONSTRAINT [TF_ActionRight_PK] PRIMARY KEY CLUSTERED
(
[ActionRightID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
So the same values are stored in the table. Yes, this might be 'shaky' perhaps, but there's no other way to do this: the code must know that '1' means actionright X and not Y, so the best place to do that is in the code, i.e. an enum. That values in the db might be changeable, so be it: you can't prevent that anyway, one can switch the descriptions for 1 and 2 for example.
(btw, Walaa and others have also written code for HnD )