Earlier quoted context omitted.
> The downside of strict tables is that some data types are not available, such as Date. There are only 5 datatypes in sqlite. INTEGER, TEXT, BLOB, REAL, and NUMERIC. https://sqlite.org/datatype3.html
Right, and that's the problem. There should be DATE and BOOL as well, especially in strict mode.
Prefer strict tables in SQLite
141–150 of 188 posts
Re: Prefer strict tables in SQLite
#142https://sqlite.org/flextypegood.html explains why this isn't the default (and probably will never be the default). > rigid type enforcement can successfully prevent the customer name (text) from being inserted into the integer Customer.creditScore column. On the other hand, if that mistake occurs, it is very easy to spot the problem and find all affected rows. That doesn't line up with my experience. (In particular,…
Re: Prefer strict tables in SQLite
#143Yeah my DB is the one place I want strict types. Well also RPCs. But SQLite is a somewhat different set of use cases, so maybe I'd understand https://sqlite.org/flextypegood.html more if I were using it. Like there's a point about random scripts not made for SQLite happening to work with it, which isn't normally a consideration for other DBMSes.
> https://sqlite.org/flextypegood.html Both the advantages and disadvantages section is missing key arguments. Key argument in favor of flexible typing: Easy to evolve schema. When you are using SQLite to store data in your embedded database and your requirements change, do you want to create a new database and migrate data each time? Evolving the schema in-place is much easier, and if your application is the only on…
Additionally, how often are there multiple apps with different release schedules written using Sqlite? I would expect overwhelmingly large number of its use cases would be a single application working on it.
Re: Prefer strict tables in SQLite
#144Coming from the enterprise SQL world, I never took SQLite seriously for the very reason that field types were not enforced by default. (Yes, I was agog when it became the backbone for app metadata on smartphones.) Anyway, reading this reminds me of the old chestnut from networking about choosing UDP over TCP for its low-latency and simplicity and then eventually adding nearly all the reliability facilities of TCP to…
The difference is that when you add all these mechanisms yourself, you can do it differently than TCP does, sometimes to a great effect: see QUIC and HTTP/3. OTOH I don't see a similar superpower arising from handcrafted data type enforcement over (non-strict) SQLite.
Datagram is also quite often more fit for applications than streams, because many applications are message oriented. The Websocket protocol acknowledges that even though over TCP. But that's more a bonus point than a strong reason to choose UDP over TCP, one can always recreate packets/messages on top of TCP. It's a bit goofy though, because TCP uses IP packets.
A lot of online games with significant real-time constrains and many-to-many connections gladly use UDP - and similarly, video conference services also use it. Smaller protocols like DNS and NTP as well.
There are other arguments beside real-time streaming with acceptable data loss, see [1] and the "end-to-end argument" paper it links in particular.
Choosing UDP and ending up recreating some of its reliability and flow control features is not a "Uh, Oh..." moment. It's normally a deliberate choice. Sometimes you do need custom wheels [2].
Re: Prefer strict tables in SQLite
#145Earlier quoted context omitted.
I also want to be able to debug the database in an SQL console with nice looking date-times.
You can already do that: https://sqlite.org/lang_datefunc.html
Re: Prefer strict tables in SQLite
#146Earlier quoted context omitted.
The downside is that you loose the place to store the metadata that a column is supposed to store a date. Which is why I prefer not to use them.
A comment will do more than a nonsensical type which is not enforced: it won’t have the wrong affinity, it will spell out what the concrete type is, and there’s no limit to what it can specify. Domain types would be the best fix, but I do not think legacy tables are the second best.
I can use either API to trigger bool and time handling in my Go driver.
https://github.com/ncruces/go-sqlite3/blob/main/driver/drive...
Re: Prefer strict tables in SQLite
#147Earlier quoted context omitted.
'0' and '1', while not ideal, seems fine to maintain? There is not even a true SQLite boolean type. Then again, I have been subjected to Oracle nonsense for too long and have had to accept all of the boolean alternatives: 0,1,'0','1',Y,N,y,n,YES,NO,T,F, etc
When you need many booleans on a table, use an integer with bitwise and/or to record them as powers of 2. I have done this many times. Function-based indexes are necessary if they must be searched.
Re: Prefer strict tables in SQLite
#148Earlier quoted context omitted.
Is it better to learn that it exists through surprise , by way of an engine upgrade suddenly changing the behavior of the software you wrote while in the bliss of your ignorance?
> Is it better to learn that it exists through surprise , by way of an engine upgrade suddenly changing the behavior of the software you wrote while in the bliss of your ignorance? The premise of your question doesn't work. If one person is going to learn about the option and a second one isn't, the better system for that to occur in is the one in which more people end up with correct behavior. In this case, that mea…
Re: Prefer strict tables in SQLite
#149Earlier quoted context omitted.
When you need many booleans on a table, use an integer with bitwise and/or to record them as powers of 2. I have done this many times. Function-based indexes are necessary if they must be searched.
Why would you do that? To save some bytes in storage?
That's one 64-bit number, or 50 different columns.
Re: Prefer strict tables in SQLite
#150Earlier quoted context omitted.
A large portion of the tests are closed source unfortunately which would make it tough to create a port.
What the hell? This is the first I'm learning of this. Why did they do that? Is it owned by a private company?