I'd like to have two columns in a database, one for tracking whether or not the user has submitted something, and another for the timestamp of that submission.
How can I structure the table definition so that the state of these two columns is never inconsistent?
Basically, I'd like the boolean field to be driven by whether or not a SubmittedDate column is null. Here's a snippet of the table definition:
CREATE TABLE SomeSchema.SomeTable
(
...
SubmittedDate datetime NULL,
Submitted bit NOT NULL DEFAULT(0), -- Drive off of SubmittedDate?
...
)
What's the best way to accomplish this?
Thanks!