Posts

SQL Query and performance tuning - Joins

Image
     🔗 Joining Tables in SQL How Databases Combine Data Across Tables Behind the Scenes 🧩 Why Do We Join Tables? Relational databases are designed to normalize data —which means instead of putting all data in one giant table, related information is spread across multiple smaller tables . 🎯 Example Scenario: customers table → holds client information (name, contact, status level) status_levels table → holds details for each status (label, benefits, criteria) Rather than duplicate status details for every customer, we join the two tables using a shared column: status_level . 🧠 What Is a SQL Join? A join allows you to retrieve combined data from two or more tables by matching rows based on a shared value—commonly using primary keys and foreign keys . 💬 Declarative SQL: SELECT c.name, s.benefits FROM customers c JOIN status_levels s ON c.status_level = s.level; This query: Fetches customer names from customers Fetches status benefits ...

SQL Query and performance tuning - Indexes

Image
From Declarative SQL to Procedural Execution Plans Understanding the Journey Behind Your Queries 🧠 Why SQL Is So Widely Used SQL (Structured Query Language) has come a long way from its roots as a tool for querying relational databases. Today, it powers data analytics in platforms like Apache Spark , and even in streaming tools like Apache Kafka . So, what makes SQL so universal? ✅ It’s Ideal for Tabular Data Most data in the real world naturally fits into tables: 🛍 Retailers track customer purchases in structured tables. 🏥 Healthcare systems manage patient records in relational databases. 💳 Financial institutions store transaction histories in tables. It's tough to find an industry that doesn't benefit from tabular data, and by extension, SQL. 📣 SQL Is Declarative — But What Does That Mean? SQL is a declarative language , meaning you state what you want , not how to get it . Example: SELECT name, email FROM customers WHERE city = 'Tallin...

Spring: How to deal with circular dependencies

Image
  🔄 Solving Circular Dependencies in Spring Boot: A Complete Guide When your Spring services get tangled up and can't start - here's how to fix it! 🤔 What is a Circular Dependency? A circular dependency happens when two or more Spring beans depend on each other, creating a loop. Spring can't figure out which bean to create first, so your application fails to start. Think of it like this: Service A needs Service B, but Service B also needs Service A - it's like two people waiting for each other to go first through a door! 🚪 💥 How Does It Happen? (Real Example) Let's say you're building an e-commerce app: @Service public class OrderService { @Autowired private PaymentService paymentService; public void createOrder(Order order) { // Process order paymentService.processPayment(order.getPaymentInfo()); } } @Service public class PaymentService { @Autowired private OrderService orderService; // ...

Kafka: How to handle duplicate messages

Image
Kafka is "at least once" by default. ???? What is "At Least Once" in Kafka? (Simple Explanation) "At least once" means: Kafka guarantees that every message will be delivered , But sometimes the same message might be delivered more than once (duplicate). 🔁 Why it happens: If a consumer crashes or times out, Kafka resends the message after retry.            (Here, what I meant by resend  that Kafka allows to pull the same message. If you know about Kafka Architecture it does not push/ send messages to consumer. Instead consumer is the one pulls the messages) If the system didn’t record that it already processed it, it may process it again . 🛠 Example: You (Consumer) receive a payment event. You process it and update the database. But before you commit (Telling Kafka "I have successfully processed this message" or in other words consumer failed to submit the offset to Kafka ), the consumer crashes. Kafka thinks it fa...

Software Architecture Fundamentals - 08

Image
🌐 Microservices, Miniservices & Reactive Systems A simple guide to modern software architecture Software systems today are getting bigger and more complex. To manage that complexity, developers use smart architectural patterns. Three of the most important ones are: Microservices Miniservices Reactive (Choreographed) Systems Let’s break them down. 👇 🧩 What Are Microservices? Microservices are small, independent programs that work together to build a larger application. 🚀 Imagine This: You run an online store. Instead of having one huge program to do everything, you split it up: A billing service 💳 A warehouse service 📦 An email service 📧 A shopping cart service 🛒 Each one runs on its own , and they all talk to each other through messages or API calls. ✅ Key Features of Microservices: Small & Focused : Each service handles one job. Independent : Can be built, deployed, and updated separately. Autonomous : Each service has i...

Software Architecture Fundamentals - 07

Image
  🏗️ Understanding Architectural Patterns: A Simple Guide In software development, the way we structure our systems matters—a lot. It affects how fast we can build features, fix bugs, and scale our apps. These structures are called architectural patterns . Think of them like blueprints for software. In this post, we’ll look at the two major patterns: Monolithic Architecture Microkernel (Plugin) Architecture Let’s break them down in simple terms. 👇 🧱 1. Monolithic Architecture: One Big Block of Code A monolith is one single, large program where all the features live together: UI (User Interface) Business logic Database access All tightly connected in a single codebase. ✅ Benefits: Fast execution – everything runs in one process Easier to start – one project, one deploy ❌ Drawbacks: Hard to maintain – huge and messy over time Slow deployment – updating takes hours or days Risky changes – one bug can break everything ☠️ The “...

Software Architecture Fundamentals - 06

Image
  🏗️ System Architecture vs. Enterprise Architecture. And Why Design Patterns Matter As developers or architects, we often get lost in the layers of structure we build. We use big words, system architecture, enterprise architecture, design patterns, but what do they really mean , and why should you care? Let’s break these ideas down. 🧱 1. System Architecture: Building a Specific Machine System Architecture is the blueprint for a single computer system . It’s the detailed plan for: How code is organized How data flows What subsystems exist How those parts communicate Think of it like designing a car: engine, wheels, sensors. all working together to move one vehicle forward. ✅ Goals: Solve a specific business problem Be lean, understandable, and maintainable Use tools and structures fit for purpose It’s focused, agile, and designed for one job,  like the comment approval workflow in a blog platform. 🏢 2. Enterprise Architecture (EA): Desig...