🗄️ 数据库:结构化存东西的"大仓库"🗄️ Database: the big warehouse that keeps things tidy
上一篇里,💻 小电脑追剧看直播,片单和弹幕堆成山。这些东西存在哪?存在数据库这间大仓库里。Last leaf, 💻 Little Computer binged shows and live streams — lists and comments piling up. Where does it all live? In a big warehouse called the database.
第 1 步:表格里,一行一条记录Step 1: In the table, one row is one record
大仓库里,东西从不乱堆,都住在表格里,找起来有门有路。Inside the warehouse, nothing piles up at random — everything lives in tables, easy to find.
一行就是一条记录,比如一个学生。一列就是一个字段,比如分数。学号人人不同,适合当主键,像身份证号。One row is one record — one pupil, say. One column is one field — the score, say. The student number differs for everyone, so it fits as the primary key, like a national ID number.
表格看着简单,撑得起银行和抢票吗?靠笔笔在册。A plain table — can it really run banks and ticket rushes? Yes, by logging every cent.
第 2 步:银行和抢票背后都是它Step 2: Behind banks and ticket apps is one of these
存入 100、取出 50,每笔都记下来。钱不能错:要么全记上,要么一笔不记,这叫事务。Deposit 100, withdraw 50 — every move gets logged. Money must never blur: either all of it lands, or none does. That all-or-nothing promise is called a transaction.
你可能会问:表格 Excel 也有,干嘛另请一位?看多人同时动手时。You might ask: spreadsheets have tables too — why hire another keeper? Watch what happens when crowds edit at once.
第 3 步:为什么不用 Excel 存一切Step 3: Why not keep everything in a spreadsheet?
Excel 一人改挺好,多人同时改就卡住、写乱。数据库万人同时查都不乱,还能按条件秒找。A spreadsheet serves one editor well; crowds editing together jam it and garble the data. A database serves ten thousand queries at once, still tidy — and finds by condition in a flash.
🎮 你来当查表员(30 秒)🎮 Your turn: table clerk (30 seconds)
道理讲完了。打开学生表:找最高分、数男生、认主键,4 关全过就是金牌查表员。Theory done. Open the student table: find the top score, count the boys, name the primary key — clear all 4 rounds.
一句话记住它:数据库 = 带索引的表格集合;一行一条记录,一列一个字段,学号这样的主键让人人不同。Remember it in one line: a database = indexed tables; one row per record, one column per field, and a primary key like the student number keeps everyone distinct.
表格:行是记录、列是字段、主键是身份证号Tables: rows are records, columns are fields, the key is the ID靠谱:银行流水笔笔在册,事务要么全记要么不记Trust: bank ledgers log every cent; transactions land whole or not at all胜过 Excel:万人同时查不乱,按条件秒找Beats spreadsheets: tidy under crowds, instant finds by condition
内容参考 OpenStax 等公开教材,多来源核对 · AI 生成、人工审核 · 发现错误欢迎指正,帮这片叶子长得更好。Based on OpenStax and other open textbooks, cross-checked across sources · AI-generated, human-reviewed · Spotted a mistake? Tell us — help this leaf grow.