I am working on a table that will hold batch data.
The table will have a BatchDate column as a DateTime type. I'm considering adding a column for BatchYear as an integer and BatchPeriod (which could be a week number, a month number or a quarter number) as an integer, even though both of these values can be derived from the BatchDate and using another column in the table.
I'm considering doing this because I'm thinking it would be easier to work with queries where someone doesn't have to pull the date from the table first, compute the period they want and then query the table again. Also, if someone is looking for a batch from the 3rd quarter of 2012, the server would have to convert each BatchDate to it's quarter equivalent and do the same for the year and then test for a match, but if the values are there in separate columns, one could simply query the BatchPeriod and the BatchYear column for a match.
Is this a bad idea to break normal form this way?
>=
and<
? This will eliminate the need for these additional columns and will also be able to use an index on the datetime column. The "pull the date from the table first" doesn't really make much sense, SQL doesn't work that way unless you literally mean run a query that gets ALL the dates, and then use that for a second query, which is not exactly efficient.