sql server programming:
I posted a question earlier today (9:25 AM). Subject: Storing DateTime
Values - Sometimes with time, Sometimes without.
If you review that thread you'll see how quickly it got WAY off topic. So I
hope it's not considered rude for me to repost the same question again
within 24 hours. I really need some relevant suggestions... thus this
new/recycled post.
My situation is that I have a "real world" mess on my hands. To summarize,
here is the short version of this difficult situation:
1. We must store values for measurements; some of which the business does
not care about the time of day, and some of which they do care about the
time of day; and all of which they do care about the date the measure was
taken.
2. There is a lot of historical data (13+ years worth) of which a large
percentage is missing time of day. The client is a medical clinic associated
with a university medical center and they want to use the data for research
purposes. And yes, they understand AND have documented the flaws accumulated
in the data over more than a couple of other database implementations over
the years (and now we're migrating it into yet another and hopefully better
model). While there are some problems, they are well-known AND there is
still a huge amount of valid and reliable data. We're trying to do better
for the future while keeping the extensive historical data available in the
same database.
3. There are [up to] hundreds of things measured about each patient. Some
measures are recorded quantitatively and others qualitatively. Some "things
we measure" have one result (patient's pulse) while other things have two
results (blood pressure has systolic and diastolic values).
4. There could reasonably be many NULLs for any given set of measurements
for any given patient. Men don't have any measures collected related to
various pregnancy-related factors. Some people don't smoke. Head
circumference is measured over time for infants, but is not measured for
adults, and on and on and on. Some people have no known allergic reactions
to certain medications - thus no list of medications they are allergic to.
That should give you a pretty good idea of the challenges being faced.
Rather than asking you to solve all of my problems, I'm simply seeking
guidance on how to store date and time values when the time value is not
always known or cared about.
Because there are up to hundreds of things being measured, we don't want to
store the data in columns. Rather we are likely going to define 3 tables. We
have not created them yet, but they would be something like this:
ThingsWeMeasure, Patients, PatientsXThingsWeMeasure.
PatientsXThingsWeMeasure would look something like this:
PatientID int NOT NULL
MeasurementID int NOT NULL
WhenWeMeasuredIT datetime NOT NULL
Value varchar(10) NOT NULL
So my specific question is do we keep WhenWeMeasuredIT as it is? Or should
we split the date and time columns out, with a "TimeWeMeasuredIt" column
that is nullable?
Thoughts, opinions, perspective?
Thanks!