Skip to content
Bible, Lee, Data

Bible, Lee, Data

Faith, software, data, and everyday life.

Engineering/DatabaseAll posts

Engineering/Database

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..

Engineering/Database

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 ..

Engineering/Database

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..

Engineering/Database

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..

Engineering/Database

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..

Engineering/Database

[Streamlit] 공공데이터 앱 제작: 대전광역시 버스 관련 데이터 시각화 및 분석

💡대전광역시 버스 관련 데이터 시각화 및 분석이번에 사용할 데이터는 대전광역시의 버스와 관련한 정보이다. 이 데이터를 활용하여 대전광역시의 버스 정류장 현황을 지도에 표시하고, 버스 이용이 많이 발생하는 자치구를 확인하려고 한다. 그리고 도로 안전을 위해 버스전용차로 단속카메라의 보완이 필요한 위치를 분석해보고자 한다. 활용한 데이터대전광역시_버스정류장 현황https://www.data.go.kr/data/15110461/fileData.do 대전광역시_시내버스 기반정보https://www.data.go.kr/data/15081730/fileData.do 대전광역시_자치구별 인구이동 현황https://www.data.go.kr/data/15062511/fileData.do 한국교통안전공단_대전광역시 ..

Engineering/Database

[Streamlit] Folium 라이브러리로 csv 파일 지도 데이터 분석하기

💡대전광역시 서구 일반음식점 현황 분석공공 데이터 포털에서 위도, 경도 지도 데이터를 포함하는 csv 파일을 Streamlit에서 folium 라이브러리를 활용하여 시각화하고, 분석해 보도록 하자. Folium 라이브러리Folium은 지리 공간 데이터를 시각화하는 데 사용되는 Python 라이브러리이다.leaflet.js 기반으로 이루어졌으며, 시각화에 활용할 수 있는 OpenStreetMap, Mapbox, Stamen과 같은 지도 이미지를 제공한다. 자세한 내용은 아래 공식 도큐먼트에서 확인할 수 있다.https://python-visualization.github.io/folium/latest/ Folium — Folium 0.1.dev1+gd6f04cb documentationFolium bui..

Engineering/Database

[R] 데이터마이닝의 이해: 선형 회귀 기반 데이터마이닝 분석

💡주택 데이터 분석주택 데이터 샘플TOTAL VALUETAXLOT SQFT YR BUILTGROSS AREA LIVING AREAFLOORSROOMSBEDROOMS FULL BATHHALF BATHKITCHENFIREPLACEREMODEL344.2433099651880243613522631110None412.65190659019453108197621042110Recent330.1415275001890229413712841110None498.66272137731957503226081951111None331.5417050001910237014382732010None337.4424451421950212410601631011Old359.4452150001954322019162731110None320.44030..