No, you use rows for everything... One Items table with the various item specs. Another table Prices with a date field, a foreign item key field and the price listed for that item at that date. Then you query them:
SELECT * FROM [Items] INNER JOIN [Prices] ON [Items].[ItemId] = [Prices].[ExItemId] WHERE [Prices].[DateOfPrice] = CONVERT(DateTime, '05/04/2012')
This makes it completely scalable, and you can add more features in the future simply by adding more relationships to other tables containing whatever additional info you want to add. For example let's say you also wanted to track the source (let's say supplier name) of each daily price, you could add a Sources table with fields for the supplier's contact info, and add an ExSourceId field to your Prices table, and modify your query like so to retrieve the contact info of the price source for one particular item on one particular day:
SELECT *
FROM [Items] INNER JOIN [Prices]
ON [Items].[ItemId] = [Prices].[ExItemId]
INNER JOIN [Sources]
ON [Sources].[SourceId] = [Prices].[ExSourceId]
WHERE [Prices].[DateOfPrice] = CONVERT(DateTime, '05/04/2012')
AND [Items].[ItemId] LIKE 'PART10293'


LinkBack URL
About LinkBacks




Reply With Quote



Bookmarks