<?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 Hasnain | Data Science &amp; AI on Medium]]></title>
        <description><![CDATA[Stories by Hasnain | Data Science &amp; AI on Medium]]></description>
        <link>https://medium.com/@hasnainabbasi755?source=rss-49d62617e9ce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DUAeZcZOzR-8fn9QA6jYDg.jpeg</url>
            <title>Stories by Hasnain | Data Science &amp;amp; AI on Medium</title>
            <link>https://medium.com/@hasnainabbasi755?source=rss-49d62617e9ce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 23 May 2026 16:24:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hasnainabbasi755/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[PostgreSQL SELECT INTO Statement: The Complete Guide for Developers]]></title>
            <link>https://medium.com/@hasnainabbasi755/postgresql-select-into-statement-the-complete-guide-for-developers-ea4618f72cfa?source=rss-49d62617e9ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea4618f72cfa</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Hasnain | Data Science & AI]]></dc:creator>
            <pubDate>Wed, 09 Jul 2025 09:57:57 GMT</pubDate>
            <atom:updated>2025-07-09T09:57:57.594Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is SELECT INTO in PostgreSQL?</h4><h4>PostgreSQL’s SELECT INTO is a convenient SQL statement that lets you create a new table directly from query results. Instead of writing separate commands to:</h4><p>PostgreSQL’s <strong>SELECT</strong> <strong>INTO</strong> is a convenient SQL statement that lets you create a new table directly from query results. Instead of writing separate commands to:</p><ol><li>Create a table structure</li><li>Insert data into it</li></ol><p>You can do both in one step with <strong>SELECT INTO</strong>. This is perfect for:</p><ul><li>Creating temporary work tables</li><li>Making quick data copies</li><li>Simplifying complex queries</li><li>Preparing reports</li></ul><h3>Basic Syntax</h3><pre>SELECT column1, column2, ...<br>INTO new_table_name<br>FROM existing_table<br>WHERE your_conditions;</pre><h3>Real-World Examples</h3><p>Example Setup (Run this first)</p><pre>-- Create sample table<br>CREATE TABLE employees (<br>    id SERIAL PRIMARY KEY,<br>    name VARCHAR(100),<br>    department VARCHAR(50),<br>    salary DECIMAL(10,2),<br>    hire_date DATE<br>);<br><br>-- Insert sample data<br>INSERT INTO employees (name, department, salary, hire_date)<br>VALUES <br>    (&#39;Sarah Johnson&#39;, &#39;Engineering&#39;, 85000, &#39;2021-03-15&#39;),<br>    (&#39;Michael Chen&#39;, &#39;Marketing&#39;, 72000, &#39;2022-06-22&#39;),<br>    (&#39;David Kim&#39;, &#39;Engineering&#39;, 92000, &#39;2020-11-05&#39;),<br>    (&#39;Lisa Wong&#39;, &#39;HR&#39;, 68000, &#39;2023-01-10&#39;);</pre><p>Example 1: Create a department-specific table</p><pre>-- Create Engineering team table<br>SELECT *<br>INTO engineering_team<br>FROM employees<br>WHERE department = &#39;Engineering&#39;;</pre><p>Example 2: Create a table with calculated columns</p><pre>-- Create salary analysis table<br>SELECT <br>    name,<br>    salary,<br>    salary * 0.15 AS bonus_estimate,<br>    salary / 12 AS monthly_salary<br>INTO salary_analysis<br>FROM employees;</pre><h3>Temporary Tables: Your Best Friend for Complex Queries</h3><p>Temporary tables only exist during your session and automatically disappear when you disconnect.</p><p>Example 3: Create a temporary table</p><pre>-- Temp table for high earners<br>SELECT *<br>INTO TEMP TABLE high_earners<br>FROM employees<br>WHERE salary &gt; 80000;</pre><p>Example 4: Complex temp table example</p><pre>-- Temp table with multiple calculations<br>SELECT <br>    department,<br>    COUNT(*) AS employee_count,<br>    AVG(salary) AS avg_salary,<br>    MAX(salary) AS max_salary<br>INTO TEMP TABLE dept_stats<br>FROM employees<br>GROUP BY department;</pre><h3>Pro Tips You Should Know</h3><ol><li>Data Types: The new table copies column data types from your query results</li><li>No Constraints: Primary keys, indexes, and constraints aren’t copied</li><li>Existing Tables: The command fails if the table already exists</li><li>Better Alternative: For existing tables, use INSERT INTO...SELECT instead</li></ol><h3>SELECT INTO vs. CREATE TABLE AS</h3><p>PostgreSQL has two similar commands:</p><pre>-- These do the same thing<br>SELECT * INTO new_table FROM original;<br>CREATE TABLE new_table AS SELECT * FROM original;</pre><p>Key differences:</p><ul><li><strong>CREATE TABLE AS</strong> is standard SQL</li><li><strong>SELECT INTO</strong> is more readable to some developers</li></ul><h3>When to Use SELECT INTO</h3><p>Perfect for:</p><ol><li>Quick data exploration</li><li>Intermediate steps in complex queries</li><li>Creating test datasets</li><li>One-time reporting</li></ol><p>Not ideal for:</p><ol><li>Production database structure (use proper CREATE TABLE)</li><li>Frequent operations (create permanent tables instead)</li></ol><h3>Performance Considerations</h3><ul><li>Temporary tables are generally memory-resident (fast)</li><li>No indexes are copied (add them manually if needed)</li><li>Large tables may impact performance during creation</li></ul><h3>Final Thoughts</h3><p>The SELECT INTO statement is one of those PostgreSQL features that seems simple but becomes indispensable once you start using it regularly. It&#39;s particularly valuable for:</p><ul><li>Data analysts preparing reports</li><li>Developers debugging complex queries</li><li>DBAs performing data migrations</li></ul><p>Try it out in your next PostgreSQL project and you’ll quickly find dozens of uses for this versatile command!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea4618f72cfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Views Explained: The Ultimate Guide for Data Engineers]]></title>
            <link>https://medium.com/@hasnainabbasi755/sql-views-explained-the-ultimate-guide-for-data-engineers-9a1667269164?source=rss-49d62617e9ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a1667269164</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sql-view]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Hasnain | Data Science & AI]]></dc:creator>
            <pubDate>Fri, 04 Jul 2025 11:32:29 GMT</pubDate>
            <atom:updated>2025-07-04T11:32:29.985Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>Why write complex queries repeatedly when views can simplify your life?</em></h3><h3>1. Introduction</h3><p>As a data engineer or analyst, you often write SQL queries that join multiple tables, apply filters, and transform data. But what if you need to reuse the same complex query in multiple places?</p><p>This is where SQL Views come in — a powerful feature that saves you time, improves security, and makes your queries cleaner.</p><p>In this guide, we’ll cover:<br>✅ What is a View?<br>✅ How to Create &amp; Use Views<br>✅ Views vs. Tables vs. Materialized Views<br>✅ Real-World Use Cases<br>✅ Limitations &amp; Best Practices</p><p>Let’s dive in!</p><h3>2. What is a SQL View?</h3><p>A view is a virtual table defined by a SQL query. Unlike real tables, it doesn’t store data — instead, it dynamically retrieves data whenever you query it.</p><h3>Analogy: A Saved Search</h3><p>Think of a view like a bookmarked search on Google:</p><ul><li>You define the search criteria once (e.g., “best laptops under $1000”).</li><li>Every time you open the bookmark, Google runs the search again and shows fresh results.</li><li>Similarly, a view reruns its underlying query each time you access it.</li></ul><h3>3. How to Create a View?</h3><h3>Basic Syntax</h3><pre>CREATE VIEW view_name AS<br>SELECT columns<br>FROM tables<br>WHERE conditions;</pre><h3>Example</h3><p>Let’s say we have:</p><ul><li>orders (order details)</li><li>customers (customer info)</li></ul><p>Instead of joining them repeatedly, we create a view:</p><pre>CREATE VIEW customer_orders AS<br>SELECT o.order_id, c.customer_name, o.order_date, o.amount<br>FROM orders o<br>JOIN customers c ON o.customer_id = c.customer_id;</pre><p>Now, we can simply run:</p><pre>SELECT * FROM customer_orders;</pre><h3>4. Views vs. Tables vs. Materialized Views</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0QKaY0B5uIkAcM3FIuVTiw.png" /></figure><h3>5. Why Use Views? (Key Benefits)</h3><h3>1. Simplifies Complex Queries</h3><p>Instead of writing long JOIN queries repeatedly, just reference the view.</p><h3>2. Security &amp; Access Control</h3><ul><li>Restrict access to sensitive columns (e.g., hide salaries).</li><li>Grant users access to views instead of raw tables.</li></ul><h3>3. Logical Data Abstraction</h3><ul><li>Rename columns for clarity (user_id → customer_id).</li><li>Combine data from multiple sources seamlessly.</li></ul><h3>4. Consistency</h3><p>Ensure everyone uses the same business logic (e.g., “active users” defined once in a view).</p><h3>6. Real-World Use Cases</h3><h3>📊 Business Reporting</h3><pre>CREATE VIEW monthly_sales AS<br>SELECT <br>    DATE_TRUNC(&#39;month&#39;, order_date) AS month,<br>    SUM(amount) AS total_sales<br>FROM orders<br>GROUP BY month;</pre><p>Now, analysts can just SELECT * FROM monthly_sales instead of rewriting aggregations.</p><h3>🔒 Row-Level Security</h3><pre>CREATE VIEW my_orders AS<br>SELECT * FROM orders WHERE user_id = CURRENT_USER;</pre><p>This ensures users only see their own orders.<br>🔄 Data Transformation</p><pre>CREATE VIEW clean_customer_data AS<br>SELECT <br>    customer_id,<br>    LOWER(TRIM(email)) AS email,<br>    INITCAP(first_name) AS first_name<br>FROM raw_customers;</pre><p>Apply formatting rules once, reuse everywhere.</p><h3>7. Limitations &amp; Best Practices</h3><h3>⚠️ Limitations</h3><ul><li>Performance Overhead: Views rerun their query each time (can be slow for complex joins).</li><li>Updatability: Not all views support INSERT/UPDATE/DELETE (depends on complexity).</li><li>Database-Specific: Views exist only in the database where they were created.</li></ul><h3>✅ Best Practices</h3><p>✔ Use for Read-Only Queries (avoid modifying data via views).<br>✔ Prefix Views (e.g., v_customer_orders) to distinguish from tables.<br>✔ Document Views (add comments explaining their purpose).</p><h3>8. Conclusion</h3><p>SQL Views are like saved queries on steroids — they simplify your workflow, enhance security, and keep your SQL DRY (Don’t Repeat Yourself).</p><p>Next Steps:</p><ul><li>Try creating a view in your database.</li><li>Experiment with CREATE OR REPLACE VIEW for updates.</li><li>Explore materialized views for performance-critical queries.</li></ul><p>Got questions? Drop them in the comments! 🚀</p><h3>📌 Enjoyed this guide?</h3><p>👉 Follow me for more data engineering &amp; SQL tips!<br>🔗 Share this post with your team!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a1667269164" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Importance of Using Databases to Store Data]]></title>
            <link>https://medium.com/@hasnainabbasi755/the-importance-of-using-databases-to-store-data-ccfa3a9cafc1?source=rss-49d62617e9ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccfa3a9cafc1</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-management]]></category>
            <category><![CDATA[data-security]]></category>
            <dc:creator><![CDATA[Hasnain | Data Science & AI]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 11:24:15 GMT</pubDate>
            <atom:updated>2025-07-02T11:24:15.922Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever lost an important file on your computer? Maybe you saved a document in the wrong folder, or your spreadsheet got corrupted. Now imagine that happening to a business with thousands of customer records, sales transactions, or product details. Chaos, right?</p><p>This is where databases come in. They are like super-organized digital filing cabinets that store, manage, and protect data efficiently. Whether you’re running a small business, managing a website, or just trying to keep your personal projects organized, databases make life easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ghYIpCyKAHapXm6_DWt24Q.png" /></figure><h3>Why Not Just Use Spreadsheets or Text Files?</h3><p>At first, storing data in Excel or a simple text file might seem fine. But as your data grows, problems arise:</p><ul><li><strong>Duplication &amp; Errors </strong>— If you update a customer’s address in one place, you might forget to update it elsewhere.</li><li><strong>Slow Searches</strong> — Finding a single record in a huge spreadsheet can be frustrating.</li><li><strong>No Real-Time Updates</strong> — If two people edit the same file, changes might conflict.</li><li><strong>Security Risks </strong>— Text files and spreadsheets aren’t built to handle sensitive data securely.</li></ul><p>Databases solve these problems by keeping everything structured, fast, and reliable.</p><h3>How Databases Make Life Easier</h3><h4>1. Organized &amp; Structured Storage</h4><ul><li>Instead of messy spreadsheets, databases store data in tables (like Excel sheets but smarter).</li><li>Each piece of data has a clear place, making it easy to find and update.</li></ul><h4>2. Quick &amp; Efficient Searches</h4><ul><li>Need to find a customer’s order from last year? A database can retrieve it in milliseconds, even with millions of records.</li></ul><p><strong>3. Prevents Duplicate &amp; Inconsistent Data</strong></p><ul><li>Databases enforce rules (e.g., “No two customers can have the same email”), reducing errors.</li></ul><h4>4. Handles Multiple Users at Once</h4><ul><li>Unlike a shared Excel file that locks when someone edits it, databases allow many people to access and update data simultaneously.</li></ul><h4>5. Secure &amp; Reliable</h4><ul><li>Databases have backups, encryption, and permissions, so only authorized users can access sensitive info.</li></ul><h3>Real-Life Examples</h3><ul><li>Online Shopping — Amazon uses databases to track millions of products, orders, and customer details.</li><li>Banking — Your account balance, transactions, and loans are all stored securely in a database.</li><li>Social Media — Every post, like, and comment on Facebook or Twitter is stored and retrieved instantly using databases.</li></ul><h3>Getting Started with Databases</h3><p>You don’t need to be a tech expert to use databases! Tools like Microsoft Access, Airtable, or Google Firebase offer simple ways to store and manage data without coding. For more advanced needs, MySQL, PostgreSQL, or MongoDB are popular choices.</p><h3>Final Thought</h3><p>Just like you wouldn’t store important papers in a shoebox, businesses and apps shouldn’t rely on scattered files or spreadsheets for critical data. Databases keep everything organized, fast, and secure — making them essential in today’s digital world.</p><p>If you’re just starting out, try experimenting with a simple database tool. You’ll quickly see how much easier it is to manage information!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccfa3a9cafc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Why Math Graduates Should Consider a Career in Data Science]]></title>
            <link>https://medium.com/@hasnainabbasi755/why-math-graduates-should-consider-a-career-in-data-science-107a1d809588?source=rss-49d62617e9ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/107a1d809588</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[learning-in-public]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[career-transitions]]></category>
            <dc:creator><![CDATA[Hasnain | Data Science & AI]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 17:19:25 GMT</pubDate>
            <atom:updated>2025-06-10T17:19:25.605Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>From theoretical models to real-world impact — my journey from math to data science.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0r4Fjl1Ps4OFvWlYhiVw0A.png" /></figure><h3>🧮 From Mathematics to Data Science: A Natural Shift</h3><p>As someone who completed a <strong>Bachelor’s in Mathematics</strong> and then pursued a <strong>Master’s in Data Science</strong>, I’ve experienced firsthand how powerful — and natural — this transition can be.</p><p>Mathematics builds a strong foundation in problem-solving, abstract thinking, and analytical reasoning — all of which are at the heart of data science.</p><p>But is it the <strong>best</strong> path for math grads? What <strong>advantages</strong> do we have — and where do we <strong>struggle</strong>?</p><p>Let’s break it down.</p><h3>✅ Why Math Grads Are Well-Suited for Data Science</h3><h3>1. Strong Theoretical Foundations</h3><p>Concepts like <strong>linear algebra</strong>, <strong>calculus</strong>, <strong>probability</strong>, and <strong>statistics</strong> are <em>core ingredients</em> in machine learning. Math grads usually find these topics easier to grasp than peers from other backgrounds.</p><h3>2. Problem-Solving Mindset</h3><p>Mathematics trains you to <strong>break down complex problems</strong>, recognize patterns, and derive solutions — which mirrors data science tasks like building models or cleaning messy data.</p><h3>3. Abstract Thinking → Real-World Insights</h3><p>Data science applies the abstraction of math to real-world problems — from predicting customer behavior to optimizing logistics or analyzing medical data.</p><h3>4. Quick Grasp of Algorithms</h3><p>Math grads often understand <em>how</em> and <em>why</em> algorithms work, not just <em>how to run them</em>. This makes model interpretation and tuning more intuitive.</p><h3>🤔 Challenges Math Grads May Face</h3><p>Even with a solid foundation, the shift isn’t always easy. Here are some common challenges:</p><h3>1. Lack of Programming Experience</h3><p>Most math courses don’t teach you to code. But in data science, <strong>Python</strong>, <strong>SQL</strong>, and libraries like <strong>Pandas</strong> and <strong>scikit-learn</strong> are essential.</p><h3>2. From Theory to Practice</h3><p>In math, problems are clean. In data science, data is messy and imperfect. Bridging that gap takes time and patience.</p><h3>3. Unfamiliar Tools</h3><p>Tools like <strong>Jupyter Notebooks</strong>, <strong>Git</strong>, <strong>data visualization software</strong>, or cloud platforms might be new — but they’re important.</p><h3>🛠️ What You Need to Learn (To Transition Smoothly)</h3><p>Here’s what helped me the most:</p><h3>📌 1. Python Programming</h3><p>Learn:</p><ul><li>Loops, functions, lists, dictionaries</li><li>Libraries like <strong>NumPy</strong>, <strong>Pandas</strong></li><li>Writing clean, modular code</li></ul><h3>📌 2. Data Analysis &amp; Visualization</h3><p>Understand how to:</p><ul><li>Explore and clean data</li><li>Create clear visuals with <strong>Matplotlib</strong>, <strong>Seaborn</strong>, or <strong>Plotly</strong></li><li>Write simple <strong>SQL</strong> queries</li></ul><h3>📌 3. Machine Learning Essentials</h3><p>Start with:</p><ul><li><strong>Linear regression</strong>, <strong>classification</strong></li><li>Concepts like <strong>overfitting</strong>, <strong>cross-validation</strong></li><li>How different models work and when to use them</li></ul><h3>📌 4. Real Projects</h3><p>Apply your skills:</p><ul><li>Analyze public datasets (e.g. from <strong>Kaggle</strong> or <strong>UCI</strong>)</li><li>Share on <strong>GitHub</strong> or in blog posts</li><li>Build a simple portfolio</li></ul><h3>🚀 Is Data Science the Best Path for Math Grads?</h3><p><strong>Yes — if you’re willing to learn and adapt.</strong></p><p>Data science is:</p><ul><li>In-demand</li><li>Well-paying</li><li>Intellectually satisfying</li><li>Full of growth opportunities</li></ul><p>Your math degree gives you a head start. With the right tools and mindset, you can thrive in this field.</p><h3>✍️ Final Thoughts</h3><p>If you’re a math graduate wondering whether you belong in data science, I’ll say this: <strong>you already have the mindset — now it’s time to build the skillset.</strong></p><p>Start small. Learn consistently. Apply often.</p><p>And if you’d like to follow along, I’ll be writing here on Medium about my learning journey, tools I discover, and lessons I pick up along the way.</p><p>Let’s learn data science — one post at a time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=107a1d809588" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>