TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst ยท 76.7K subscribers
Post #2637 2.06K
๐Ÿš€ SQL Project Series #25

Manufacturing Production Analytics ๐Ÿญ

Analyze production, machines, inventory, quality, and maintenance using SQL to improve operational efficiency, reduce downtime, and optimize manufacturing performance.

๐ŸŽฏ Business Objectives

โœ… Monitor production output

โœ… Analyze machine utilization

โœ… Track product quality

โœ… Measure production efficiency

โœ… Identify production bottlenecks

โœ… Analyze inventory consumption

โœ… Monitor machine maintenance

โœ… Build executive manufacturing dashboards

๐Ÿ“‚ Step 1: Create Database

CREATE DATABASE manufacturing_db;
USE manufacturing_db;


๐Ÿ“‚ Step 2: Create Products Table

CREATE TABLE products (
product_id INT PRIMARY KEY,
product_name VARCHAR(100),
category VARCHAR(50),
standard_cost DECIMAL(10,2)
);


๐Ÿ“‚ Step 3: Create Machines Table

CREATE TABLE machines (
machine_id INT PRIMARY KEY,
machine_name VARCHAR(100),
production_line VARCHAR(50),
installation_date DATE
);


๐Ÿ“‚ Step 4: Create Production Table

CREATE TABLE production (
production_id INT PRIMARY KEY,
product_id INT,
machine_id INT,
production_date DATE,
units_produced INT,
defective_units INT,
production_hours DECIMAL(5,2),
FOREIGN KEY (product_id) REFERENCES products(product_id),
FOREIGN KEY (machine_id) REFERENCES machines(machine_id)
);


๐Ÿ“‚ Step 5: Create Maintenance Table

CREATE TABLE maintenance (
maintenance_id INT PRIMARY KEY,
machine_id INT,
maintenance_date DATE,
maintenance_type VARCHAR(50),
downtime_hours DECIMAL(5,2),
maintenance_cost DECIMAL(10,2),
FOREIGN KEY (machine_id) REFERENCES machines(machine_id)
);


๐Ÿ“‚ Step 6: Insert Sample Products

INSERT INTO products VALUES
(101,'Laptop','Electronics',45000),
(102,'Smartphone','Electronics',25000),
(103,'Tablet','Electronics',18000),
(104,'Smart Watch','Wearables',8000),
(105,'Wireless Earbuds','Accessories',3500);


๐Ÿ“‚ Step 7: Insert Sample Machines

INSERT INTO machines VALUES
(201,'Assembly Line A','Line 1','2022-01-15'),
(202,'Assembly Line B','Line 1','2022-06-20'),
(203,'Packaging Machine','Line 2','2023-02-10'),
(204,'Quality Inspection','Line 3','2023-08-18');


๐Ÿ“‚ Step 8: Insert Sample Production Data

INSERT INTO production VALUES
(1001,101,201,'2025-01-05',250,5,8.5),
(1002,102,202,'2025-01-05',420,8,9.0),
(1003,103,201,'2025-01-06',180,3,7.5),
(1004,104,203,'2025-01-06',520,10,8.0),
(1005,105,204,'2025-01-07',650,6,7.0);


๐Ÿ“‚ Step 9: Insert Sample Maintenance Data

INSERT INTO maintenance VALUES
(1,201,'2025-01-08','Preventive',2.5,12000),
(2,202,'2025-01-10','Corrective',5.0,25000),
(3,203,'2025-01-12','Preventive',1.5,9000),
(4,204,'2025-01-15','Inspection',1.0,5000);
  • โค 4
  • ๐Ÿ‘ 1
More from @sqlanalyst
  1. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  2. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  3. Oct 7, 2026SQL Interview Series โ€” Part 4 ๐Ÿ“Œ Question 4: Find the Highest Salary in Each Department Suโ€ฆ
  4. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  5. Sep 29, 2026SQL Interview Series โ€” Part 2 ๐Ÿ“Œ Question 2: Find Duplicate Records Suppose you have an Emโ€ฆ
  6. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’