Tables That Point at Each Other

Tables That Point at Each Other: Related Tables and Foreign Keys, Joining Tables.

Updated

  1. Related Tables and Foreign Keys (Journeyman): One vendor sells many products, so the products go in a table of their own and each product row holds its vendor's id in a foreign key column that REFERENCES the vendors table, a link SQLite checks only once PRAGMA foreign_keys = ON is sent on the connection.
  2. Joining Tables (Journeyman): A JOIN puts two related tables back together in one query, matching each product to its vendor with ON and naming columns from both tables through short aliases, and a LEFT JOIN keeps the vendors that have no products yet, with None where a product would be.