Bible, Lee, Data
Faith, software, data, and everyday life.
CategoriesAll posts
How Does Java Decide Which Method to Call?
Java allows several methods to share the same name.A class can provide different methods for different parameter types, and a subclass can replace an inherited method with its own implementation. The first feature is called overloading. The second is called overriding.They are often introduced with two simple definitions:Overloading means using the same method name with different parameter lists..
What Problems Do Design Patterns Actually Solve?
When design patterns are first introduced, they often appear as a list of names to memorize.Creational patternsFactory Method, Abstract Factory, Builder, Prototype, SingletonStructural patternsAdapter, Bridge, Composite, Decorator, Facade, Flyweight, ProxyBehavioral patternsChain of Responsibility, Command, Interpreter, Iterator,Mediator, Memento, Observer, State, Strategy,Template Method, Visit..
How to Read SQL Execution Plans with EXPLAIN
When a SQL query is slow, the first instinct is often to add an index.That may solve the problem, but it may also miss the real cause. The query might already have a usable index that the optimizer decided not to use. The join order may be inefficient, the optimizer may have estimated the wrong number of rows, or the database may be sorting a large intermediate result.Consider the following quer..
How Subqueries and CTEs Work in SQL
As SQL queries become more complex, a single table is often not enough to produce the result we need.Suppose we want to answer the following question:Which orders have a total amount greater than the average order amount?Before identifying those orders, the database must first calculate the average.SELECT AVG(total_amount)FROM orders;It must then compare each order with that value.SQL allows us ..
Database Indexes and SQL Execution Plans
Suppose we have the following orders table:CREATE TABLE orders ( order_id BIGINT PRIMARY KEY, customer_id BIGINT NOT NULL, order_status VARCHAR(20) NOT NULL, ordered_at DATETIME NOT NULL, total_amount BIGINT NOT NULL);When the table contains only a few hundred rows, the following query returns almost immediately:SELECT *FROM ordersWHERE customer_id = 1001;The situation changes whe..
Processes, Threads, and Operating System Execution Management
A program stored on a computer is not yet an active task.An executable file contains instructions and data, but it does not use the CPU or maintain an execution state until someone runs it. When a user launches the program, the operating system loads it into memory, assigns resources, creates management structures, and prepares it for execution.The running instance is called a process.A single p..
Transactions and Concurrency Control in Database Systems
uppose a database contains the following bank accounts.Account IDOwnerBalanceA-100Isaac1,000,000B-200Sophie500,000To transfer 100,000 from Isaac to Sophie, the system must perform at least two changes:Subtract 100,000 from account A-100Add 100,000 to account B-200A simplified SQL implementation might look like this:UPDATE accountsSET balance = balance - 100000WHERE account_id = 'A-100';UPDATE ac..
Why Does Database Normalization Matter?
Database normalization is often introduced through a short list of rules:First Normal Form: atomic valuesSecond Normal Form: remove partial dependenciesThird Normal Form: remove transitive dependenciesBCNF: every determinant must be a candidate keyThese definitions are useful when preparing for an exam.On their own, however, they do not explain how to examine a real table, identify what is wrong..