Monday, March 19, 2012

Maintaining a Date/Time Last Updated Value

Using SQL Server 2000...
In support of a Web site's product catalogs; we will have at least two
tables [Products] and [ProductCatalogs].
The application needs to show the Date/Time any given product catalog was
last updated. For purposes of this "last updated date/time" value, we
consider the catalog as having been updated when [anything about the
catalog, itself] has been updated OR [any items presented in the catalog]
have been updated. This means one Date/Time value when either (1) the given
catalog's row in [ProductCatalogs] or (2) any associated rows in [Products]
have been updated. We do not need a complete update history - we only want
to know the last date/time an update happened to either the given catalog or
to any of the items presented in the catalog (and not any "per item" update
date/time).
One solution would be to have a column in [ProductCatalogs] of the DateTime
data type. The value in this column gets maintained by triggers on both
[Products] and [ProductCatalogs].
While that solution would work, I'd appreciate your perspective, opinions,
and alternatives - if any - before I go off and implement this.
Thanks!As far as I can see, you only need one datetime field on the table
ProductCatalogs. If you have only one way of updating your data (through
stored procedure) I would recommend implementing this logic in the stored
procedure. If not (or you think that someone could change data without using
sp) you would need to implement triggers.
MC
"Jeff" <Jeff@.NoSpam.com> wrote in message
news:u87GGjH9FHA.3020@.TK2MSFTNGP09.phx.gbl...
> Using SQL Server 2000...
> In support of a Web site's product catalogs; we will have at least two
> tables [Products] and [ProductCatalogs].
> The application needs to show the Date/Time any given product catalog was
> last updated. For purposes of this "last updated date/time" value, we
> consider the catalog as having been updated when [anything about the
> catalog, itself] has been updated OR [any items presented in the catalog]
> have been updated. This means one Date/Time value when either (1) the
> given catalog's row in [ProductCatalogs] or (2) any associated rows in
> [Products] have been updated. We do not need a complete update history -
> we only want to know the last date/time an update happened to either the
> given catalog or to any of the items presented in the catalog (and not any
> "per item" update date/time).
> One solution would be to have a column in [ProductCatalogs] of the
> DateTime data type. The value in this column gets maintained by triggers
> on both [Products] and [ProductCatalogs].
> While that solution would work, I'd appreciate your perspective, opinions,
> and alternatives - if any - before I go off and implement this.
> Thanks!
>

No comments:

Post a Comment