Last updated: August 27, 2026.
The SQL tutorial examples use a small set of related tables. The schema below keeps the relationships explicit and gives each table a primary key.
Core tables
CREATE TABLE AntiqueOwners (
OwnerID INTEGER PRIMARY KEY,
OwnerLastName VARCHAR(50) NOT NULL,
OwnerFirstName VARCHAR(50) NOT NULL,
City VARCHAR(80),
State VARCHAR(80),
Country VARCHAR(80)
);
CREATE TABLE Antiques (
ItemID INTEGER PRIMARY KEY,
SellerID INTEGER NOT NULL,
BuyerID INTEGER,
Item VARCHAR(100) NOT NULL,
Price DECIMAL(10, 2) NOT NULL,
FOREIGN KEY (SellerID) REFERENCES AntiqueOwners(OwnerID),
FOREIGN KEY (BuyerID) REFERENCES AntiqueOwners(OwnerID)
);Other lessons add employee and order tables. Use consistent key data types, declare relationships, and index foreign-key columns when joins or referential checks need them.
Inspect the data
SELECT OwnerID, OwnerLastName, OwnerFirstName, City
FROM AntiqueOwners
ORDER BY OwnerID;Return only the columns a lesson needs so result sets remain readable.