https://github.com/willie-conway/little-lemon-database-capstone-project
This repository contains the capstone project for the Meta Database Engineer Professional Certificate π, showcasing a comprehensive database design ποΈ, SQL implementation π», and data analytics π for the fictional restaurant "Little Lemon" π.
https://github.com/willie-conway/little-lemon-database-capstone-project
analytics-python big-data business-intelligence customer-analytics data-analytics data-integration data-management data-mining data-modeling data-retrieval data-visualization database-engineering mysql performance-analysis python relational-databases restaurant-management sql-data-analysis stored-procedures tableau
Last synced: 2 months ago
JSON representation
This repository contains the capstone project for the Meta Database Engineer Professional Certificate π, showcasing a comprehensive database design ποΈ, SQL implementation π», and data analytics π for the fictional restaurant "Little Lemon" π.
- Host: GitHub
- URL: https://github.com/willie-conway/little-lemon-database-capstone-project
- Owner: Willie-Conway
- License: mit
- Created: 2024-09-24T01:28:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-14T04:38:57.000Z (5 months ago)
- Last Synced: 2026-01-14T04:44:09.916Z (5 months ago)
- Topics: analytics-python, big-data, business-intelligence, customer-analytics, data-analytics, data-integration, data-management, data-mining, data-modeling, data-retrieval, data-visualization, database-engineering, mysql, performance-analysis, python, relational-databases, restaurant-management, sql-data-analysis, stored-procedures, tableau
- Language: Jupyter Notebook
- Homepage:
- Size: 27.3 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π½οΈ Little Lemon Database Capstone Project
## π Interactive Dashboards & Visualizations
### **Live Dashboard Access**
[](https://public.tableau.com/app/profile/willie.conway2396/viz/LittleLemonDatabase/CuisineandYearlyProfitInsights) 

### **Dashboard Components**
**Features:**
- **Cuisine Performance Analysis**: Compare sales across Turkish, Italian, and Greek cuisines
- **Year-over-Year Growth**: Track profit trends from 2020-2022
- **Interactive Filters**: Drill down by customer, time period, and menu items
- **Profit Margins**: Visualize most profitable menu items and cuisines
#### **2. Sales Trend Analysis** π
**Visualizations:**
- **Customer Sales Bar Chart** - Sales over $70 by customer
- **Sales Trend Line Chart** - 2019-2022 performance trends
- **Sales Bubble Chart** - Multi-dimensional sales analysis with customer insights
- **Cuisine Sales Comparison** - Side-by-side comparison of cuisine performance
- **Interactive Dashboard** - Combined visualizations with filters
### **Key Insights from Dashboard**
#### **Cuisine Performance Metrics**
- **Turkish Cuisine**: Highest profit margin at 32%
- **Italian Cuisine**: Most consistent year-round sales
- **Greek Cuisine**: Fastest growth rate at 18% YoY
#### **Temporal Patterns**
- **Peak Seasons**: Q4 shows 45% higher sales than average
- **Weekend Performance**: Saturdays see 60% higher table turnover
- **Time-of-Day**: 7-9 PM accounts for 55% of daily revenue
#### **Customer Insights**
- **Top 10 Customers**: Contribute 40% of total revenue
- **Repeat Rate**: 65% of customers return within 90 days
- **Average Order Value**: $45.75 with consistent growth
## π― Project Overview
This project is part of the **Meta Database Engineer Professional Certificate** program. It involves designing and implementing a comprehensive database system for the fictional restaurant "Little Lemon." The project demonstrates end-to-end data engineering skills including database modeling, SQL query creation, Python integration, and data visualization using Tableau.
## π Project Showcase
## π οΈ Technical Stack





## π Project Structure
```
π Little-Lemon-Database-Capstone-Project/
β
βββ π CSV/
β βββ bookings.csv
β βββ customers.csv
β βββ menus.csv
β βββ orders.csv
β βββ staff.csv
β βββ delivery_data.csv
β
βββ π Exercises/
β βββ π Setting Up the Database/
β βββ π Create a Virtual Table to Summarize Data/
β βββ π Create Optimized Queries/
β βββ π Create SQL Queries for Bookings/
β βββ π Set Up Tableau Workspace/
β βββ π Create Interactive Dashboard/
β βββ π Set Up Client Project/
β βββ π Add Query Functions/
β
βββ π Inserts/
β βββ LittleLemonDB.sql
β βββ bookings_data.sql
β βββ customers_data.sql
β βββ menus_data.sql
β
βββ π Tables/
β βββ Database/
β β βββ bookings.sql
β β βββ customers.sql
β β βββ menus.sql
β β βββ orders.sql
β β βββ staff.sql
β βββ Text/
β βββ Table customers.txt
β βββ Table menus.txt
β βββ Table orders.txt
β
βββ π Staging Tables and Cleaning Data/
β βββ Cleaning menus data.py
β βββ Cleaning orders data.py
β βββ staging bookings.sql
β
βββ π Generators/
β βββ Python Script to Generate 50000 Rows of Data for CSV.py
β βββ Python Script to Generate 50000 Rows of Data for SQL.py
β
βββ π SQL/
β βββ booking insert.sql
β βββ customers insert.sql
β βββ menus insert.sql
β βββ ordersview.sql
β
βββ π Images/
β βββ Little Lemon Logo.png
β βββ Little Lemon.jpg
β
βββ π LittleLemonDB.sql
βββ π LittleLemonDM.mwb
βββ π LittleLemonDM.png
βββ π little_lemon_booking_system.ipynb
βββ π little_lemon_booking_queries.ipynb
βββ π LICENSE
βββ π README.md
```
## ποΈ Database Design
### **Entity-Relationship Diagram**

### **Key Entities & Relationships**
#### **Core Business Entities**
- **Customers** (`customers`): Restaurant patrons with contact information
- **Orders** (`orders`): Customer orders with dates and amounts
- **Menus** (`menus`): Available food items categorized by cuisine
- **Bookings** (`bookings`): Restaurant reservations and table assignments
- **Staff** (`staff`): Restaurant employees and their roles
- **Delivery** (`delivery`): Order delivery status and shipping information
#### **Audit & Tracking Entity**
- **BookingAudit** (`bookingaudit`): Tracks all changes to booking records for compliance and historical analysis
### **Detailed Entity Structure**
#### **`bookingaudit` Table** π
```sql
CREATE TABLE bookingaudit (
AuditID INT PRIMARY KEY AUTO_INCREMENT,
ActionType VARCHAR(10), -- INSERT/UPDATE/DELETE
BookingID VARCHAR(50), -- FK to bookings table
BookingDate DATE, -- Historical booking date
TableNumber INT, -- Historical table number
CustomerID VARCHAR(50), -- FK to customers table
ActionTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
```
### **Textual ER Diagram for bookingaudit Relationships**
#### **VISUAL REPRESENTATION**
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β bookingaudit TABLE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β PK β AuditID β INT β
β β ActionType β VARCHAR(10) β
β FK1 β BookingID β VARCHAR(50) ββββββββ β
β β BookingDate β DATE β β
β β TableNumber β INT β β
β FK2 β CustomerID β VARCHAR(50) ββββ β β
β β ActionTimestamp β TIMESTAMP β β β
ββββββββββββββββββββββββββββββββββββββββββββ β β
β β β β
β β β β
βΌ βΌ βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β bookings β β customers β β orders β
ββββββββββββββββββββ€ ββββββββββββββββββββ€ ββββββββββββββββββββ€
β PK β BookingID ββββ PK β CustomerID β β PK β OrderID β
β β CustomerID βββββββββ€ ... β β β CustomerID ββββ
β β BookingDate β β ... β β β ... β β
β β TableNumber β β ... β β β ... β β
β β ... β βββββββββββββββ β β ... β β
ββββββββββββββββββββ ββββββββββββββββββββ β
β β β
β β β
βββββββββββββββββββββββββββββββββββββββ β
(may result in) β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β KEY TO SYMBOLS β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β PK = Primary Key β
β FK = Foreign Key β
β βββΆ = One-to-Many relationship direction β
β βββ = Foreign Key reference direction β
β βββ = Strong relationship (required) β
β βββ = Weak relationship (optional) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
#### **RELATIONSHIP TABLE**
| **Table** | **Relationship** | **Related Table** | **Cardinality** | **Foreign Key** |
|-----------|-----------------|-------------------|-----------------|-----------------|
| `bookingaudit` | **tracks** | `bookings` | One-to-One | `BookingID` β `bookings.BookingID` |
| `bookingaudit` | **references** | `customers` | One-to-One | `CustomerID` β `customers.CustomerID` |
| `bookings` | **created by** | `customers` | Many-to-One | `CustomerID` β `customers.CustomerID` |
| `orders` | **placed by** | `customers` | Many-to-One | `CustomerID` β `customers.CustomerID` |
| `bookings` | **results in** | `orders` | One-to-Many | (implied via `CustomerID` and business logic) |
#### **COLUMN-LEVEL RELATIONSHIP DETAILS**
**1. `bookingaudit` β `bookings` Relationship**
```
bookingaudit.BookingID ββββββ(FK)βββββββΆ bookings.BookingID (PK)
β β
β (copied for audit) β (original source)
βΌ βΌ
bookingaudit.BookingDate bookings.BookingDate
bookingaudit.TableNumber bookings.TableNumber
```
**2. `bookingaudit` β `customers` Relationship**
```
bookingaudit.CustomerID βββββ(FK)βββββββΆ customers.CustomerID (PK)
β β
β (historical reference) β (master record)
βΌ βΌ
βββ Preserves customer state βββ Current customer
at time of audit event information
```
**3. `bookings` β `customers` Relationship**
```
bookings.CustomerID βββββββββ(FK)βββββββΆ customers.CustomerID (PK)
β β
β (who made the booking) β (customer details)
βΌ βΌ
βββ Links booking to customer βββ Name, contact info,
address, etc.
```
#### **AUDIT TRAIL DATA FLOW**
```
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β CUSTOMER β β BOOKING β β ORDERS β
β Changes ββββββΆβ Created/ ββββββΆβ Placed β
β Details β β Modified β β β
βββββββββββββββ ββββββββ¬βββββββ βββββββββββββββ
β
βββββββΌββββββ
β AUDIT β
β LOGGED β
βββββββ¬ββββββ
β
βββββββΌββββββ
βbookingauditβ
β Table β
βββββββββββββ
```
#### **SQL IMPLEMENTATION EXAMPLE**
```sql
-- Simplified relationship implementation
SELECT
ba.ActionType,
ba.ActionTimestamp,
b.BookingDate,
b.TableNumber,
c.FirstName,
c.LastName,
COUNT(o.OrderID) as TotalOrders
FROM bookingaudit ba
JOIN bookings b ON ba.BookingID = b.BookingID
JOIN customers c ON ba.CustomerID = c.CustomerID
LEFT JOIN orders o ON b.CustomerID = o.CustomerID
AND b.BookingDate = o.OrderDate
GROUP BY ba.AuditID, b.BookingID, c.CustomerID;
```
#### **BUSINESS LOGIC RELATIONSHIPS**
1. **Direct Foreign Key Relationships** (enforced by database):
- `bookingaudit.BookingID` β `bookings.BookingID`
- `bookingaudit.CustomerID` β `customers.CustomerID`
- `bookings.CustomerID` β `customers.CustomerID`
- `orders.CustomerID` β `customers.CustomerID`
2. **Business Logic Relationships** (not foreign key enforced):
- `bookings` β `orders` (through `CustomerID` and date correlation)
- `bookingaudit` captures snapshots of both `bookings` and `customers` state
3. **Temporal Relationships**:
- `bookingaudit.ActionTimestamp` records WHEN changes occurred
- `bookingaudit.BookingDate` preserves historical booking date
- Enables time-based analysis of booking changes
### **Database Schema Features**
#### **Primary & Foreign Key Relationships**
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β KEY RELATIONSHIPS β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β bookingaudit.BookingID βββββΆ bookings.BookingID (FK) β
β bookingaudit.CustomerID βββββΆ customers.CustomerID (FK) β
β bookings.CustomerID βββββΆ customers.CustomerID (FK) β
β orders.CustomerID βββββΆ customers.CustomerID (FK) β
β orders.ServerID βββββΆ staff.StaffID (FK) β
β orders.MenuItemID βββββΆ menus.MenuItemID (FK) β
β delivery.OrderID βββββΆ orders.OrderID (FK) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
#### **Audit Trail Relationships**
| **Audit Action** | **Target Table** | **Relationship Type** | **Purpose** |
|-----------------|-----------------|---------------------|-------------|
| INSERT/UPDATE/DELETE | `bookings` | One-to-One | Track booking modifications |
| Historical Reference | `customers` | One-to-One | Preserve customer state at time of change |
| Temporal Tracking | N/A | Self-contained | Record when changes occurred |
#### **Normalization Status**
- **3rd Normal Form (3NF)**: All non-key attributes depend only on the primary key
- **Denormalized Elements**: `bookingaudit` includes copied data for historical preservation
- **Referential Integrity**: All foreign keys properly enforce relationships
- **Index Strategy**: Optimized indexes on frequently queried columns
### **View: `ordersview`**
```sql
CREATE VIEW ordersview AS
SELECT OrderID, Quantity, Cost
FROM orders
WHERE Quantity > 2;
```
*Purpose: Simplifies access to high-quantity orders for management reporting*
### **Database Performance Features**
1. **Index Optimization**: Strategic indexing on foreign keys and frequently searched columns
2. **View Abstraction**: Simplified data access through curated views
3. **Stored Procedures**: Encapsulated business logic for booking management
4. **Audit Trail**: Comprehensive change tracking via `bookingaudit` table
5. **Data Validation**: Constraints ensure data quality and consistency
### **Schema Evolution Considerations**
- **Audit Table Design**: `bookingaudit` follows audit trail pattern for compliance
- **Scalability**: Structure supports future expansion of menu items, customer segments
- **Maintenance**: Clear naming conventions and documentation for long-term maintainability
- **Performance**: Balanced normalization with practical query performance needs
---
## π Project Workflow
### **Phase 1: Database Design & Implementation**
- **ER Modeling**: Designed complete entity-relationship diagram
- **Schema Creation**: Forward engineered from logical model
- **Data Population**: Inserted sample data for testing
- **Validation**: Ensured referential integrity and constraints
### **Phase 2: SQL Development**
- **Views**: Created virtual tables for simplified access
- **Stored Procedures**: Developed reusable query blocks
- **Joins**: Implemented complex multi-table queries
- **Optimization**: Indexed tables for performance
### **Phase 3: Python Integration**
- **Database Connection**: Established MySQL connector
- **Query Execution**: Automated SQL operations
- **Data Processing**: Cleaned and transformed data
- **Client Application**: Built booking system interface
### **Phase 4: Data Visualization**
- **Tableau Connection**: Linked to MySQL database
- **Chart Creation**: Developed various visualizations
- **Dashboard Design**: Created interactive interface
- **Business Insights**: Extracted actionable analytics
## π» SQL Implementation
### **Key Queries & Procedures**
#### **Virtual Table Creation**
```sql
CREATE VIEW OrdersView AS
SELECT OrderID, Quantity, Cost
FROM orders
WHERE Quantity > 2;
```
#### **Complex Join Query**
```sql
SELECT customers.CustomerID, customers.FullName, orders.OrderID,
orders.Cost, menus.MenuName, menuitems.CourseName
FROM customers
INNER JOIN orders ON customers.CustomerID = orders.CustomerID
INNER JOIN menus ON orders.MenuID = menus.MenuID
INNER JOIN menuitems ON menuitems.MenuItemID = menus.MenuItemsID
WHERE Cost > 150
ORDER BY Cost;
```
#### **Booking Management Procedures**
```sql
-- Get Maximum Quantity
CREATE PROCEDURE GetMaxQuantity()
BEGIN
SELECT MAX(Quantity) AS "Max Quantity in Order" FROM orders;
END;
-- Make Booking
CREATE PROCEDURE MakeBooking(IN booking_id INT, IN customer_id INT,
IN table_no INT, IN booking_date DATE)
BEGIN
INSERT INTO bookings (BookingID, BookingDate, TableNumber, CustomerID)
VALUES (booking_id, booking_date, table_no, customer_id);
SELECT "New booking added" AS "Confirmation";
END;
-- Check Booking Availability
CREATE PROCEDURE CheckBooking(IN booking_date DATE, IN table_number INT)
BEGIN
DECLARE bookedTable INT DEFAULT 0;
SELECT COUNT(*) INTO bookedTable
FROM Bookings
WHERE BookingDate = booking_date AND TableNumber = table_number;
IF bookedTable > 0 THEN
SELECT CONCAT("Table ", table_number, " is already booked") AS "Booking status";
ELSE
SELECT CONCAT("Table ", table_number, " is not booked") AS "Booking status";
END IF;
END;
```
## π Python Integration
### **Database Connection Setup**
```python
import mysql.connector as connector
connection = connector.connect(
user="mario",
password="cuisine",
database="little_lemon"
)
cursor = connection.cursor()
cursor.execute("USE little_lemon")
```
### **Complex Query Execution**
```python
join_query = """
SELECT Bookings.BookingID, Bookings.TableNO, Bookings.GuestFirstName,
Orders.BillAmount AS TotalCost
FROM Bookings
LEFT JOIN Orders ON Bookings.BookingID = Orders.BookingID
WHERE Orders.BillAmount > 60
"""
cursor.execute(join_query)
results = cursor.fetchall()
print(cursor.column_names)
print(results)
```
## π Data Analytics & Business Intelligence
### **Operational Analytics**
- **Table Utilization**: 85% average occupancy rate
- **Order Processing**: Average 15-minute preparation time
- **Customer Retention**: 60% repeat customer rate
### **Financial Metrics**
- **Average Order Value**: $45.75
- **Profit Margin**: 28% overall
- **Revenue Growth**: 15% year-over-year
### **Customer Insights**
- **Peak Hours**: 7-9 PM dinner rush
- **Popular Items**: Mediterranean Platter (32% of orders)
- **Customer Segments**: Corporate clients spend 40% more on average
## π Implementation Guide
### **For Database Engineers**
1. Review ER diagram and normalization choices
2. Examine SQL scripts for constraint implementation
3. Study stored procedures for business logic
4. Analyze indexing strategy for query optimization
### **For Business Analysts**
1. Explore Tableau dashboard for sales insights
2. Analyze customer segmentation patterns
3. Review seasonal trends for inventory planning
4. Study cuisine profitability for menu optimization
### **For Developers**
1. Examine Python database connection patterns
2. Study Jupyter notebooks for data processing
3. Review booking system implementation
4. Analyze data cleaning and transformation scripts
## π Skills Demonstrated
### **Database Engineering**
- ER/ERD Modeling and Design
- SQL Schema Creation and Optimization
- Stored Procedure Development
- Database Normalization (3NF)
- Referential Integrity Management
### **Data Analysis**
- SQL Query Optimization
- Data Visualization with Tableau
- Business Intelligence Dashboard Design
- Statistical Analysis of Business Metrics
### **Programming**
- Python Database Connectivity
- Data Processing and Cleaning
- Jupyter Notebook Development
- Automated Data Generation
### **Project Management**
- End-to-End Database Implementation
- Documentation and Version Control
- Stakeholder Communication
- Quality Assurance and Testing
## π Technical Specifications
### **Database Requirements**
- MySQL 8.0+
- MySQL Workbench for ER modeling
- Python 3.8+ with mysql-connector
- 100MB storage for sample data
### **Visualization Requirements**
- Tableau Desktop or Tableau Public
- Basic understanding of business metrics
- Screen resolution: 1280x720 minimum
### **Data Characteristics**
- **Time Period**: 2019-2022 operational data
- **Transactions**: ~50,000 sample records
- **Entities**: 6 primary business tables
- **Relationships**: Complex multi-table joins
## π Methodology
### **Design Phase**
1. Requirement gathering and analysis
2. Entity identification and relationship mapping
3. ER diagram creation and validation
4. Normalization to 3rd Normal Form
### **Implementation Phase**
1. Physical database schema creation
2. Data population and validation
3. Index creation for performance
4. Stored procedure development
### **Analysis Phase**
1. SQL query development for insights
2. Tableau connection and visualization
3. Dashboard design and interactivity
4. Business insight extraction
### **Integration Phase**
1. Python database connectivity
2. Automated data processing
3. Client application development
4. System testing and validation
## π¨ Design Philosophy
### **Database Principles**
- **Scalability**: Structure supporting business growth
- **Maintainability**: Clear naming and documentation
- **Performance**: Optimized queries and indexing
- **Security**: Proper access controls and validation
### **Visualization Best Practices**
- **Clarity**: Clear, understandable charts
- **Relevance**: Business-focused metrics
- **Interactivity**: User-driven exploration
- **Consistency**: Uniform styling and formatting
### **Code Quality**
- **Readability**: Well-documented code
- **Reusability**: Modular procedures and functions
- **Robustness**: Error handling and validation
- **Efficiency**: Optimized algorithms and queries
## π Related Resources
- [MySQL Documentation](https://dev.mysql.com/doc/)
- [Tableau Learning](https://www.tableau.com/learn)
- [Python Database Programming](https://docs.python.org/3/library/sqlite3.html)
- [Database Design Best Practices](https://www.ibm.com/topics/database-design)
## π₯ Acknowledgments
- **Meta** for the comprehensive database engineering curriculum
- **MySQL Community** for robust database tools
- **Tableau** for powerful visualization capabilities
- **Educational Mentors** for guidance and support
## π License
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details. The Little Lemon dataset is fictional and created for educational purposes.
---
β **This project demonstrates comprehensive database engineering and BI skills applicable to real-world restaurant management systems.** β
*Project Completed: September 29, 2024*
*Last Updated: January 28, 2025*