YouChen's Blog

YouChen's Blog

RDBMS vs NoSQL:關聯式資料庫選型指南
發表於2025-10-01|backend
什麼是關聯式資料庫?關聯式資料庫是一組資訊,以預先定義的關係整理資料,可將資料儲存在一或多個資料表 (或「關係」) 的資料欄或資料列中,以輕鬆查看及瞭解不同的資料結構之間有何關聯。「關係」是不同資料表之間的邏輯連結,根據這些資料表之間的互動來建立。 『關聯』是指不同表格中可以通過共同的欄位(通常是主鍵鍵和外鍵)建立關聯。 為什麼我們使用 RDBMS 而不是 noSQLRDBMS 主要的核心在於提供嚴格的 ACID 特性,來確保事務(transaction)的可靠度。這對需要絕對準確性的應用(金融系統、訂單處理 etc…)至關重要。 RDBMS 提供複雜查詢功能,包括多表 JOIN、聚合函數、子查詢等,雖然 noSQL 本身有具備類似的功能,但 noSQL 的 JOIN 效能通常不如 RDBMS,因為 noSQL 設計理念是避免 JOIN RDBMS 中預先定義的 Schema 確保資料格式一致,減少資料品質問題。這在需要嚴格資料規範的企業應用中特別重要。 RDBMS 的設計哲學與核心價值RDBMS 主要圍繞著幾個原則來確保資料的一致性、完整性以及可靠性: ACID 特性 正規化...
redis
發表於2025-09-26|backend
什麼是 Redis?Redis 是一種快速、開放原始碼的記憶體內鍵值資料結構存放區。Redis 隨附一組多功能的記憶體內資料結構,讓您能夠輕鬆地建立各種自訂應用程式。Redis 主要使用案例包含快取、工作階段管理、發佈/訂閱以及排行榜。 Redis 位於其他資料庫「之前」,目的是建立一套快取系統,減輕 noSQL or RDB 的負擔,並且加速服務。 ref : https://aws.amazon.com/tw/elasticache/what-is-redis/ 我們該如何使用它?上一段曾說道, Redis 是一套鍵值資料結構存放區,我們可以利用 key 來存放資料,在官方文件有提到 Redis 可以儲存各種位元組序列,包括文字內容、序列化後的物件、計數器數值,以及二進位資料陣列。 以 golang 為例 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707...
Binary Search
發表於2025-09-23|data structures and algorithms
二元搜尋法(binary search)用於尋找有序陣列中目標值位置的搜尋演算法。 二元搜尋比較目標值與陣列中間的元素的大小,如果兩者不相等則會捨棄不可能包含目標值那一半區間,然後在剩餘區間重複此過程,每次選取新的中間元素並與目標值比較,直至找到目標或區間為空。若區間為空,則說明目標值不存在。 worst case 狀況時間複雜度為 $O(logn)$,其中 n 為元素數量。 二分搜尋有許多其他形式。例如,分數級聯能加快在多個陣列中尋找同一數值的速度,還能高效地解決計算幾何等領域的搜尋問題;指數搜尋則將搜尋範圍擴充至無界列表。二元搜尋樹和B樹等資料結構的實現也基於二分搜尋原理。 1234567891011121314151617181920212223#include <vector>using namespace std;int binary_search(vector<int>& arr, int target) { int L = 0; int R = arr.size() - 1; while (L &l...
Two Pointer
發表於2025-09-19|data structures and algorithms
Two Pointer 的產生源自於一個核心問題,如何有效處理陣列或者序列中的配對、區間以及範圍搜尋問題。 最初,我們在遇到需要在陣列中尋找配對或者子陣列的問題時,最直觀的方式便是使用雙重迴圈 (nested loops)。例如,在一個陣列中找到兩個數的和等於目標值: 1234567for(int i = 0; i < arr.len(); i++){ for(int j = i + 1; j < arr.len(); j++){ for(arr[i] + arr[j] == target){ return [i, j]; } }} 但是雙重迴圈的方式,導致的後果就是時間複雜度為 $O(n^2)$ 相比於暴力解法的「盲目搜尋」,Two Pointer 提供了一種「有方向性的搜尋」策略。 兩者差異在於,暴力解需要檢查所有可能組合,two pointer 需要根據問題特性,有策略性的縮小搜尋範圍。 Key PointTwo Pointer 的產生基於對...
Split Array Largest Sum
發表於2025-09-19|leetcode
Split Array Largest SumProblem DescriptionGiven an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized. Return the minimized largest sum of the split. A subarray is a contiguous part of the array. IntuitionThe front element of preorder traversal determines the tree’s root node(the middle of inorder traversal). We use it to determine which element belong to the left subtree or right subtree, and keep comparing the pr...
Trapping Rain Water
發表於2025-09-19|leetcode
Trapping Rain WaterProblem DescriptionGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Approach: Two PointersIntuitionThe key insight is that at any position, the water level is dtermined the minimum of the maximum heights to its left and right. We can use two pointers moving towards each other from both ends. Algorithm Initialize two pointer left and right at the beginning and each of the array. Ke...
Number of Visible People in a Queue
發表於2025-09-16|leetcode
Number of Visible People in a Queue題目敘述There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the i person. A person can see another person to their right in the queue if everybody in between is shorter than both of them. More formally, the ith person can see the j person if i < j and min(heights[i], heights[j]) > max(heights[i+1], heights[i+2], ..., h...
K8s Development Tool
發表於2025-08-03|backend
Kubernetes 是現在最常被使用的容器編排平台 (container orchestration platform),對於想要在 local 環境開發的開發者,選擇一套能夠模擬 Kubernetes 行為的工具,來進行本地的測試開發,變得越來越重要。 像是 Kind 和 Minikube 等工具就提供了方便的解決方式。該篇文章中會提及每一種工具所著重的地方在哪裡,而我們需要根據怎樣的情景選擇對應的工具進行開發。 接下來針對以下四套不同的開源軟體 kind, Minikube, k3s, kubeadm 進行介紹 kind 介紹 kind is a tool for running local Kubernetes clusters using Docker container “nodes”. kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI. kind 是 Kubernetes 底下的一個子專案,他的全名是 Kube...
Word Break
發表於2024-10-05|leetcode
Word Break題目敘述Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation. Example1Input: s = “leetcode”, wordDict = [“leet”,”code”]Output: trueExplanation: Return true because “leetcode” can be segmented as “leet code”. Example 2:Input: s = “applepenapple”, wordDict = [“apple”,”pen”]Output:...
Longest Common Subsequence
發表於2024-10-05|leetcode
Longest Common Subsequence題目敘述Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. DefinitionsSubsequenceA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. For example, “ace” is a subsequence of “abcde”. Common SubsequenceA common subsequence of two strings is a subsequence that...
1…34
avatar
YouChen Huang
不吃早餐會變笨蛋
文章
40
標籤
16
分類
3
Follow Me
公告
This is my Blog
最新文章
Introduce Design Pattern III2026-05-27
Introduce Design Pattern II2026-05-27
Introduce Design Pattern I2026-05-27
rust-sync2026-05-26
Design Patterns Summary2026-05-26
分類
  • backend12
  • data structures and algorithms12
  • leetcode14
標籤
linked_list sliding_windows dynamic_programming OS design-pattern Tree csharp bfs dfs two_pointer database development tool architecture rust BST stack
歸檔
  • 五月 2026 5
  • 一月 2026 10
  • 十月 2025 16
  • 九月 2025 6
  • 八月 2025 1
  • 十月 2024 2
網站資訊
文章數量 :
40
訪客數 :
總瀏覽量 :
最後更新時間 :
© 2025 - 2026 By YouChen Huang框架 Hexo 7.3.0|主題 Butterfly 5.5.4