Page 530 - Computer_Science_F5
P. 530
Common commands used in MongoDB are summarized in Table 8.18:
Command Function
>db.collection_name.drop() drop the collection
>db.dropDatabase() drop the current Database
FOR ONLINE READING ONLY
>db show the current Database name Chapter Eight: Databases and Database Management Systems
> show dbs show all the list of databases
>show collections show the collection name
>db.collection_name.find() find the documents in the collection
> use databasename create the new DB
>db.createCollection(name,options) create new collection
Comparison of SQL against NoSQL Exercise 8.9
(i) Data Structure and Scalability: If the
data is highly structured and integrity 1. Compare and contrast the benefits
is paramount, an SQL database is of using a wide-column store
preferred. For unstructured data with versus a graph database in different
a need for horizontal scaling, NoSQL application scenarios.
is more suitable. 2. Discuss the use cases where a
(ii) Development Speed and Flexibility: document-oriented database like
NoSQL databases offer more flexibility MongoDB would be more suitable
and can speed up development by than a relational database system.
allowing changes to data models 3. What are the advantages of using
without impacting existing data. NoSQL databases for handling
(iii) Query Complexity: SQL databases unstructured data compared to
are better suited for complex queries traditional relational databases?
requiring joins and transactions. 4. Set up a MongoDB database using
(iv) Consistency Requirements: SQL MongoDB Atlas Free Tier. Then,
databases offer strong consistency perform the following:
(ACID), whereas NoSQL databases
might offer eventual consistency, (a) Create a new MongoDB cluster
making them more apt for distributed on MongoDB Atlas.
systems. Understanding these (b) Define a collection named
differences, strengths, and limitations “books” with fields like title,
is crucial in choosing the appropriate author, and genre.
database system for specific needs,
ensuring the efficient, reliable, and (c) Insert sample documents into
scalable management of data. the “books” collection.
521
Student’s Book Form Five
Computer Science Form 5.indd 521 23/07/2024 12:35

