This project explores LEGO's dataset using advanced SQL queries, including data cleaning, database optimization, and exploratory data analysis (EDA) in PostgreSQL, complemented by Python visualizations using matplotlib and seaborn.
Demonstrate Data Engineering and Data Analysis skills using PostgreSQL + Python by structuring, optimizing, querying, and visualizing a relational LEGO dataset.
- Modeled the relational database based on the Rebrickable LEGO Database.
- Established primary and foreign keys to define relationships between sets, parts, colors, and themes.
- 📂 List all tables and define their relationships.
- 🔑 Identify foreign key constraints and normalization rules.
- 🔄 Count records per table to understand distribution and density.
- 📈 Analyze historical trends in set releases, parts, and themes.
Analysis done using PostgreSQL, then visualized with Python.
Displays total number of LEGO sets released annually, with a 5-year and 10-year rolling average for trend detection.
Shows the most complex and diverse LEGO themes based on the number of unique parts used.
Highlights explosive growth in specific themes during certain years.
Compares forecasted set volume using a 10-year Moving Average and Exponential Weighted Moving Average (EWMA 70/30).
This diagram represents the full PostgreSQL schema designed for querying and relationships.
lego-data-analysis/
├── data/ # Original CSV dataset
├── sql/ # SQL scripts for queries & maintenance
├── diagrams/ # Database schema models
├── scripts/ # Python scripts for visualization & automation
├── results/ # Query results in CSV format
├── visuals/ # PNG charts generated with matplotlib/seaborn
└── README.md # This file
- PostgreSQL 🐘 – Relational database engine
- SQL 📘 – Data cleaning, transformation, and EDA
- Python 🐍 – Visualization and automation
- Matplotlib & Seaborn 📊 – For charts
- DB Diagram 🧱 – For schema modeling
✅ Visual storytelling for analysis
✅ CSV exports of query insights
✅ Expand to interactive dashboards with Power BI or Streamlit
☑️ Automate workflow with SQLAlchemy + pandas
📧 celton.aret@gmail.com
📞 +56 9 3438 0596
🔗 LinkedIn
🐙 GitHub
Feel free to open a pull request or contact me directly. All suggestions are welcome to improve this analytical project!




