January 2008
Intermediate to advanced
384 pages
8h 1m
English
The start and stop times are what you should have been catching in the first place and not the computed hours. Think raw data and single facts when designing a table. Let me use a history table for price changes. The fact to store is that a price had duration:
CREATE TABLE PriceHistory (sku CHAR(13) NOT NULL REFERENCES Inventory (sku), start_date DATE NOT NULL, end_date DATE, -- null means current CHECK(start date < end_date), PRIMARY KEY (sku, start_date), item_price DECIMAL (12,4) NOT NULL CHECK (item_price > 0.0000), etc.);
You actually need more checks to assure that the start date is at 00:00 Hrs if you cannot work with whole days in your SQL engine. This is the case with MS SQL Server and the Sybase family. Likewise, ...
Read now
Unlock full access