0% found this document useful (0 votes)
108 views

Intro To Sqlite: Inf2033 Basis Data 1

The document provides an introduction to SQLite, an open-source, lightweight relational database management system. It discusses key features such as being embedded, serverless, lightweight, portable, and transactional. Common uses of SQLite are also outlined, such as for mobile apps, embedded systems, and temporary datasets. The document then covers SQLite's installation, creating and modifying databases and tables, and some limitations.

Uploaded by

Renaldi Fernando
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views

Intro To Sqlite: Inf2033 Basis Data 1

The document provides an introduction to SQLite, an open-source, lightweight relational database management system. It discusses key features such as being embedded, serverless, lightweight, portable, and transactional. Common uses of SQLite are also outlined, such as for mobile apps, embedded systems, and temporary datasets. The document then covers SQLite's installation, creating and modifying databases and tables, and some limitations.

Uploaded by

Renaldi Fernando
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Intro to SQLite

INF2033 Basis Data 1


Pertemuan 05

R. Kristoforus JB
Fakultas Sains & Teknologi
Universitas Katolik Musi Charitas
Sub Capaian Mata Kuliah
• Mahasiswa mengetahui dan memahami penggunaan
SQLite
• Mahasiswa mengetahui dan memahami BD Browser for
SQLite (DB4S) sebagai tools
• Mahasiswa dapat membuat sebuah basisdata sederhana
dengan menggunakan dengan menggunakan DB4S.
• Mahasiswa dapat membuat dan memodifikasi sebuah tabel
sederhana dengan menggunakan DB4S
• Mahasiswa dapat menambahkan, memodifiksi dan
menghapus record pada sebuah tabel

2
Outline
• SQLite
– Fitur
– Penggunaan
– Kompatibilitas
– Pengguna
– Limitasi
• DB Browser for SQLite
– Instalasi
– Membuat database
– Tipe data
– Membuat tabel
– Modifikasi tabel
– Menambah data record

3
What is SQLite?
• SQLite is :
– an open-source,
– embedded,
– relational database management system,
– designed circa 2000.
• It is a lightweight database,
– with zero configuration,
– no requirements of a server or installation.
• Despite its simplicity,
– it is laden with popular features of database management systems.

4
History
• D. Richard Hipp designed SQLite in the spring of 2000.
• In August 2000, version 1.0 of SQLite was released, based on gdbm
(GNU Database Manager).
• SQLite 2.0 replaced gdbm with a custom B-tree implementation, adding
support for transactions.
• SQLite 3.0.2 beta was released on 2004-06-30.
• In 2011 Hipp announced his plans to add an UnQL interface to SQLite
databases and to develop UnQLite, an embeddable document-oriented
database
• Howard Chu ported SQLite 3.7.7.1 to use Openldap MDB instead of the
original Btree code and called it sqlightning.

5
Key Features
• SQLite is very lightweight (it is less than 500Kb size) compare to other
database management systems like SQL Server, or Oracle.
• SQLite is not a client-server database management system. It is an in-
memory library that you can call and use directly. No installation and
no configuration required.
• A typical SQLite database is contained on a single file on the computer
disk storage with all the database objects (tables, views, triggers, etc.)
included in that file. No dedicated server required.

6
Key Features
• Self-contained: no external dependencies.
• Written in ANSI-C.
• Zero-configuration - no setup or administration needed.
• A complete database is stored in a single cross-platform disk file.
• The database file format is cross-platform (Linux, Mac OS-X, Android, iOS and
Windows) - you can freely copy a database between 32-bit and 64-bit systems or
between big-endian and little-endian architectures.
• Great for use as an application file format.
• Available as a single ANSI-C source-code file that can be easily dropped into
another project.
• Simple, easy to use API.
• Implements most of the SQL92 except some features.
• Transactions are ACID (atomic, consistent, isolated, and durable) compatible,
even after system crashes and power failures.
• Comes with a standalone command-line interface (CLI) client that can be used
to administer SQLite databases.

7
Key Features
• Traditional RDBMS client /server
architecture

• SQLite server-less architecture

8
When to use SQLite?
• If you are developing embedded software for devices like televisions,
Mobile phones, cameras, home electronic devices, etc., then SQLite is a
good choice.
• SQLite can handle low to medium traffic HTTP requests and manage
complex session information for a website
• When you need to store an archive of files, SQLite can produce smaller
size archives and with lesser metadata included than regular ZIP
archives.
• If you want to do processing on some data within an application, you
can use SQLite as a temporary dataset. You can load the data into an
SQLite in-memory database and execute the desired queries. You can
extract the data in a format you want to display in your application.

9
When to use SQLite?
• It gives you an easy and efficient way to process using in-memory
variables. For example, you are developing a program where you have
to perform calculations on some records. You can create an SQLite
database and insert the records there, and with only one query, you can
select the records and perform calculations.
• When you need a database system for learning and training purposes,
SQLite is a good fit. As we explained earlier, no installation or
configuration is required. Copy the SQLite libraries in your computer,
and you are ready to learn.

10
Why use SQLite?
• It is free. SQLite is an open source, no commercial license required to
work with it.
• SQLite is cross-platform database management system. It can be used
on a broad range of platforms like Windows, Mac OS, Linux, and Unix.
It can also be used on a lot of embedded operating systems like
Symbian, and Windows CE.
• SQLite offers an efficient way of storing data, the length of the columns
is variable and is not fixed. So SQLite will allocate only space a field
needs. For example, if you have a varchar(200) column, and you put a
10 characters' length value on it, then SQLite will allocate only 20
characters' space for that value and not the whole 200 space.
• A broad range of SQLite APIs – SQLite provides APIs for a broad range
of programming language, for example.Net languages (Visual Basic,
C#), PHP, Java, Objective C, Python and a lot of other programming
languages.

11
Programming Langugae

Clipper// Common
BASIC Delphi C C# C++ Curl
Harbour Lisp

Java (on
D Free Pascal Go Haskell JVM and JavaScript Julia Livecode
DVM)

Objective-
Lua newLisp C (on OS X OCaml Perl PHP Pike PureBasic
and iOS)

Python R REALbasic REBOL Ruby Scheme Smalltalk Tcl

Visual
Xojo
Basic

12
Who Use SQLite
• Google : Google uses SQLite in their Desktop for Mac, in Google Gears,
in the Android cell-phone operating system, and in the Chrome Web
Browser.
• Dropbox : Dropbox uses SQLite as the primary data store on the client-
side for archiving and synchronization service.
• Mozilla : Mozilla uses SQLite as the primary meta-data storage format
for the Firefox, Web Browser, and the Thunderbird Email Reader.
• McAfee : McAfee uses SQLite in its antivirus programs.
• Flame : Flame is a malware spy program uses SQLite.
• Microsoft : It can be inferred from traffic on the SQLite mailing list that
at least one group within Microsoft is using SQLite in the development
of a game program.
• Skype : Skype uses SQLite in the Skype client for Mac OS X and
Windows.

13
Who Use SQLite
• Adobe : Adobe uses SQLite as the application file format for their
Photoshop Lightroom product.
• Airbus : Airbus uses SQLite in their flight software.
• Apple : Apple uses SQLite for many functions within Mac OS X,
including Apple Mail, Safari, and in Aperture. Apple uses SQLite in the
iPhone and in the iPod touch and in iTunes software.
• Intuit : Intuit apparently uses SQLite in QuickBooks and in TurboTax
• PHP : PHP programming language comes with both SQLite2 and
SQLite3 built in.
• Python : SQLite comes bundled with the Python programming
language since Python 2.5.
• REALbasic : The REALbasic programming environment comes bundled
with an enhanced version of SQLite that supports AES encryption.
• Tcl/Tk : The Tcl/Tk programming language now comes with SQLite
built-in.

14
Limits in SQLite
• Maximum database size : Every database consists of one or more "pages" with
different sizes between 512 and 65536. The maximum size of a database file is
2147483646 pages.
• Maximum number of tables in a schema : Each table and index require at least
one page in the database file. The maximum number of pages in a database file
is 2147483646, therefore this is an upper bound on the number of tables and
indices in a schema.
• Maximum number of rows in a table : The theoretical maximum number of
rows in a table is 264 (18446744073709551616 or about 1.8e+19). This limit is
unreachable since the maximum database size of 140 terabytes will be reached
first.
• Maximum number of attached databases : The number of simultaneously
databases connection is limited to SQLITE_MAX_ATTACHED which is set to
10 by default. The code generator in SQLite uses bitmaps to keep track of
attached databases. That means that the number of attached databases cannot
be increased above 62.

15
Limits in SQLite
• Maximum length of a string or BLOB : The maximum number of bytes
in a string or BLOB in SQLite is defined by the preprocessor macro
SQLITE_MAX_LENGTH. The default value of this macro is 1 billion (1
thousand million or 1,000,000,000).
• Maximum number of columns : The SQLITE_MAX_COLUMN compile-
time parameter is used to set an upper bound on the number of
columns in a table. The default setting for SQLITE_MAX_COLUMN is
2000. You can change it at compile time to values as large as 32767.
• Maximum length of an SQL statement : The maximum number of bytes
in the text of an SQL statement is limited to
SQLITE_MAX_SQL_LENGTH which defaults to 1000000. You can
redefine this limit to be as large as the smaller of
SQLITE_MAX_LENGTH and 1073741824.

16
Limits in SQLite
• Maximum number of tables in a join : SQLite does not support joins
containing more than 64 tables.
• Maximum number of arguments on a function : The
SQLITE_MAX_FUNCTION_ARG parameter determines the maximum
number of parameters that can be passed to an SQL function and the
upper bound on SQLITE_MAX_FUNCTION_ARG of 127.
• Maximum number of terms in a compound SELECT statement : A
compound SELECT statement is two or more SELECT statements
connected by operators UNION, UNION ALL, EXCEPT, or
INTERSECT. The maximum number of terms is
SQLITE_MAX_COMPOUND_SELECT which defaults to 500.

17
SQLite Tools
• SQLite Studio
• DB Browser for SQLite
• Others tools for mobile can be downloaded trough
Playstore or Applestore

18
DB Browser for SQLite
• DB Browser for SQLite (DB4S) is a high quality, visual, open source tool
to create, design, and edit database files compatible with SQLite.
• DB4S is for users and developers who want to create, search, and edit
databases. DB4S uses a familiar spreadsheet-like interface, and
complicated SQL commands do not have to be learned.
• This program is not a visual shell for the sqlite command line tool, and
does not require familiarity with SQL commands. It is a tool to be used
by both developers and end users, and must remain as simple to use as
possible in order to achieve these goals.

19
DB4S Features
• Create and compact database files
• Create, define, modify and delete tables
• Create, define, and delete indexes
• Browse, edit, add, and delete records
• Search records
• Import and export records as text
• Import and export tables from/to CSV files
• Import and export databases from/to SQL dump files
• Issue SQL queries and inspect the results
• Examine a log of all SQL commands issued by the application
• Plot simple graphs based on table or query data

20
Installing DB4S
• Masuk ke laman: https://sqlitebrowser.org/dl/
• Pilih installer yang sesuai dengan platform

• Download isntaller, kemudian isntall pada komputer anda

21
DB4S Interface

22
BD4S Menu
• File:
– New database
– New In-memory database
– Open database
– Open database read only
– Attach database
– Close database
– Write changes
– Revert changes
– Import
– Export
– Open project
– Save Project

23
Create a database
• Klik new database
• Tuliskan nama file database: INF2033_NIM (Contoh: INF2033_1813001)
• Pilih folder untuk menyimpan file database
• Klik: Save

Tulis nama file

Klik Save

24
Create a table
• Klik: Create table

• Akan muncul window baru: Edit


table definition

25
Create a table
• Tuliskan nama tabel

• Klik add field untuk menambah


atribut
• Tuliskan: nama atribut, tipe, Not
Null (NN),primary key (PP)
Autoincrement (AI).
• Perhatikan slide berikut

26
Create a table
• Tabel: Prodi

• Setelah selesai, klik OK

27
SQLite data types
• SQLite is typed less. There are no data types, you can store any type of
data you like in any column. This is called dynamic types.

• In static types, like in other database management systems, if you


declared a column with a data type integer, you can only insert values
of data type integer. However, in dynamic types like in SQLite, the type
of the column is determined by the value inserted. And then SQLite
stores that value depending on its type.

28
SQLite data types
• NULL – this storage class is used to store any NULL value.
• INTEGER – any numeric value is stored as a signed integer value (It can
hold both positive and negative integer values). The INTEGER values in
SQLite are stored in either 1, 2, 3, 4, 6, or 8 bytes of storage depending
on the value of the number.
• REAL – this storage class is used to store the floating point values, and
they are stored in an 8-bytes of storage.
• TEXT – stores text strings. It also supports different encoding like UTF-
8, UTF-16 BE, or UTF-26LE.
• BLOB – used to store large files, like images or text files. The value is
stored as byte array the same as the input value.

29
SQLite data types

30
Add a record
• Klik tab: Browse Data

• Klik tombol: New Record


• Data dapat diisi melalui
• Gunakan ‘Tab’ untuk
berpindah
Klik ‘apply’ setelah mengisi

31
Add a record
• Tambahkan record berikut ke tabel Prodi

32
Delete a record
• Klik pada record yang akan dihapus
• Klik tombol: Delete Record Klik ‘Delete Record’

Pilih record yang akan dihapus

33
Modify data
• Misal:
– Analis Kesehatan akan diganti menjadi Teknologi Laboratorium Medik
– Jenjang Sarjana diubah menjadi Diploma Empat
Ketikkan perubahan data

Klik pada data yang akan diubah


Klik ‘apply’

34
Modify data

35
Modify a table
• Klik pada tabel yang akan diubah
• Klik Modify table
• Atau dengan cara klik kanan
• Perubahan struktur tabel
mengharuskan konsdisi database
sudah terseimpan (write changes)
• Jika belum akan muncul pesan
berikut. Klik Save

36
Modify a table
• Tambahkan field ‘lokasi’ bertipe
text pada tabel prodi
• Modifikasi termasuk mengubah
nama tabel

Struktur baru setelah ditambahkan

37
Tambahkan data berikut
Kode Nama Jenjang Akreditasi Lokasi
1 Arsitektur Sarjana B Kampus Bangau
2 Teknik Industri Sarjana B Kampus Bangau
3 Informatika Sarjana B Kampus Bangau
4 Sistem Informasi Sarjana B Kampus Bangau
5 Akuntansi Sarjana B Kampus Bangau
6 Manajemen Sarjana B Kampus Bangau
7 Keperawatan Diploma Tiga B Kampus Burlian
8 Kebidanan Diploma Tiga B Kampus Burlian
9 Ilmu Keperawatan Sarjana B Kampus Burlian
10 Ners Profesi B Kampus Burlian
11 Teknologi Laboratorium Medik Diploma Empat B Kampus Burlian
12 Pendidikan Bahasa Inggris Sarjana C Kampus Bangau
13 Pendidikan Guru SD Sarjana C Kampus Bangau
14 Psikologi Sarjana C Kampus Bangau

38
Jadwal
Prt Tgl T P
1 05/09 Pengantar Kuliah Basis Data 1 V
2 05/09 Intro to Database System, DB System Environment V
3 12/09 Into to Relational Model V
4 12/09 Intro to SQLite & DB4S V
5 19/09 Query Language: Overview, Data Definition V
6 19/09 SQLite: Data Definition V
7 26/09 Query Language: Basic Structure V
8 26/09 SQLite: Basic Structure V

39
Jadwal
Prt Tgl Teori T P
9 03/10 Relational Database: Relational Algebra V
10 03/10 Relational Database: Relational Algebra V
11 10/10 Query Language: Set Operation, Null Values V
12 10/10 SQLite: Set Operation, Null Values V
13 17/10 Relational Database: Calculus Relational V
14 17/10 Relational Database: Calculus Relational V
15 24/10 UTS V
16 24/10 Project 1 V

40
Jadwal
Prt Tgl Teori T P
17 31/10 Data Modeling: ER Model V
18 31/10 Data Modeling: ER Model V
19 07/11 Query language: Aggregate func., Join Expr V
20 07/11 SQLite V
21 14/11 Data Modeling: ER Model V
22 14/11 Data Modeling: ER Model V
23 21/11 Query language: Views V
24 21/11 SQLite V

41
Jadwal
Prt Tgl Teori T P
25 28/11 Data Modeling Integrity Rules & Normalization V
26 28/11 Data Modeling Integrity Rules & Normalization V
27 05/12 Query Language: Integrity Constraints V
28 05/12 SQLite V
29 12/12 Data Modeling Integrity Rules & Normalization V
30 12/12 Data Modeling Integrity Rules & Normalization V
31 UAS V
32 Project 2 V

42

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy