Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is sqlite's manifest typing useful?

sqlite uses something that the authors call "Manifest Typing", which basically means that sqlite is dynamically typed: You can store a varchar value in a "int" column if you want to.

This is an interesting design decision, but whenever I've used sqlite, I've used it like a standard RDMS and treated the types as if they were static. Indeed, I've never even wished for dynamically typed columns when designing databases in other systems.

So, when is this feature useful? Has anybody found a good use for it in practice that could not have been done just as easily with statically typed columns?

like image 204
Jason Creighton Avatar asked May 20 '09 21:05

Jason Creighton


2 Answers

It really just makes types easier to use. You don't need to worry about how big this field needs to be at a database level anymore, or how many digets your intergers can be. More or less it is a 'why not?' thing.

On the other side, static typing in SQL Server allows the system to search and index better, in some cases much better, but for half of all applications, I doubt that database performance improvements would matter, or their performance is 'poor' for other reasons (temp tables being created every select, exponential selects, etc).

I use SqLite all the time for my .NET projects as a client cache because it is just too easy too use. Now if they can only get it to use GUIDs the same as SQL server I would be a happy camper.

like image 175
JasonRShaver Avatar answered Oct 15 '22 05:10

JasonRShaver


Dynamic typing is useful for storing things like configuration settings. Take the Windows Registry, for example. Each key is a lot like having an SQLite table of the form:

CREATE TABLE Settings (Name TEXT PRIMARY KEY, Value);

where Value can be NULL (REG_NONE) or an INTEGER (REG_DWORD/REG_QWORD), TEXT (REG_SZ), or BLOB (REG_BINARY).

Also, I'll have to agree with the Jasons about the usefulness of not enforcing a maximum size for strings. Because much of the time, those limits are purely arbitary, and you can count on someday finding a 32-byte string that needs to be stored in your VARCHAR(30).

like image 31
dan04 Avatar answered Oct 15 '22 06:10

dan04