ก่อนมีคอมพิวเตอร์ หอสมุดใช้ลิ้นชักแบบนี้ เก็บบัตรหนึ่งใบต่อหนังสือ Each holding the same few facts, all kept in order — so a librarian could find any book…
English narration · English + 中文 subtitles burned in · การบรรยายภาษาอังกฤษ · คำบรรยายภาษาอังกฤษ + 中文 ลอยตัวบนภาพ
Syllabus · หลักสูตร
English
Candidates should be able to:
Notes and guidance
1 Define a single-table database from given data storage requirements
• Including: – fields – records – validation
2 Suggest suitable basic data types
• Including: – text/alphanumeric – character – Boolean – integer – real – date/time
3 Understand the purpose of a primary key and identify a suitable primary key for a given database table
4 Read, understand and complete structured query language (SQL) scripts to query data stored in a single database table
• Limited to: – SELECT – FROM – WHERE – ORDER BY DESCENDING – ORDER BY ASCENDING – SUM – COUNT – AND – OR • Identifying the output given by an SQL statement that will query the given contents of a database table
4 อ่าน ทำความเข้าใจ และเติม สคริปต์ structured query language (SQL) เพื่อค้นหาข้อมูลที่จัดเก็บในตารางฐานข้อมูลเดียว
•จำกัดอยู่ที่: – SELECT – FROM – WHERE – ORDER BY DESCENDING – ORDER BY ASCENDING – SUM – COUNT – AND – OR • ระบุผลลัพธ์ที่ได้จากคำสั่ง SQL ที่จะค้นหาเนื้อหาที่กำหนดของตารางฐานข้อมูล
Source: Cambridge International syllabus · แหล่งที่มา: หลักสูตร Cambridge International
9.1
What is a database? · ฐานข้อมูลคืออะไร?
English
A database 数据库 is an organised store of data, kept so that it is easy to search, sort and update. At IGCSE you work with a single-table database 单表数据库 — all the data is held in one table.
A primary key 主键 is a field that holds a unique 唯一的 value for every record. No two records can have the same primary key, so it lets you pick out exactly one record.
In the table above, StudentID is a good primary key because every student has a different number. A field like FormClass would be a bad primary key, because many students share the same class.
Validation in a database · การตรวจสอบความถูกต้องในฐานข้อมูล
English
When data is put into a database, validation 验证 checks make sure it is sensible — for example a range check on an age field, or a presence check so a field is not left empty. (You saw these checks in topic 7.)
Structured Query Language 结构化查询语言 (SQL) is a language used to query 查询 a database — to pick out the records you want. You must understand and complete SQL scripts.
SELECT, FROM and WHERE
SELECT says which fields to show.
FROM says which table to use.
WHERE gives a condition 条件, so only matching records are shown.
This shows the first name and class of every student who has paid the fees.
Use * to select all fields:
ORDER BY
ORDER BY sorts the results. Use ASC for ascending 升序 (smallest first, A→Z) or DESC for descending 降序 (largest first, Z→A).
AND and OR
Join conditions with AND (both must be true) or OR (at least one must be true).
SUM and COUNT
SUM adds up the values in a number field.
COUNT counts how many records match.
This counts how many students have not paid. SUM works the same way but adds a number field instead of counting rows.
Working out the output
To find the output of an SQL script, read it in this order:
FROM — which table;
WHERE — keep only the records that match the condition;
SELECT — show only the chosen fields;
ORDER BY — put the results in order.
Following these steps, you can write down exactly which rows and columns the query returns.
Worked example. A Book table has the fields Title, Author, Price and InStock. Write a query showing the title and price of every book by Orwell that is in stock, cheapest first.
Build it in the reading order: FROM names the table; WHERE keeps only the matching records, and because there are two conditions they need AND; SELECT shows only the two fields asked for; ORDER BY … ASC sorts them. Text values go in quotes, and only the fields the question asks for belong in SELECT - adding Author just because you filtered on it is the commonest way to lose a mark here.
Pick one and the site follows you — notes, papers, videos and practice all open on it. · เลือกหนึ่งตัว และเว็บจะติดตามคุณ — หมายเหตุ, ใบงาน, วิดีโอ และการฝึกฝนจะเปิดอยู่ที่นั้น
Type to search notes, lessons, code, vocabulary and past-paper questions across every subject. · พิมพ์เพื่อค้นหาบันทึก, บทเรียน, โค้ด, คำศัพท์ และคำถามข้อสอบเก่าในทุกวิชา