Data Control and Data Organisation

Master the fundamental concepts of data management, validation, verification, and database operations

Learning Objectives:
• Identify different levels of items in a data hierarchy
• Recognise the concept of "garbage in, garbage out"
• Explain and apply various methods of data validation and verification
• Describe the functions of database systems
• Compare file access methods: sequential and direct access

數據控制與數據組織

掌握數據管理、驗證、校驗和數據庫操作的基本概念

學習目標:
• 識別數據層次結構中不同級別的項目
• 認識「無用輸入,無用輸出」的概念
• 解釋並應用各種數據驗證和數據校驗方法
• 描述數據庫系統的功能
• 比較文件訪問方法:順序訪問和直接訪問

Table of Contents

📊 Data Hierarchy

📊 數據層次結構

Understanding the levels of data organization from fields to databases

理解從字段到數據庫的數據組織層次

🛡️ Data Control

🛡️ 數據控制

GIGO principle and the importance of data quality control

GIGO原則和數據質量控制的重要性

✅ Validation

✅ 數據驗證

8 types of validation checks and error detection methods

8種驗證檢查和錯誤檢測方法

🔍 Verification

🔍 數據校驗

Methods to ensure data accuracy through double-checking

通過雙重檢查確保數據準確性的方法

💾 Database Functions

💾 數據庫功能

Organisation, storage, and retrieval of data in databases

數據庫中數據的組織、存儲和檢索

📁 File Access

📁 文件訪問

Comparing sequential and direct access methods

比較順序訪問和直接訪問方法

Data Hierarchy

🔤

Field (Column)

The smallest unit of data. A single piece of information about an entity. Example: "Name", "Age", "Email"

字段 (列)

數據的最小單位。關於實體的單一信息片段。例如:"姓名"、"年齡"、"電子郵件"

📝

Record (Row)

A collection of related fields. All information about a single entity. Example: One student's complete information

記錄 (行)

相關字段的集合。關於單個實體的所有信息。例如:一個學生的完整信息

📋

File/Table

A collection of related records. All entities of the same type. Example: All students in a school

文件/表

相關記錄的集合。相同類型的所有實體。例如:學校中的所有學生

🗄️

Database

A collection of related files/tables. A complete information system. Example: School management system

數據庫

相關文件/表的集合。完整的信息系統。例如:學校管理系統

Feature 特徵 Database 數據庫 Spreadsheet 電子表格
Data Structure 數據結構 Multiple related tables 多個相關表 Single worksheet or workbook 單個工作表或工作簿
Data Volume 數據量 Large volumes (millions of records) 大量數據(數百萬條記錄) Limited (thousands of rows) 有限(數千行)
Relationships 關係 Complex relationships between tables 表之間的複雜關係 Simple or no relationships 簡單或無關係
Multi-user Access 多用戶訪問 Concurrent access supported 支持並發訪問 Limited concurrent access 有限的並發訪問
Data Integrity 數據完整性 Strong validation and constraints 強大的驗證和約束 Basic validation only 僅基本驗證

DBMS (Database Management System)

數據庫管理系統 (DBMS)

Software that manages databases. Examples: MySQL, Oracle, Microsoft SQL Server. Provides tools for creating, maintaining, and querying databases.

管理數據庫的軟件。例如:MySQL、Oracle、Microsoft SQL Server。提供創建、維護和查詢數據庫的工具。

GUI (Graphical User Interface)

圖形用戶界面 (GUI)

Visual interface for interacting with databases. Makes database operations accessible without knowing SQL. Examples: forms, buttons, menus.

與數據庫交互的可視化界面。使數據庫操作無需了解SQL即可訪問。例如:表單、按鈕、菜單。

Data Control

Garbage In, Garbage Out (GIGO)

When unreliable or incoherent data is input to a data analysis, the output information will not be useful. This principle emphasizes the importance of data quality.

Example: If a student's age is entered as "200" instead of "20", any analysis based on this data will be meaningless.

無用輸入,無用輸出 (GIGO)

當不可靠或不連貫的數據輸入到數據分析中時,輸出資訊將不會有用。這一原則強調數據質量的重要性。

例子: 如果學生的年齡輸入為"200"而不是"20",基於此數據的任何分析都將毫無意義。

Common Data Errors

Data Source Errors

數據源錯誤

Errors that exist in the original source data. Example: A survey respondent provides incorrect information.

原始源數據中存在的錯誤。例如:調查受訪者提供不正確的信息。

Transcription Errors

抄錄錯誤

Errors made when copying data from one medium to another. Example: Typing "1000" instead of "100" when entering data from a form.

從一種媒介複製數據到另一種媒介時出現的錯誤。例如:從表單輸入數據時輸入"1000"而不是"100"。

Transposition Errors

置換錯誤

Errors where two digits or characters are swapped. Example: Typing "12345678" instead of "12346578".

兩個數字或字符被交換的錯誤。例如:輸入"12345678"而不是"12346578"。

Two Approaches to Data Control

Data Validation

Automatic checking by computer to ensure data is reasonable, sensible, and within acceptable boundaries.

Data Verification

Checking to ensure that data has been accurately copied from the original source to the computer system.

數據控制的兩種方法

數據驗證

計算機自動檢查以確保數據合理、明智且在可接受的範圍內。

數據校驗

檢查以確保數據已從原始來源準確複製到計算機系統。

Data Validation

1. Presence Check

1. 存在性檢查

Ensures that essential data is entered. Example: Email field must not be empty.

確保輸入必要數據。例如:電子郵件字段不能為空。

2. Fixed Value Check

2. 固定值檢查

Checks if data matches a predefined set of values. Example: Gender must be "M" or "F".

檢查數據是否匹配預定義的值集。例如:性別必須是"M"或"F"。

3. Type Check

3. 類型檢查

Ensures data is of the correct type. Example: Age must be a number, not text.

確保數據類型正確。例如:年齡必須是數字,而不是文本。

4. Range Check

4. 範圍檢查

Checks if data falls within acceptable limits. Example: Age must be between 0 and 120.

檢查數據是否在可接受的範圍內。例如:年齡必須在0到120之間。

5. Length Check

5. 長度檢查

Ensures data has correct length. Example: HKID must be exactly 8 characters.

確保數據具有正確的長度。例如:香港身份證必須正好是8個字符。

6. Format Check

6. 格式檢查

Checks if data matches a specific pattern. Example: Email must contain "@" and "."

檢查數據是否匹配特定模式。例如:電子郵件必須包含"@"和"."

7. Consistency Check

7. 一致性檢查

Ensures data is logically consistent. Example: End date must be after start date.

確保數據邏輯一致。例如:結束日期必須在開始日期之後。

8. Uniqueness Check

8. 唯一性檢查

Ensures data is unique in the system. Example: Student ID must not already exist.

確保數據在系統中是唯一的。例如:學生ID不能已經存在。

Check Digit Calculator - HKID Example

Hong Kong Identity Card uses check digit for validation. Enter the first 7 characters of an HKID:

校驗位計算器 - 香港身份證例子

香港身份證使用校驗位進行驗證。輸入香港身份證的前7個字符:

Parity Check

A method to detect errors in data transmission. An extra bit is added to ensure the total number of 1s is even (even parity) or odd (odd parity).

Example:

Data: 1011001 (four 1s - even)

Even parity bit: 0 (to keep total even)

Transmitted: 10110010

奇偶校驗

一種檢測數據傳輸錯誤的方法。添加額外的位以確保1的總數為偶數(偶校驗)或奇數(奇校驗)。

例子:

數據: 1011001 (四個1 - 偶數)

偶校驗位: 0 (保持總數為偶數)

傳輸: 10110010

UI Design Elements for Validation

Drop-down List

下拉列表

Provides fixed value choices. Prevents type and format errors. Example: Country selection.

提供固定值選擇。防止類型和格式錯誤。例如:國家選擇。

Radio Buttons

單選按鈕

Single choice from options. Good for fixed value check. Example: Gender selection.

從選項中單選。適合固定值檢查。例如:性別選擇。

Checkboxes

複選框

Multiple choices allowed. Useful for presence check. Example: Terms and conditions.

允許多選。適用於存在性檢查。例如:條款和條件。

Date Picker

日期選擇器

Ensures correct date format. Prevents format and type errors. Example: Birth date selection.

確保正確的日期格式。防止格式和類型錯誤。例如:出生日期選擇。

Data Types

Integer

整數

Whole numbers without decimal points. Example: 42, -17, 0

沒有小數點的整數。例如: 42, -17, 0

Floating Point

浮點數

Numbers with decimal points. Example: 3.14, -0.5, 2.0

帶小數點的數字。例如: 3.14, -0.5, 2.0

String

字符串

Text data. Can contain letters, numbers, symbols. Example: "Hello", "A123"

文本數據。可以包含字母、數字、符號。例如: "Hello", "A123"

Boolean

布爾值

True or False values. Used for logical conditions. Example: True, False

真或假值。用於邏輯條件。例如: True, False

Data Verification

1. Inputting Data Twice

1. 輸入數據兩次

User enters the same data twice (e.g., password confirmation). System compares both entries. If they match, data is likely correct.

用戶輸入相同數據兩次(例如,密碼確認)。系統比較兩次輸入。如果匹配,數據可能是正確的。

2. Double Data Entry

2. 雙重數據輸入

Two different people enter the same data independently. System compares both versions. Discrepancies are flagged for review.

兩個不同的人獨立輸入相同的數據。系統比較兩個版本。差異被標記以供審查。

3. Proofreading Data

3. 校對數據

Visual check by comparing entered data with original source. Can be done on screen or printed copy. Human verification method.

通過將輸入的數據與原始來源進行比較來進行視覺檢查。可以在屏幕上或打印副本上完成。人工驗證方法。

Aspect 方面 Validation 驗證 Verification 校驗
Purpose 目的 Check if data is reasonable 檢查數據是否合理 Check if data is accurate 檢查數據是否準確
Method 方法 Automatic computer checks 自動計算機檢查 Manual comparison or double entry 手動比較或雙重輸入
When Applied 何時應用 During data entry 在數據輸入期間 After data entry 在數據輸入之後
Example 例子 Range check: Age 0-120 範圍檢查:年齡0-120 Re-enter email address 重新輸入電子郵件地址
Limitation 限制 Cannot detect all errors 無法檢測所有錯誤 Time-consuming and costly 耗時且成本高

Functions of Database

1. Organisation

1. 組織

Structuring data in tables with defined fields and data types.

Example:

Table: Students

Fields: StudentID (Integer), Name (String), Age (Integer), Email (String)

在具有定義字段和數據類型的表中構建數據。

例子:

表: 學生

字段: 學生ID (整數), 姓名 (字符串), 年齡 (整數), 電子郵件 (字符串)

2. Storage

2. 存儲

Saving data permanently in the database.

SQL Example:

INSERT INTO Students (StudentID, Name, Age, Email)
VALUES (1001, 'John Chan', 16, '[email protected]');

GUI Method: Fill in a form and click "Save" button

將數據永久保存在數據庫中。

SQL例子:

INSERT INTO Students (StudentID, Name, Age, Email)
VALUES (1001, 'John Chan', 16, '[email protected]');

GUI方法: 填寫表單並點擊"保存"按鈕

3. Retrieval

3. 檢索

Searching and extracting data from the database.

SQL Example:

SELECT Name, Age FROM Students
WHERE Age >= 16
ORDER BY Name;

GUI Methods:

• Sorting: Click column header to sort

• Filtering: Enter search criteria in filter box

從數據庫中搜索和提取數據。

SQL例子:

SELECT Name, Age FROM Students
WHERE Age >= 16
ORDER BY Name;

GUI方法:

• 排序: 點擊列標題進行排序

• 過濾: 在過濾框中輸入搜索條件

Index in Database

An index is a data structure that improves the speed of data retrieval operations. It works like a book index - instead of searching through every page, you can jump directly to the relevant section.

How it works:

1. Index stores field values and their locations

2. When searching, database checks index first

3. Index points directly to the data location

4. Much faster than scanning entire table

Example: Finding a student by StudentID with index takes milliseconds instead of seconds.

數據庫中的索引

索引是一種提高數據檢索操作速度的數據結構。它就像書籍索引 - 無需搜索每一頁,您可以直接跳到相關部分。

工作原理:

1. 索引存儲字段值及其位置

2. 搜索時,數據庫首先檢查索引

3. 索引直接指向數據位置

4. 比掃描整個表快得多

例子: 使用索引通過學生ID查找學生只需毫秒而不是秒。

File Access Methods

Sequential Access

順序訪問

Data is accessed in order from beginning to end, one record after another.

Storage Medium: Magnetic tape

Advantages:

• Simple and inexpensive

• Good for backup and archiving

• Efficient for processing all records

Disadvantages:

• Slow for finding specific records

• Must read through all previous data

• Not suitable for random access

數據按順序從頭到尾訪問,一條記錄接一條記錄。

存儲介質: 磁帶

優點:

• 簡單且便宜

• 適合備份和歸檔

• 處理所有記錄效率高

缺點:

• 查找特定記錄速度慢

• 必須讀取所有先前的數據

• 不適合隨機訪問

Direct Access

直接訪問

Data can be accessed directly without reading through previous records.

Storage Media: Hard disk, USB flash drive, Optical disk (CD/DVD)

Advantages:

• Very fast access to any record

• Suitable for interactive applications

• Can update individual records easily

Disadvantages:

• More expensive than sequential

• More complex technology

• Requires indexing system

可以直接訪問數據而無需讀取先前的記錄。

存儲介質: 硬盤、USB閃存驅動器、光盤 (CD/DVD)

優點:

• 訪問任何記錄非常快

• 適合交互式應用

• 可以輕鬆更新單個記錄

缺點:

• 比順序訪問更昂貴

• 技術更複雜

• 需要索引系統

Attribute 屬性 Sequential Access 順序訪問 Direct Access 直接訪問
Access Speed 訪問速度 Slow for specific records 查找特定記錄慢 Fast for any record 訪問任何記錄快
Storage Medium 存儲介質 Magnetic tape 磁帶 Hard disk, USB, CD/DVD 硬盤、USB、CD/DVD
Cost 成本 Lower 較低 Higher 較高
Best Use 最佳用途 Backup, batch processing 備份、批處理 Interactive applications 交互式應用
Update Method 更新方法 Must rewrite entire file 必須重寫整個文件 Can update individual records 可以更新單個記錄

Interactive Quiz

Flashcards

Click on any card to flip it and see the definition

點擊任何卡片翻轉並查看定義

made with 由以下製作