I am creating a Posts SQL table where I need to save:
1. If the post is approved;
2. When the post was approved.
I am considering naming these columns IsApproved and ApprovedAt:
create table dbo.Posts ( Id int identity not null, IsApproved bit null, ApprovedAt datetime null ) Is there any convention for such a case?
boolean, but your naming convention is reasonable.BITcolumn unless there's a really good reason to, because you raise the specter of what it means for a binary condition to be "unknown". PreferNOT NULLand a sensible default (in this case,0). Or, as you mentioned, if it can never be the case thatIsApproved = 1andApprovedAt IS NULL, then makeIsApproveda computed column (IsApproved = CONVERT(BIT, CASE WHEN ApprovedAt IS NULL THEN 0 ELSE 1 END)).IsApprovedcolumn. As for the naming conventions, Is... and ...Date are very reasonable for bit and date.