SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. It means a simplicity. Simplicity in a database engine can be either a strength or a weakness, depending on what you are trying to do.
A. Appropriate Uses
The primary design goal of SQLite is to be simple:
- Simple to administer
- Simple to operate
- Simple to embed in a larger program
- Simple to maintain and customize
So use SQLite in situations where simplicity of administration, implementation, and maintenance are more important than the countless complex features that enterprise database engines provide. SQLite is small, fast and reliable. Reliability is a consequence of simplicity. With less complication, there is less to go wrong.
B. Situations Where SQLite Works Well
1. Application File Format
SQLite has been used with great success as the on-disk file format for desktop applications such as financial analysis tools, CAD packages, record keeping programs, and so forth. The traditional File/Open operation does an sqlite3_open() and executes a BEGIN TRANSACTION to get exclusive access to the content. The use of transactions guarantees that updates to the application file are atomic, consistent, isolated, and durable (ACID).
2. Embedded devices and applications
SQLite is a good choice for devices or services that must work unattended and without human support. SQLite is a good fit for use in cellphones, PDAs, set-top boxes, and/or appliances. It also works well as an embedded database in downloadable consumer applications.
3. Websites
SQLite usually will work great as the database engine for low to medium traffic websites (which is to say, 99.9% of all websites). The amount of web traffic that SQLite can handle depends, of course, on how heavily the website uses its database. Generally speaking, any site that gets fewer than 100K hits/day should work fine with SQLite.
4. Replacement for ad hoc disk files
Many programs use fopen(), fread(), and fwrite() to create and manage files of data in home-grown formats. SQLite works particularly well as a replacement for these ad hoc data files.
5. Internal or temporary databases
For programs that have a lot of data that must be sifted and sorted in diverse ways, it is often easier and quicker to load the data into an in-memory SQLite database and use queries with joins and ORDER BY clauses to extract the data in the form and order needed rather than to try to code the same operations manually. Using an SQL database internally in this way also gives the program greater flexibility since new columns and indices can be added without having to recode every query.
6. Command-line dataset analysis tool
Experienced SQL users can employ the command-line sqlite program to analyze miscellaneous datasets. Raw data can be imported from CSV files, then that data can be sliced and diced to generate a myriad of summary reports. Possible uses include website log analysis, sports statistics analysis, compilation of programming metrics, and analysis of experimental results.
You can also do the same thing with an enterprise client/server database, of course. The advantages to using SQLite in this situation are that SQLite is much easier to set up and the resulting database is a single file that you can store on a floppy disk or flash-memory stick or email to a colleague.
7. Stand-in for an enterprise database during demos or testing
If you are writing a client application for an enterprise database engine, it makes sense to use a generic database backend that allows you to connect to many different kinds of SQL database engines. It makes even better sense to go ahead and include SQLite in the mix of supported databases and to statically link the SQLite engine in with the client. That way the client program can be used standalone with an SQLite data file for testing or for demonstrations.
8. Database Pedagogy
Because it is simple to setup and use (installation is trivial: just copy the sqlite or sqlite.exe executable to the target machine and run it) SQLite makes a good database engine for use in teaching SQL. Students can easily create as many databases as they like and can email databases to the instructor for comments or grading.
11. Experimental SQL language extensions
The simple, modular design of SQLite makes it a good platform for prototyping new, experimental database language features or ideas.
C. Situations Where Another RDBMS May Work Better
1. Client/Server Applications
If you have many client programs accessing a common database over a network, you should consider using a client/server database engine instead of SQLite. A good rule of thumb is that you should avoid using SQLite in situations where the same database will be accessed simultaneously from many computers over a network filesystem.
2. High-volume Websites
SQLite will normally work fine as the database backend to a website. But if you website is so busy that you are thinking of splitting the database component off onto a separate machine, then you should definitely consider using an enterprise-class client/server database engine instead of SQLite.
3. Very large datasets
With the default page size of 1024 bytes, an SQLite database is limited in size to 2 tebibytes (241 bytes). And even if it could handle larger databases, SQLite stores the entire database in a single disk file and many filesystems limit the maximum size of files to something less than this. So if you are contemplating databases of this magnitude, you would do well to consider using a client/server database engine that spreads its content across multiple disk files, and perhaps across multiple volumes.
4. High Concurrency
SQLite uses reader/writer locks on the entire database file. That means if any process is reading from any part of the database, all other processes are prevented from writing any other part of the database. Similarly, if any one process is writing to the database, all other processes are prevented from reading any other part of the database. For many situations, this is not a problem. Each application does its database work quickly and moves on, and no lock lasts for more than a few dozen milliseconds. But there are some applications that require more concurrency, and those applications may need to seek a different solution.
D. Want to explore?
1. Installation
Download Precompiled Windows Binaries:
1. Download http://www.sqlite.org/sqlite-3_6_23_1.zip (contains: sqllite3.exe)
2. and this http://www.sqlite.org/sqlitedll-3_6_23_1.zip (This is a DLL of the SQLite library)
3. Extract all the file and put in one directory (ex: C:/sqlite3)
C:\sqlite3>dir
Volume in drive C has no label.
Volume Serial Number is 9863-4221
Directory of C:\sqlite3
2010-04-27 00:13 .
2010-04-27 00:13 ..
2010-03-29 16:02 3.809 sqlite3.def
2010-03-29 16:02 520.234 sqlite3.dll
2010-03-29 16:02 528.522 sqlite3.exe
3 File(s) 1.052.565 bytes
2 Dir(s) 84.336.992.256 bytes free
The only external dependency is MSVCRT.DLL.
2. Create Database
A standalone program called sqlite3 is provided which can be used to create a database, define tables within it, insert and change rows, run queries and manage an SQLite database file. This program is a single executable file on the host machine. It also serves as an example for writing applications that use the SQLite library.
C:\sqlite3>sqlite3 pontianak.db3
SQLite version 3.6.23.1
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .exit
SQLite will create a new one, if the database does not exist.
3. Create Table
If you are not exit in the previous step, just dosqlite> create table create table mytab (pk integer primary key, nametext not null);
sqlite> .table (this a sqllite command line to display tables, for other commands just type .help
mytab
sqlite>
or if you have exitted, type this:
C:\sqlite3>sqlite3 pontianak.db3 "create table mytab (pk integer primary key, nametext not null);
4. Insert DataC:\sqlite3>sqlite3 pontianak.db3 "insert into mytab values (100, 'My Name');"
or
C:\sqlite3>sqlite3 pontianak.db3 "insert into mytab values (200, 'Your Name');"
sqlite>insert into mytab values (300, 'Tova Naruto');
5. Display DataC:\sqlite3>sqlite3 pontianak.db3 "select * from mytab ;"
or
sqlite>select * from mytab;
100My Name
200Your Name
300Tova Naruto
E. GUI for Data Administration
Yes, you are absolutely right...for productivity reason we use GUI for data administration. You can find some in Management Tools , and I use SQLite Administration.
As stated above, if we want to move our database into another folder, computer, other device or mail it, just copy and paste pontianak.db3 database into destination.
At all...it's so simple and now it's time for me to do my job.
Happy coding and for detail see this.
Tidak ada komentar:
Posting Komentar