1 of 26

Hello World! � ~SQLite intro

CSE 414, Fall '25

Section 1 - CD

09/25/25

2 of 26

Your TAs

  • Moses Lurbur
    • BS in CS and Econ
    • ex Amazon and NOAA
    • CS PhD
    • Outside of school: getting outside! 🏔️🌊🌳
  • OHs:
    • Wednesday 3:30-4:30pm Allen 5nd Floor Breakout

3 of 26

Your TAs

  • Maria Protogerou
    • AMATH DS and Business
    • Athens, GR -> Baltimore, MD -> Portland, OR -> Seattle, WA
  • OHs:
    • Wednesday 1:00pm - 2:00pm, Gates Center 150

4 of 26

Ice Breakers

Let's get to know each other!

  • Small groups of 4-6ish
  • Please share…
    • Your name and major
    • What you're looking forward to learning about in CSE 414
    • Favorite memory from summer break
    • Largest mammal you’ve ever seen

5 of 26

Announcements

  • Let us know if you're unable to access Gradescope or Ed
  • HW 1 due Friday, October 3rd at 11:59pm
    • Intro to SQL and sqlite3
    • Submitted via Gradescope
    • Visit OH or post on Ed if you're stuck!
    • Office hours start next week, see course website for times
  • Questions?

5

6 of 26

Review: Database and DBMS

  • What is a database?

  • What is a DBMS?

6

7 of 26

Review: Database and DBMS

  • What is a database?
  • Collection of organized files containing related data persisting over a long period of time
  • What is a DBMS?
  • Program that allows for efficient management of large databases

7

8 of 26

SQL (Structured Query Language)

  • Language designed for managing data held in a relational database management system (RDBMS)

  • Declarative query language

  • What can it do?
    • Data insert, delete, query, schema creation, etc.

8

9 of 26

SQLite: What is it?

  • C library that implements a relational database management system (RDBMS)
  • sqlite3: a standalone program that can run programs and manage a SQLite database
  • Here and here are links to helpful documentation

9

10 of 26

SQLite: Special Commands

.help - list other . commands

.header on/off - show/hide column headers in query results

.mode [mode type] - change how to separate the columns in each row/tuple (for better formatting)

Mode type examples: csv, tabs, line

.show - lists all display options

10

11 of 26

SQLite: Basic SQL Statements

CREATE TABLE: creates a new table

[ex] CREATE TABLE tableName (columnName int, ... );

11

12 of 26

SQLite: Basic SQL Statements

INSERT INTO: inserts new data into table

[ex] INSERT INTO tableName VALUES (value1, …);

12

13 of 26

SQLite: Basic SQL Statements

SELECT: gets existing data from table

[ex] SELECT columnName FROM tableName;

13

14 of 26

SQLite: Basic SQL Statements

UPDATE: updates data in table

[ex] UPDATE tableName

SET ….

WHERE [condition];

14

15 of 26

SQLite: Basic SQL Statements

DELETE: deletes data in table

[ex] DELETE FROM tableName

WHERE [condition];

15

16 of 26

SQLite: Basic SQL Statements

ALTER: modify an existing table’s attributes/characteristics

[ex] ALTER TABLE tableName

ADD COLUMN columnName columnDatatype;

[ex] ALTER TABLE tableName DROP COLUMN columnName;

(Note: SQLite does not support dropping an attribute for versions prior to 3.35.5)

[ex] ALTER TABLE oldName RENAME TO newName;

16

17 of 26

What if we want to add more data?

  • We have a table regarding Companies. What if we want to also add the products they manufacture? How can we add this information?
    • Hint: Tables have to be FLAT in SQL

Answer: Create another table!

18 of 26

SQL Foreign Keys

  • A column (or a collection of columns) in one table that refers to the Primary Key of another table
    • Used to establish a link between two tables
    • Requirement: When declared, foreign key values must also be in the primary key values of the linked table

19 of 26

SQLite: Special Operators

DATE operator: lets you work with dates and times; declare as varchar (see hw1 documentation)

[ex] SELECT * FROM tableName WHERE dateColumn ='YYYY-MM-DD';

SELECT * FROM tableName WHERE dateColumn < DATE('now', '-1

month');

Other operators: LIKE, LENGTH(string), SUBSTR(string, start index, end index), etc.

19

20 of 26

More SQL (For Reference)

  • WHERE clause - filter records
  • AND, OR operator - filter records based on more than one condition
  • LIKE operator - used in a WHERE clause to search�for a specified pattern in a column
  • AS - give an alias name to a table or a column
  • Relational operators: =, >, >=, <, <=

20

21 of 26

SQLite Installation

21

22 of 26

SQLite Installation

Linux - Open a terminal, then run the command:

sudo apt-get install sqlite3

Mac -

  1. Check if installed: sqlite3 --version
  2. Download Homebrew: instructions @ https://brew.sh/
  3. Open a terminal, then run the command:

brew install sqlite3

22

23 of 26

SQLite Installation (con’t)

Windows -

  1. Go to https://www.sqlite.org/download.html and download the third option down under “Precompiled Binaries for Windows”
  2. Extract files into directory of your choice
  3. Add that directory to the environment variable “path”

Video walkthrough: https://www.youtube.com/watch?v=XA3w8tQnYCA&t=2s

23

24 of 26

Running SQLite

Linux/Mac - Open a terminal, then run the command:

sqlite3 [database]

where “database” is the name of the database

Windows -

  1. In cmd, go to directory where you extracted sqlite3.exe files
  2. Run the command: sqlite3 [database]

24

25 of 26

SQL Demo!

25

26 of 26

26

Didn’t understand everything or having trouble with SQLite install? That’s okay! This was just a preview.

SQL basics will be explained further in lecture before your homework is due.

*Post on Ed or come to OH with questions!