DDD  ·  Before you start

Setting up DB Browser for SQLite

Windows 11 Do this once before DDD1 Approx 10 min
Before you start — check all three
  • DB Browser for SQLite is installed on this computer — your teacher has done this for you. You do not need to install anything yourself.
  • You have the database file for your current lesson — download it from the lesson page. The file will be named something like films.sql.
  • You know where it saved — by default, downloads go to your Downloads folder. Keep that in mind for Step 4.

Setup steps

1

Open DB Browser for SQLite

DB Browser for SQLite is already installed. Here is how to find and open it on Windows 11:

  • a

    Click the Start button — the Windows logo icon in the centre of your taskbar at the bottom of the screen.

  • b

    Start typing DB Browser — you do not need to click a search box first, just start typing and Windows will search automatically.

  • c

    You will see "DB Browser for SQLite" appear in the results. Click it once to open it.

Can't find it? Try clicking Start > All Apps (top-right of the Start menu) and scroll down to the letter D. If it still isn't there, let your teacher know.
2

Recognise the DB Browser window

When DB Browser opens, it will look something like this — mostly empty until you import a database:

DB Browser for SQLite
File Edit View Tools Help
Database Structure
Browse Data
Edit Pragmas
Execute SQL
No database open — import a file to begin

The four tabs you will use in this unit:

  • Database Structure — shows your tables and their fields. Start here to check the import worked.
  • Browse Data — shows the actual data in each table, row by row.
  • Execute SQL — where you will type and run SQL queries from DDD5 onwards.
  • Edit Pragmas — settings you won't need to change.
3

Download the database file from your lesson page

Go to your current lesson page (e.g. DDD1) and click the Download database file button near the top of the lesson. The file will save to your Downloads folder automatically — you will navigate to it in the next step.

Important — save the file, don't open it. If your browser opens the file as plain text instead of downloading it, right-click the download button and choose "Save link as…" from the menu. Make sure the file is saved as a .sql file, not a .txt file.
Where are my Downloads? Open File Explorer (the yellow folder icon on your taskbar) and look in the left panel for Downloads. Your file will be listed there by date, newest first.
4

Import the SQL file into DB Browser

This creates a new database from the SQL file. You only do this once per file.

  • a

    In DB Browser, click File in the menu bar at the top.

  • b

    Hover over Import — a submenu slides out to the right.

  • c

    Click Database from SQL file…

File Import Database from SQL file…
  • d

    A standard Windows Open dialog appears. Navigate to your Downloads folder (look in the left panel of the dialog under "This PC"). Click the .sql file once to select it, then click Open.

  • e

    A Save As dialog now appears — DB Browser is asking where to save the new database file (.db). Navigate to your H drive > N5 Computing Science > Databases folder. Name the file films and click Save.

  • f

    DB Browser may show a small message saying "Import completed" or similar. Click OK to dismiss it.

Nothing happened after I clicked Open? Check that you selected a file ending in .sql. If the file picker shows "All Files (*.*)" in the file-type dropdown, change it to show SQL files, or make sure you can see the file extension in the filename.
5

Check the import worked — Database Structure tab

After importing, you should be taken straight to the Database Structure tab. If not, click it now.

You should see two tables listed:

DB Browser for SQLite — films.db
Database Structure
Browse Data
Edit Pragmas
Execute SQL
Tables (2)
director
film
  • a

    If you see Tables (2) with director and film listed underneath — the import worked. Move on to Step 6.

  • b

    Click the small triangle (▶) next to a table name to expand it and see its fields listed below.

  • c

    If you see 0 tables or nothing at all — the import did not work. Go back to Step 4 and try again, or raise your hand.

Your films.db file is now saved on your H drive in H: › N5 Computing Science › Databases. Next lesson, open DB Browser and use File > Open Database to re-open it from there — you do not need to import the SQL file again.
6

Browse the data

Click the Browse Data tab to see the actual data in the tables.

  • a

    At the top of the Browse Data tab there is a Table dropdown. Click it to switch between director and film.

  • b

    The director table should show 15 rows (one per director).

  • c

    The film table should show 52 rows (one per film). You may need to scroll right to see all 8 fields.

  • d

    Some cells in the runtime_mins column will show NULL — this is intentional and is something you will learn about in DDD1.

You're all set! If you can see data in both tables, DB Browser is set up correctly. You can now start DDD1.
7

A quick look at the Execute SQL tab (you'll use this later)

Click the Execute SQL tab. You won't use this until DDD5, but it is worth knowing what it looks like:

  • The large text area in the middle is where you type SQL queries.
  • The Run button (a blue triangle ▶, or press F5) executes whatever you have typed.
  • Results appear in the panel below the text area.
  • If your query has an error, a red error message will appear at the bottom instead of results.
Keyboard shortcut: Press F5 to run a query — faster than clicking the Run button every time.

Troubleshooting

✗  I can't find DB Browser in the Start menu
Try Start > All Apps and scroll down to the letter D. If it still isn't listed, it may not be installed on this machine — let your teacher know so they can install it.
✗  I clicked File > Import but "Database from SQL file" is greyed out
This can happen on some versions. Try this instead: click File > New Database, save a blank file, then go to the Execute SQL tab, open your .sql file using File > Open SQL in that tab, and press F5 to run it.
✗  My browser opened the SQL file as text instead of downloading it
Right-click the download link on the lesson page and choose "Save link as…" from the menu. In the Save dialog, make sure the file name ends in .sql (not .txt). Save it to your Downloads folder, then follow Step 4 to import it.
✗  After importing I see 0 tables in Database Structure
The SQL file may not have been read correctly. Close DB Browser, reopen it, and try the import again from Step 4. Make sure you are selecting the .sql file (not the .db file you created in a previous attempt). If the problem persists, raise your hand.
✗  The director table shows 0 rows / film table shows 0 rows
The tables exist but the data wasn't inserted. This usually means you imported a different file, or the SQL file was incomplete. Download the .sql file again from the lesson page and repeat the import.
✗  I get an error message when I try to import
Note down the exact error message and show your teacher. Common causes: the file was renamed with a wrong extension, or the download was interrupted and the file is incomplete.