SQL & PHP Case Study

SQL Databases & PHP/MySQL Projects

A pair of projects that focus on designing relational databases in SQL and connecting them to dynamic web pages using PHP and MySQL. Together, they show how data moves from schema and queries to real-world web applications.

SQL Database Projects — Family Reunion Database

The SQL portion of this case study centers on a Family Reunion database. The goal was to design a relational schema that could track family members, contact information, event details, and RSVP data in a way that remained flexible, normalized, and easy to query.

Schema Definition

Family reunion SQL schema definition code screenshot.

SQL DDL for creating tables, primary keys, and foreign key relationships between family members, addresses, events, and RSVP records.

Sample Data

Insert statements for family reunion database sample data.

Insert statements populate the database with realistic test data so joins and aggregate queries can be exercised.

Queries & Reports

Select queries running against the family reunion database.

Queries that answer real questions: who’s attending which events, dietary restrictions, and roll-up counts for planning.

These scripts were later adapted to SQLite so the database could be demoed easily without requiring a full SQL Server instance. The structure stayed the same: strong relational design with clear keys and constraints.

PHP/MySQL Projects — Dynamic Web Integration

The PHP/MySQL projects build on the database fundamentals by connecting web front ends to a MySQL backend. The assignments focused on retrieving data from the database, displaying it in styled HTML tables, and performing basic calculations with reusable PHP functions and classes.

Main Application View

Screenshot of a PHP page showing account information in a table.

A browser view of account data rendered from PHP. Data is pulled from objects or database records and displayed in a clean HTML table.

Midterm Code (Accounts & Customers)

Screenshot of PHP midterm code using Account and Customer classes.

PHP classes and setup code for accounts and customers, including helper functions to format currency and compute totals.

Midterm Code (Output & Table)

Screenshot of PHP midterm code generating HTML output.

Logic that loops through account data and builds the HTML table output, echoing values in a way that stays readable and maintainable.

These projects emphasized keeping presentation and logic reasonably separated: PHP classes and helper functions handle the calculations, while small templates generate the HTML. The end result is more reusable than mixing everything into a single monolithic script.

Key Logic (PHP Loop & Formatting)

A simplified example of how PHP walks account data and formats it for display:

// accounts array created earlier
$total = 0;

foreach ($customer->accounts as $account) {
    $total += $account->balance;
    echo "<tr>";
    echo "<td>" . $account->number . "</td>";
    echo "<td>" . $account->type . "</td>";
    echo "<td>" . formatCurrency($account->balance) . "</td>";
    echo "</tr>";
}

echo "<tr><td colspan='2'><strong>Total</strong></td>";
echo "<td><strong>" . formatCurrency($total) . "</strong></td></tr>";

The real project also pulls in includes, classes, and configuration, but this snippet captures the essence: loop over records, keep a running total, and use a helper to ensure currency is consistently formatted.

What I Learned

Explore the Repositories

You can review the full SQL scripts and PHP/MySQL code, including additional exercises and variations, in the GitHub repositories.