Tables, rows and columns
A table holds one kind of thing. A row is one of them. A column is one fact about it, of one type, for every row.
CREATE TABLE books (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
year INTEGER,
author_id INTEGER REFERENCES authors(id)
);- One table, one kind of thing. A table holding both books and authors is the first thing to fix.
- A column has one type and one meaning. A column that holds a date for some rows and a note for others will hurt later.
- Rows have no inherent order. Without ORDER BY the database may return them in any order it likes, and may change its mind.