I have data that I need to store in look up tables. I've tried a couple of combinations of tables and keep getting stumped with the best way to store them because I keep feeling like I'm duplicating, but can make an argument for each way I choose to store. So I was hoping to get some feedback from folks here.The business problem is that I have valid combinations that come from a production database. The combinations themselves have descriptions. The descriptions then have valid date ranges and a status associated with them during that date range. This is what I have now (writing as declared tables and shortened for ease of use):declare @PassClassCombo table (PCCId int, Tnum int, Ttype int)insert into @PassClassCombo (PCCId, Tnum, Ttype)values(1, 2, 119),(2, 2, 143),(3, 2, 144),(4, 7, 118),(5, 8, 119)declare @PassClassStatus table (PCSId int, PCCid int, PassClassDescription varchar(20), FromDate date, ToDate date, IsActive tinyint)insert into @PassClassStatus (PCSId, PCCid, PassClassDescription, FromDate, ToDate, IsActive)values(1, 1, 'RegularFare', '2011-01-01', '2011-06-30', 0),(2, 1, 'NonFare', '2011-07-01', null, 1),(3, 2, 'SchoolFare', '2011-01-01', '2011-06-30', 0),(4, 2, 'University', '2011-07-01', null, 1),(5, 3, 'PSD', '2011-01-01', null, 1),(6, 4, 'CSU', '2011-01-01', null, 1),(7, 5, 'MTP', '2011-01-01', '2011-08-30', 0)declare @checkdate dateset @checkdate='2012-01-01'select *from @PassClassCombo PCCjoin @PassClassStatus PCS on PCS.PCCid=PCC.PCCIdwhere PCS.IsActive=1 and PCS.FromDate<=@checkdate and (PCS.ToDate>=@checkdate or PCS.ToDate is null)
The results are as expected; the issue is whether or not I'm storing this properly. The data will be read-only as this is for reporting purposes only.The first table, @PassClassCombo is used primarily during an insert query to ensure that only valid combinations are taken from production and loaded into a small archive or data warehouse that I'm developing. But since there are no descriptions in the table, once I need to get a look up on the PCCId from other tables, it's just easier to go directly to the second table (@PassClassStatus). So I'm wondering if I really need to separate them out, or maybe move the description to the first table.Thanks folks!