H5N1 wrote:
Unfortunately it means adding tens of "WHERE FiscalYearID =
@CurrentFiscalYearID" in all queries, or something similar, which seem
not so elegant and error prone.
It feels awkward for me, since for the whole year I would like to be
able to abstract from temporal dimension - current year records are
usually the whole universe for me (except some historical data
reporting).
Does it ring any bell? Could anybody point me in a right direction (if
it exists)? I'd be gratefull for any comments.
--
The other problem is DB duplication when the year ends - what would be
the recommended way to do that - to duplicate every record in db,
changing only relationship to next FiscalYear record (ms sql server)?
--
Thanks a lot
H.N.
--
You seem to be somewhat confused as what you want/need. You say
that you only want to deal with one year, but you also say that
you sometimes need to deal with historical data.
--
you're right, it wasn't too clear - what I meant was that in 95% of all
operations I would be dealing with the current year. So the question
wasn't wether to keep historical data (because I need it fo reports)
but rather how to construct queries in a such way that I would not have
to add WHERE year=@current for each query for each table.
So have the "current" year tables. THe previous years data should be in
a Datawarehouse, ie, another set of tables, which includes the "year"
in the key.
Assuming you need the historical data you should keep the
information for all of the years you are interested in in a
single table and include a column with the year in each row of
the table.
I just thought about other way - I construct something like database
view for each table (but not read-only), some kind of virtual table
(it's just a fuzzy idea) so that it would contain only records from the
current year. When I would add record to this table, it would be
automatically added to it's corresponding 'real' table with current
year value. (Maybe it would be normal table with trigger on update,
updating corresponding table?).
A view is better. It puts the "WHERE year=<current year>" where the
programmer doesn't need to think about it.
Another option would be to, once a year, create all those auxilliary
tables by copying old values (from last year) to the normal, additional
tables and perform all main queries on them (then I could abstract the
temporal dimension, since they wouldn't containt YEAR column), and,
after fiscal year ends - to copy all the values to main tables, with
YEAR column filled appropriately.
I think you are copying in the wrong direction.
Just to be sure that you get why would I do that - in such case I could
abstract from year value in all queries pertaining budget planning by
using CurrentYear* (i.e. select * FRM CurrentYearBudgetTypes) tables,
and use WHERE only in reporting queries (i.e. select * from BudgetTypes
WHERE year="1996").
What do you guys think about it? May look strange, but isn't it more
convenient and less error prone?
--
thanks a lot
Well, You proposed about three solutions there, so it is kind of hard
to say which "it" you want us to think about.
Suggestion: the corporate structure does not change automatically,
instantaneously at midnight of newsyears Eve. Think aboiut the
implications of that fact. It should help drive your thoughts toward a
good solution.
Ed