I want to build an SQL-based recipe editor for a brewery. I have n recipes:
I have 3 recipes (BeerA, BeerB and BeerC):
BeerA specific set-points could be:
BeerB has the same steps, same order, but with different set-points. BeerC has only 3 steps. What would be an example of table design? I was thinking:
How can I deal with steps using different set-points? I believe I need also a Setpoints table, but how to design it?
-- Beer category BCT exists.
--
category {BCT}
PK {BCT}
-- Brewing step STP exists
--
step {STP}
PK {STP}
-- Step sequence number ST# for brewing beer
-- of category BCT is step STP.
--
cat_step {BCT, ST#, STP}
PK {BCT, ST#}
FK1 {BCT} REFERENCES category {BCT}
FK2 {STP} REFERENCES step {STP}
-- Note: ST# in [1,2,3 ..]
-- Beer BER is of beer category BCT.
--
beer {BER, BCT}
PK {BER}
SK {BER, BCT}
FK {BCT} REFERENCES category {BCT}
-- Step sequence number ST# of recipe
-- for brewing beer BER of beer category BCT
-- is at temperature TMP deg, for TIM minutes.
--
recipe {BER, BCT, ST#, TIM, TMP}
PK {BER, ST#}
FK1 {BER, BCT} REFERENCES beer {BER, BCT}
FK2 {BCT, ST#} REFERENCES cat_step {BCT, ST#}
Note:
All attributes (columns) NOT NULL
PK = Primary Key
AK = Alternate Key (Unique)
SK = Proper Superkey (Unique)
FK = Foreign Key
Using suffix # to save on screen space.
OK for SQL Server and Oracle, for others use _NO.
For example, rename OPT# to OPT_NO.