Case Study: Designing a Library Management System—A Pre-U OCR Computer Science Walkthrough | 案例分析:图书馆管理系统设计——Pre-U OCR 计算机科学实战演练

📚 Case Study: Designing a Library Management System—A Pre-U OCR Computer Science Walkthrough | 案例分析:图书馆管理系统设计——Pre-U OCR 计算机科学实战演练

Case studies are a cornerstone of the Pre-U OCR Computer Science syllabus, bridging theoretical knowledge and practical application. In this walkthrough, we will explore the complete lifecycle of a library management system for a fictional community library called ‘BookWorm’. From gathering initial requirements to evaluating the final product, this article demonstrates how to apply key concepts such as system modeling, database design, algorithm selection and project management within a realistic context. Each stage is examined in detail, giving you a concrete model for your own coursework or revision.

案例研究是 Pre-U OCR 计算机科学大纲的基石,它将理论知识与实际应用相结合。在本演练中,我们将探讨一个虚构社区图书馆 ‘BookWorm’ 的图书馆管理系统的完整生命周期。从收集初始需求到评估最终产品,本文展示了如何在现实情境中应用系统建模、数据库设计、算法选择和项目管理等关键概念。每个阶段都进行了详细研究,为你的课程作业或复习提供了一个具体范例。


1. Understanding the Scenario and Stakeholders | 理解场景与利益相关者

BookWorm is a small community library serving around 1,500 registered members. Currently, all records are kept on paper or in disconnected spreadsheets, leading to errors in stock tracking and overdue notifications. The primary stakeholders include the librarian, who needs to manage cataloguing, loans and returns efficiently; the library members, who want a simple way to search for and reserve books online; and the IT support volunteer, who will maintain the system. An external auditor may also be a secondary stakeholder, as the library receives public funding and must provide usage reports.

BookWorm 是一个为约 1500 名注册会员服务的小型社区图书馆。目前所有记录都保存在纸上或互不关联的电子表格中,导致库存追踪和逾期通知出现错误。主要的利益相关者包括需要高效管理编目、借阅和归还的图书管理员;希望能够在网上便捷地搜索和预约图书的会员;以及将维护该系统的 IT 支持志愿者。外部审计员也可能是次要利益相关者,因为图书馆接受公共资金,必须提供使用情况报告。

The core problem is to design an integrated system that automates inventory management, member registration, loan processing and overdue reporting. Understanding these human and organisational needs is the first step in any successful analysis. The stakeholders’ expectations must be balanced with technical and budgetary constraints.

核心问题是设计一个集成系统,自动化库存管理、会员注册、借阅处理和逾期报告。在任何成功的分析中,理解这些人的需求和组织需求都是第一步。必须将利益相关者的期望与技术及预算限制进行平衡。


2. Requirements Elicitation and Analysis | 需求获取与分析

Through interviews and questionnaires with the librarian and a representative group of members, a set of functional and non-functional requirements was gathered. Functional requirements describe what the system should do, while non-functional requirements capture quality attributes. The table below summarises the key findings after prioritisation.

通过与图书管理员及代表性会员群体进行访谈和问卷调查,收集了一套功能性和非功能性需求。功能性需求描述了系统应该做什么,而非功能性需求则捕捉了质量属性。以下表格总结了经过优先级排序后的关键发现。

Type Requirement
Functional Search for books by title, author or ISBN.
Functional Borrow and return books with automatic due-date calculation.
Functional Renew a loan if no other member has reserved the item.
Functional Generate overdue reports and send email reminders.
Non-functional The system must handle up to 50 concurrent searches without performance degradation.
Non-functional Member data must be encrypted at rest and in transit (GDPR compliance).
Non-functional Availability of 99.5% during library opening hours (08:00–20:00).

这些需求经过剖析,使得我们可以清晰界定系统边界。例如,通过邮件发送逾期提醒意味着需要集成一个邮件服务,而 GDPR 合规性则强制要求实施严格的访问控制和数据加密。需求分析阶段也揭示了不会包含在首批版本中的功能,例如在线支付罚款,它被推迟到了未来的更新中。


3. Feasibility Study | 可行性研究

Before proceeding to design, a feasibility study was conducted. Technically, the system is viable: a relational database can store all necessary records, a web-based front end built with HTML, CSS and JavaScript will provide cross-platform access, and a server-side language like Python with a lightweight framework can handle business logic. The library already owns a low-cost server and a domain name, so the technical risk is minimal. Economically, the initial development cost is estimated at £4,000, which can be covered by a community grant. Ongoing costs for hosting and maintenance are projected at £30 per month, well within the library’s budget. Operationally, the librarian and volunteers are willing to be trained, and the system will run parallel to the old manual processes for one month to ensure a smooth transition. The study concluded the project is feasible in all dimensions.

在进入设计之前,进行了可行性研究。技术上,该系统是可行的:关系数据库可以存储所有必要记录,用 HTML、CSS 和 JavaScript 构建的 Web 前端将提供跨平台访问,而像 Python 加上轻量级框架这样的服务器端语言可以处理业务逻辑。图书馆已经拥有一台低成本服务器和一个域名,因此技术风险很小。经济上,初始开发成本估计为 4000 英镑,可由一项社区拨款覆盖。每月的主机和维护费用预计为 30 英镑,完全在图书馆预算之内。运营上,图书管理员和志愿者愿意接受培训,系统将与旧的手动流程并行运行一个月,以确保顺利过渡。该研究得出结论,该项目在所有维度上都是可行的。


4. System Modeling Using UML | 使用 UML 进行系统建模

To visualise the system’s structure and behaviour, we created several Unified Modeling Language (UML) diagrams. The use case diagram identified two primary actors: Librarian and Member. Key use cases for the Librarian include Add/Edit Book, Manage Members, View Overdue Loans and Generate Reports. The Member can trigger Search Catalogue, Borrow Book, Return Book and Renew Loan. A ‘Notify Member’ use case is triggered automatically by a scheduler and is linked to the Overdue Loan condition.

为了可视化系统的结构和行为,我们创建了几个统一建模语言(UML)图。用例图确定了两个主要参与者:图书管理员和会员。图书管理员的关键用例包括添加/编辑图书、管理会员、查看逾期借阅和生成报告。会员可以触发搜索目录、借书、还书和续借。’通知会员’ 用例由调度程序自动触发,并与逾期借阅条件关联。

For the static structure, a class diagram was developed. The central classes are Book (attributes: ISBN, title, author, genre, publicationYear, totalCopies, availableCopies), Member (memberID, name, email, joinDate, phone) and Loan (loanID, borrowDate, dueDate, returnDate, status). Associations include a Member ‘has’ 0..* Loans and a Book ‘is involved in’ 0..* Loans. We also included a Librarian class inheriting from Member with additional privilege methods such as overrideLoan(). This object-oriented decomposition clarifies responsibilities and guides the database and code design.

对于静态结构,我们开发了类图。核心类是 Book(属性:ISBN、title、author、genre、publicationYear、totalCopies、availableCopies)、Member(memberID、name、email、joinDate、phone)和 Loan(loanID、borrowDate、dueDate、returnDate、status)。关联包括一个 Member ‘拥有’ 0..* 个 Loan,以及一个 Book ‘参与’ 0..* 个 Loan。我们还包含了一个 Librarian 类,它继承自 Member,并具有额外的特权方法,如 overrideLoan()。这种面向对象的分解明确了职责,并指导了数据库和代码设计。


5. Database Design and Normalization | 数据库设计与规范化

Translating the class diagram into a relational schema, we arrived at three core tables. Normalization to Third Normal Form (3NF) ensures data integrity and avoids update anomalies. The Book table has ISBN as the primary key, with columns for title, author, genre, publicationYear, totalCopies and availableCopies. The Member table uses memberID as the primary key and includes name, email, joinDate and phone. The Loan table has loanID as primary key, with foreign keys ISBN and memberID linking to Book and Member respectively, plus borrowDate, dueDate, returnDate and status. Because a member can borrow multiple books and a book can be borrowed by many members over time, the Loan table acts as a junction entity resolving the many-to-many relationship. All non-key attributes depend fully on the primary key, and there are no transitive dependencies.

将类图转换为关系模式后,我们得到了三个核心表。规范化到第三范式(3NF)可确保数据完整性并避免更新异常。Book 表以 ISBN 为主键,列包括 title、author、genre、publicationYear、totalCopies 和 availableCopies。Member 表使用 memberID 作为主键,并包含 name、email、joinDate 和 phone。Loan 表以 loanID 为主键,外键 ISBN 和 memberID 分别连接到 Book 和 Member,此外还有 borrowDate、dueDate、returnDate 和 status。由于一个会员可以借阅多本书,而一本书可以随时间被多个会员借阅,Loan 表充当了解析多对多关系的连接实体。所有非键属性都完全函数依赖于主键,并且没有传递依赖。

Indexes will be created on frequently queried columns such as title, author and memberID to speed up searches. Stored procedures will be used to encapsulate complex operations like borrowing a book, which must decrement availableCopies and create a new Loan record in a single transaction to maintain consistency.

我们将在 title、author 和 memberID 等经常查询的列上创建索引,以加快搜索速度。将使用存储过程来封装复杂操作,例如借书,它必须在一个事务中递减 availableCopies 并创建新的 Loan 记录,以保持一致性。


6. Algorithm Design for Key Functions | 关键功能的算法设计

The most performance-sensitive operation is searching the catalogue. Since the collection size is under 20,000 books, a simple linear search on a sorted dataset would be acceptable, but we plan for growth. We will implement a binary search on the title index if the user searches by exact title. For partial-title or author searches, an inverted index implemented with a hash map will offer O(1) average lookup time. The core search algorithm is outlined below in pseudocode.

最影响性能的操作是搜索目录。由于藏书量在 20,000 册以下,对已排序数据集使用简单的线性搜索也是可以接受的,但我们要为增长做计划。如果用户按精确书名搜索,我们将对书名索引执行二分搜索。对于部分书名或作者搜索,使用哈希映射实现的倒排索引将提供 O(1) 的平均查找时间。下面用伪代码概述核心搜索算法。

FUNCTION searchCatalogue(searchTerm, searchType)
IF searchType = ‘isbn’ THEN
RETURN binarySearch(bookIndexByISBN, searchTerm)
ELSE IF searchType = ‘title’ THEN
IF exactMatch THEN
RETURN binarySearch(bookIndexByTitle, searchTerm)
ELSE
RETURN hashMapLookup(invertedTitleIndex, searchTerm)
END IF
ELSE IF searchType = ‘author’ THEN
RETURN hashMapLookup(invertedAuthorIndex, searchTerm)
END IF
RETURN emptyList
END FUNCTION

图书借阅操作也需要小心设计,以避免竞态条件。当多个会员同时尝试借阅同一本书的最后一本可用副本时,必须使用事务和锁定。伪代码显示了一个简化的借阅过程:BEGIN TRANSACTION; SELECT availableCopies WHERE ISBN = x FOR UPDATE; IF availableCopies > 0 THEN decrement availableCopies, INSERT Loan; COMMIT; ELSE ROLLBACK。这种并发控制保证了数据的一致性。


7. User Interface Design Principles | 用户界面设计原则

A clean and intuitive user interface is crucial for adoption, especially as many members are elderly and not tech-savvy. We follow Nielsen’s heuristics: visibility of system status is provided through clear feedback messages such as ‘Book borrowed successfully’ or ‘Due date: 15/03/2025’. Consistency is achieved by using a standard navigation bar and the same button styles across all pages. The search bar is placed prominently at the top of every page, and error prevention techniques include input masks for dates and ISBN validation using check digits.

一个清晰直观的用户界面对于系统被采用至关重要,特别是因为许多会员是老年人且不太精通技术。我们遵循尼尔森的启发式原则:通过诸如 ‘借阅成功’ 或 ‘到期日:2025年3月15日’ 等清晰的反馈信息,提供系统状态的可见性。通过在所有页面上使用标准导航栏和相同的按钮样式来实现一致性。搜索栏显眼地放置在每个页面的顶部,错误预防技术包括日期输入掩码和使用校验位进行 ISBN 验证。

Accessibility standards (WCAG 2.1 level AA) will be met by ensuring sufficient colour contrast, providing text alternatives for images, and supporting full keyboard navigation. A responsive design will allow members to use the catalogue on smartphones and tablets. User testing with a small group of members will refine the layout before full launch.

通过确保足够的色彩对比度、为图像提供替代文本以及支持完整的键盘导航,满足无障碍标准(WCAG 2.1 AA 级)。响应式设计将允许会员在智能手机和平板电脑上使用目录。在全面发布前,将与一小部分会员进行用户测试以完善布局。


8. Implementation Considerations: Programming Paradigm and Data Structures | 实现考虑:编程范型与数据结构

We have chosen an object-oriented paradigm because the natural mapping from real-world entities (Book, Member, Loan) to classes simplifies development and maintenance. The back-end will be written in Python using the Flask micro-framework, which supports MVC (Model-View-Controller) separation. The Book, Member and Loan classes will encapsulate their data and relevant methods. For the data layer, we will use an Object-Relational Mapping (ORM) library such as SQLAlchemy to interact with the database, reducing boilerplate SQL and improving security against injection attacks.

我们选择了面向对象范型,因为现实世界实体(Book、Member、Loan)到类的自然映射简化了开发和维护。后端将使用 Python 和 Flask 微框架编写,它支持 MVC(模型-视图-控制器)分离。Book、Member 和 Loan 类将封装其数据和相关方法。对于数据层,我们将使用像 SQLAlchemy 这样的对象关系映射(ORM)库与数据库交互,减少样板 SQL 并提高对注入攻击的安全性。

The choice of data structures directly impacts performance. An ordered list will store the catalogue for efficient binary search, while a hash table will back the inverted index for fast partial lookups. The member list will be held in a balanced binary search tree (e.g., AVL tree) to allow logarithmic time insertions and lookups by memberID, which is important when processing loans at the counter. The loan history will be stored in a queue-like structure for generating chronological reports.

数据结构的选择直接影响性能。一个有序列表将存储目录以实现高效的二分搜索,而一个哈希表将支持倒排索引以实现快速部分查找。会员列表将保存在一个平衡二叉搜索树(例如 AVL 树)中,以便在对会员 ID 进行插入和查找时实现对数时间复杂度,这在进行前台借阅处理时非常重要。借阅历史将存储在一个类似队列的结构中,用于生成按时间顺序排列的报告。


9. Testing Strategies | 测试策略

A layered testing strategy ensures reliability. Unit tests will verify individual functions and methods, for instance checking that the calculateDueDate() method correctly accounts for weekends and holidays. Integration tests will confirm that the borrowing process works end-to-end, from the web form submission through to the database update and the confirmation page. We will use the pytest framework for automated testing. System testing will involve loading the database with a representative dataset and simulating typical user workflows such as searching, borrowing and returning. Acceptance testing will be conducted with the librarian and a focus group of five members, who will follow scripted scenarios and provide feedback.

一个分层的测试策略确保了可靠性。单元测试将验证各个函数和方法,例如检查 calculateDueDate() 方法是否正确考虑了周末和节假日。集成测试将确认借阅流程从 Web 表单提交到数据库更新再到确认页面能够端到端工作。我们将使用 pytest 框架进行自动化测试。系统测试将包括用代表性数据集加载数据库,并模拟典型用户工作流程,如搜索、借阅和归还。验收测试将由图书管理员和一个由五名会员组成的焦点小组进行,他们将按照脚本化的场景操作并提供反馈。

Non-functional testing will validate performance under load: we will simulate 50 concurrent searches using a tool like Locust and measure response times, ensuring they remain under two seconds. Security testing will include penetration testing for common vulnerabilities such as SQL injection and cross-site scripting (XSS). All test results will be logged, and defects will be tracked using a simple issue tracker.

非功能测试将验证负载下的性能:我们将使用像 Locust 这样的工具模拟 50 次并发搜索,并测量响应时间,确保它们保持在两秒以内。安全测试将包括针对常见漏洞(如 SQL 注入和跨站脚本 XSS)的渗透测试。所有测试结果都将被记录,缺陷将使用一个简易的问题跟踪器进行追踪。


10. Project Management and Development Methodology | 项目管理与开发方法

Given the project’s modest size and the likelihood of evolving requirements, we adopt an Agile methodology, specifically Scrum. Development will be divided into three two-week sprints. Sprint 1 focuses on core backend and database setup, Sprint 2 on the public-facing catalogue and member features, and Sprint 3 on the librarian dashboard, reporting and testing. Daily stand-ups will be held (remotely, as the developer and librarian are not co-located), and a burndown chart will track progress. The librarian acts as the Product Owner, prioritising the product backlog, while the lead developer fills the Scrum Master role.

考虑到项目规模适中且需求可能发生变化,我们采用敏捷方法论,特别是 Scrum。开发将分为三个为期两周的冲刺。冲刺 1 专注于核心后端和数据库搭建,冲刺 2 专注于面向公众的目录和会员功能,冲刺 3 专注于图书管理员仪表板、报告和测试。将每天举行站会(由于开发人员和图书管理员不在同一地点,采取远程形式),并使用燃尽图跟踪进度。图书管理员充当产品负责人,对产品待办列表进行优先级排序,而首席开发人员承担 Scrum Master 角色。

A Gantt chart was also prepared for high-level milestones and grant reporting. The critical path runs through database design, API development and user testing. Resource allocation includes one senior developer (total 30 person-days) and a junior tester (10 person-days). This lightweight management approach minimises bureaucracy while maintaining accountability.

还准备了一个甘特图用于高层里程碑和拨款报告。关键路径贯穿数据库设计、API 开发和用户测试。资源分配包括一名高级开发人员(总计 30 人天)和一名初级测试人员(10 人天)。这种轻量级管理方法在保持问责制的同时最大限度地减少了官僚作风。


11. Evaluation and Maintenance | 评价与维护

A post-implementation evaluation will compare the system’s performance against the original objectives. Metrics such as average search time, librarian task completion time, and member satisfaction score (collected via a survey) will be analysed. We anticipate a 70% reduction in time spent on manual loan processing and a significant drop in overdue items thanks to automatic reminders. If the evaluation reveals that search under high concurrency exceeds the two-second threshold, additional indexing or caching with Redis will be considered.

实施后评估将把系统的性能与最初的目标进行对比。将分析平均搜索时间、图书管理员任务完成时间和会员满意度评分(通过调查收集)等指标。我们预计手动借阅处理所花费的时间将减少 70%,并且由于自动提醒,逾期项目将显著减少。如果评估显示高并发下的搜索时间超过了两秒阈值,则将考虑增加索引或使用 Redis 进行缓存。

Maintenance will be of three types: corrective (fixing bugs), adaptive (modifying the system to work with a new email service provider) and perfective (adding a recommendation engine based on borrowing history). A maintenance log will document all changes. The librarian will attend a one-day handover session, and comprehensive documentation, including a user manual and technical API specification, will be delivered. This ensures the library can manage minor issues independently.

维护将分为三种类型:修正性维护(修复错误)、适应性维护(修改系统以与新的电子邮件服务提供商协同工作)和完善性维护(基于借阅历史添加推荐引擎)。维护日志将记录所有变更。图书管理员将参加为期一天的交接会议,并将交付全面的文档,包括用户手册和技术 API 规范。这确保了图书馆能够独立处理小问题。


12. Ethical and Legal Issues | 伦理与法律问题

Managing personal data of library members brings important ethical and legal responsibilities. Under the General Data Protection Regulation (GDPR), the library acts as a data controller. We must obtain explicit consent from members before storing their email and phone number, and provide a clear privacy notice explaining how data will be used. Data minimisation is applied: only necessary fields are collected. Members will have the right to access their data and request deletion. The system will enforce role-based access control so that volunteers can only view member contact information when explicitly authorised to send overdue reminders.

管理图书馆会员的个人数据带来了重要的伦理和法律责任。根据《通用数据保护条例》(GDPR),图书馆充当数据控制者。在存储会员的电子邮件和电话号码之前,我们必须获得其明确同意,并提供清晰的隐私声明,说明数据将如何使用。适用数据最小化原则:仅收集必要的字段。会员将有权访问其数据并请求删除。系统将强制执行基于角色的访问控制,以便志愿者仅在明确授权发送逾期提醒时才能查看会员的联系信息。

Beyond legal compliance, ethical design means the system should not discriminate against any group. For example, over-reliance on email reminders could disadvantage members without regular internet access; thus, an optional SMS alert system is proposed for the future. All source code will be open-sourced under a permissive license, aligning with the library’s community-oriented mission. The project demonstrates that technology, when applied thoughtfully, can enhance public services while respecting individual rights.

除了法律合规,伦理设计还意味着系统不应歧视任何群体。例如,过度依赖电子邮件提醒可能使没有定期互联网访问的会员处于不利地位;因此,提议未来增加可选的短信提醒系统。所有源代码都将在一个宽松许可证下开源,这与图书馆面向社区的使命一致。该项目表明,技术在深思熟虑地应用时,可以在尊重个人权利的同时提升公共服务。

Published by TutorHao | Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading