views:

187

answers:

2

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?

+4  A: 

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.

JasonRShaver
This is a good point about, eg, varchar fields no longer being limited to a certain number of characters, which is something that has always bothered me about traditional RDMSes.
Jason Creighton
I thought there would be at least a few other 'answers' besides mine. This is just more evidence that we need to get SqLite.NET out there more. It is SO easy to use and deploy in places where you don't *need* SQL Server or Express.
JasonRShaver
+1  A: 

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).

dan04