Database
  Home arrow Database arrow Using SQLite for Simple Database Storage
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Using SQLite for Simple Database Storage
By: Clay Dowling
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 24
    2004-10-19

    Table of Contents:
  • Using SQLite for Simple Database Storage
  • SQLite in Action
  • An Example User Object
  • Saving a Record
  • Storing it in the Database
  • The Last Step

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using SQLite for Simple Database Storage


    (Page 1 of 6 )

    Web applications frequently need a persistent data store, and a database is often the most appropriate choice. Although some users have succeeded in using a file-based database engine such as Access, getting full SQL compliance usually involves a database engine. For a large number of applications, this adds unnecessary complexity. SQLite is a good compromise between simplicity and full SQL compliance.

    SQLite can be downloaded for free from http://www.sqlite.org. This site contains full documentation, binary versions for Linux and Windows, and wrappers for a very wide variety of languages.

    Features

    SQLite is a disk-based database engine. The entire database resides in a single disk file. Access control is provided by the operating system's own security. 

    Most of SQL92 is supported, including views, sub queries and triggers. The database is transaction compliant, although any transaction locks the entire database until it has completed.  It's easier to list the features that it doesn't support.  It doesn't support foreign key constraints, alter table statements, writable views, right and full outer joins, and the grant and revoke statements.  These are only the features that I use (or would use) regularly.  A complete list is available as part of the documentation.

    The one thing that isn't supported that might confuse people is data typing.  As far as SQLite is concerned, all data types are strings. As a C and C++ programmer, I revolted at this idea until I had a chance to put it into use.  As long as access to the database is controlled by the program, and you design uniform interfaces, the consistency checks provided by data typing are not as necessary.  For a language like PHP, which has a fairly flexible concept of data typing, the typeless database is pretty much unnoticed.

    SQLite is natively accessible through a C interface library that is remarkably easy to use.  It is also natively supported by PHP 5, and via an add-on module to PHP 4.  Wrapper libraries make it accessible to TCL, a COM interface makes it available for Visual Basic, ASP, ADO.Net, and the latest beta of Zeos Database Objects from http://www.zeoslib.net make SQLite available as a native database type to Delphi users.

    The database engine also allows multiple simultaneous users.
    Concurrency support is somewhat weak, because locking occurs on the entire database using the operating system's file locking support. 

    When to Use SQLite

    Because it doesn't require a database engine which has to be installed and maintained, SQLite is great for any situation where SQL support is necessary but simplicity is desired.

    If the application is to have multiple users, SQLite is a solid choice if most access is reading. Because of the locking issues, multi user applications with a high ratio of writes to reads and a heavy user load are not a good match with SQLite. For a situation like that, a server database engine is preferred.

    This combination of factors make SQLite a good choice for a lot of web applications, which make heavy use of persistent storage, but don't need to support a lot of interactive users at one time.  Guest book and user preference tools are good candidates because they typically require a very small number of writes per user and a whole lot of reads.

    More Database Articles
    More By Clay Dowling


       · Hello!Great article here. SQLite really is a simple, fast and powerful database...
       · Its a very helpful article...I have been looking for database designed with...
     

    DATABASE ARTICLES

    - Building Applications with Anonymous Types
    - A Closer Look at Anonymous Types
    - Programming with Anonymous Types
    - Converting Your Excel Worksheet into a Worki...
    - Excel Reference
    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek