<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Janavi Mehta on Medium]]></title>
        <description><![CDATA[Stories by Janavi Mehta on Medium]]></description>
        <link>https://medium.com/@janavi.mehta2003?source=rss-8cd2efcea279------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4weOcm-SgnPsGmhf</url>
            <title>Stories by Janavi Mehta on Medium</title>
            <link>https://medium.com/@janavi.mehta2003?source=rss-8cd2efcea279------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:52:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@janavi.mehta2003/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What Indian Food Can Teach Us About Data Analysis]]></title>
            <link>https://medium.com/@janavi.mehta2003/what-indian-food-can-teach-us-about-data-analysis-e350bfbb7878?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/e350bfbb7878</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-data-analysis]]></category>
            <category><![CDATA[google-colab]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 13:50:57 GMT</pubDate>
            <atom:updated>2026-01-05T13:50:57.560Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnL4O4VOaidokstORLBSHA.png" /></figure><h3>Exploratory Data Analysis Using Python</h3><p>Data analysis doesn’t always have to start with finance or sales data. Sometimes, the most interesting insights come from everyday things — like food.</p><p>In this project, I performed an <strong>Exploratory Data Analysis (EDA)</strong> on an Indian food dataset to uncover patterns related to <strong>regions, diet types, cooking time, and preparation behavior</strong> using Python.</p><p>This article walks through my <strong>thought process, analysis steps, and code</strong>, demonstrating how raw data can be transformed into business-ready insights.</p><h3>1. Importing Required Libraries</h3><p>We begin by importing the core Python libraries used in data analysis and visualization.</p><pre>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt</pre><h3>2. Loading the Dataset</h3><p>The dataset is stored as a CSV file and loaded using Pandas.</p><pre>df = pd.read_csv(&#39;indian_food.csv&#39;)</pre><p>Previewing the data helps us understand its structure.</p><pre>df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8AJ8c3Ec66f8o2Mj-CF-wQ.png" /></figure><h3>3. Initial Data Exploration</h3><p>Before analysis, it’s essential to understand the dataset at a high level.</p><pre>df.info()<br>df.describe()<br>df.dtypes<br>df.shape</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*R4gbt0ZN1tdJxv8yBJvMSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*5DKFAC3wZEY2le1IHGgeTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*e2bgIZ5mbR1Xiz6_arYApg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*O4X4pJ7c8D1uIyx8yr1veA.png" /></figure><p>These commands help answer questions like:</p><ul><li>How many rows and columns are present?</li><li>Are there missing or incorrect data types?</li><li>What does the statistical distribution look like?</li></ul><h3>4. Data Quality Checks</h3><h4>Checking for Duplicates</h4><pre>df.duplicated().sum()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*Wi3Z1Fua3zzuh1c-yMHUIA.png" /></figure><h4>Checking Missing Values Column-wise</h4><pre>df.isnull().sum()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*wODuQH-HUn60-fJdTdLzAg.png" /></figure><h3>5. Understanding Categorical Variables</h3><h4>Exploring Regions</h4><pre>df[&#39;region&#39;].unique()<br>df[&#39;region&#39;].value_counts()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kvd3gp9BlGABmSocq1oZkQ.png" /></figure><h4>Pivot Table: Region vs State</h4><p>This helps understand how dishes are distributed across states and regions.</p><pre>pd.pivot_table(<br>    df,<br>    index=&#39;region&#39;,<br>    columns=&#39;state&#39;,<br>    values=&#39;name&#39;,<br>    aggfunc=&#39;count&#39;<br>).fillna(0)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wdC-DWozQwkdtiONFVaetQ.png" /></figure><h3>6. Identifying Invalid Values (-1)</h3><p>Some columns contain -1, indicating missing or unknown information.</p><pre>df1 = df[<br>    (df[&#39;flavor_profile&#39;] == &#39;-1&#39;) |<br>    (df[&#39;course&#39;] == &#39;-1&#39;) |<br>    (df[&#39;state&#39;] == &#39;-1&#39;) |<br>    (df[&#39;region&#39;] == &#39;-1&#39;)<br>]<br>len(df1)<br>df1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ysNdfrhGm_gKaRVHyVOe8w.png" /></figure><p>This step is important because such values can distort analysis if left untreated.</p><h3>7. Handling Missing Values</h3><p>For the <strong>region</strong> column, missing values were replaced with the most frequent value (mode).</p><pre>df[&#39;region&#39;] = df[&#39;region&#39;].fillna(df[&#39;region&#39;].mode()[0])<br>df.info()<br>df[&#39;region&#39;].value_counts()</pre><p>This approach preserves data while maintaining logical consistency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*zMcK1yQ1jqVfrPG3GCGU6A.png" /></figure><h3>8. Cooking Time &amp; Preparation Time Analysis</h3><h4>Maximum and Minimum Cooking Time</h4><pre>df[&#39;cook_time&#39;].max()<br>df[df[&#39;cook_time&#39;] != -1][&#39;cook_time&#39;].min()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*vtEyIitLhxDbgdWIETlHLw.png" /></figure><h3>9. Diet Distribution Visualization</h3><pre>df[&#39;diet&#39;].value_counts()</pre><h4>Donut Chart for Diet Types</h4><pre>plt.figure(figsize=(4,4))<br>plt.title(&quot;Distribution of Diet Types&quot;, fontsize=14, fontweight=&#39;bold&#39;)<br>df[&#39;diet&#39;].value_counts().plot(<br>    kind=&#39;pie&#39;,<br>    autopct=&#39;%1.1f%%&#39;,<br>    startangle=90,<br>    pctdistance=0.85,<br>    wedgeprops={&#39;edgecolor&#39;: &#39;white&#39;, &#39;linewidth&#39;: 1}<br>)<br>centre_circle = plt.Circle((0,0), 0.70, fc=&#39;white&#39;)<br>fig = plt.gcf()<br>fig.gca().add_artist(centre_circle)<br>plt.ylabel(&quot;&quot;)<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*HKA2j3Z33sPe5X8o8iboaQ.png" /></figure><p>This visualization clearly shows dietary preferences in a clean, modern format.</p><h3>10. Distribution of Prep Time &amp; Cook Time</h3><h4>Histograms</h4><pre>df[&#39;prep_time&#39;].hist()<br>df[&#39;cook_time&#39;].hist()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfS2mp3RBzCZSRHdJ_fweA.png" /><figcaption>prep time</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tywEKVkw-Bo83Eax-sv9Dw.png" /><figcaption>cook time</figcaption></figure><h4>Box Plot for Prep Time</h4><pre>df[&#39;prep_time&#39;].plot(kind=&#39;box&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nCkFuODrRUGmNbyvvA5n2A.png" /></figure><p>These plots help identify skewness and outliers — crucial for operational insights.</p><h3>11. Feature Engineering: Cooking Time Levels</h3><p>To make cooking time more interpretable, I binned it into 30-minute intervals.</p><pre>df[&#39;cook_time_level&#39;] = pd.cut(<br>    df[&#39;cook_time&#39;],<br>    bins=[0,30,60,90,120,150,180,210,240,270,300,330,360,390,<br>          420,450,480,510,540,570,600,630,660,690,720],<br>    labels=[<br>        &#39;Level 1&#39;,&#39;Level 2&#39;,&#39;Level 3&#39;,&#39;Level 4&#39;,&#39;Level 5&#39;,&#39;Level 6&#39;,<br>        &#39;Level 7&#39;,&#39;Level 8&#39;,&#39;Level 9&#39;,&#39;Level 10&#39;,&#39;Level 11&#39;,&#39;Level 12&#39;,<br>        &#39;Level 13&#39;,&#39;Level 14&#39;,&#39;Level 15&#39;,&#39;Level 16&#39;,&#39;Level 17&#39;,<br>        &#39;Level 18&#39;,&#39;Level 19&#39;,&#39;Level 20&#39;,&#39;Level 21&#39;,&#39;Level 22&#39;,<br>        &#39;Level 23&#39;,&#39;Level 24&#39;<br>    ]<br>)<br>df[&#39;cook_time_level&#39;].value_counts()</pre><h3>12. Correlation Analysis with Heatmaps</h3><h4>Numeric Correlation Matrix</h4><pre>import seaborn as sns<br>numeric_df = df.select_dtypes(include=[&#39;number&#39;])<br>plt.figure(figsize=(10,10))<br>sns.heatmap(numeric_df.corr(), annot=True, cmap=&#39;coolwarm&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*u4dAxUQx5zJUROorTTwmIw.png" /></figure><p>Including Engineered Feature</p><pre>df[&#39;cook_time_level_numeric&#39;] = df[&#39;cook_time_level&#39;].cat.codes<br>numeric_df = df.select_dtypes(include=[&#39;number&#39;])<br>plt.figure(figsize=(10,10))<br>sns.heatmap(numeric_df.corr(), annot=True, cmap=&#39;coolwarm&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*BN-qzYSgZaBzExZu9T0cFw.png" /></figure><p>This reveals relationships between cooking time, preparation time, and other numerical variables.</p><h3>Key Takeaways</h3><ul><li>Real-world datasets require <strong>cleaning before analysis</strong></li><li>Feature engineering improves interpretability</li><li>Visualization turns numbers into insights</li><li>EDA is a critical skill for <strong>Business Analysts</strong></li></ul><h3>Final Thoughts</h3><p>This project demonstrates how everyday data — like food — can be used to showcase <strong>analytical thinking, technical skills, and business intuition</strong>.</p><p>As someone transitioning into <strong>Business Analytics</strong>, projects like this help bridge creativity with structured data analysis.</p><p>If you enjoyed this, feel free to explore my other work where <strong>data meets design and storytelling</strong> ✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e350bfbb7878" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Engineering a Command-Line Typing Speed Test in Python: A Systematic Analysis]]></title>
            <link>https://medium.com/@janavi.mehta2003/engineering-a-command-line-typing-speed-test-in-python-a-systematic-analysis-b318e983f287?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/b318e983f287</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[minigames]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Wed, 31 Dec 2025 07:17:02 GMT</pubDate>
            <atom:updated>2025-12-31T07:17:02.522Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gs5PAGxiWKoEmRqMcL7ROg.png" /></figure><p>Typing speed is a foundational skill for programmers, analysts, writers, and anyone who interacts extensively with computers. Measuring this skill programmatically provides an excellent opportunity to explore <strong>time-based computation, string comparison, performance metrics, and user interaction</strong> in Python.</p><p>This article presents a detailed technical breakdown of a <strong>command-line Typing Speed Test application built using Python</strong>, focusing on algorithmic decisions, accuracy measurement, performance calculation, and system design considerations.</p><h3>Problem Statement</h3><p>The objective of the typing test is to evaluate a user’s typing performance based on two primary metrics:</p><ol><li><strong>Speed</strong> — measured in Words Per Minute (WPM)</li><li><strong>Accuracy</strong> — percentage of correctly typed characters</li></ol><p>The system must:</p><ul><li>Present a randomized sentence</li><li>Capture precise timing of user input</li><li>Compare typed input against a reference sentence</li><li>Compute performance metrics</li><li>Provide qualitative feedback based on results</li></ul><p>This problem is inherently <strong>time-sensitive and state-driven</strong>, making it an ideal candidate for analytical programming.</p><h3>System Overview and Architecture</h3><p>The application follows a <strong>procedural design pattern</strong>, structured around a central controller function:</p><pre>def typing_test():</pre><p>This function coordinates:</p><ul><li>User instructions</li><li>Sentence selection</li><li>Timing logic</li><li>Metric computation</li><li>Result presentation</li><li>Replay control</li></ul><p>Supporting functions are abstracted for:</p><ul><li>Output formatting</li><li>Metric calculations</li><li>Performance classification</li></ul><p>This separation of concerns improves maintainability and enables independent testing of individual components.</p><h3>Sentence Pool and Randomization</h3><p>A predefined list of sentences serves as the test corpus:</p><pre>sentences = [ ... ]</pre><p>Each test session selects a sentence at random:</p><pre>sentence = random.choice(sentences)</pre><h3>Technical significance:</h3><ul><li>Introduces <strong>non-deterministic behavior</strong></li><li>Prevents memorization-based bias</li><li>Simulates real-world typing variation</li></ul><p>In more advanced systems, this corpus could be extended to:</p><ul><li>External text files</li><li>Difficulty-based categories</li><li>Language-specific datasets</li></ul><h3>Terminal Output Abstraction (ANSI Coloring)</h3><p>To improve usability, ANSI escape codes are used for colored terminal output:</p><pre>def print_colored(text, color):</pre><p>This abstraction:</p><ul><li>Centralizes formatting logic</li><li>Keeps business logic visually clean</li><li>Enhances cognitive readability of results</li></ul><p>While optional, such enhancements mirror real-world UI concerns, even in command-line applications.</p><h3>Time Measurement and Precision</h3><p>Typing duration is captured using Python’s time module:</p><pre>start_time = time.time()<br>typed_sentence = input()<br>end_time = time.time()</pre><p>The elapsed time is computed as:</p><pre>time_taken = end_time - start_time</pre><h4>Why this matters:</h4><ul><li>Demonstrates real-time system measurement</li><li>Introduces floating-point precision considerations</li><li>Mimics performance benchmarking techniques used in software profiling</li></ul><p>Accurate time capture is critical, as even small errors significantly affect WPM calculations.</p><h3>Words Per Minute (WPM) Calculation</h3><p>Typing speed is calculated using the industry-standard formula:</p><pre>WPM = (characters / 5) / minutes</pre><p>Implemented as:</p><pre>def calculate_wpm(characters, time_taken):</pre><h3>Technical reasoning:</h3><ul><li>Assumes an average word length of 5 characters</li><li>Normalizes speed across varying sentence lengths</li><li>Converts raw character count into a standardized metric</li></ul><p>This formula is widely used in typing software, making the result comparable to professional tools.</p><h3>Accuracy Computation via Character-Level Comparison</h3><p>Accuracy is calculated by comparing each character in the typed input against the reference sentence:</p><pre>for i in range(min(len(original), len(typed))):</pre><p>Each matching character increments a correctness counter.</p><h3>Key design choices:</h3><ul><li>Uses character-level comparison instead of word-level</li><li>Accounts for shorter or longer user input</li><li>Avoids index out-of-range errors</li></ul><p>Accuracy is then expressed as a percentage of the original sentence length:</p><pre>accuracy = (correct / total) * 100</pre><p>This approach prioritizes <strong>precision and fairness</strong> in evaluation.</p><h3>Performance Rating System</h3><p>To translate numeric metrics into meaningful feedback, a classification system is introduced:</p><pre>def get_rating(wpm, accuracy):</pre><p>Ratings consider both:</p><ul><li>Speed thresholds</li><li>Accuracy constraints</li></ul><h4>Why this is important:</h4><ul><li>Prevents high-speed but low-accuracy results from being overvalued</li><li>Encourages balanced performance</li><li>Demonstrates multi-variable decision logic</li></ul><p>This mirrors real-world scoring systems used in assessments and analytics dashboards.</p><h3>Result Visualization and Feedback</h3><p>After computation, results are presented in a structured format:</p><ul><li>Time taken</li><li>WPM</li><li>Accuracy</li><li>Qualitative rating</li><li>Optional mistake comparison</li></ul><p>Displaying both the <strong>original sentence</strong> and <strong>user input</strong> reinforces learning by making errors explicit — a technique commonly used in educational software.</p><h3>Replay Logic and Session Control</h3><p>The application supports repeated testing via controlled recursion:</p><pre>typing_test()</pre><p>This demonstrates:</p><ul><li>Function reusability</li><li>Stack-based execution</li><li>Clean session termination paths</li></ul><p>In large-scale systems, this would typically be replaced with iterative session management, but recursion remains effective for small, self-contained applications.</p><h3>Full Code</h3><pre>import time<br>import random<br><br># List of sentences to type<br>sentences = [<br>    &quot;The quick brown fox jumps over the lazy dog.&quot;,<br>    &quot;Python is a powerful programming language.&quot;,<br>    &quot;Practice makes perfect in typing speed.&quot;,<br>    &quot;Learning to code is fun and rewarding.&quot;,<br>    &quot;Google Colab is great for running Python code.&quot;,<br>    &quot;Speed and accuracy are both important skills.&quot;,<br>    &quot;The early bird catches the worm every morning.&quot;,<br>    &quot;Success comes to those who work hard daily.&quot;,<br>    &quot;Technology is changing the world every single day.&quot;,<br>    &quot;Keep practicing and you will improve quickly.&quot;<br>]<br><br>def print_colored(text, color):<br>    &quot;&quot;&quot;Print colored text&quot;&quot;&quot;<br>    colors = {<br>        &#39;red&#39;: &#39;\033[91m&#39;,<br>        &#39;green&#39;: &#39;\033[92m&#39;,<br>        &#39;yellow&#39;: &#39;\033[93m&#39;,<br>        &#39;blue&#39;: &#39;\033[94m&#39;,<br>        &#39;purple&#39;: &#39;\033[95m&#39;,<br>        &#39;cyan&#39;: &#39;\033[96m&#39;,<br>        &#39;white&#39;: &#39;\033[97m&#39;,<br>        &#39;end&#39;: &#39;\033[0m&#39;<br>    }<br>    print(colors[color] + text + colors[&#39;end&#39;])<br><br>def calculate_wpm(characters, time_taken):<br>    &quot;&quot;&quot;Calculate words per minute&quot;&quot;&quot;<br>    # Average word length is 5 characters<br>    words = characters / 5<br>    minutes = time_taken / 60<br>    wpm = words / minutes<br>    return round(wpm, 1)<br><br>def calculate_accuracy(original, typed):<br>    &quot;&quot;&quot;Calculate typing accuracy&quot;&quot;&quot;<br>    correct = 0<br>    total = len(original)<br>    <br>    for i in range(min(len(original), len(typed))):<br>        if original[i] == typed[i]:<br>            correct += 1<br>    <br>    accuracy = (correct / total) * 100<br>    return round(accuracy, 1)<br><br>def get_rating(wpm, accuracy):<br>    &quot;&quot;&quot;Get performance rating&quot;&quot;&quot;<br>    if accuracy &lt; 80:<br>        return &quot;⚠️  Keep practicing!&quot;, &#39;yellow&#39;<br>    elif wpm &lt; 30:<br>        return &quot;🐢 Beginner - You&#39;re just starting!&quot;, &#39;blue&#39;<br>    elif wpm &lt; 50:<br>        return &quot;🚶 Average - Good progress!&quot;, &#39;cyan&#39;<br>    elif wpm &lt; 70:<br>        return &quot;🏃 Good - Nice speed!&quot;, &#39;green&#39;<br>    elif wpm &lt; 90:<br>        return &quot;⚡ Excellent - Very fast!&quot;, &#39;purple&#39;<br>    else:<br>        return &quot;🚀 MASTER - Incredible speed!&quot;, &#39;green&#39;<br><br>def typing_test():<br>    &quot;&quot;&quot;Main typing test function&quot;&quot;&quot;<br>    print_colored(&quot;⌨️  TYPING SPEED TEST ⌨️&quot;, &#39;cyan&#39;)<br>    print_colored(&quot;=&quot; * 50, &#39;cyan&#39;)<br>    print()<br>    print_colored(&quot;Instructions:&quot;, &#39;yellow&#39;)<br>    print(&quot;• Type the sentence exactly as shown&quot;)<br>    print(&quot;• Press Enter when done&quot;)<br>    print(&quot;• Try to be both fast AND accurate!&quot;)<br>    print()<br>    <br>    # Choose random sentence<br>    sentence = random.choice(sentences)<br>    <br>    input(&quot;Press Enter when you&#39;re ready to start...&quot;)<br>    print()<br>    <br>    # Show the sentence to type<br>    print_colored(&quot;Type this sentence:&quot;, &#39;yellow&#39;)<br>    print_colored(sentence, &#39;white&#39;)<br>    print()<br>    <br>    # Start timer<br>    start_time = time.time()<br>    <br>    # Get user input<br>    typed_sentence = input(&quot;Start typing: &quot;)<br>    <br>    # End timer<br>    end_time = time.time()<br>    time_taken = end_time - start_time<br>    <br>    print()<br>    print_colored(&quot;=&quot; * 50, &#39;cyan&#39;)<br>    print_colored(&quot;📊 RESULTS 📊&quot;, &#39;cyan&#39;)<br>    print_colored(&quot;=&quot; * 50, &#39;cyan&#39;)<br>    print()<br>    <br>    # Calculate statistics<br>    wpm = calculate_wpm(len(typed_sentence), time_taken)<br>    accuracy = calculate_accuracy(sentence, typed_sentence)<br>    <br>    # Display results<br>    print_colored(f&quot;⏱️  Time taken: {round(time_taken, 2)} seconds&quot;, &#39;blue&#39;)<br>    print_colored(f&quot;⚡ Speed: {wpm} WPM (Words Per Minute)&quot;, &#39;purple&#39;)<br>    print_colored(f&quot;🎯 Accuracy: {accuracy}%&quot;, &#39;green&#39; if accuracy &gt;= 90 else &#39;yellow&#39;)<br>    print()<br>    <br>    # Show rating<br>    rating, rating_color = get_rating(wpm, accuracy)<br>    print_colored(f&quot;Rating: {rating}&quot;, rating_color)<br>    print()<br>    <br>    # Show mistakes if any<br>    if accuracy &lt; 100:<br>        print_colored(&quot;Original sentence:&quot;, &#39;yellow&#39;)<br>        print(sentence)<br>        print_colored(&quot;Your typing:&quot;, &#39;yellow&#39;)<br>        print(typed_sentence)<br>        print()<br>    else:<br>        print_colored(&quot;🎉 PERFECT! No mistakes!&quot;, &#39;green&#39;)<br>        print()<br>    <br>    # Fun facts<br>    if wpm &gt; 70:<br>        print_colored(&quot;💡 Fun fact: You type faster than average!&quot;, &#39;cyan&#39;)<br>    elif wpm &gt; 40:<br>        print_colored(&quot;💡 Fun fact: The average typing speed is 40 WPM.&quot;, &#39;cyan&#39;)<br>    else:<br>        print_colored(&quot;💡 Tip: Practice regularly to improve your speed!&quot;, &#39;cyan&#39;)<br>    <br>    print()<br>    <br>    # Play again option<br>    play_again = input(&quot;Want to test again? (yes/no): &quot;).lower()<br>    if play_again == &#39;yes&#39; or play_again == &#39;y&#39;:<br>        print(&quot;\n&quot; * 2)<br>        typing_test()<br>    else:<br>        print_colored(&quot;\n👋 Thanks for practicing! Keep typing!&quot;, &#39;cyan&#39;)<br>        print_colored(&quot;Remember: Practice makes perfect! 💪&quot;, &#39;green&#39;)<br><br># Start the test<br>typing_test()</pre><h3>Visuals of the Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*zEt8dE4d_6O3SyK3dMKYLQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*c3nty8WsjeQv8mWzTr-uLw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XrCbWtcxY4YBQo54STfKbw.png" /></figure><h3>Technical Value of This Project</h3><p>Despite its apparent simplicity, this typing test reinforces several critical programming concepts:</p><ul><li>Time-based computation</li><li>Input/output synchronization</li><li>Metric normalization</li><li>String comparison algorithms</li><li>State-driven logic</li><li>User-centric feedback design</li></ul><p>These skills translate directly to:</p><ul><li>Performance monitoring systems</li><li>Analytics pipelines</li><li>Human-computer interaction tools</li><li>Assessment and testing platforms</li></ul><h3>Conclusion</h3><p>The Typing Speed Test is more than a beginner exercise — it is a compact performance evaluation system. It combines <strong>timing precision, analytical computation, and feedback-driven design</strong> into a cohesive application.</p><p>For Python learners progressing toward intermediate proficiency, projects like this help develop the mindset required to build reliable, user-focused systems.</p><p>Ultimately, strong software is not just about correctness — it is about measurement, interpretation, and meaningful feedback. This typing test embodies all three.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b318e983f287" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing a Command-Line Hangman Game in Python: An Analytical Breakdown]]></title>
            <link>https://medium.com/@janavi.mehta2003/designing-a-command-line-hangman-game-in-python-an-analytical-breakdown-f803d397054f?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/f803d397054f</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[python-game]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Wed, 31 Dec 2025 07:16:45 GMT</pubDate>
            <atom:updated>2025-12-31T07:16:45.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvOPUYJ-M6KzKEKMMQWl-Q.png" /></figure><p>When learning Python, the shift from syntax-level understanding to <strong>problem-solving through structured programs</strong> is a critical milestone. One effective way to bridge this gap is by building small but complete systems that incorporate logic, state management, and user interaction.</p><p>The <strong>Hangman game</strong> is a classic example of such a system. While simple on the surface, it encapsulates several foundational programming concepts that appear repeatedly in real-world software development.</p><p>This article presents an analytical walkthrough of a <strong>command-line Hangman game implemented in Python</strong>, focusing on architectural decisions, data structures, control flow, and extensibility.</p><h3>Problem Definition</h3><p>At its core, Hangman is a <strong>finite-state guessing game</strong> with the following constraints:</p><ol><li>A hidden word is randomly selected from a predefined set.</li><li>The player guesses one letter at a time.</li><li>Correct guesses reveal positions in the word.</li><li>Incorrect guesses move the game closer to termination.</li><li>The game ends when:</li></ol><ul><li>All letters are guessed correctly (win state), or</li><li>The maximum number of incorrect guesses is reached (loss state).</li></ul><p>6. From a technical standpoint, the challenge lies in <strong>tracking game state accurately</strong> while validating and responding to user input in real time.</p><h3>High-Level Architecture</h3><p>The program is structured around a single orchestration function:</p><pre>def play_hangman():</pre><p>This function encapsulates the entire lifecycle of a game session:</p><ul><li>Initialization</li><li>Gameplay loop</li><li>Termination</li><li>Replay logic</li></ul><p>Supporting components include:</p><ul><li>A word repository</li><li>Visual state representations</li><li>Utility functions for enhanced output</li></ul><p>This modular separation improves <strong>readability, maintainability, and scalability</strong>.</p><h3>Word Selection and Randomization</h3><p>The game begins by randomly selecting a word from a predefined list:</p><pre>word = random.choice(words)</pre><p>This introduces:</p><ul><li><strong>Non-determinism</strong>, ensuring replayability</li><li>Exposure to Python’s standard library (random module)</li></ul><p>In production-grade systems, this could later be abstracted to:</p><ul><li>External files</li><li>APIs</li><li>Database-backed word pools</li></ul><h3>Representing Visual State (ASCII Art)</h3><p>A distinctive feature of this implementation is the use of <strong>ASCII art</strong> to represent the Hangman’s progression:</p><pre>stages = [ ... ]</pre><p>Each index in the stages list corresponds to a specific number of incorrect guesses.</p><h3>Why this matters technically:</h3><ul><li>The list acts as a <strong>state-to-visual mapping</strong></li><li>Index-based access (stages[wrong_guesses]) ensures O(1) lookup</li><li>Demonstrates how data structures can replace complex conditionals</li></ul><p>This pattern is commonly used in UI state management and game development.</p><h3>State Management</h3><p>The game tracks three critical pieces of mutable state:</p><pre>guessed_letters = []<br>wrong_guesses = 0<br>max_wrong = 6</pre><h4>1. guessed_letters</h4><ul><li>Stores user guesses</li><li>Prevents duplicate inputs</li><li>Used to dynamically generate word progress</li></ul><h4>2. wrong_guesses</h4><ul><li>Represents failure count</li><li>Drives both termination logic and visual rendering</li></ul><h4>3. max_wrong</h4><ul><li>Acts as a configurable constraint</li><li>Enables easy difficulty adjustments</li></ul><p>This mirrors <strong>state variables</strong> used in interactive systems and simulations.</p><h3>Dynamic Word Rendering</h3><p>The word is rendered dynamically based on user guesses:</p><pre>for letter in word:<br>    if letter in guessed_letters:<br>        display += letter + &quot; &quot;<br>    else:<br>        display += &quot;_ &quot;</pre><p>From an analytical perspective:</p><ul><li>This is a <strong>projection of internal state to user-facing output</strong></li><li>Introduces character-level iteration over strings</li><li>Reinforces the idea of derived state (output ≠ stored data)</li></ul><p>Such patterns are common in dashboards, reports, and front-end rendering logic.</p><h3>Input Validation and Defensive Programming</h3><p>User input is validated rigorously:</p><pre>if len(guess) != 1 or not guess.isalpha():</pre><p>This prevents:</p><ul><li>Invalid data types</li><li>Unexpected runtime behavior</li><li>Logical corruption of game state</li></ul><p>Additionally, repeated guesses are explicitly handled:</p><pre>if guess in guessed_letters:</pre><p>This demonstrates <strong>defensive programming</strong>, a critical habit for production systems where user input is rarely reliable.</p><h3>Control Flow and Game Loop</h3><p>The main gameplay occurs inside a while loop:</p><pre>while wrong_guesses &lt; max_wrong:</pre><p>This loop:</p><ul><li>Represents continuous system operation</li><li>Terminates only when a terminal condition is met</li></ul><p>Victory detection uses Python’s expressive all() function:</p><pre>if all(letter in guessed_letters for letter in word):</pre><p>This is a clean, declarative way to express <strong>completion conditions</strong>, reducing complexity compared to manual counters.</p><h3>Terminal Output Optimization (Colored Text)</h3><p>To improve usability, ANSI escape sequences are used for colored output:</p><pre>def print_colored(text, color):</pre><p>This abstraction:</p><ul><li>Centralizes formatting logic</li><li>Keeps the core game logic clean</li><li>Demonstrates separation of concerns</li></ul><p>While purely cosmetic, such enhancements significantly improve user engagement — an often overlooked aspect of software design.</p><h3>End States and Replay Mechanism</h3><p>The game explicitly handles both terminal states:</p><ul><li>Win → celebratory message</li><li>Loss → full hangman display and word reveal</li></ul><p>The replay mechanism is implemented via <strong>controlled recursion</strong>:</p><pre>play_hangman()</pre><p>This highlights:</p><ul><li>Function reuse</li><li>Stack-based execution flow</li><li>The importance of defining clean exit conditions</li></ul><p>In larger systems, this pattern would typically be replaced by loop-based session management.</p><h3>FULL CODE</h3><pre>import random<br><br># List of words to guess<br>words = [&#39;python&#39;, &#39;programming&#39;, &#39;computer&#39;, &#39;keyboard&#39;, &#39;mouse&#39;,          &#39;laptop&#39;, &#39;internet&#39;, &#39;software&#39;, &#39;hardware&#39;, &#39;google&#39;]<br><br># Hangman stages<br>stages = [    &quot;&quot;&quot;<br>       -----<br>       |   |<br>       |   <br>       |   <br>       |   <br>       |<br>    --------<br>    &quot;&quot;&quot;,    &quot;&quot;&quot;<br>       -----<br>       |   |<br>       |   O<br>       |   <br>       |   <br>       |<br>    --------<br>    &quot;&quot;&quot;,    &quot;&quot;&quot;<br>       -----<br>       |   |<br>       |   O<br>       |   |<br>       |   <br>       |<br>    --------<br>    &quot;&quot;&quot;,    &quot;&quot;&quot;<br>       -----<br>       |   |<br>       |   O<br>       |  /|<br>       |   <br>       |<br>    --------<br>    &quot;&quot;&quot;,    &quot;&quot;&quot;<br>       -----<br>       |   |<br>       |   O<br>       |  /|\\<br>       |   <br>       |<br>    --------<br>    &quot;&quot;&quot;,    &quot;&quot;&quot;<br>       -----<br>       |   |<br>       |   O<br>       |  /|\\<br>       |  / <br>       |<br>    --------<br>    &quot;&quot;&quot;,    &quot;&quot;&quot;<br>       -----<br>       |   |<br>       |   O<br>       |  /|\\<br>       |  / \\<br>       |<br>    --------<br>    &quot;&quot;&quot;]<br><br>def print_colored(text, color):<br>    &quot;&quot;&quot;Print colored text&quot;&quot;&quot;<br>    colors = {<br>        &#39;red&#39;: &#39;\033[91m&#39;,<br>        &#39;green&#39;: &#39;\033[92m&#39;,<br>        &#39;yellow&#39;: &#39;\033[93m&#39;,<br>        &#39;blue&#39;: &#39;\033[94m&#39;,<br>        &#39;purple&#39;: &#39;\033[95m&#39;,<br>        &#39;cyan&#39;: &#39;\033[96m&#39;,<br>        &#39;end&#39;: &#39;\033[0m&#39;<br>    }<br>    print(colors[color] + text + colors[&#39;end&#39;])<br><br>def play_hangman():<br>    &quot;&quot;&quot;Main game function&quot;&quot;&quot;<br>    word = random.choice(words)<br>    guessed_letters = []<br>    wrong_guesses = 0<br>    max_wrong = 6<br>    <br>    print_colored(&quot;🎮 WELCOME TO HANGMAN! 🎮&quot;, &#39;cyan&#39;)<br>    print_colored(&quot;=&quot; * 40, &#39;cyan&#39;)<br>    print()<br>    <br>    while wrong_guesses &lt; max_wrong:<br>        # Show current hangman stage<br>        print_colored(stages[wrong_guesses], &#39;yellow&#39;)<br>        <br>        # Show word progress<br>        display = &quot;&quot;<br>        for letter in word:<br>            if letter in guessed_letters:<br>                display += letter + &quot; &quot;<br>            else:<br>                display += &quot;_ &quot;<br>        <br>        print_colored(f&quot;Word: {display}&quot;, &#39;blue&#39;)<br>        print_colored(f&quot;Wrong guesses left: {max_wrong - wrong_guesses}&quot;, &#39;purple&#39;)<br>        <br>        if guessed_letters:<br>            print_colored(f&quot;Guessed letters: {&#39;, &#39;.join(sorted(guessed_letters))}&quot;, &#39;cyan&#39;)<br>        <br>        # Check if won<br>        if all(letter in guessed_letters for letter in word):<br>            print_colored(&quot;\n🎉 CONGRATULATIONS! YOU WON! 🎉&quot;, &#39;green&#39;)<br>            print_colored(f&quot;The word was: {word}&quot;, &#39;green&#39;)<br>            break<br>        <br>        # Get player guess<br>        print()<br>        guess = input(&quot;Guess a letter: &quot;).lower()<br>        <br>        # Validate input<br>        if len(guess) != 1 or not guess.isalpha():<br>            print_colored(&quot;❌ Please enter a single letter!&quot;, &#39;red&#39;)<br>            continue<br>        <br>        if guess in guessed_letters:<br>            print_colored(&quot;⚠️  You already guessed that letter!&quot;, &#39;yellow&#39;)<br>            continue<br>        <br>        guessed_letters.append(guess)<br>        <br>        # Check if guess is correct<br>        if guess in word:<br>            print_colored(f&quot;✅ Good job! &#39;{guess}&#39; is in the word!&quot;, &#39;green&#39;)<br>        else:<br>            wrong_guesses += 1<br>            print_colored(f&quot;❌ Sorry! &#39;{guess}&#39; is not in the word.&quot;, &#39;red&#39;)<br>        <br>        print()<br>    <br>    # Game over - lost<br>    if wrong_guesses == max_wrong:<br>        print_colored(stages[wrong_guesses], &#39;red&#39;)<br>        print_colored(&quot;\n💀 GAME OVER! 💀&quot;, &#39;red&#39;)<br>        print_colored(f&quot;The word was: {word}&quot;, &#39;red&#39;)<br>    <br>    # Ask to play again<br>    print()<br>    play_again = input(&quot;Do you want to play again? (yes/no): &quot;).lower()<br>    if play_again == &#39;yes&#39; or play_again == &#39;y&#39;:<br>        print(&quot;\n&quot; * 2)<br>        play_hangman()<br>    else:<br>        print_colored(&quot;\n👋 Thanks for playing! Goodbye!&quot;, &#39;cyan&#39;)<br><br># Start the game<br>play_hangman()</pre><h3>VISUAL OUTPUTS AFTEER RUNNING</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*vd4gaEV5Zr6Dg9-g6dMv-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*pjPccZCvf3StXCFmPGNmKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*7kJoQLEg-a276rWqyQPsfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*b7bQ7Q8me7o9wQiEJpHFfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*cPB0pFpsfB-lmqqRuZf1OA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*HWPvjD3AhH8VLb-DBM29Aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*q72t7F58aQRPqDb7rapmUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*VKXpeo3RWTli1NfL0UAMvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*-KWS9FqtaqIaoCzhySnCJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*71SEDDRq6QmTQz7ffdZD1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*a3dl0w_7jAiQvyxhEsqjLQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*f2hDR5XAnM_oibhu3z12DQ.png" /></figure><h3>Technical Value of This Project</h3><p>Despite its simplicity, this Hangman implementation reinforces:</p><ul><li>Procedural program design</li><li>Stateful system thinking</li><li>Input/output abstraction</li><li>Loop invariants and termination conditions</li><li>User-centric feedback mechanisms</li></ul><p>These skills translate directly to:</p><ul><li>Backend services</li><li>Data pipelines</li><li>Business logic layers</li><li>Interactive analytics tools</li></ul><h3>Conclusion</h3><p>The Hangman game is not merely a beginner exercise — it is a <strong>microcosm of interactive system design</strong>. By implementing it thoughtfully, developers practice skills that extend far beyond games.</p><p>For learners progressing toward intermediate Python, projects like this are invaluable. They encourage analytical thinking, disciplined structure, and an appreciation for both logic and user experience.</p><p>In software development, mastery is built one small system at a time — and Hangman is an excellent place to start.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f803d397054f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Seat Selection to Receipt: Building a Movie Booking Console in Python]]></title>
            <link>https://medium.com/@janavi.mehta2003/from-seat-selection-to-receipt-building-a-movie-booking-console-in-python-9b848cba2fea?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b848cba2fea</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-mini-project]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Mon, 29 Dec 2025 11:56:44 GMT</pubDate>
            <atom:updated>2025-12-29T11:56:44.203Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*le0b2oKNlTBWwOMHIgPCBw.png" /></figure><p>Booking a movie ticket seems simple on the surface.</p><p>But behind the scenes, there’s a lot happening:</p><ul><li>Movie listings</li><li>Show timings</li><li>Seat availability</li><li>Pricing tiers</li><li>Payments</li><li>Receipts</li></ul><p>So I decided to recreate this entire experience using <strong>Python</strong>, inside a <strong>console-based Movie Booking System</strong>.</p><p>The goal wasn’t just to “book a ticket” — it was to <strong>model a real-world booking workflow end to end</strong>.</p><h3>Project Idea</h3><p>Instead of isolated features, I wanted this project to behave like a real ticketing system:</p><blockquote>Choose a movie → select a date → pick a show → select seats → pay → get a receipt</blockquote><p>This project focuses heavily on:</p><ul><li>Flow control</li><li>State management</li><li>User validation</li><li>Pricing logic</li><li>Clean system navigation</li></ul><h3>Booking Flow (High-Level)</h3><p>The system follows this exact sequence:</p><ol><li>Display list of movies</li><li>Select date and available shows</li><li>Enter number of seats</li><li>Choose seats from a grid (with prices)</li><li>Calculate total price</li><li>Confirm booking</li><li>Make payment confirmation</li><li>Generate final receipt</li><li>Booking completed</li><li>Exit or start again</li></ol><p>Each step mirrors what users experience on real booking platforms.</p><h3>Movie, Date &amp; Showtime Management</h3><p>Movies are stored using a structured dictionary:</p><pre>movies = {<br>    &quot;Inception&quot;: {<br>        &quot;dates&quot;: {<br>            &quot;2025-11-28&quot;: [&quot;10:00 AM&quot;, &quot;1:30 PM&quot;, &quot;6:00 PM&quot;],<br>            &quot;2025-11-29&quot;: [&quot;11:00 AM&quot;, &quot;4:00 PM&quot;, &quot;9:30 PM&quot;]<br>        }<br>    }<br>}</pre><blockquote>Why this structure works:</blockquote><blockquote>- Easy date-based filtering</blockquote><blockquote>- Clear mapping between movie → date → showtime</blockquote><blockquote>- Simple to extend with new movies or schedules</blockquote><h3>Seat Grid with Pricing Logic</h3><p>The seating layout uses a <strong>grid-based model</strong>:</p><pre>grid_template = [<br>    [&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;],<br>    [&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;,&quot;B&quot;,&quot;B&quot;,&quot;B&quot;,&quot;B&quot;,&quot;A&quot;,&quot;A&quot;],<br>]</pre><p>Each seat type has a different price:</p><pre>seat_price = {<br>    &quot;A&quot;: 150,  # premium<br>    &quot;B&quot;: 120   # regular<br>}</pre><p>This introduces:</p><ul><li>Tiered pricing</li><li>Visual seat selection</li><li>Realistic theater behavior</li></ul><h3>Interactive Seat Selection</h3><p>Seats are selected using coordinates like:</p><pre>R1C5</pre><p>The system:</p><ul><li>Displays seat availability</li><li>Marks booked seats as X</li><li>Prevents double-booking</li><li>Validates incorrect inputs</li></ul><p>This simulates how modern seat maps behave — but through pure logic.</p><h3>Total Price Calculation</h3><p>Once seats are selected, pricing is calculated dynamically:</p><pre>def calculate_total(chosen, old_grid):<br>    total = 0<br>    for row, col in chosen:<br>        seat_type = old_grid[row][col]<br>        total += seat_price[seat_type]<br>    return total</pre><p>This ensures:</p><ul><li>Accurate billing</li><li>Seat-based pricing</li><li>Transparent cost calculation</li></ul><h3>Booking &amp; Payment Confirmation</h3><p>Before completing the booking, the system asks for:</p><ul><li>Booking confirmation</li><li>Payment confirmation</li></ul><pre>confirm = input(&quot;Confirm booking? (yes/no): &quot;)<br>payment = input(&quot;Proceed to payment? (yes/no): &quot;)</pre><p>This introduces <strong>decision checkpoints</strong>, similar to real-world systems where users can cancel mid-flow.</p><h3>Final Receipt Generation</h3><p>Once payment is successful, the system generates:</p><ul><li>A unique booking ID</li><li>Movie details</li><li>Seats booked</li><li>Timestamp</li><li>Total amount paid</li></ul><pre>print(&quot;=============== BOOKING RECEIPT ===============&quot;)<br>print(f&quot;Booking ID: {b[&#39;id&#39;]}&quot;)<br>print(f&quot;Movie: {b[&#39;movie&#39;]}&quot;)<br>print(f&quot;Seats: {&#39;, &#39;.join(b[&#39;seats&#39;])}&quot;)</pre><p>This gives the user a <strong>printable, final confirmation</strong> — completing the experience.</p><h3>Why This Project Matters</h3><p>This isn’t just a coding exercise.</p><p>It demonstrates:</p><ul><li>Translating a real business process into logic</li><li>Managing multiple user decisions</li><li>Preventing invalid operations</li><li>Handling pricing tiers and confirmations</li><li>Building a full transactional flow</li></ul><p>These are <strong>core skills used in product thinking, operations, and business analysis</strong>.</p><h3>Visuals from Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*kUP4F0waRmii_UmiPM7S9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*_aRz8P9uSSSokekf6koZPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*LOoxHcRaYG9XmRxDywAwgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*aY_IB2eW_Kevw9EZk2-5PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*UUFYW7L_gJnzHy-km6nYpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vuquop_PM37F1wc7w61oow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*azO_yKe1ahCea4GDGsRXMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*uwMiEuA4VQx_rEHCT5j--Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*5Yt5IT7yk-F9541X09mj7g.png" /></figure><h3>Final Thoughts</h3><p>This project helped me understand how <strong>complex systems are just simple decisions layered together</strong>.</p><p>From movie selection to payment confirmation, every step required thinking like:</p><ul><li>A user</li><li>A system designer</li><li>And a business stakeholder</li></ul><p>And that’s exactly what made this project valuable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b848cba2fea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coffee, Code, and Calculations: A Python Cafe Ordering System]]></title>
            <link>https://medium.com/@janavi.mehta2003/coffee-code-and-calculations-a-python-cafe-ordering-system-345a80e424f2?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/345a80e424f2</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Mon, 29 Dec 2025 11:56:31 GMT</pubDate>
            <atom:updated>2025-12-29T11:56:31.328Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VGzkQLJvif6NvEqfdhV1dw.png" /></figure><p>When learning programming, it’s easy to get stuck building examples that don’t feel <em>real</em>.</p><p>So instead of another abstract exercise, I decided to build something familiar, practical, and business-driven:</p><blockquote><strong><em>A complete Cafe Ordering System using Python</em></strong></blockquote><p>This project simulates how a real café handles menus, orders, and billing — all through a clean command-line interface.</p><h3>🧠 The Idea Behind the Project</h3><p>A café doesn’t just take orders. It :</p><ul><li>Organizes menus</li><li>Supports dietary preferences</li><li>Allows searching</li><li>Manages multiple orders</li><li>Calculates bills accurately</li></ul><p>I wanted my program to reflect this <strong>end-to-end flow</strong>, not just isolated functions.</p><h3>System Features</h3><p>The system supports the following operations:</p><ol><li>View menu (Veg / Non-Veg / Both)</li><li>Search by category</li><li>Search for dishes</li><li>Place orders</li><li>Update orders <em>(extendable)</em></li><li>Order delivery &amp; billing</li><li>Receipt generation with GST</li></ol><p>This makes the project closer to a <strong>real-world business workflow</strong> rather than a toy example.</p><h3>Designing the Menu Structure</h3><p>Instead of flat lists, the menu is stored in a <strong>nested data structure</strong>:</p><pre># CATEGORY, [ DISH, PRICE ]<br>menu = [<br>    [&quot;Veg&quot;, [<br>        [&quot;Coffee&quot;, [<br>            [&quot;Espresso&quot;, 90],<br>            [&quot;Cappuccino&quot;, 120]<br>        ]],<br>        [&quot;Snacks&quot;, [<br>            [&quot;Veg Sandwich&quot;, 110],<br>            [&quot;French Fries&quot;, 100]<br>        ]]<br>    ]],<br>    [&quot;Non-Veg&quot;, [<br>        [&quot;Snacks&quot;, [<br>            [&quot;Chicken Sandwich&quot;, 150],<br>            [&quot;Chicken Burger&quot;, 180]<br>        ]],<br>        [&quot;Beverages&quot;, [<br>            [&quot;Protein Shake&quot;, 160]<br>        ]]<br>    ]]<br>]</pre><h3>Why this matters:</h3><ul><li>Reflects real menu hierarchy</li><li>Easy to extend</li><li>Enables category-based searches</li><li>Mimics how databases store structured data</li></ul><h3>Choosing Menu Type (Veg / Non-Veg / Both)</h3><p>Before showing any menu, the user selects their preference:</p><pre>def choose_menu_type():<br>    print(&quot;1. Veg&quot;)<br>    print(&quot;2. Non-Veg&quot;)<br>    print(&quot;3. Both&quot;)</pre><p>This allows:</p><ul><li>Personalized menu views</li><li>Filtering without duplicating logic</li><li>Cleaner user experience</li></ul><h3>Viewing the Menu</h3><p>Based on the selected menu type, the system dynamically displays relevant items:</p><pre>def view_menu(selected_type):<br>    for category in menu:<br>        if selected_type == &quot;Both&quot; or selected_type == category[0]:<br>            print(f&quot;\n--- {category[0]} Menu ---&quot;)</pre><p>This avoids hardcoding and keeps the display logic flexible.</p><h3>Searching Categories &amp; Dishes</h3><p>The system supports <strong>two types of search</strong>:</p><h4>1. Search by Category</h4><pre>def search_category(selected_type):<br>    category_name = input(&quot;Enter category to search: &quot;)</pre><h4>2. Search by Dish Name</h4><pre>def search_dishes(selected_type):<br>    dish_name = input(&quot;Enter dish to search: &quot;)</pre><p>This mimics real café POS systems where staff quickly locate items.</p><h3>Placing an Order</h3><p>Orders are stored in a list of dictionaries:</p><pre>orders = []</pre><p>Each order contains:</p><ul><li>Dish name</li><li>Quantity</li><li>Price</li><li>Total price</li></ul><pre>order = {<br>    &quot;name&quot;: name,<br>    &quot;qty&quot;: qty,<br>    &quot;price&quot;: price,<br>    &quot;total_price&quot;: total_price<br>}</pre><p>This structure makes it easy to:</p><ul><li>Update orders later</li><li>Generate receipts</li><li>Perform billing calculations</li></ul><h3>Main Order Flow (System Navigation)</h3><p>All operations are tied together using a <strong>menu-driven loop</strong>:</p><pre>def order_process():<br>    while True:<br>        print(&quot;1. View Menu&quot;)<br>        print(&quot;2. Search Category&quot;)<br>        print(&quot;3. Search Dishes&quot;)<br>        print(&quot;4. Place Order&quot;)<br>        print(&quot;5. Update Order&quot;)<br>        print(&quot;6. Order Delivered and Billed&quot;)<br>        print(&quot;7. Exit&quot;)</pre><p>This design:</p><ul><li>Keeps the program interactive</li><li>Simulates a real ordering terminal</li><li>Makes feature expansion easy</li></ul><h3>Billing &amp; Receipt Generation</h3><p>Once the order is delivered, the system generates a detailed receipt:</p><pre>gst = round(grand_total * 0.05)  # 5% GST<br>final_amount = grand_total + gst</pre><h3>Receipt includes:</h3><ul><li>Item-wise breakdown</li><li>Quantity &amp; pricing</li><li>Subtotal</li><li>GST calculation</li><li>Final payable amount</li></ul><pre>print(&quot;THANK YOU! VISIT AGAIN 😊&quot;)</pre><p>Orders are then cleared — just like a real café system resets after billing.</p><h3>Why This Project Matters</h3><p>This isn’t just a Python exercise.</p><p>It demonstrates:</p><ul><li>Translating business requirements into logic</li><li>Data structuring and hierarchy</li><li>Menu-driven system design</li><li>Real-world billing logic</li><li>Modular, readable code</li></ul><p>These are <strong>core problem-solving skills</strong> used in business analysis, operations, and system design.</p><h3>Visuals from the output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*4D0JfljfTKED5ovdg_OO5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*MqPDoSxsYekcdF3a_xiTTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*lCyQDqEtozxEv5pA1l8B7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*x9ilyopRRKBhkbXDD1Lsvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*tzDBVz3-TwRXWHEB8iZXfg.png" /></figure><h3>Final Thoughts</h3><p>Building this café ordering system helped me understand how <strong>everyday business processes translate into code</strong>.</p><p>From menu design to billing logic, each step required thinking like both:</p><ul><li>A developer</li><li>And a business owner</li></ul><p>That balance is exactly what makes projects like this valuable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=345a80e424f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mini Project 1: I Built a Rock–Paper–Scissors Game in Python — But Made the Computer Smarter]]></title>
            <link>https://medium.com/@janavi.mehta2003/mini-project-1-i-built-a-rock-paper-scissors-game-in-python-but-made-the-computer-smarter-52d4fe0f8cae?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/52d4fe0f8cae</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[minigames]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 07:02:19 GMT</pubDate>
            <atom:updated>2025-12-27T07:02:19.475Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mini Project 1: I Built a Rock–Paper–Scissors Game in Python — But Made the Computer Smarter</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_k1S-x9--lYhcEabtJkEfw.png" /></figure><p>Rock–Paper–Scissors is usually one of the <em>first</em> games we build when learning to code.</p><p>It’s simple.<br>It’s familiar.<br>And honestly… it can be boring.</p><p>So when I decided to build this mini project in Python, I asked myself one question:</p><blockquote>What if the computer actually learned how I play?</blockquote><p>That question turned a basic beginner game into a surprisingly fun exercise in <strong>logic, pattern tracking, and decision-making</strong>.</p><h3>The Idea</h3><p>Instead of letting the computer choose randomly every round, I wanted it to:</p><ul><li>Observe the player’s past moves</li><li>Identify patterns</li><li>Predict the next move</li><li>Respond strategically</li></ul><p>This makes the game feel less mechanical and more… competitive.</p><h3>Game Flow/</h3><p>Each game follows a clear loop:</p><ol><li>User decides how many rounds to play</li><li>Player makes a move</li><li>Computer makes a <em>predicted</em> move</li><li>Winner is decided</li><li>Scores are updated and displayed</li><li>Final winner (or tie) is announced</li></ol><p>Simple structure — but powerful logic underneath.</p><h3>Making the Computer “Think”</h3><p>The heart of this project is the <strong>prediction logic</strong>.</p><p>Instead of randomness, the computer keeps a history of the player’s choices and counts how often each move appears.</p><pre>def smart_computer(history):<br>    if not history:<br>        return random.choice([&quot;rock&quot;, &quot;paper&quot;, &quot;scissors&quot;])<br>counts = {m: history.count(m) for m in [&quot;rock&quot;, &quot;paper&quot;, &quot;scissors&quot;]}<br>    predicted = max(counts, key=counts.get)<br>    if predicted == &quot;rock&quot;:<br>        return &quot;paper&quot;<br>    elif predicted == &quot;paper&quot;:<br>        return &quot;scissors&quot;<br>    else:<br>        return &quot;rock&quot;</pre><h3>What’s happening here?</h3><ul><li>The player’s move history becomes <strong>data</strong></li><li>Frequency analysis identifies behavior</li><li>The computer plays the <strong>counter move</strong></li></ul><p>This is a simple form of <strong>data-driven decision-making</strong> — something that shows up everywhere in analytics.</p><h3>Deciding the Winner (and Handling Ties)</h3><p>The rules of Rock–Paper–Scissors are straightforward, but implementing them cleanly matters.</p><pre>def winner(player, comp):<br>    if player == comp:<br>        return &quot;draw&quot;<br>    if (player == &quot;rock&quot; and comp == &quot;scissors&quot;) or \<br>       (player == &quot;paper&quot; and comp == &quot;rock&quot;) or \<br>       (player == &quot;scissors&quot; and comp == &quot;paper&quot;):<br>        return &quot;player&quot;<br>    return &quot;computer&quot;</pre><p>This function ensures:</p><ul><li>Clear win conditions</li><li>Explicit tie handling</li><li>Easy readability and reuse</li></ul><h3>Tracking Scores Like a Dashboard</h3><p>Scores are stored using a dictionary — simple and effective.</p><pre>score = {<br>    &quot;player&quot;: 0,<br>    &quot;computer&quot;: 0,<br>    &quot;draw&quot;: 0<br>}</pre><p>After every round, the scoreboard is displayed:</p><pre> Score → You: 2 | Computer: 1 | Draws: 1</pre><p>This immediate feedback makes the game engaging and easy to follow.</p><h3>Visuals of the Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SR4J5HbrjEFLFOu3dDjvDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIE0EWPzfzLsipFPMQBhZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zf0L9dFb4dRmYrzUmSVzag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wdRbe_mbhXeHs13mVQIIVQ.png" /></figure><h3>Final Winnings &amp; Tie Conditions</h3><p>Once all rounds are completed, the game evaluates the <strong>final outcome</strong>.</p><pre>if score[&quot;player&quot;] &gt; score[&quot;computer&quot;]:<br>    print(&quot;🎉 YOU BEAT THE COMPUTER!&quot;)<br>elif score[&quot;player&quot;] &lt; score[&quot;computer&quot;]:<br>    print(&quot;🤖 COMPUTER OUTSMARTED YOU!&quot;)<br>else:<br>    print(&quot;⚖️ IT&#39;S A TIE — GOOD GAME!&quot;)</pre><h3>Final Conditions:</h3><ul><li>Player wins → higher score</li><li>Computer wins → higher score</li><li>Tie → equal scores</li></ul><p>No ambiguity. No loose ends.</p><h3>Why This Simple Game Matters</h3><p>On the surface, this is just a game.</p><p>But underneath, it demonstrates:</p><ul><li>Translating real-world rules into logic</li><li>Tracking and analyzing behavioral data</li><li>Predicting outcomes based on patterns</li><li>Writing modular, readable Python code</li></ul><p>These are <strong>core analytical thinking skills</strong>, not just programming tricks.</p><h3>🎯 Final Thoughts</h3><p>This project reminded me that learning doesn’t have to be complex to be meaningful.</p><p>Sometimes, adding <em>one smart idea</em> — like prediction — is enough to turn a beginner exercise into a <strong>thinking exercise</strong>.</p><p>And honestly?<br>Losing to your own algorithm is kind of fun 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52d4fe0f8cae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Dating App Database from Scratch Using SQL Server]]></title>
            <link>https://medium.com/@janavi.mehta2003/building-a-dating-app-database-from-scratch-using-sql-server-910d00165e84?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/910d00165e84</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[dating]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[database-design]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 07:02:01 GMT</pubDate>
            <atom:updated>2025-12-27T07:02:01.085Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iGLpA_HH3Vo3ObCx1V3-ZQ.png" /></figure><h3>An End-to-End Case Study: HeartConnect</h3><p>In this project, I designed and built a <strong>complete dating app database from scratch</strong> using SQL Server. The goal was not just to store data, but to <strong>model real human interactions</strong> — profiles, interests, likes, matches, conversations, and safety reports — and then extract <strong>meaningful business insights</strong> from that data.</p><p>This article walks through the <strong>entire lifecycle</strong> of the project:</p><ul><li>Database design</li><li>Table creation</li><li>Data insertion</li><li>Analytical queries</li><li>Business insights</li></ul><h3>Problem Statement: Why This Database Exists</h3><p>Dating apps are not just social platforms — they are <strong>behavior-driven products</strong>. Every swipe, message, and match is data that helps answer questions like:</p><ul><li>Which users are most engaged?</li><li>What interests drive successful matches?</li><li>How effective is the matching system?</li><li>Where are safety risks occurring?</li></ul><p>To answer these questions, the database must:</p><ul><li>Be <strong>normalized</strong></li><li>Support <strong>many-to-many relationships</strong></li><li>Enforce <strong>data integrity</strong></li><li>Enable <strong>advanced analysis</strong></li></ul><h3>Database Setup: Starting Clean</h3><pre>USE master;<br>IF EXISTS (SELECT name FROM sys.databases WHERE name = &#39;HeartConnect&#39;)<br>BEGIN<br>    ALTER DATABASE HeartConnect SET SINGLE_USER WITH ROLLBACK IMMEDIATE;<br>    DROP DATABASE HeartConnect;<br>END</pre><blockquote>Why this matters : This ensures:</blockquote><blockquote>- No leftover corrupted data</blockquote><blockquote>- Full reproducibility</blockquote><blockquote>- Clean environment for testing and demos</blockquote><p>This mirrors <strong>real-world ETL and staging practices</strong>, where environments are often reset.</p><h3>Core Entity: Users Table</h3><p>The Users table is the <strong>foundation of the entire system</strong>.</p><pre>CREATE TABLE Users (<br>    UserID INT PRIMARY KEY IDENTITY,<br>    Username NVARCHAR(50) UNIQUE NOT NULL,<br>    Email NVARCHAR(100) UNIQUE NOT NULL,<br>    ...<br>    IsActive BIT DEFAULT 1<br>);</pre><h3>Design decisions &amp; reasoning</h3><ul><li>IDENTITY → scalable primary key</li><li>UNIQUE constraints → no duplicate accounts</li><li>IsActive → allows soft deletion instead of data loss</li><li>CreatedAt, LastActive → critical for retention analysis</li></ul><blockquote><strong>Business impact:</strong><br>This table enables <strong>user lifecycle analysis</strong>: onboarding, engagement, churn.</blockquote><h3>Modeling Interests (Many-to-Many Relationship)</h3><h4>Interests Table</h4><pre>CREATE TABLE Interests (<br>    InterestID INT PRIMARY KEY IDENTITY,<br>    InterestName NVARCHAR(50) UNIQUE NOT NULL<br>);</pre><h4>UserInterests (Junction Table)</h4><pre>CREATE TABLE UserInterests (<br>    UserID INT,<br>    InterestID INT,<br>    PRIMARY KEY (UserID, InterestID),<br>    FOREIGN KEY (UserID) REFERENCES Users(UserID) ON DELETE CASCADE<br>);</pre><p><strong>Why this matters : </strong>A user can have many interests, and an interest can belong to many users.<br>This design:</p><ul><li>Prevents duplication</li><li>Scales easily</li><li>Enables interest-based matching algorithms</li></ul><blockquote><strong>Business impact:</strong><br>Supports <strong>recommendation systems</strong> and personalization.</blockquote><h3>Likes &amp; Matches: Capturing User Intent</h3><h4>Likes Table</h4><pre>CREATE TABLE Likes (<br>    FromUserID INT,<br>    ToUserID INT,<br>    CONSTRAINT CK_NoSelfLike CHECK (FromUserID != ToUserID),<br>    CONSTRAINT UQ_OneLikePerPair UNIQUE (FromUserID, ToUserID)<br>);</pre><h4>Matches Table</h4><pre>CREATE TABLE Matches (<br>    User1ID INT,<br>    User2ID INT,<br>    CONSTRAINT CK_DifferentUsers CHECK (User1ID &lt; User2ID)<br>);</pre><p><strong>Why these constraints matter :</strong></p><ul><li>Prevents self-likes</li><li>Avoids duplicate likes</li><li>Ensures consistent match ordering</li></ul><blockquote><strong>Business impact:</strong><br>Accurate calculation of:</blockquote><blockquote>— Match rate</blockquote><blockquote>— Conversion funnel (Like → Match)</blockquote><h3>Messaging System: Engagement Tracking</h3><pre>CREATE TABLE Messages (<br>    MatchID INT,<br>    SenderID INT,<br>    MessageText NVARCHAR(1000),<br>    IsRead BIT DEFAULT 0<br>);</pre><p><strong>Why this matters</strong></p><p>Messages are the <strong>strongest engagement signal</strong> on a dating app.</p><p>This enables:</p><ul><li>Conversation analysis</li><li>Read vs unread metrics</li><li>Engagement depth measurement</li></ul><blockquote><strong>Business impact:</strong><br>Helps product teams understand <strong>what drives real connections</strong>, not just swipes.</blockquote><h3>Safety Layer: Reports Table</h3><pre>CREATE TABLE Reports (<br>    ReporterID INT,<br>    ReportedUserID INT,<br>    Reason NVARCHAR(255),<br>    Status NVARCHAR(20) DEFAULT &#39;Pending&#39;<br>);</pre><p><strong>Why this matters :</strong></p><p>Trust and safety are critical for user retention.</p><blockquote><strong>Business impact:</strong></blockquote><blockquote>- Identifying high-risk users</blockquote><blockquote>- Moderation workflows</blockquote><blockquote>- Compliance reporting</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*spSJhKZyZSUBzYYA9F2pIw.png" /></figure><h3>Data Insertion Strategy</h3><p>Sample data was inserted to simulate:</p><ul><li>Diverse demographics</li><li>Overlapping interests</li><li>Mutual and non-mutual likes</li><li>Active conversations</li><li>User reports</li></ul><p>This allows <strong>realistic analysis</strong>, not synthetic demos.</p><h3>Data analysis</h3><h4>1. Get all active users</h4><pre>SELECT UserID, Username, City, Country<br>FROM Users<br>WHERE IsActive = 1;</pre><h4>2. Count total number of users</h4><pre>SELECT COUNT(*) AS TotalUsers<br>FROM Users;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/151/1*wOWpyAfEyrr-dtRXcCncQA.png" /></figure><h4>3. List all distinct interests</h4><pre>SELECT DISTINCT InterestName<br>FROM Interests;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*Kfz5xmV7tYwZzbfAIHDcXQ.png" /></figure><h4>4. Get users from a specific city (example: Mumbai)</h4><pre>SELECT UserID, Username, Email<br>FROM Users<br>WHERE City = &#39;Mumbai&#39;;</pre><h4>5. Count total likes given</h4><pre>SELECT COUNT(*) AS TotalLikes<br>FROM Likes;</pre><h4>6. Get users along with their interests</h4><pre>SELECT <br>    U.Username,<br>    I.InterestName<br>FROM Users U<br>JOIN UserInterests UI ON U.UserID = UI.UserID<br>JOIN Interests I ON UI.InterestID = I.InterestID;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*QvrMkGiNI-tZKbEtR-Ys6A.png" /></figure><h4>7. Number of interests per user</h4><pre>SELECT <br>    U.Username,<br>    COUNT(UI.InterestID) AS TotalInterests<br>FROM Users U<br>LEFT JOIN UserInterests UI ON U.UserID = UI.UserID<br>GROUP BY U.Username;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*Dq0d2xyLe_xFCVyzWsCw7w.png" /></figure><h4>8. Users who received the most likes</h4><pre>SELECT <br>    ToUserID,<br>    COUNT(*) AS LikesReceived<br>FROM Likes<br>GROUP BY ToUserID<br>ORDER BY LikesReceived DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*rl_xhCIC-5zEpKgNzLnEPw.png" /></figure><h4>9. Total matches per user</h4><pre>SELECT <br>    UserID,<br>    COUNT(*) AS TotalMatches<br>FROM Matches<br>GROUP BY UserID;</pre><h4>10. Messages sent per user</h4><pre>SELECT <br>    SenderID,<br>    COUNT(*) AS MessagesSent<br>FROM Messages<br>GROUP BY SenderID;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*tyVPRZwwfgzm_y99lxXrNg.png" /></figure><h4>11. Top 3 most liked users</h4><pre>SELECT TOP 3<br>    ToUserID,<br>    COUNT(*) AS LikesReceived<br>FROM Likes<br>GROUP BY ToUserID<br>ORDER BY LikesReceived DESC;</pre><h4>12. Users who have never received a like</h4><pre>SELECT U.UserID, U.Username<br>FROM Users U<br>LEFT JOIN Likes L ON U.UserID = L.ToUserID<br>WHERE L.ToUserID IS NULL;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*0uRCNj4gW6qfMvaM6KaMfw.png" /></figure><h4>13. Users with more than 3 interests</h4><pre>SELECT <br>    U.UserID,<br>    U.Username,<br>    COUNT(UI.InterestID) AS InterestCount<br>FROM Users U<br>JOIN UserInterests UI ON U.UserID = UI.UserID<br>GROUP BY U.UserID, U.Username<br>HAVING COUNT(UI.InterestID) &gt; 3;</pre><h4>14. Mutual matches (User1 ↔ User2)</h4><pre>SELECT <br>    M1.UserID AS UserA,<br>    M1.User2ID AS UserB<br>FROM Matches M1<br>JOIN Matches M2<br>    ON M1.UserID = M2.User2ID<br>   AND M1.User2ID = M2.UserID;</pre><h4>15. Most reported users</h4><pre>SELECT <br>    ReportedUserID,<br>    COUNT(*) AS TotalReports<br>FROM Reports<br>GROUP BY ReportedUserID<br>ORDER BY TotalReports DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*Lv1Brz31Om4ZHS2RzZoDHw.png" /></figure><h3>Key Business Insights This Database Enables</h3><p>With this system, stakeholders can answer:</p><ul><li>Which cities are most active?</li><li>What interests lead to higher match success?</li><li>Who are the most reported users?</li><li>Are messages driving retention?</li><li>How efficient is the matching algorithm?</li></ul><h3>Why This Project Matters for a Business Analyst</h3><p>This project demonstrates:</p><ul><li><strong>Data modeling from business requirements</strong></li><li><strong>SQL proficiency beyond CRUD</strong></li><li><strong>Analytical storytelling</strong></li><li><strong>Product thinking using data</strong></li><li><strong>End-to-end ownership</strong></li></ul><p>It bridges the gap between:</p><blockquote>“I know SQL”<em><br>and<br></em>“I can analyze and influence product decisions.”</blockquote><h3>Final Thoughts</h3><p>HeartConnect is not just a database — it’s a <strong>simulation of a real product ecosystem</strong>. By designing the schema thoughtfully and writing analytical queries with intent, this project mirrors how data is used in real-world dating and social platforms.</p><p>If you’re transitioning into <strong>Business Analytics</strong>, this is exactly the kind of project that <strong>signals depth, clarity, and impact</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=910d00165e84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Game Logs to Growth : End-to-End SQL Server Analytics Case Study for a Gaming Platform.]]></title>
            <link>https://medium.com/@janavi.mehta2003/from-game-logs-to-growth-end-to-end-sql-server-analytics-case-study-for-a-gaming-platform-bae5ed68b732?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/bae5ed68b732</guid>
            <category><![CDATA[data-storytelling]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[dashboard-design]]></category>
            <category><![CDATA[business-analytics]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Thu, 25 Dec 2025 16:32:40 GMT</pubDate>
            <atom:updated>2025-12-25T16:32:40.245Z</atom:updated>
            <content:encoded><![CDATA[<h3>From Game Logs to Growth : End-to-End SQL Server Analytics Case Study for a Gaming Platform.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M2UHOr2ACQRbuCbNbzHAlA.png" /></figure><h3>Executive Summary</h3><p>In this project, I designed a <strong>gaming analytics database</strong>, populated it with realistic transactional data, and performed <strong>multi-level SQL analysis</strong> to answer strategic business questions around:</p><ul><li>Player engagement &amp; performance</li><li>Match behavior &amp; game popularity</li><li>Tournament effectiveness &amp; prize efficiency</li><li>Player segmentation for retention and monetization</li></ul><p>The entire analysis was executed in <strong>SQL Server</strong>, and the outputs were structured to directly feed into <strong>Excel / Power BI dashboards</strong>.</p><h3>Business Context &amp; Problem Statement</h3><p>Online gaming platforms operate at the intersection of:</p><ul><li><strong>Engagement</strong> (players &amp; matches)</li><li><strong>Competition</strong> (rankings &amp; tournaments)</li><li><strong>Revenue</strong> (tournaments, rewards, retention)</li></ul><p>However, stakeholders often struggle to answer:</p><ul><li><em>Which players matter most?</em></li><li><em>Which games deserve investment?</em></li><li><em>Are tournaments actually worth the cost?</em></li><li><em>How balanced is player skill distribution?</em></li></ul><p><strong>Objective:</strong><br>Transform raw operational data into <strong>actionable insights</strong> using SQL Server.</p><h3>Data Modeling: Thinking Like an Analyst</h3><p>Instead of jumping into queries, I first designed an <strong>analytics-ready schema</strong>.</p><h3>Modeling Decisions</h3><ul><li><strong>Fact tables</strong> capture measurable events</li></ul><p>Matches</p><p>PlayerMatchPerformance</p><p>TournamentParticipants</p><ul><li><strong>Dimension tables</strong> provide descriptive context</li></ul><p>Players</p><p>Games</p><p>Achievements</p><p>This structure supports:</p><ul><li>Time-based trends</li><li>Player-level aggregation</li><li>Performance ranking</li><li>Dashboard scalability</li></ul><h3>Data Preparation (SQL Server Compatible)</h3><h4>Core Table Example:</h4><p><strong>1.1 Players</strong></p><pre>CREATE TABLE Players (<br>    PlayerID INT PRIMARY KEY,<br>    Username VARCHAR(50) NOT NULL,<br>    Email VARCHAR(100) NOT NULL,<br>    Country VARCHAR(50),<br>    JoinDate DATE,<br>    LastLogin DATETIME2,<br>    Status VARCHAR(20) CHECK (Status IN (&#39;Active&#39;, &#39;Inactive&#39;))<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*mKFHQa5GQq0lklTc5r1shg.png" /></figure><p><strong>1.2 Games</strong></p><pre>CREATE TABLE Games (<br>    GameID INT PRIMARY KEY,<br>    GameName VARCHAR(100) NOT NULL,<br>    Genre VARCHAR(50),<br>    DifficultyLevel VARCHAR(20),<br>    ActivePlayers INT,<br>    ReleaseDate DATE<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*n6KyT8-ODV2YUgRqRXzQxQ.png" /></figure><p><strong>1.3 Matches</strong></p><pre>CREATE TABLE Matches (<br>    MatchID INT PRIMARY KEY,<br>    GameID INT,<br>    MatchDate DATE,<br>    MatchStartTime DATETIME2,<br>    MatchEndTime DATETIME2,<br>    MatchType VARCHAR(30)<br>        CHECK (MatchType IN (&#39;Solo&#39;, &#39;Duo&#39;, &#39;Squad&#39;, &#39;Tournament&#39;)),<br>    CONSTRAINT FK_Matches_Games<br>        FOREIGN KEY (GameID) REFERENCES Games(GameID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*A3wVBc1_FFSW6sfCQTYpyg.png" /></figure><p><strong>1.4 PlayerMatchPerformance</strong></p><pre>CREATE TABLE PlayerMatchPerformance (<br>    PerformanceID INT PRIMARY KEY,<br>    MatchID INT,<br>    PlayerID INT,<br>    Score INT,<br>    Kills INT,<br>    Deaths INT,<br>    Assists INT,<br>    RankPosition INT,<br>    MatchDurationMinutes INT,<br>    CONSTRAINT FK_PMP_Matches<br>        FOREIGN KEY (MatchID) REFERENCES Matches(MatchID),<br>    CONSTRAINT FK_PMP_Players<br>        FOREIGN KEY (PlayerID) REFERENCES Players(PlayerID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qxD4NGvwcLghkz57Lt8tAQ.png" /></figure><p><strong>1.5 Achievements</strong></p><pre>CREATE TABLE Achievements (<br>    AchievementID INT PRIMARY KEY,<br>    AchievementName VARCHAR(100),<br>    Description VARCHAR(255),<br>    Points INT,<br>    Difficulty VARCHAR(20)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*z-ctCDuACzXNM1FiYCIViQ.png" /></figure><p><strong>1.6 PlayerAchievements</strong></p><pre>CREATE TABLE PlayerAchievements (<br>    PlayerID INT,<br>    AchievementID INT,<br>    AchievedDate DATE,<br>    PRIMARY KEY (PlayerID, AchievementID),<br>    CONSTRAINT FK_PA_Players<br>        FOREIGN KEY (PlayerID) REFERENCES Players(PlayerID),<br>    CONSTRAINT FK_PA_Achievements<br>        FOREIGN KEY (AchievementID) REFERENCES Achievements(AchievementID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*1G53DrcdzZIO2Wb6jWyPhQ.png" /></figure><p><strong>1.7 Tournaments</strong></p><pre>CREATE TABLE Tournaments (<br>    TournamentID INT PRIMARY KEY,<br>    TournamentName VARCHAR(100),<br>    GameID INT,<br>    StartDate DATE,<br>    EndDate DATE,<br>    PrizePool DECIMAL(12,2),<br>    Status VARCHAR(20)<br>        CHECK (Status IN (&#39;Upcoming&#39;, &#39;Ongoing&#39;, &#39;Completed&#39;)),<br>    CONSTRAINT FK_Tournaments_Games<br>        FOREIGN KEY (GameID) REFERENCES Games(GameID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*c_NWb8nqcuURwMaxwRDnjg.png" /></figure><p><strong>1.8 TournamentParticipants</strong></p><pre>CREATE TABLE TournamentParticipants (<br>    TournamentID INT,<br>    PlayerID INT,<br>    FinalRank INT,<br>    TotalScore INT,<br>    PrizeMoney DECIMAL(12,2),<br>    PRIMARY KEY (TournamentID, PlayerID),<br>    CONSTRAINT FK_TP_Tournaments<br>        FOREIGN KEY (TournamentID) REFERENCES Tournaments(TournamentID),<br>    CONSTRAINT FK_TP_Players<br>        FOREIGN KEY (PlayerID) REFERENCES Players(PlayerID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*WGxPcUwxaMUFxbYbtKbXlg.png" /></figure><p><strong>1.9 PlayerInventory</strong></p><pre>CREATE TABLE PlayerInventory (<br>    InventoryID INT PRIMARY KEY,<br>    PlayerID INT,<br>    ItemName VARCHAR(100),<br>    ItemType VARCHAR(50),<br>    Rarity VARCHAR(20),<br>    AcquiredDate DATE,<br>    CONSTRAINT FK_PI_Players<br>        FOREIGN KEY (PlayerID) REFERENCES Players(PlayerID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*00KnjxiZs9ZKGMC8ToemEw.png" /></figure><h3>INSERT QUERIES examples:</h3><p><strong>2.1 Players</strong></p><pre>INSERT INTO Players<br>(PlayerID, Username, Email, Country, JoinDate, LastLogin, Status)<br>VALUES<br>(1, &#39;ProGamer123&#39;, &#39;progamer@email.com&#39;, &#39;USA&#39;, &#39;2023-01-15&#39;, &#39;2024-01-25 18:30:00&#39;, &#39;Active&#39;),<br>(2, &#39;SkillMaster&#39;, &#39;skill@email.com&#39;, &#39;UK&#39;, &#39;2023-02-20&#39;, &#39;2024-01-24 22:15:00&#39;, &#39;Active&#39;),<br>(3, &#39;ShadowNinja&#39;, &#39;shadow@email.com&#39;, &#39;Japan&#39;, &#39;2023-03-10&#39;, &#39;2024-01-25 14:45:00&#39;, &#39;Active&#39;),<br>(4, &#39;EliteSniper&#39;, &#39;elite@email.com&#39;, &#39;Canada&#39;, &#39;2023-01-25&#39;, &#39;2024-01-23 20:00:00&#39;, &#39;Active&#39;),<br>(5, &#39;ThunderBolt&#39;, &#39;thunder@email.com&#39;, &#39;Germany&#39;, &#39;2023-04-05&#39;, &#39;2024-01-25 16:20:00&#39;, &#39;Active&#39;),<br>(6, &#39;DragonSlayer&#39;, &#39;dragon@email.com&#39;, &#39;South Korea&#39;, &#39;2023-02-14&#39;, &#39;2024-01-25 19:10:00&#39;, &#39;Active&#39;),<br>(7, &#39;PhantomWarrior&#39;, &#39;phantom@email.com&#39;, &#39;Brazil&#39;, &#39;2023-05-18&#39;, &#39;2024-01-22 11:30:00&#39;, &#39;Active&#39;),<br>(8, &#39;CyberKnight&#39;, &#39;cyber@email.com&#39;, &#39;Australia&#39;, &#39;2023-03-22&#39;, &#39;2024-01-25 21:00:00&#39;, &#39;Active&#39;),<br>(9, &#39;NoobSlayer&#39;, &#39;noob@email.com&#39;, &#39;India&#39;, &#39;2023-06-10&#39;, &#39;2024-01-20 09:45:00&#39;, &#39;Inactive&#39;),<br>(10, &#39;LegendKiller&#39;, &#39;legend@email.com&#39;, &#39;Mexico&#39;, &#39;2023-01-30&#39;, &#39;2024-01-25 17:30:00&#39;, &#39;Active&#39;),<br>(11, &#39;StealthMode&#39;, &#39;stealth@email.com&#39;, &#39;France&#39;, &#39;2023-07-08&#39;, &#39;2024-01-19 13:20:00&#39;, &#39;Active&#39;),<br>(12, &#39;RapidFire&#39;, &#39;rapid@email.com&#39;, &#39;Spain&#39;, &#39;2023-04-15&#39;, &#39;2024-01-25 15:00:00&#39;, &#39;Active&#39;);</pre><p><strong>2.2 Games</strong></p><pre>INSERT INTO Games<br>(GameID, GameName, Genre, DifficultyLevel, ActivePlayers, ReleaseDate)<br>VALUES<br>(1, &#39;Battle Royale Arena&#39;, &#39;Battle Royale&#39;, &#39;Hard&#39;, 10000, &#39;2022-06-15&#39;),<br>(2, &#39;Speed Racers Championship&#39;, &#39;Racing&#39;, &#39;Medium&#39;, 5000, &#39;2021-03-20&#39;),<br>(3, &#39;Fantasy Quest Online&#39;, &#39;RPG&#39;, &#39;Expert&#39;, 15000, &#39;2020-09-10&#39;),<br>(4, &#39;Tactical Warfare&#39;, &#39;FPS&#39;, &#39;Hard&#39;, 8000, &#39;2022-11-05&#39;),<br>(5, &#39;Puzzle Masters&#39;, &#39;Puzzle&#39;, &#39;Easy&#39;, 3000, &#39;2023-01-18&#39;);</pre><p><strong>2.3 Matches</strong></p><pre>INSERT INTO Matches<br>(MatchID, GameID, MatchDate, MatchStartTime, MatchEndTime, MatchType)<br>VALUES<br>(1, 1, &#39;2024-01-20&#39;, &#39;2024-01-20 14:00:00&#39;, &#39;2024-01-20 14:30:00&#39;, &#39;Solo&#39;),<br>(2, 1, &#39;2024-01-20&#39;, &#39;2024-01-20 15:00:00&#39;, &#39;2024-01-20 15:35:00&#39;, &#39;Squad&#39;),<br>(3, 2, &#39;2024-01-21&#39;, &#39;2024-01-21 16:00:00&#39;, &#39;2024-01-21 16:20:00&#39;, &#39;Solo&#39;),<br>(4, 3, &#39;2024-01-21&#39;, &#39;2024-01-21 18:00:00&#39;, &#39;2024-01-21 19:30:00&#39;, &#39;Duo&#39;),<br>(5, 4, &#39;2024-01-22&#39;, &#39;2024-01-22 20:00:00&#39;, &#39;2024-01-22 20:45:00&#39;, &#39;Squad&#39;),<br>(6, 1, &#39;2024-01-22&#39;, &#39;2024-01-22 21:00:00&#39;, &#39;2024-01-22 21:25:00&#39;, &#39;Solo&#39;),<br>(7, 2, &#39;2024-01-23&#39;, &#39;2024-01-23 17:00:00&#39;, &#39;2024-01-23 17:25:00&#39;, &#39;Solo&#39;),<br>(8, 3, &#39;2024-01-23&#39;, &#39;2024-01-23 19:00:00&#39;, &#39;2024-01-23 20:15:00&#39;, &#39;Tournament&#39;),<br>(9, 4, &#39;2024-01-24&#39;, &#39;2024-01-24 15:00:00&#39;, &#39;2024-01-24 15:50:00&#39;, &#39;Squad&#39;),<br>(10, 1, &#39;2024-01-24&#39;, &#39;2024-01-24 22:00:00&#39;, &#39;2024-01-24 22:30:00&#39;, &#39;Solo&#39;),<br>(11, 5, &#39;2024-01-25&#39;, &#39;2024-01-25 10:00:00&#39;, &#39;2024-01-25 10:30:00&#39;, &#39;Solo&#39;),<br>(12, 1, &#39;2024-01-25&#39;, &#39;2024-01-25 16:00:00&#39;, &#39;2024-01-25 16:28:00&#39;, &#39;Duo&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z2r9iypfJiGAkkv7b_QyfA.png" /><figcaption>final database</figcaption></figure><h3>Exploratory Analysis: Understanding the Platform</h3><h4>KPI 1: Active Player Base</h4><pre>SELECT COUNT(*) AS ActivePlayers<br>FROM Players<br>WHERE Status = &#39;Active&#39;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/169/1*pl58lrbiZgnoHcx9rhg3pA.png" /></figure><blockquote><strong>Insight:</strong><br>This forms the foundation for <strong>DAU / MAU metrics</strong> and capacity planning.</blockquote><h4>KPI 2: Game Popularity</h4><pre>SELECT GameID, COUNT(*) AS TotalMatches<br>FROM Matches<br>GROUP BY GameID;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*H5wls0E9h8Hz0eRkAgMxGg.png" /></figure><blockquote><strong>Insight:</strong><br>A small number of games drive most matches → <strong>Pareto effect</strong>.</blockquote><h4>KPI 3: Top Players by Total Score</h4><pre>SELECT <br>    P.Username,<br>    SUM(PMP.Score) AS TotalScore<br>FROM PlayerMatchPerformance PMP<br>JOIN Players P ON PMP.PlayerID = P.PlayerID<br>GROUP BY P.Username<br>ORDER BY TotalScore DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*iHFELWRTr2fv2vA2CsAhFA.png" /></figure><blockquote><strong>Story:</strong><br>Elite players consistently outperform others, making them ideal for:</blockquote><blockquote>- Esports promotion</blockquote><blockquote>- Premium features</blockquote><blockquote>- Community leadership</blockquote><h4>KPI 4: Average Match Duration by Match Type</h4><pre>SELECT <br>    M.MatchType,<br>    AVG(PMP.MatchDurationMinutes) AS AvgDuration<br>FROM PlayerMatchPerformance PMP<br>JOIN Matches M ON PMP.MatchID = M.MatchID<br>GROUP BY M.MatchType;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*wSlqeUEhH5Oigq2Ye5J3Cg.png" /></figure><blockquote><strong>Insight:</strong><br>Tournament matches are longer → <strong>higher engagement, higher cost</strong>.</blockquote><h4>KPI 5: Player Ranking</h4><pre>SELECT <br>    P.Username,<br>    SUM(PMP.Score) AS TotalScore,<br>    RANK() OVER (ORDER BY SUM(PMP.Score) DESC) AS PlayerRank<br>FROM PlayerMatchPerformance PMP<br>JOIN Players P ON PMP.PlayerID = P.PlayerID<br>GROUP BY P.Username;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*_zuwyhO9MaYi7NYl9tEpgg.png" /></figure><blockquote><strong>Why this is powerful:</strong></blockquote><blockquote>- Enables fair matchmaking</blockquote><blockquote>- Supports tier-based rewards</blockquote><blockquote>- Demonstrates advanced SQL proficiency</blockquote><h4>KPI 6: Win Rate Analysis</h4><pre>SELECT <br>    P.Username,<br>    COUNT(CASE WHEN PMP.RankPosition = 1 THEN 1 END) * 100.0 / COUNT(*) AS WinRate<br>FROM PlayerMatchPerformance PMP<br>JOIN Players P ON PMP.PlayerID = P.PlayerID<br>GROUP BY P.Username;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*MNahntetwtejKrptTJJZYw.png" /></figure><blockquote><strong>Insight:</strong><br>Win rate is a stronger skill indicator than raw score.</blockquote><h4>KPI 7: Prize Pool Utilization</h4><pre>SELECT <br>    T.TournamentName,<br>    T.PrizePool,<br>    SUM(TP.PrizeMoney) AS DistributedPrize<br>FROM Tournaments T<br>LEFT JOIN TournamentParticipants TP<br>    ON T.TournamentID = TP.TournamentID<br>GROUP BY T.TournamentName, T.PrizePool;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*_-DZ-mC2qJwYL6mUki9DtQ.png" /></figure><blockquote><strong>Storytelling Insight:</strong><br>Not all tournaments distribute 100% of prize pools → signals:</blockquote><blockquote>- Participation issues</blockquote><blockquote>- Operational inefficiencies</blockquote><blockquote>- Optimization opportunities</blockquote><h4>KPI 8: Performance Tier Classification</h4><pre>SELECT <br>    P.Username,<br>    CASE<br>        WHEN AVG(PMP.Score) &gt;= 10000 THEN &#39;Elite&#39;<br>        WHEN AVG(PMP.Score) &gt;= 7000 THEN &#39;Pro&#39;<br>        ELSE &#39;Beginner&#39;<br>    END AS PerformanceTier<br>FROM PlayerMatchPerformance PMP<br>JOIN Players P ON PMP.PlayerID = P.PlayerID<br>GROUP BY P.Username;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*5LDqIjBlV_JzvsIuzcu1ww.png" /></figure><p><strong>Business Use:</strong></p><ul><li>Personalized rewards</li><li>Dynamic difficulty</li><li>Retention campaigns</li></ul><h3>Final Business Recommendations</h3><h4>From the analysis:</h4><ul><li>🎯 Focus investment on top 20% games</li><li>🏆 Leverage elite players for branding</li><li>💰 Optimize tournament prize allocation</li><li>🧠 Introduce tier-based matchmaking</li><li>📉 Monitor long match durations for server costs</li></ul><h3>Analysis (Key Insights)</h3><ul><li>Transformed raw gaming data into structured insights by linking <strong>player behavior, match activity, and competitive outcomes</strong> across the platform.</li><li>Aggregated <strong>match-level performance data</strong> to identify engagement patterns by match type.</li><li>Found that <strong>tournament and squad matches</strong> generate longer session durations and higher cumulative scores, indicating deeper engagement.</li><li>Identified <strong>win rate and performance consistency</strong> as stronger indicators of player skill than isolated high scores.</li><li>Enabled more accurate <strong>player ranking and segmentation</strong> through multi-metric evaluation.</li><li>Analyzed tournament data to uncover <strong>gaps between prize pool allocation and actual prize distribution</strong>.</li><li>Highlighted potential <strong>operational and participation inefficiencies</strong>, rather than lack of player demand.</li><li>Demonstrated how well-modeled relational data can explain <strong>why outcomes occur</strong>, not just <strong>what happened</strong>, supporting strategic decisions.</li></ul><h3>Conclusion</h3><p>This case study demonstrates an end-to-end analytics workflow, from database design and SQL Server–compatible data ingestion to advanced analytical queries and business-driven insights. By treating SQL not merely as a querying tool but as an analytical language, the project shows how structured data can inform product strategy, player retention, competitive balance, and tournament ROI. The final outputs are intentionally dashboard-ready, ensuring that insights are accessible to both technical and non-technical stakeholders. Ultimately, this project reflects the role of a business analyst as a bridge between data and decisions — converting complex game logs into clear growth levers for the business.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bae5ed68b732" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Online Shopping Database from Scratch (SQL Server)]]></title>
            <link>https://medium.com/@janavi.mehta2003/building-an-online-shopping-database-from-scratch-sql-server-7ee197852955?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ee197852955</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[business-analyst]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Thu, 25 Dec 2025 16:31:59 GMT</pubDate>
            <atom:updated>2025-12-25T16:31:59.535Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Beginner–Intermediate End-to-End SQL Project with Real Business Analysis</h3><p>If you’re learning SQL and want a <strong>realistic project</strong> (not toy examples), this article walks through building an <strong>online shopping mini database</strong> completely from scratch using <strong>SQL Server</strong>.</p><p>We’ll go step by step — from <strong>database setup</strong> to <strong>table design</strong>, <strong>data insertion</strong>, and finally <strong>business-style analytical queries</strong> that reflect how SQL is used in real companies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9hdbXhWAvcGTXO2rTgf08Q.png" /></figure><h3>Introduction</h3><p>Learning SQL becomes far more effective when you stop writing isolated queries and start thinking in terms of <strong>real business problems</strong>.</p><p>Most beginners struggle not because SQL is difficult, but because they don’t understand <strong>how databases are designed or used in real-world systems</strong>.</p><p>This project focuses on building a <strong>mini online shopping (e-commerce) database</strong> entirely from scratch using SQL Server. Instead of working with pre-built datasets, we design the schema ourselves, insert realistic transactional data, and then analyze it using business-driven SQL queries.</p><p>The database mirrors how a real online shopping platform operates:</p><ul><li>Customers browse products</li><li>Customers place orders</li><li>Each order contains multiple products</li><li>Businesses analyze revenue, customers, and product performance</li></ul><p>By the end of this project, SQL stops feeling like a set of commands and starts feeling like a <strong>decision-making tool</strong>.</p><h4>Skills Covered</h4><p>This project demonstrates:</p><ul><li>Relational database design</li><li>Primary keys &amp; foreign keys</li><li>One-to-many relationships</li><li>SQL joins &amp; aggregations</li><li>Views for reporting</li><li>Subqueries, CTEs, and window functions</li></ul><p><strong>Tech used:</strong> SQL Server (SSMS)</p><h3>Project Objective</h3><p>The primary objective of this project is to <strong>design, populate, and analyze a relational database</strong> for an online shopping platform using SQL Server.</p><ul><li>Build a clean and logical database schema using multiple related tables</li><li>Understand primary key and foreign key relationships</li><li>Insert realistic sample data that reflects real business transactions</li><li>Write SQL queries that answer practical business questions, such as:</li></ul><ol><li>Who are the top-spending customers?</li></ol><p>2. Which products sell the most?</p><p>3. How much revenue is generated by each city?</p><ul><li>Gradually move from <strong>basic SQL queries</strong> to <strong>intermediate analytical queries</strong> using: Joins, Aggregations, Subqueries, CTEs, Window functions,</li></ul><p>The goal is not just to <em>run SQL queries</em>, but to <strong>think like an analyst working with production data</strong>.</p><h3>Database Design Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*gSL0oppENVtAxgvI6KPnmg.png" /></figure><h4>Create Database</h4><pre>CREATE DATABASE OnlineShopDB;<br>GO<br>USE OnlineShopDB;<br>GO</pre><h4>Create Tables</h4><p><strong>1. Customers</strong></p><pre>CREATE TABLE Customers (<br>    CustomerID INT IDENTITY PRIMARY KEY,<br>    FirstName VARCHAR(50),<br>    LastName VARCHAR(50),<br>    Email VARCHAR(100),<br>    Phone VARCHAR(20),<br>    City VARCHAR(50),<br>    CreatedDate DATE DEFAULT GETDATE()<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*6VwLP6gtD272vEwYkYC0Vg.png" /></figure><p><strong>2. Products</strong></p><pre>CREATE TABLE Products (<br>    ProductID INT IDENTITY PRIMARY KEY,<br>    ProductName VARCHAR(100),<br>    Category VARCHAR(50),<br>    Brand VARCHAR(50),<br>    Price DECIMAL(10,2),<br>    StockQuantity INT,<br>    IsActive BIT<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*vP2oes43J3B9pB84AP2YwQ.png" /></figure><p><strong>3. Orders</strong></p><pre>CREATE TABLE Orders (<br>    OrderID INT IDENTITY PRIMARY KEY,<br>    CustomerID INT,<br>    OrderDate DATE DEFAULT GETDATE(),<br>    OrderStatus VARCHAR(30),<br>    PaymentMethod VARCHAR(30),<br>    ShippingCity VARCHAR(50),<br>    TotalAmount DECIMAL(10,2),<br>    FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*9sBUtAMtE3okjieh15fajw.png" /></figure><p><strong>4. OrderItems</strong></p><pre>CREATE TABLE OrderItems (<br>    OrderItemID INT IDENTITY PRIMARY KEY,<br>    OrderID INT,<br>    ProductID INT,<br>    Quantity INT,<br>    UnitPrice DECIMAL(10,2),<br>    Discount DECIMAL(5,2),<br>    FOREIGN KEY (OrderID) REFERENCES Orders(OrderID),<br>    FOREIGN KEY (ProductID) REFERENCES Products(ProductID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*7u4UHerILEuNo_izzqSk-g.png" /></figure><h4>Insert Sample Data</h4><p><strong>Insert Customers</strong></p><pre>INSERT INTO Customers VALUES<br>(&#39;Aarav&#39;,&#39;Patel&#39;,&#39;aarav@gmail.com&#39;,&#39;9876543210&#39;,&#39;Mumbai&#39;,GETDATE()),<br>(&#39;Neha&#39;,&#39;Sharma&#39;,&#39;neha@gmail.com&#39;,&#39;9123456789&#39;,&#39;Delhi&#39;,GETDATE()),<br>(&#39;Rahul&#39;,&#39;Verma&#39;,&#39;rahul@gmail.com&#39;,&#39;9988776655&#39;,&#39;Bangalore&#39;,GETDATE());</pre><p><strong>Insert Products</strong></p><pre>INSERT INTO Products VALUES<br>(&#39;Smartphone&#39;,&#39;Electronics&#39;,&#39;Samsung&#39;,25000,50,1),<br>(&#39;Laptop&#39;,&#39;Electronics&#39;,&#39;Dell&#39;,65000,20,1),<br>(&#39;Headphones&#39;,&#39;Accessories&#39;,&#39;Boat&#39;,2000,100,1);</pre><p><strong>Insert Orders</strong></p><pre>INSERT INTO Orders VALUES<br>(1,GETDATE(),&#39;Delivered&#39;,&#39;Card&#39;,&#39;Mumbai&#39;,29000),<br>(2,GETDATE(),&#39;Shipped&#39;,&#39;UPI&#39;,&#39;Delhi&#39;,65000),<br>(1,GETDATE(),&#39;Confirmed&#39;,&#39;COD&#39;,&#39;Mumbai&#39;,2000);</pre><p><strong>Insert Order Items</strong></p><pre>INSERT INTO OrderItems VALUES<br>(1,1,1,25000,0),<br>(1,3,2,2000,0),<br>(2,2,1,65000,0),<br>(3,3,1,2000,0);</pre><h3>Data Analysis</h3><h4>Orders with Customer Details</h4><pre>SELECT<br>    o.OrderID,<br>    c.FirstName + &#39; &#39; + c.LastName AS CustomerName,<br>    o.OrderStatus,<br>    o.TotalAmount<br>FROM Orders o<br>JOIN Customers c ON o.CustomerID = c.CustomerID;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*NiDWe-WfZb9YVQWces-bgA.png" /></figure><h4>Total Spending Per Customer</h4><pre>SELECT<br>    c.FirstName,<br>    SUM(o.TotalAmount) AS TotalSpent<br>FROM Customers c<br>JOIN Orders o ON c.CustomerID = o.CustomerID<br>GROUP BY c.FirstName;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*Hi3IO8-YLHxZZqKXmeeYPw.png" /></figure><h4>Best Selling Products</h4><pre>SELECT<br>    p.ProductName,<br>    SUM(oi.Quantity) AS TotalSold<br>FROM Products p<br>JOIN OrderItems oi ON p.ProductID = oi.ProductID<br>GROUP BY p.ProductName<br>ORDER BY TotalSold DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*mOH5RyuR5DlTG5jzIw0TLQ.png" /></figure><h4>Revenue by City</h4><pre>SELECT<br>    ShippingCity,<br>    SUM(TotalAmount) AS Revenue<br>FROM Orders<br>GROUP BY ShippingCity;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*hsusLjJi2tMnVQac245auQ.png" /></figure><h4>Create View (Reporting)</h4><pre>CREATE VIEW vw_OrderSummary AS<br>SELECT<br>    o.OrderID,<br>    c.FirstName + &#39; &#39; + c.LastName AS CustomerName,<br>    o.OrderDate,<br>    o.OrderStatus,<br>    o.TotalAmount<br>FROM Orders o<br>JOIN Customers c ON o.CustomerID = c.CustomerID;</pre><h4>Customers Who Placed More Than Average Number of Orders</h4><pre>SELECT<br>    c.CustomerID,<br>    c.FirstName,<br>    COUNT(o.OrderID) AS OrderCount<br>FROM Customers c<br>JOIN Orders o ON c.CustomerID = o.CustomerID<br>GROUP BY c.CustomerID, c.FirstName<br>HAVING COUNT(o.OrderID) &gt;<br>(<br>    SELECT AVG(OrderCount)<br>    FROM (<br>        SELECT COUNT(*) AS OrderCount<br>        FROM Orders<br>        GROUP BY CustomerID<br>    ) x<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*EdGZAepgw_xqiezZWeAuBg.png" /></figure><h4>Rank Customers by Total Spending</h4><pre>SELECT<br>    c.FirstName,<br>    SUM(o.TotalAmount) AS TotalSpent,<br>    RANK() OVER (ORDER BY SUM(o.TotalAmount) DESC) AS SpendRank<br>FROM Customers c<br>JOIN Orders o ON c.CustomerID = o.CustomerID<br>GROUP BY c.FirstName;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*Mcs130TkvKGbQixuzxy4GQ.png" /></figure><h4>Running Total of Revenue by Order Date</h4><pre>WITH DailyRevenue AS (<br>    SELECT<br>        OrderDate,<br>        SUM(TotalAmount) AS Revenue<br>    FROM Orders<br>    GROUP BY OrderDate<br>)<br>SELECT<br>    OrderDate,<br>    Revenue,<br>    SUM(Revenue) OVER (ORDER BY OrderDate) AS RunningRevenue<br>FROM DailyRevenue;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*5W22zDmmDVvCQzz6T75sow.png" /></figure><h4>Orders Above Average Order Value</h4><pre>WITH AvgOrderValue AS (<br>    SELECT AVG(TotalAmount) AS AvgAmount<br>    FROM Orders<br>)<br>SELECT<br>    o.OrderID,<br>    o.TotalAmount<br>FROM Orders o<br>CROSS JOIN AvgOrderValue a<br>WHERE o.TotalAmount &gt; a.AvgAmount;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*hWvoCTfzT16kYbhvAmh71w.png" /></figure><h3>Analysis Pointers :</h3><p><strong>Customer Analysis —</strong></p><ul><li>Track customer spending</li><li>Identify repeat vs one-time buyers</li><li>Rank customers by revenue</li></ul><blockquote><em>Why it matters:</em> Helps identify high-value customers and retention opportunities.</blockquote><p><strong>Sales &amp; Revenue Analysis —</strong></p><ul><li>Calculate total revenue</li><li>Analyze revenue by city</li><li>Track revenue trends over time</li></ul><blockquote><em>Why it matters:</em> Enables leadership to understand growth and regional performance.</blockquote><p><strong>Product Performance Analysis —</strong></p><ul><li>Identify best-selling products</li><li>Understand product demand</li></ul><blockquote><em>Why it matters:</em> Supports inventory planning and product strategy.</blockquote><p><strong>Order Behavior Analysis —</strong></p><ul><li>Identify high-value orders</li><li>Compare orders to average order value</li><li>Analyze payment methods and order status</li></ul><blockquote><em>Why it matters:</em> Helps optimize pricing and checkout experience.</blockquote><h3>Conclusion</h3><p>This project demonstrates how SQL is much more than a querying language — it is a <strong>foundation for business decision-making</strong>.</p><p>By designing an online shopping database from scratch, inserting realistic data, and performing structured analysis, we replicate the workflow of a <strong>junior data analyst or business analyst</strong> working with real systems.</p><p>This project proves the ability to:</p><ul><li>Design relational databases logically</li><li>Work with multi-table relationships</li><li>Write clean, business-oriented SQL queries</li><li>Progress from basic reporting to intermediate analytics</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ee197852955" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an End-to-End Employee Management & Payroll System Using SQL Server]]></title>
            <link>https://medium.com/@janavi.mehta2003/building-an-end-to-end-employee-management-payroll-system-using-sql-server-b2a2c67f60c0?source=rss-8cd2efcea279------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2a2c67f60c0</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[payroll-management-system]]></category>
            <dc:creator><![CDATA[Janavi Mehta]]></dc:creator>
            <pubDate>Wed, 24 Dec 2025 13:37:41 GMT</pubDate>
            <atom:updated>2025-12-24T13:37:41.653Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Real-World Database Case Study Built from Scratch</h3><blockquote><strong><em>Project Name:</em></strong><em> WorkForce Pro<br></em><strong><em>Tech Stack:</em></strong><em> SQL Server<br></em><strong><em>Domain:</em></strong><em> HR Analytics · Payroll · Workforce Management<br></em><strong><em>Level:</em></strong><em> Intermediate → Advanced SQL</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F-kaJrAQ_d5qnrSI4hwBQA.png" /></figure><h3>Introduction: The Business Problem</h3><p>Every organization, regardless of size, depends on an accurate and reliable <strong>employee payroll system</strong>. Payroll errors don’t just affect salaries — they impact <strong>employee trust, legal compliance, budgeting, and leadership decisions</strong>.</p><p>A real-world payroll system must go far beyond basic salary storage. It must integrate:</p><ul><li>Employee records and reporting hierarchy</li><li>Departments and job roles</li><li>Attendance and leave tracking</li><li>Payroll calculations with deductions and bonuses</li><li>Benefits enrollment</li><li>Performance reviews and training</li><li>Promotion and salary history</li></ul><p>In this project, I built <strong>WorkForce Pro</strong>, a <strong>fully normalized, end-to-end Employee Management &amp; Payroll database</strong>using <strong>SQL Server</strong>, designed to closely resemble how enterprise HR systems work in practice.</p><p>This article walks through the <strong>entire lifecycle</strong>:</p><ul><li>Database design from scratch</li><li>Table creation and relationships</li><li>Realistic data population</li><li>Advanced HR &amp; payroll analytics</li><li>Business insights derived from SQL</li></ul><h3>2. Database Initialization (Starting Clean)</h3><p>We begin by ensuring a <strong>clean slate</strong>, dropping the database if it already exists and recreating it.</p><pre>USE master;<br>GO<br>IF EXISTS (SELECT name FROM sys.databases WHERE name = &#39;WorkForcePro&#39;)<br>BEGIN<br>    ALTER DATABASE WorkForcePro SET SINGLE_USER WITH ROLLBACK IMMEDIATE;<br>    DROP DATABASE WorkForcePro;<br>END<br>GO<br>CREATE DATABASE WorkForcePro;<br>GO<br>USE WorkForcePro;<br>GO</pre><h3>3. ER Diagram &amp; Data Model Explanation</h3><h4>The Architecture Behind WorkForce Pro</h4><p>Before inserting data or running analytics, it’s essential to design a <strong>strong relational foundation</strong>.</p><p>The <strong>WorkForce Pro</strong> database follows <strong>Third Normal Form (3NF)</strong> principles to:</p><ul><li>Minimize redundancy</li><li>Preserve historical accuracy</li><li>Support complex HR and payroll analytics</li></ul><p>At the center of the model is the <strong>Employees</strong> table, which connects nearly every business process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXUgICpP5nMIG1Q3xRsNLA.png" /></figure><h3>4. Making tables :</h3><p><em>Tables include Departments, JobTitles, Employees, Attendance, Leave, Payroll, Benefits, PerformanceReviews, Training, and more — all created exactly as shown in the SQL script</em></p><blockquote>Core Master Tables</blockquote><h4>Employees (Central Entity)</h4><ul><li><strong>Primary Key:</strong> EmployeeID</li><li>Acts as the single source of truth for the system</li></ul><p>Each employee:</p><ul><li>Belongs to <strong>one department</strong></li><li>Holds <strong>one job title</strong></li><li>May report to <strong>another employee (manager)</strong></li><li>Can have multiple records across payroll, attendance, leave, reviews, training, and benefits</li></ul><pre>CREATE TABLE Employees (<br>    EmployeeID INT PRIMARY KEY IDENTITY(1,1),<br>    FirstName NVARCHAR(50) NOT NULL,<br>    LastName NVARCHAR(50) NOT NULL,<br>    Email NVARCHAR(100) UNIQUE NOT NULL,<br>    PhoneNumber NVARCHAR(20),<br>    HireDate DATE NOT NULL,<br>    JobTitleID INT NOT NULL,<br>    DepartmentID INT NOT NULL,<br>    ManagerID INT NULL,<br>    Salary DECIMAL(12,2) NOT NULL,<br>    DateOfBirth DATE,<br>    Gender NVARCHAR(10),<br>    Address NVARCHAR(255),<br>    City NVARCHAR(100),<br>    State NVARCHAR(50),<br>    ZipCode NVARCHAR(10),<br>    EmergencyContactName NVARCHAR(100),<br>    EmergencyContactPhone NVARCHAR(20),<br>    IsActive BIT DEFAULT 1,<br>    TerminationDate DATE NULL,<br>    FOREIGN KEY (JobTitleID) REFERENCES JobTitles(JobTitleID),<br>    FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID),<br>    FOREIGN KEY (ManagerID) REFERENCES Employees(EmployeeID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNGx0_4u9Xv7HounfPj95g.png" /></figure><h4>Departments</h4><p>Represents the organizational structure.</p><ul><li><strong>Primary Key:</strong> DepartmentID</li><li>One department → many employees</li><li>Each department is managed by <strong>one employee</strong></li></ul><p>This design supports:</p><ul><li>Department cost analysis</li><li>Manager span-of-control evaluation</li><li>Budget tracking</li></ul><pre>CREATE TABLE Departments (<br>    DepartmentID INT PRIMARY KEY IDENTITY(1,1),<br>    DepartmentName NVARCHAR(100) NOT NULL UNIQUE,<br>    ManagerID INT NULL,<br>    Location NVARCHAR(100),<br>    Budget DECIMAL(15,2),<br>    CreatedDate DATE DEFAULT GETDATE()<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*rG5QYiR2x5VTMjEG5_LCQA.png" /></figure><h4>JobTitles</h4><p>Defines employee roles and salary bands.</p><ul><li><strong>Primary Key:</strong> JobTitleID</li><li>One job title → many employees</li></ul><p><em>Business value:</em><br>Separating job titles allows role-based pay analysis, promotion tracking, and compensation benchmarking.</p><pre>CREATE TABLE JobTitles (<br>    JobTitleID INT PRIMARY KEY IDENTITY(1,1),<br>    TitleName NVARCHAR(100) NOT NULL UNIQUE,<br>    MinSalary DECIMAL(12,2),<br>    MaxSalary DECIMAL(12,2),<br>    Description NVARCHAR(500)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oFAN0QwncY-MkOB4zDvF7Q.png" /></figure><blockquote>Historical &amp; Transactional Tables:</blockquote><h4>EmploymentHistory</h4><p>Tracks promotions, transfers, and salary changes.</p><p>Instead of overwriting data, history is preserved — enabling:</p><ul><li>Salary growth analysis</li><li>Career progression timelines</li><li>Retention insights</li></ul><pre>CREATE TABLE EmploymentHistory (<br>    HistoryID INT PRIMARY KEY IDENTITY(1,1),<br>    EmployeeID INT NOT NULL,<br>    JobTitleID INT NOT NULL,<br>    DepartmentID INT NOT NULL,<br>    Salary DECIMAL(12,2) NOT NULL,<br>    StartDate DATE NOT NULL,<br>    EndDate DATE NULL,<br>    ChangeReason NVARCHAR(100),<br>    FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID) ON DELETE CASCADE,<br>    FOREIGN KEY (JobTitleID) REFERENCES JobTitles(JobTitleID),<br>    FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*Da4aX_WMwLL_nt8_CQ-RdA.png" /></figure><h4>Attendance</h4><p>Stores daily attendance records.</p><ul><li>Unique constraint on (EmployeeID, AttendanceDate)</li><li>Prevents duplicate attendance entries</li></ul><p>Enables absenteeism analysis and productivity monitoring.</p><pre>CREATE TABLE Attendance (<br>    AttendanceID INT PRIMARY KEY IDENTITY(1,1),<br>    EmployeeID INT NOT NULL,<br>    AttendanceDate DATE NOT NULL,<br>    CheckInTime TIME,<br>    CheckOutTime TIME,<br>    Status NVARCHAR(20) DEFAULT &#39;Present&#39;,<br>    Notes NVARCHAR(255),<br>    FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID) ON DELETE CASCADE,<br>    CONSTRAINT UQ_EmployeeDate UNIQUE (EmployeeID, AttendanceDate)<br>);</pre><h4>LeaveTypes &amp; LeaveRequests</h4><p>Leave definitions are separated from leave transactions.</p><ul><li><strong>LeaveTypes:</strong> Policy-level data</li><li><strong>LeaveRequests:</strong> Employee-level usage</li></ul><p>This allows HR to analyze leave trends without altering core policy data.</p><pre>CREATE TABLE LeaveTypes (<br>    LeaveTypeID INT PRIMARY KEY IDENTITY(1,1),<br>    LeaveTypeName NVARCHAR(50) NOT NULL UNIQUE,<br>    Description NVARCHAR(255),<br>    MaxDaysPerYear INT,<br>    IsPaid BIT DEFAULT 1<br>);<br><br><br>CREATE TABLE LeaveRequests (<br>    LeaveRequestID INT PRIMARY KEY IDENTITY(1,1),<br>    EmployeeID INT NOT NULL,<br>    LeaveTypeID INT NOT NULL,<br>    StartDate DATE NOT NULL,<br>    EndDate DATE NOT NULL,<br>    TotalDays INT NOT NULL,<br>    Reason NVARCHAR(500),<br>    Status NVARCHAR(20) DEFAULT &#39;Pending&#39;,<br>    RequestDate DATETIME DEFAULT GETDATE(),<br>    ApprovedBy INT NULL,<br>    ApprovalDate DATETIME NULL,<br>    FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID) ON DELETE CASCADE,<br>    FOREIGN KEY (LeaveTypeID) REFERENCES LeaveTypes(LeaveTypeID),<br>    FOREIGN KEY (ApprovedBy) REFERENCES Employees(EmployeeID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*sjcl4-EyLGvjyWTd99Dr3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gXNE_Phta19T0YOtRBlGlw.png" /></figure><blockquote>Payroll &amp; Compensation Tables</blockquote><h4>Payroll</h4><p>Stores monthly payroll calculations:</p><ul><li>Base salary</li><li>Overtime</li><li>Bonuses</li><li>Deductions</li><li>Net pay</li></ul><p>Designed to support payroll audits, cost-to-company analysis, and forecasting.</p><pre>CREATE TABLE Payroll (<br>    PayrollID INT PRIMARY KEY IDENTITY(1,1),<br>    EmployeeID INT NOT NULL,<br>    PayPeriodStart DATE NOT NULL,<br>    PayPeriodEnd DATE NOT NULL,<br>    BaseSalary DECIMAL(12,2) NOT NULL,<br>    Overtime DECIMAL(12,2) DEFAULT 0,<br>    Bonuses DECIMAL(12,2) DEFAULT 0,<br>    Deductions DECIMAL(12,2) DEFAULT 0,<br>    NetPay DECIMAL(12,2) NOT NULL,<br>    PaymentDate DATE NOT NULL,<br>    PaymentMethod NVARCHAR(20),<br>    Status NVARCHAR(20) DEFAULT &#39;Processed&#39;,<br>    FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID) ON DELETE CASCADE<br>);</pre><h4>Benefits &amp; EmployeeBenefits</h4><p>Many-to-many relationship handled using a junction table.</p><p>Supports flexible benefit plans and cost-sharing analytics.</p><pre>-- Benefits Table<br>CREATE TABLE Benefits (<br>    BenefitID INT PRIMARY KEY IDENTITY(1,1),<br>    BenefitName NVARCHAR(100) NOT NULL UNIQUE,<br>    BenefitType NVARCHAR(50),<br>    Description NVARCHAR(500),<br>    EmployerCost DECIMAL(10,2),<br>    EmployeeCost DECIMAL(10,2)<br>);<br><br>-- Employee Benefits Junction Table<br>CREATE TABLE EmployeeBenefits (<br>    EmployeeID INT,<br>    BenefitID INT,<br>    EnrollmentDate DATE NOT NULL,<br>    Status NVARCHAR(20) DEFAULT &#39;Active&#39;,<br>    PRIMARY KEY (EmployeeID, BenefitID),<br>    FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID) ON DELETE CASCADE,<br>    FOREIGN KEY (BenefitID) REFERENCES Benefits(BenefitID) ON DELETE CASCADE<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*_qZvQ82FiZv-rtuAb-QiJA.png" /></figure><blockquote>Performance &amp; Growth Tables</blockquote><h4>PerformanceReviews</h4><p>Captures employee evaluations over time. Connects performance ratings to:</p><ul><li>Promotions</li><li>Bonuses</li><li>Training decisions</li></ul><pre>CREATE TABLE PerformanceReviews (<br>    ReviewID INT PRIMARY KEY IDENTITY(1,1),<br>    EmployeeID INT NOT NULL,<br>    ReviewerID INT NOT NULL,<br>    ReviewDate DATE NOT NULL,<br>    ReviewPeriodStart DATE NOT NULL,<br>    ReviewPeriodEnd DATE NOT NULL,<br>    PerformanceRating INT CHECK (PerformanceRating BETWEEN 1 AND 5),<br>    Goals NVARCHAR(1000),<br>    Achievements NVARCHAR(1000),<br>    AreasForImprovement NVARCHAR(1000),<br>    Comments NVARCHAR(1000),<br>    FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID) ON DELETE CASCADE,<br>    FOREIGN KEY (ReviewerID) REFERENCES Employees(EmployeeID)<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FArKDXVRWQvwGJatVeQatw.png" /></figure><h4>TrainingPrograms &amp; EmployeeTraining</h4><p>Tracks upskilling and certifications.</p><p>Enables analysis of training ROI and employee development.</p><pre>-- Training Programs Table<br>CREATE TABLE TrainingPrograms (<br>    ProgramID INT PRIMARY KEY IDENTITY(1,1),<br>    ProgramName NVARCHAR(100) NOT NULL,<br>    Description NVARCHAR(500),<br>    Duration INT,<br>    Cost DECIMAL(10,2),<br>    Provider NVARCHAR(100)<br>);<br><br>-- Employee Training Junction Table<br>CREATE TABLE EmployeeTraining (<br>    EmployeeID INT,<br>    ProgramID INT,<br>    EnrollmentDate DATE NOT NULL,<br>    CompletionDate DATE NULL,<br>    Status NVARCHAR(20) DEFAULT &#39;In Progress&#39;,<br>    Score DECIMAL(5,2) NULL,<br>    CertificateIssued BIT DEFAULT 0,<br>    PRIMARY KEY (EmployeeID, ProgramID),<br>    FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID) ON DELETE CASCADE,<br>    FOREIGN KEY (ProgramID) REFERENCES TrainingPrograms(ProgramID) ON DELETE CASCADE<br>);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*gDgtpW0Vqc0gZLpiR7_1AQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*z8cyb-wV-rAwOcuPNPR4xg.png" /></figure><h3>ER Relationship Summary</h3><pre>Employees<br> ├── Departments (Many-to-One)<br> ├── JobTitles (Many-to-One)<br> ├── Employees (Self-referencing Manager)<br> ├── Attendance (One-to-Many)<br> ├── Payroll (One-to-Many)<br> ├── LeaveRequests (One-to-Many)<br> ├── PerformanceReviews (One-to-Many)<br> ├── EmploymentHistory (One-to-Many)<br> ├── EmployeeBenefits (Many-to-Many)<br> └── EmployeeTraining (Many-to-Many)</pre><h3>5. Data Population (Realistic Business Data)</h3><p>To simulate real-world operations, the database includes:</p><ul><li><strong>10 departments</strong></li><li><strong>20 job titles</strong></li><li><strong>50+ employees</strong></li><li>Attendance data for the <strong>last 30 days</strong></li><li>Payroll data for the <strong>last 6 months</strong></li><li>Leave requests, benefits, training, and performance reviews</li></ul><p>Randomized but controlled logic ensures <strong>realistic distributions</strong> without manual data entry.</p><h3>6. Analytical Queries: Turning Data into Insights</h3><h4>🔹 Department-Wise Workforce &amp; Salary Analysis</h4><pre>SELECT<br>    d.DepartmentName,<br>    COUNT(e.EmployeeID) AS EmployeeCount,<br>    AVG(e.Salary) AS AvgSalary,<br>    SUM(e.Salary) AS TotalSalaryExpense<br>FROM Departments d<br>LEFT JOIN Employees e ON d.DepartmentID = e.DepartmentID<br>WHERE e.IsActive = 1<br>GROUP BY d.DepartmentName<br>ORDER BY EmployeeCount DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*o3Ll-LUkG4PSi1FLqNrkoA.png" /></figure><blockquote><strong>Insight:</strong> Identifies high-cost departments and workforce concentration.</blockquote><h4>🔹 Top 10 Highest Paid Employees</h4><pre>SELECT TOP 10<br>    FirstName + &#39; &#39; + LastName AS FullName,<br>    Salary<br>FROM Employees<br>WHERE IsActive = 1<br>ORDER BY Salary DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*xwCTSGI6661-FPgzi72WPw.png" /></figure><blockquote>Used for executive compensation review and benchmarking.</blockquote><h4>🔹 Gender Pay Gap Analysis</h4><pre>SELECT<br>    Gender,<br>    COUNT(*) AS Employees,<br>    AVG(Salary) AS AvgSalary<br>FROM Employees<br>WHERE IsActive = 1<br>GROUP BY Gender;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*87ij8szC2gqRtYy-CyaL2w.png" /></figure><blockquote>Highlights pay equity and diversity metrics.</blockquote><h4>🔹 Attendance Behavior (Last 30 Days)</h4><pre>SELECT<br>    Status,<br>    COUNT(*) AS Records<br>FROM Attendance<br>WHERE AttendanceDate &gt;= DATEADD(DAY, -30, GETDATE())<br>GROUP BY Status;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*BP9TZ12y5gfL2muvAoLchg.png" /></figure><blockquote>Detects absenteeism and punctuality trends.</blockquote><h4>🔹 Salary Growth After Promotion</h4><pre>SELECT<br>    e.EmployeeID,<br>    e.FirstName + &#39; &#39; + e.LastName AS FullName,<br>    eh.Salary AS InitialSalary,<br>    e.Salary AS CurrentSalary,<br>    (e.Salary - eh.Salary) AS SalaryIncrease<br>FROM Employees e<br>JOIN EmploymentHistory eh ON e.EmployeeID = eh.EmployeeID<br>WHERE e.Salary &gt; eh.Salary;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azioRrMHPeSeIw3EH0e1hA.png" /></figure><blockquote>Measures effectiveness of promotions and retention strategies.</blockquote><h4>🔹 Manager Span of Control</h4><pre>SELECT<br>    m.FirstName + &#39; &#39; + m.LastName AS Manager,<br>    COUNT(e.EmployeeID) AS DirectReports<br>FROM Employees m<br>JOIN Employees e ON m.EmployeeID = e.ManagerID<br>GROUP BY m.FirstName, m.LastName;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*zlmXQ3FvkUxtnweoiEI8DQ.png" /></figure><blockquote>Helps leadership balance team sizes and prevent burnout.</blockquote><h3>7. End-to-End Payroll Workflow (Business View)</h3><ol><li>Employee joins → record created</li><li>Attendance tracked daily</li><li>Leave impacts payroll eligibility</li><li>Benefits and deductions applied</li><li>Payroll calculated monthly</li><li>Performance &amp; training influence promotions</li><li>Employment history preserved</li></ol><p>This mirrors <strong>enterprise HR systems</strong> like SAP, Workday, and Oracle HCM.</p><h3>Final Thoughts</h3><p><strong>WorkForce Pro</strong> is not just a database — it’s a <strong>business system</strong>.<br>By building it from scratch, this project bridges the gap between <strong>technical SQL skills</strong> and <strong>real-world analytical problem-solving</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2a2c67f60c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>