3 ms·
You do sum types in SQL the same way you do everything else. You create more tables, and add relationships.
by marcosdumay 2y ago
You do sum types in SQL the same way you do everything else. You create more tables, and add relationships.
- burakemir 2y agoIn other words: you encode them. That is likely also the reason why many programming languages did not have sums. You have something else that can be used similarly. A sum type is a disjoint union so a straightforward encoding of A+B would be (tag:bool, A?, B?) in made-up syntax. When tag==0 then A is present When tag==1 then B is present On a different level, the fact that a column can be NULL itself can be considered a sum, like A? = A + {NULL}.