Skip to content

The example library

Most examples in this documentation use the same small database: a library with authors, books, members, and loans. Keeping one familiar set of tables makes it easier to focus on the concept each page is teaching.

TableColumns
authorsauthor_id (serial, primary key), name (text), birth_year (int)
booksbook_id (serial, primary key), title (text), author_id (int → authors), published (int), isbn (text, unique)
membersmember_id (serial, primary key), name (text), joined (date)
loansloan_id (serial, primary key), book_id (int → books), member_id (int → members), loaned_on (date), returned_on (date)
  • An author has many books. books.author_id points at authors.author_id — a one-to-many relationship.
  • Members borrow books. Each row in loans ties one book to one member, so loans connects books and members — a many-to-many relationship expressed through a bridging table.

You will build these tables and relationships step by step in Build the library. Individual reference pages use whichever part of this schema illustrates the command at hand.