SQL · Case Study 05

UFC in SQL: A Live Query Console

Thirty years of UFC fights modeled into a clean relational database you can query live in the browser.

SQLRelational modelingWindow functions
Live in-browser database + notebook
The question

Take 30 years of UFC fights and do what a data analyst is actually paid to do: model the data into a clean relational database, then answer real questions in SQL, from simple joins up to window functions. And make it something a recruiter can run themselves.

The data

A real scrape of ufcstats.com: every event, fighter, and bout. It arrives flat and denormalized, so the first job was modeling it into four linked tables with proper keys: events (789), fighters (4,623), bouts (8,885), and per-fight fight_stats (17,726), spanning 1994 to 2026.

The approach

Normalize the schema, then write eight analyst queries, each matched to the right technique: JOIN plus GROUP BY for win counts, CTE plus CASE for finish rates, conditional aggregation for method mix, a self-join for reach, date bucketing for growth, and window functions (gaps-and-islands) for win streaks, then ship the whole SQLite database into the browser with sql.js, so every result is computed live and visitors can run their own SQL.

What it found

Jim Miller holds the most wins at 28; the window-function query surfaces the legendary streaks, Jon Jones at 19 and Anderson Silva at 16; heavyweights finish 51% by KO while lighter classes go to decision far more often; and a reach advantage, contrary to the myth, wins only about 52% of the time. The best part is the live console: anyone can write their own query against the real database and get an answer instantly, no server involved.

8,885
bouts, fully queryable
4
linked tables
8
showcase queries
live
runs in your browser
Skills demonstrated
SQLrelational data modelingnormalizationJOINsGROUP BY / aggregationCTEswindow functionsself-joinsdate functionsCASE logicin-browser database (sql.js)