I have a table materials
which contains (I'm using web2py):
materials_db.define_table('materials',
Field('name','string'),
Field('reference','string'),
Field('manufacturer','string'),
Field('date_added','date'),
Field('density','double'), # Density - kg/m³
Field('emissivity','double'),
Field('specific_heat','double'), # Specific Heat - kJ/kg.K
Field('thermal_conductivity','double') # Thermal conductivity - W/m.K
)
I now would like to create a table constructions
. Each construction is an assembly of any number of materials in an ordered way, e.g. something like this:
+------------+-------+
| Material | Layer |
+------------+-------+
| Concrete | 1 |
| Airgap | 2 |
| Insulation | 3 |
| Plaster | 4 |
+------------+-------+
Layer
should enable changing the location of a material in the construction. Constructions will have new properties that will be calculated from the properties of the materials used and the location within the construction.
I don't really have a clue on how to go about it. The value for layer
within a construction must be unique, however obviously must not be unique between constructions, i.e. every construction can have a layer with the value 1.
Do I need to create a new table for each construction and then reference all these table in my table constructions
? That's the only vague idea I have at the moment, however that doesn't seem quite right... Is there a good way of doing this?