RDBMS 與 SQL 的差異,他們是一樣的嗎?

RDBMS vs SQL

會想寫這一篇是因為我每次都說 SQL, NoSQL,當有一天有人問我 RDBMS 與 NoSQL 資料庫差異時,我想說:「不就 SQL 跟 NoSQL 的差異嗎?」

但其實 RDBMS ≠ SQL 唷!

RDBMSSQL 的區別 —
記住,一個是關連式資料庫管理系統,一個是關連式資料庫中常用來查詢資料的高階語言

RDBMS

其實看名字就知道,RDBMS 全名是 Relational Database Management System。他是資料庫軟體,可以做資料的管理、儲存、查詢、更新等。其資料儲存使用的是關聯式模型。資料儲存的模型有很多種,有興趣的可以參考 RDBMS vs NoSQL

An RDBMS is a Relational Database Management System. It is the database software itself, which manages storage, querying, updating, and, well, everything. Specifically, an RDBMS uses a relational model of data, as the name suggests.

SQL

SQL 的全名是 Structured Query Language,顧名思義是種高階語言,而且是 declarative 類別,常用在 RDBMS 中的查詢語言。不曉得 declarative 是什麼意思的朋,可以參考下方的補充。

SQL, the Structured Query Language, is a declarative query language which is typically used to query the RDBMS.

結論

SQL 是常用來與 RDBMS 系統互動的語言。也就是說你,可以用其他語言跟 RDBMS 互動,也可以用 SQL 跟其他資料庫系統互動。

So: the RDBMS is the system, and SQL is the language used to interact with the system. In principle you could have an RDBMS that uses some other language for access, and in principle you could use SQL to interact with some other kind of database system, though in practice the two are closely coupled.



補充

SQL 是一種 declarative programming language。
高階語言的類別,有興趣可以參考 Programming Paradigms,這邊簡單介紹兩種

imperative & declarative

假設你今天想要從資料庫拿動物種類  animal species 為鯊魚 sharks 的品種,而你的動物種類  animal species 是以陣列 list 的方式儲存,那麼用兩種不同類型語言拿資料的方式就會如下:

可以發現許多常見的語言屬於 imperative,他們用很直觀的 step by step for loop 把品種為 sharks 的資料拿出來。就連最一開始 database 中使用的語言也是 imperative,是一直到 relational model 的引入, 身為 declarative query language 的 SQL 才開始廣泛被使用。(ref: DDIA)

而 declarative 類的 SQL 就像個黑盒子一樣,只要下 family = sharks 就搞定了一切。

Comments

Popular posts from this blog

《 Imgproxy 使用分析一:圖片下載速度優化分析:Akamai CDN vs Imgproxy 效能比較》

《 Akamai + S3 與 CloudFront + Imgproxy + S3 使用分析二:壓縮圖片設計流程:檔案大小 vs 載入時間的權衡》

程式語言初學者 Docker 入門第二章 —— 安裝與驗證 (Mac)