Tables, Rows, Columns and Data Types
A table stores one kind of thing (students, orders, products). Each column is one attribute of it and has a data type; each row (also called a record) is one item.
SQLite's main types: INTEGER (whole numbers), REAL (decimals), TEXT (words) and BLOB (raw bytes). Missing information is stored as NULL, which means "unknown", not zero and not an empty string. Other databases add DATE, BOOLEAN, DECIMAL(10,2) for exact money and so on.
Choose the narrowest type that fits: numbers stored as numbers can be added and sorted correctly, while numbers stored as text sort as "10" before "9".
What does NULL mean in a database?
Create items (name TEXT, qty INTEGER), insert ('pen', 10) and ('ink', NULL), then print the rows where qty IS NULL as a list of names.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.