|
|
|
|
|
by 35mm
1403 days ago
|
|
Thanks! I’m trying to define a product model which can have multiple types, each of which has required attributes. For example a solar panel has to have a peak output, but no energy storage. But a battery type of product is required to have a storage capacity. |
|
Why is this an "escape hatch"? Well, if you want to process that data later, it would most likely be very convenient, if you had all product attributes as columns, instead of having them as rows in another table. One would then have to translate back to the usual form of having them as columns. It is possible, but annoying. However, if you never need to analyze the data like that, then storing in this kind of extra table might solve all your use cases. It is ultimately a trade-off between safety or type strictness and flexibility (being able to add arbitrary attributes without having to change the schema).
Another, but in my opinion quite bad, solution is, to have loads of empty columns for future attributes. But it is really a terrible solution, running contrary to any good database design.