Re:A Pure Types-Driven real-world apps development approach
by codeismath on Sunday September 12, 2021 @08:10AM
(#28500450)
I do this too in some apps. Very near exactly how you show it.
How do you enforce required fields in the data model? By eliminating the possibility of null values, you eliminate the possibility of not-null constraints in the data model. I end up having to enforce these types of (non-complex) constraints outside the relational model. A missing row is not detectable in the same way as a null column value.
Re:A Pure Types-Driven real-world apps development approach
by archibaldJ on Sunday September 12, 2021 @02:50PM
(#28503701)
This is really interesting; if we hook this up with hasura we can still get some nice graphql endpoints
This already exists in my view. With enough discipline, you can accurately encode any type system into the relational model itself. Something to settle up front is the notion of basic types vs domain types. Basic types are required anywhere and you just need to target the simplest subset that is guaranteed to work everywhere - string, int, guid, date, bool, etc.
Domain types are the most important part of solving complex problems. If it would help, this is an example of one of my schemas. Each line item below is a table:
The above encodes a fairly detailed view of the domain in my opinion. If you look carefully, you will see that Null is not possible here and that complex data types are strictly enforced.