I'm working on building a simulator for HVAC units. The conceptual model I am working with is basically that an HVAC unit has inputs and outputs, and I need to be able to calculate the outputs for a particular input. An HVAC Unit is comprised of some base stats, but those could be altered by adding other components to the unit (e.g. adding a bigger fan changes the electricity draw, and also airflow).
Conceptually it looks something like this:

In code, we'll design a number of classes for these components and subcomponents that will each handle the individual input/output calculations based on metadata stored in a database (e.g. every Fan might work identically, but might have different electrical draw, or airflow characteristics, so we'd have one Fan class, but it would take parameters to define the size of changes to the inputs as they become outputs).
I'm pretty confident all of that can be handled easily enough, what I am struggling with is how to store the "shape" of the unit in the database, as it needs to know the order components exist and potentially which inputs and outputs it has. I'm of two minds of it.
- Store just what components and what order they are in
- e.g. Unit ABC has a data table that looks like
Name | Order | Owning Unit
Filter | 1 | ABC
Fan | 2 | ABC
Heat Exchanger | 3 | ABC
And then our classes understand that a Filter needs Outside Air 1 as its inputs, passes through any other inputs, and provide an altered Outside Air 1 as an output as well. Similarly, Fan (in our example at least) takes Inside Air 1, Outside Air 1, and Input Electrical 1 and delivers Mixed Air and Electrical. Finally, Heat Exchanger takes Mixed Air and Electrical and returns Outflow Air 1, Outflow Air 2, and Output Electrical 1. When the unit "runs" it takes in the three inputs, passes them through all its child components, and delivers the relevant outputs.
- Some way of storing the references to the "next" component on a particular intput/output. I have no clue exactly how to do this though.
Does idea 1 sound plausible? Is there a way to do idea 2 that doesn't involve a lot of really nasty joining?