📚 Case Study Mastery: Eduqas GCSE Computer Science Practical Exercises | 案例分析实战演练:Eduqas GCSE 计算机科学
Case studies are a vital component of the Eduqas GCSE Computer Science specification. They allow you to apply computational thinking, programming theory, and system design principles to realistic scenarios. In this article, we will walk through a comprehensive library book management case study, demonstrating how to break down a complex problem, design algorithms, choose appropriate data structures, consider database and network aspects, and evaluate ethical implications. Each section provides both English and Chinese explanations to support bilingual learners.
案例分析是Eduqas GCSE计算机科学课程的重要组成部分。它能让你将计算思维、编程理论和系统设计原则应用到真实场景中。本文将通过一个完整的图书馆图书管理案例,一步步演示如何分解复杂问题、设计算法、选择合适的数据结构、考虑数据库和网络因素,以及评估伦理影响。每个章节均提供中英双语讲解,以支持双语学习者。
1. Understanding the Scenario: Library Book Management System | 理解情境:图书馆图书管理系统
A local public library needs a digital system to replace its paper‑based records. Currently, librarians record book loans, returns, and member registrations in notebooks. The library has about 10,000 books and 1,500 active members. The new system must allow librarians to add new books, search for books by title or author, manage member accounts, and process borrowing and returning. Members should be able to view their borrowed books and due dates via a public terminal. The system must also generate overdue reports automatically.
一家本地公共图书馆需要一个数字系统来取代其纸质记录。目前,图书管理员在笔记本上登记借书、还书和会员注册。该图书馆约有10000本书和1500名活跃会员。新系统必须允许图书管理员添加新书,按书名或作者搜索图书,管理会员账户,并处理借阅和归还。会员应能通过公共终端查看已借图书和到期日期。系统还必须自动生成逾期报告。
By reading the scenario carefully, we identify the main entities: books, members, loans. We also note the functional requirements (search, add, borrow, return, overdue reports) and non‑functional requirements (simple enough for public terminals, reliable, secure member data).
仔细阅读情境后,我们可以识别出主要实体:图书、会员、借阅记录。还能注意到功能性需求(搜索、添加、借阅、归还、逾期报告)和非功能性需求(足够简单以用于公共终端、可靠、保护会员数据安全)。
2. Identifying Stakeholders and Requirements | 识别利益相关者与需求
Stakeholders include librarians (primary users), library members, the library management, and the local council that funds the library. Each stakeholder group has different expectations. Librarians want a fast, intuitive interface for daily transactions. Members want to find books and check their accounts without assistance. Management needs reports on popular books and overdue items to justify funding. The council may require data on user numbers and book circulation to plan services.
利益相关者包括图书管理员(主要用户)、图书馆会员、图书馆管理层以及资助图书馆的地方议会。每组利益相关者都有不同的期望。图书管理员希望日常事务处理界面快速、直观。会员希望能自行查找图书并查看账户。管理层需要热门图书和逾期图书报告以证明资金合理性。议会可能需要用户数量和图书流通数据以规划服务。
Functional requirements can be listed: allow librarian to log in securely, add/remove/update book records, register new members, issue a book (check for availability, link to member, set due date), return a book (update stock, clear loan record), search catalogue by keyword, and generate overdue list. The system must also allow a member to view their current loans and due dates at a public terminal without logging in – perhaps using a membership card number.
功能性需求可以列出:允许图书管理员安全登录,添加/删除/更新图书记录,注册新会员,借出图书(检查可借状态、关联会员、设定到期日),归还图书(更新库存、清除借阅记录),按关键词搜索目录,生成逾期列表。系统还必须允许会员在公共终端上查看当前借阅和到期日期,无需登录——可能使用会员卡号。
Non‑functional requirements: the system should respond in under 2 seconds for any search, protect personal data in compliance with GDPR, be accessible to users with visual impairments (screen reader support), and be maintainable by the council's IT department.
非功能性需求:任何搜索的响应时间应低于2秒,保护个人数据以符合GDPR法规,对视障用户可访问(支持屏幕阅读器),并由议会IT部门维护。
3. Decomposition and Abstraction | 分解与抽象
We break the problem into smaller sub‑problems: a) book catalogue management, b) member management, c) loan processing, d) search functionality, e) reporting module, f) user authentication, g) public access terminal interface. Each sub‑problem can be developed and tested independently.
我们将问题分解为更小的子问题:a) 图书目录管理,b) 会员管理,c) 借阅处理,d) 搜索功能,e) 报告模块,f) 用户认证,g) 公共访问终端界面。每个子问题可以独立开发和测试。
Abstraction helps us model the real‑world library in a simplified way. We only need to represent the attributes relevant to the system. A book can be abstracted as: BookID, Title, Author, ISBN, Genre, Status (Available/On Loan). A member: MemberID, Name, Contact, MembershipExpiry. A loan: LoanID, BookID, MemberID, DateBorrowed, DueDate, DateReturned. We deliberately ignore details like book cover image or member's reading preferences unless required later.
抽象帮助我们用简化的方式对真实图书馆进行建模。我们只需要表示与系统相关的属性。一本书可以抽象为:图书ID,书名,作者,ISBN,类型,状态(可借/已借出)。会员:会员ID,姓名,联系方式,会员到期日。借阅:借阅ID,图书ID,会员ID,借阅日期,到期日,归还日期。我们特意忽略图书封面图像或会员阅读偏好等细节,除非后续有要求。
4. Algorithm Design – Searching and Sorting | 算法设计 – 搜索与排序
Two key operations in this system are searching for books and sorting results. For the search, we need to match a keyword against book titles and authors. A linear search over an array of 10,000 books might be acceptable if optimised by index, but we could also use a binary search if the catalogue is kept sorted alphabetically by title. However, since users may search by partial title or author, a linear search through all records with string matching is more realistic. We can pre‑sort the catalogue by title and by author in separate arrays to speed up exact searches, but fuzzy matching requires scanning.
该系统的两个关键操作是搜索图书和对结果排序。对于搜索,我们需要将关键词与书名和作者进行匹配。如果经过索引优化,对一万本图书的数组进行线性搜索可能可以接受,但如果目录按书名字母顺序排序,我们也可以使用二分搜索。不过,由于用户可能按部分书名或作者搜索,使用字符串匹配遍历所有记录的线性搜索更现实。我们可以预先将目录按书名和作者分别排序到不同数组中,以加快精确搜索,但模糊匹配仍需扫描。
Pseudocode for a simple keyword search returning a list of matching BookIDs:
一个简单的关键词搜索伪代码,返回匹配图书ID列表:
PROCEDURE searchBooks(keyword, catalogue)
FOR each book IN catalogue
IF keyword IN book.title OR keyword IN book.author THEN
ADD book.id TO results
ENDFOR
RETURN results
Sorting results by relevance or alphabetic order improves user experience. A bubble sort might be simple to implement but inefficient for large results; we can use a merge sort (O(n log n)) to sort the result list by title before displaying. We also need a function to check overdue loans: compare current date with due date, add to overdue list. This can be done by scanning the Loans table and selecting records where DueDate < currentDate AND DateReturned is null.
按相关性或字母顺序对结果排序能改善用户体验。冒泡排序可能实现简单,但对大量结果效率低下;我们可以使用归并排序(O(n log n))在显示前按书名排序结果列表。我们还需要一个功能来检查逾期借阅:比较当前日期与到期日期,将逾期记录添加到列表中。这可以通过扫描借阅表,并选择到期日期早于当前日期且归还日期为空的记录来实现。
5. Data Structures and Storage | 数据结构与存储
We need persistent storage. A relational database is ideal because of structured relationships and SQL support. We can design tables: Books, Members, Loans, and perhaps Categories (Genre). A 2D array could temporarily hold the catalogue in memory during program execution, but long‑term storage requires a database. In Python, we could use SQLite for a local implementation. Records (structs) with named fields are another way to group data in memory before saving to disk.
我们需要持久化存储。关系数据库是理想之选,因为它具有结构化关系和SQL支持。我们可以设计表:图书、会员、借阅,或许还有类别(类型)。在程序执行期间,二维数组可以临时保存内存中的目录,但长期存储需要数据库。在Python中,我们可以使用SQLite进行本地实现。带有命名字段的记录(结构体)是在保存到磁盘之前将数据分组的另一种方式。
Example table structures:
示例表结构:
| Books | BookID (PK), Title, Author, ISBN, Genre, Status |
| Members | MemberID (PK), FullName, Email, Phone, ExpiryDate |
| Loans | LoanID (PK), BookID (FK), MemberID (FK), BorrowDate, DueDate, ReturnDate |
Choosing appropriate data types saves storage and improves performance. For example, ISBN can be a string of 13 characters; Status could be a Boolean or a short text ('Available','On Loan'). DueDate is a date type. Using a foreign key constraint ensures referential integrity, so a loan cannot be created with a non‑existent member or book.
选择合适的数据类型可以节省存储空间并提高性能。例如,ISBN 可以为长度为13个字符的字符串;状态可以是布尔值或短文本('Available','On Loan')。到期日是日期类型。使用外键约束可确保引用完整性,因此借阅记录不能使用不存在的会员或图书创建。
If we implement a simple prototype without a full database, we could store data in CSV files or JSON. However, the Eduqas specification expects knowledge of SQL for querying databases, so we should demonstrate SQL skills.
如果我们实现一个简单的原型而不用完整的数据库,我们可以将数据存储在CSV文件或JSON中。然而,Eduqas考试大纲期望具备使用SQL查询数据库的知识,因此我们应展示SQL技能。
6. Programming Techniques and Code Examples | 编程技巧与代码示例
We need to consider input validation, defensive design, and maintainable code. When a librarian issues a book, the program should check if the book is available, if the member exists and has a valid membership, and if the member has reached the maximum loan limit (e.g., 8 books). Validation rules prevent logical errors and data corruption. For example, a due date must be after the borrow date, and membership expiry must be after today.
我们需要考虑输入验证、防御性设计和可维护的代码。当图书管理员借出一本书时,程序应检查该书是否可借、会员是否存在且会员资格有效,以及会员是否已达到最大借阅册数(例如8本)。验证规则可防止逻辑错误和数据损坏。例如,到期日期必须在借阅日期之后,会员到期日必须在今天之后。
In Python, a function to issue a book could look like:
在Python中,一个借出图书的函数可能如下:
def issue_book(book_id, member_id):
if not book_available(book_id): return 'Book not available'
if not member_valid(member_id): return 'Invalid member'
if member_loan_count(member_id) >= MAX_LOANS: return 'Loan limit reached'
due = today + timedelta(days=LOAN_PERIOD)
add_loan(book_id, member_id, today, due)
set_book_status(book_id, 'On Loan')
return 'Book issued successfully'
ust. Comments and meaningful variable names improve readability. We also should handle exceptions, such as database connection errors, using try‑except blocks.
我们使用常量表示LOAN_PERIOD和MAX_LOANS,以便调整代码。注释和有意义的变量名提高了可读性。我们还应使用try‑except块处理异常,比如数据库连接错误。
7. Database Design and SQL Queries | 数据库设计与SQL查询
The database can be queried to produce useful information. For example, to find all books currently on loan by a specific member:
可以查询数据库以生成有用信息。例如,查找某一会员当前借出的所有图书:
SELECT Books.Title, Loans.DueDate
FROM Books INNER JOIN Loans ON Books.BookID = Loans.BookID
WHERE Loans.MemberID = 105 AND Loans.ReturnDate IS NULL;
To generate an overdue report with member contact details:
生成包含会员联系方式的逾期报告:
SELECT Members.FullName, Members.Email, Books.Title, Loans.DueDate
FROM Members INNER JOIN Loans ON Members.MemberID = Loans.MemberID
INNER JOIN Books ON Loans.BookID = Books.BookID
WHERE Loans.DueDate < '2025-05-01' AND Loans.ReturnDate IS NULL
ORDER BY Loans.DueDate;
These queries demonstrate joins across multiple tables and filtering with conditions. We could also use aggregate functions: COUNT books per genre to see popular categories. Database normalisation avoids data duplication. For instance, storing author name only in the Books table rather than duplicating an authors table may be acceptable for this scale, but a normalised design with a separate Authors table and an AuthorBook link table would be better for flexibility and consistency if an author writes many books.
这些查询展示了多表连接和条件过滤。我们还可以使用聚合函数:按类型统计图书数量以了解受欢迎类别。数据库规范化可以避免数据重复。例如,只将作者姓名存储在图书表中,而不重复作者表,在这种规模下可能可以接受;但如果一位作者写了多本书,采用规范化设计(单独的作者表和作者-图书关联表)会更灵活、更一致。
8. Network and Security Considerations | 网络与安全考量
The library system will run on the local council's intranet. Librarians use desktop PCs connected via Ethernet; the public terminal is a touchscreen kiosk. A client‑server architecture is appropriate: the database resides on a central server, and client applications (librarian software and kiosk interface) access it. This allows multiple librarians to work concurrently. Concurrency control is needed to prevent two librarians from issuing the same book simultaneously. Transactions and record locking can ensure consistency.
该系统将在本地议会的内部网上运行。图书管理员使用通过以太网连接的台式电脑;公共终端是一台触摸屏自助机。客户-服务器架构是合适的:数据库驻留在中央服务器上,客户端应用程序(图书管理员软件和自助机界面)访问该服务器。这允许多名管理员同时工作。需要并发控制以防止两名管理员同时借出同一本书。事务和记录锁定可以确保一致性。
Security is crucial. Librarians must authenticate with a username and strong password; passwords should be hashed (e.g., SHA‑256) and salted before storage. The public kiosk only accesses read‑only views of member loans, and the member must scan their library card or enter their membership number. However, we must not display full member details publicly to protect privacy. Data transmitted between client and server should be encrypted (HTTPS or TLS) to prevent eavesdropping on passwords or personal data. Regular backups of the database protect against data loss. The code should use parameterised SQL queries to prevent SQL injection attacks, especially on the public search box.
安全至关重要。图书管理员必须通过用户名和强密码进行认证;密码在存储前应进行哈希处理(例如SHA‑256)并加盐。公共自助机仅访问会员借阅信息的只读视图,会员必须扫描借书卡或输入会员编号。然而,我们不能公开显示完整的会员详细信息以保护隐私。客户端与服务器之间传输的数据应进行加密(HTTPS或TLS),以防止密码或个人数据被窃听。定期备份数据库可防范数据丢失。代码应使用参数化SQL查询来防止SQL注入攻击,特别是在公共搜索框上。
9. Testing and Evaluation | 测试与评价
A thorough test plan is necessary. We need to test normal operation: adding a new book, borrowing and returning successfully, searching for an existing book. Boundary testing: attempting to borrow when a book is already on loan, borrowing when member has reached the loan limit, searching for a non‑existent title. Erroneous data: entering text where a number is expected (ISBN), leaving mandatory fields blank. The system should provide clear error messages without crashing.
需要一份详尽的测试计划。我们需要测试正常操作:添加新书、成功借阅和归还、搜索现有书籍。边界测试:尝试借出一本已借出的书,在会员达到借阅上限时借阅,搜索不存在的书名。错误数据:在需要数字的地方输入文本(如ISBN),将必填字段留空。系统应提供明确的错误信息而不崩溃。
We can design a test table with test ID, description, input data, expected outcome, actual result, and pass/fail. For performance, we can simulate 10 concurrent searches to check response time. User acceptance testing involves real librarians trying the system and providing feedback. Evaluation against the original requirements helps us determine if the system meets the needs. We might find that the kiosk screen font is too small for elderly members, leading to a design change. Reflective evaluation is a key skill for the exam.
我们可以设计一个测试表,包含测试ID、描述、输入数据、预期结果、实际结果和通过/失败。对于性能,我们可以模拟10个并发搜索来检查响应时间。用户验收测试包括让真实的图书管理员试用该系统并提供反馈。对照原始需求进行评估,有助于我们确定系统是否满足需求。我们可能会发现自助机屏幕字体对老年会员来说太小,从而导致设计变更。反思性评估是考试中的一项关键技能。
10. Ethical, Legal and Environmental Impacts | 伦理、法律与环境影响
The library system collects personal data (names, contact details, loan history), so it must comply with the UK Data Protection Act 2018 and GDPR. Principles include: data collected for specified, explicit and legitimate purposes; not kept longer than necessary; kept secure. Members must be informed about what data is held and have the right to access it. The system should allow members to request deletion of their data when they leave the library, unless retention is required by law.
该系统收集个人数据(姓名、联系方式、借阅历史),因此必须遵守《2018年英国数据保护法》和GDPR。原则包括:为特定、明确和合法的目的收集数据;保存时间不超过必要期限;确保安全。必须告知会员所持有的数据是什么,并且他们有权访问这些数据。系统应允许会员在离开图书馆时请求删除其数据,除非法律要求保留。
Environmental impact: a digital system reduces paper usage for records and overdue notices, which is positive. However, the server and computers consume electricity and require cooling. The council should choose energy‑efficient hardware and enable power‑saving settings. When devices become obsolete, they must be disposed of responsibly under WEEE regulations. The software could be designed to work on older hardware to extend its lifespan, reducing e‑waste.
环境影响:数字系统减少了用于记录和逾期通知的纸张消耗,这是积极的。然而,服务器和计算机消耗电力并需要散热。议会应选择节能硬件并启用省电设置。当设备过时时,必须根据WEEE法规负责任地进行处置。软件可以设计为能在旧硬件上运行,以延长其使用寿命,减少电子废弃物。
Ethical considerations also include accessibility. The public terminal must be usable by people with disabilities – large buttons, high‑contrast mode, audio output. Not providing accessibility could exclude some members and be considered discriminatory. The system should also be fair: not restrict access based on postcode or reading history in a way that creates bias.
伦理考量还包括可访问性。公共终端必须可供残障人士使用——大按钮、高对比度模式、音频输出。不提供无障碍功能可能会将一些会员排除在外,并被视为歧视。系统还应公平公正:不以邮政编码或阅读历史等方式限制访问,从而造成偏见。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图