A family of Microsoft relational database management systems designed for ease of use.
Rather than having IsSeasonal and IsAvailableThisMonth columns in the Products table create the following related table:
MonthsAvailable
….ProductID (FK – Long Integer Number)
….MonthAvailable (Integer Number)
Create an enforced relationship between Products and this table on ProductID. The primary key of this table is a composite of the two columns. For each seasonal product this table would include one or more rows with values for the months in which the product is available. The following query would return all seasonal products available in the current month:
SELECT *
FROM Products INNER JOIN MonthsAvailable
ON Products.ProductID = MonthsAvailable.ProductID
WHERE MonthAvailable = MONTH(DATE());
If you want to return all seasonal products available in the current month, and all non-seasonal products, i.e. those with no matching rows in MonthAvailable:
SELECT *
FROM Products INNER JOIN MonthsAvailable
ON Products.ProductID = MonthsAvailable.ProductID
WHERE MonthAvailable = MONTH(DATE()) OR MonthAvailable IS NULL;
The above is one of the few situations in which a query can be restricted on a column on the right side of a LEFT OUTER JOIN. Alternatively for non-seasonal products you could include 12 rows for each in MonthsAvailable, with values from 1 to 12, and use the first query.