Sample SaaS database
A small company schema is an organization and the people in it. The member row has to name an organization that exists. This sample generates organizations first, then fills organization_id from those ids.
CREATE TABLE organizations (
id INTEGER PRIMARY KEY,
company VARCHAR(160) NOT NULL,
country VARCHAR(80),
plan VARCHAR(20) CHECK (plan IN ('free', 'pro', 'enterprise')),
created_at TIMESTAMP
);
CREATE TABLE members (
id INTEGER PRIMARY KEY,
organization_id INTEGER NOT NULL REFERENCES organizations(id),
email VARCHAR(255) NOT NULL,
role VARCHAR(20) CHECK (role IN ('owner', 'admin', 'member')),
joined_at TIMESTAMP
);
Company names and countries follow the column. plan is only free, pro, or enterprise. role is only owner, admin, or member. The SQL file inserts organizations before members.
A store schema is on the ecommerce sample. Authors and posts are on the blog sample. Paste your own tables when you need subscriptions, invoices, or a different shape.