ConceptStep · learning platform for computer science

Databases and SQLite

SQL and databases · Lesson

SQL · Lesson 1 / 8 · SQLite lab

Databases and SQLite

From tables to the first biblioteca.db file: guided DB Browser for SQLite lab.

← Back to SQL path

Before you start

These lessons use biblioteca.db: a libri table with eight rows. In the lab you can try queries immediately and download the same database to continue with DB Browser for SQLite.

Experiment freely: use «Reset» whenever you want to return to the original eight books.

What is a database?

A database is an organized collection of information. A school library can store books, authors and loans; a school register stores students, grades and attendance. SQLite normally stores a database in a single file without a separate server.

Tables, columns and rows

A table organizes related data. A column describes an attribute such as title or year; a row describes a book. The primary key id_libro uniquely identifies a row. INTEGER stores whole numbers, TEXT stores text, and NOT NULL requires a value.

Lab: create biblioteca.db

Open DB Browser for SQLite → New Database → save biblioteca.db. Create the libri table with id_libro (INTEGER, PK and AI), titolo (TEXT, NN), autore (TEXT, NN), anno (INTEGER), genere (TEXT). Open Browse Data and add the first five books: Il piccolo principe (1943, Narrativa), Harry Potter e la pietra filosofale (1997, Fantasy), Il Signore degli Anelli (1954, Fantasy), 1984 (1949, initially Fantascienza), and Io, Robot (1950, Fantascienza), with their authors. Press Write Changes. Close and reopen the file to confirm the data was saved. No SQL knowledge is needed in this first lesson: use the graphical interface.

Complete and check the database

Add La fattoria degli animali, Fahrenheit 451 and Il nome della rosa. Change the genre for 1984 from Fantascienza to Distopia. Press Write Changes. Filter by George Orwell in the author column: you should find two books. You can download the sample database on this page and open it in DB Browser to compare the schema and records.

Lab and practice

0 completed · 3 to go

Complete these tasks using the DB Browser graphical interface. Use the web lab to explore the reference database.

Exercise 1

Create biblioteca.db with a libri table and add the first five rows using the graphical interface.

Create or edit the database in DB Browser, save with Write Changes and import it using «Open .db» in the lab. Then select this task and press «Check exercise».

Exercise 2

Add the remaining three books. Change the genre of 1984 to Distopia and save with Write Changes.

Create or edit the database in DB Browser, save with Write Changes and import it using «Open .db» in the lab. Then select this task and press «Check exercise».

Exercise 3

Filter the author column: how many George Orwell books do you find? Expected answer: 2.

Create or edit the database in DB Browser, save with Write Changes and import it using «Open .db» in the lab. Then select this task and press «Check exercise».

Choose «Check exercise» to verify your result. If you get stuck, use «Help me» for gradual hints without seeing the full solution immediately.

Your competency map

What you need to know for Databases and SQLite

ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.

You can start right away. This is a foundation module: it does not require earlier skills from the learning path.
GUIDED LEARNING PATHS

Want to choose the next skill to develop?