SQLite Forum

Multi-column Foreign Key with one "hard-coded" column value
Login
Note that this technique, while working when using generated columns,  
is really a poor-man's substitute to a real type-system that supports  
enums, the way [PostgreSQL does](https://www.postgresql.org/docs/12/datatype-enum.html).

Given that `sqlite_` prefixed tables are reserved, we could have SQLite  
doing the heavy lifting behind the scenes, on inserts and selects.  
Given how SQLite is *flexibly typed* as Richard likes to say, a new  
enum(X) type which implicitly converts text to ints if it can, and stores  
everything as-is otherwise, would be possible, w/o any format change.  
It would just be one more of these features that if used, prevents older  
SQLite version from using the DB, although not even in practice, since a  
real value is always stored regardless, only known ints are implicitly  
converted back to the enum *text value* on select, or the reverse on insert.

Could even hook into the subtype machinery used by function call chains.

Using enums would be both storage efficient, and user friendly.  
I know, I know, SQLite is *lite*, and all...

Just thinking aloud :)