introduction to sqlite: the most popular database in the world
DESCRIPTION
Introduction to SQLite, given at the Champaign Urbana Database Users Group (cuDBug) on 20 June 2013. http://www.meetup.com/cuDBug/TRANSCRIPT
![Page 1: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/1.jpg)
An Introduction to
SQLiteThe Most Popular Database In the World
cuDBug20 June 2013
![Page 2: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/2.jpg)
My history with DBs
• Undergrad at UIUC, the Web 1.0 era
• Full time software developer for 17 years
• 8 years at CITES, including many network monitoring and management tools
• Almost 7 years at Volition, the last three years doing data collection and analysis
![Page 3: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/3.jpg)
Relationship with DBs
• School: Databases are for COBOL programmers
• Early work: Databases are useful
• Later work: Database theory is amazing
![Page 4: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/4.jpg)
My history with SQLite
• First learned about it at WWDC 2004
• Used for a number of work projects
• Tried to stuff Wikipedia dump onto an ebook reader
![Page 5: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/5.jpg)
So I wrote a book...
![Page 6: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/6.jpg)
So I wrote a book...
• Great White Heron
• No, I didn’t get to choose
• August 2010
• 2.5 years to write & edit
![Page 7: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/7.jpg)
What is SQLite?
The power of a full RDBMS...
...without all the headaches.
![Page 8: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/8.jpg)
What is SQLite?
• Database-in-a-file
• Self-Contained
• Serverless
• Zero-configuration
• Concurrent Access
• ACID compliant
• In the Public Domain
SQLite is an SQL based RDBMS that is...
![Page 9: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/9.jpg)
Database-in-a-File
• Database instance is a common file
• File contains schema, data, blobs, etc.
• Files are cross-platform
• Endian
• Word size (32 bit & 64 bit)
• Encoding (UTF-8, UTF-16be, UTF-16le)
![Page 10: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/10.jpg)
Self-Contained
• The database engine is compiled directly into the application
• No external libraries or processes
![Page 11: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/11.jpg)
Serverless
Application Client lib ServerServerProcs
Typical Client/Server
SQLite
Application SQLite
![Page 12: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/12.jpg)
Zero Configuration
• No server means no server admin, no DBA
• Application can self-configure DB
![Page 13: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/13.jpg)
Concurrent Access
• SQLite uses file locking to allow safe concurrent access from multiple connections, threads, or processes
• Local processes only
• Network storage typically does not work
![Page 14: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/14.jpg)
ACID Compliant
• SQLite provides full ACID transactions
• Two different transaction methods:
• Rollback Journal
• Write-Ahead Log
• Different levels of locking and access
![Page 15: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/15.jpg)
Public Domain
• Core source code and algorithms arein the Public Domain
• Rigorously enforced
• “SQLite” name is still under trademark
• Causes more problems than it solves
![Page 16: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/16.jpg)
SQLite Types
• Signed 64-bit Integers
• IEEE 754 64-bit Float Point
• Unicode Text
• BLOBs
• NULL
• (No date/time types; no “numeric” type)
![Page 17: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/17.jpg)
Other Features
• Connection can “attach” multiple DBs
• SQLite uses manifest typing
• Column types are not rigidly enforced
• Very few issues
• DDL is transactional
![Page 18: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/18.jpg)
Other Features
• Supports in-memory DBs (very fast)
• Depends on file access for Auth/Auth
• Right Outer Joins not supported (Left is)
• Triggers are supported
• Custom functions/aggs, but not in-DB
![Page 19: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/19.jpg)
Other Features
• Virtual Tables
Virtual DB Engine
Query PlannerOptimizer
API
Virtual DB Engine
Query PlannerOptimizer
API
Application Code
![Page 20: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/20.jpg)
Good Uses for SQLite• Database Junior
• Application Cache
• Archives and Data Stores
• Client/Server Stand-in
• Application File Format
• Teaching Tool
• Generic SQL Engine (external data source)
![Page 21: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/21.jpg)
Bad Uses for SQLite
• High Transaction Rates
• Very Large Datasets
• Detailed Access Control
• Client/Server or Multi-Host
• Advanced Replication
![Page 22: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/22.jpg)
SQLite Distribution
• Code for SQLite library
• Code for sqlite3 CLI application
![Page 23: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/23.jpg)
Most popular?
SQLite is, most likely, themost popular database in the worldby number of database instances.
You use it all the time.
![Page 24: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/24.jpg)
Most popular?
• Firefox, Safari, Chrome
• iTunes, MacOS X
• Thunderbird, Mail
• McAfee
• Adobe Air
• Dropbox
• Skype
• QuickBooks, TurboTax
• Python, PHP, WebSQL
Lots of Desktop Apps:
![Page 25: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/25.jpg)
Most popular?
• 550M iOS devices
• 750M Android devices
• ~500M Symbian (Nokia) devices
• ~100M Blackberry devices
Lots of Mobile Devices:
![Page 26: Introduction to SQLite: The Most Popular Database in the World](https://reader034.vdocuments.us/reader034/viewer/2022052602/559c30701a28abe0468b4651/html5/thumbnails/26.jpg)
Most popular?
~10,000,000,000 active database instances