VJC Chapter 22 NoSQL
Uploaded by cheesemuffin · 10 December 2025
Preview
Text from the first pagesVJC/H2Computing/9569 Chapter 22: NoSQL Contents 1 What is NoSQL 2 Differences between relational databases and NoSQL databases 3 Advantages of NoSQL 4 Applications of relational databases and NoSQL databases 5 Introduction to MongoDB 5.1 Terms used in MongoDB 5.2 Document in MongoDB 5.3 Starting the MongoDB server 6 PyMongo 6.1 Create a MongoClient 6.2 Create a Mongo database 6.3 Create a collection 6.4 Inserting documents 6.4.1 Inserting one document 6.4.2 Inserting multiple documents 6.4.3 Importing from a text file 6.4.4 Importing from a JSON file 6.5 Searching for documents 6.5.1 Find the first document 6.5.2 Find all documents 6.5.3 Find documents that satisfy certain criteria 6.5.4 Find documents that satisfy multiple criteria 6.5.5 Count the number of documents in a collection 6.6 Update documents 6.7 Remove documents 6.8 Remove a collection 6.9 Remove a database Annex 1 – Using MongoDB shell Syllabus Learning Outcomes 3.3 Databases and Data Management Understand, create and use SQL and NoSQL databases, as well as understand techniques to protect the privacy and integrity of data. 3.3.6 Understand how NoSQL database management system addresses the shortcomings of relational database management system (SQL) 3.3.7 Explain the applications of SQL and NoSQL 3.3.8 Use a programming language to work with both SQL and NoSQL databases.
1 VJC/H2Computing/9569 1 Introduction to NoSQL NoSQL, stands for “non SQL” or “not only SQL”, is a type of database management system (DBMS) that is designed to handle and store large volumes of unstructured and semi-structured data. Unlike traditional relational databases that use tables with pre-defined schemas to store data, NoSQL databases use non-relational data structures which are flexible and allows dynamic schema for unstructured data. NoSQL databases can adapt to changes in data structures and are capable of scaling horizontally to handle growing amounts of data. There are four main types of NoSQL databases: document databases, key-value databases, wide-column databases, and graph databases. 2 Differences between relational databases and NoSQL databases 2.1 Data Structure Relational databases have a fixed, predefined schema where data must fit into tables with specific columns and data types. This rigid structure ensures consistency, and it works well for applications with stable, well-structured, and predictable data requirements. In contrast, NoSQL databases adopt flexible data models, allowing for dynamic and non schematic data storage. This flexibility enables developers to insert data without a predefined schema. NoSQL databases are most useful in scenarios where data structures may be undefined, not fully known in advance, or are subject to frequent changes. 2.2 Scalability Relational databases and NoSQL databases emphasize different scaling strengths due to their designs. Relational databases typically rely on vertical scaling, which involves improving and adding resources, such as faster processors and more memory, to the same server to handle increased load. Such high-performance components can be expensive, and upgrades are limited by the capacity of a single machine. Horizontal scaling, typically seen in NoSQL systems, is achieved by adding more servers or nodes to a distributed system, which then helps increase capacity. The nodes communicate with each other and distribute the load, so adding more nodes helps increase the overall capacity of the system. This is a more scalable and cost-effective solution for managing a growing database and increasing database traffic.
2 VJC/H2Computing/9569 2.3 Properties Relational database and NoSQL database management systems take different approaches to ensuring reliability. Relational databases rely on ACID properties : ● Atomicity: A change in the database must either be performed completely or not performed at all. ● Consistency: A transaction (read/write operations) must take a whole database from one consistent state to another consistent state, for example in a bank transfer transaction the amount of money in the whole system must be the same at the end of the transaction as it was at the beginning. ● Isolation: A transaction must be performed in isolation so that other users or processes cannot have access to the data concerned until the new consistent state has been committed (saved). In practice, this means that while an operation is being performed in a record, the record is locked. This may involve making the record invisible to others or it may only lock the record for writing. After the transaction is committed, the record may be unlocked again. ● Durability: Once a change has been made to a database, the change must not be lost because of any subsequent system failure or operator error. Ideally, the transaction is written immediately to secondary storage. ACID properties ensure immediate and strict consistency in the database. SQL queries guarantee that either all or none of the changes made during a transaction are committed to the database and have rules for how to handle concurrent transactions and unexpected events. On the other hand, NoSQL databases, emphasize scalability and distributed architectures (a distributed system is a network that stores data on more than one node (physical or virtual machines) at the same time.), adopt the concept of eventual consistency. Eventual consistency acknowledges that, in a distributed system, it may take some time for all nodes to converge to a consistent state after an update. While NoSQL databases sacrifice immediate consistency for scalability and fault tolerance, they ensure that, given enough time, all replicas of the data will eventually converge to the same state. This trade-off allows NoSQL systems to handle large-scale, distributed environments where real time consistency might be challenging to achieve efficiently.
3 VJC/H2Computing/9569 In general, the differences between relational databases and NoSQL databases can be summarised in the table below. Relational databases NoSQL databases Language Use structured query languages to perform operations Use a dynamic schema to query data. Also, some NoSQL databases use SQL-like syntax for document manipulation. Data Schema Have a predefined and fixed format, which cannot be changed for new data. NoSQL databases are more flexi
Content continues in the PDF. Download PDF
Related notes
- NYJC 2026 Prelim P2Exam Papers · 2026
- NYJC 2026 Prelim P1Exam Papers · 2026
- DHS 2026 Y6 H2 Computing Prelim Paper 2_finalExam Papers · 2026
- ACJC 2026 JC2 Computing Prelim Paper 2 (Practical)Exam Papers · 2026
- 2026_NJC Prelim_Computing_P2.pdfExam Papers · 2026
- 2026_JPJC_Computing_Prelim_P2_finalExam Papers · 2026
- 2026_JPJC_Computing_Prelim_P1_markschemeExam Papers · 2026
- 2026_JPJC_Computing_Prelim_P1_finalExam Papers · 2026
- 2026 ACJC Prelim Computing Paper 2Exam Papers · 2026
- 2024 ACJC Computing PromoExam Papers · 2024
- 2023 ACJC Promo QPExam Papers · 2023
- 2022 ACJC Computing Promo Paper 2Exam Papers · 2022
- See all H2 Computing notes

