| ▲ | TylerE 3 hours ago | |
Isn’t that schema actually the opposite of poor for SQLite, since it stores everything as text internally? | ||
| ▲ | adityaathalye an hour ago | parent [-] | |
It employs "flexible typing", which does not mean "everything is text". What I am doing is writing fully denormalised text (strings) in most fields, with column type declared as TEXT. This is deliberate, to emulate "whoops, if I screw up my types, how bad does it get?". However, when written into the DB with some care, each value is stored per the following storage classes: https://sqlite.org/datatype3.html Quoting... ``` Each value stored in an SQLite database (or manipulated by the database engine) has one of the following storage classes:
A storage class is more general than a datatype. The INTEGER storage class, for example, includes 7 different integer datatypes of different lengths. This makes a difference on disk. But as soon as INTEGER values are read off of disk and into memory for processing, they are converted to the most general datatype (8-byte signed integer). And so for the most part, "storage class" is indistinguishable from "datatype" and the two terms can be used interchangeably.Any column in an SQLite version 3 database, except an INTEGER PRIMARY KEY column, may be used to store a value of any storage class. All values in SQL statements, whether they are literals embedded in SQL statement text or parameters bound to precompiled SQL statements have an implicit storage class. Under circumstances described below, the database engine may convert values between numeric storage classes (INTEGER and REAL) and TEXT during query execution. ``` (edits: formatting, clarify what I'm doing v/s what SQLite does) | ||