Experiment 9
Experiment 9
Experiment 9
KJSCE/IT/SYBTech/SEM III/DMS/2024-25
Theory:
MongoDB:
MongoDB is a general-purpose document database designed for modern application
development and for the cloud. Its scale-out architecture allows you to meet the increasing
demand for your system by adding more nodes to share the load
scale. One recent addition is the Union stage, which flexibly aggregate results from
multiple collections.
PostgreSQL:
PostgreSQL is a powerful, open source object-relational database system that uses and
extends the SQL language combined with many features that safely store and scale the most
complicated data workloads. The origins of PostgreSQL date back to 1986 as part of the
POSTGRES project at the University of California at Berkeley and has more than 30 years of
active development on the core platform.
PostgreSQL comes with many features aimed to help developers build applications,
administrators to protect data integrity and build fault-tolerant environments, and help you
manage your data no matter how big or small the dataset. In addition to being free and open
source, PostgreSQL is highly extensible. For example, you can define your own data types,
build out custom functions, and even write code from different programming languages
without recompiling your database.
Some of the features of PostgreSQL are as follows,
● Data Types
o Primitives: Integer, Numeric, String, Boolean
o Structured: Date/Time, Array, Range / Multirange, UUID
o Document: JSON/JSONB, XML, Key-value (Hstore)
o Geometry: Point, Line, Circle, Polygon
o Customizations: Composite, Custom Types
● Data Integrity
o UNIQUE, NOT NULL
o Primary Keys
o Foreign Keys
o Exclusion Constraints
o Explicit Locks, Advisory Locks
● Concurrency, Performance
o Indexing: B-tree, Multicolumn, Expressions, Partial
o Advanced Indexing: GiST, SP-Gist, KNN Gist, GIN, BRIN, Covering indexes,
Bloom filters
o Sophisticated query planner / optimizer, index-only scans, multicolumn
statistics
o Transactions, Nested Transactions (via savepoints)
o Multi-Version concurrency Control (MVCC)
o Parallelization of read queries and building B-tree indexes
o Table partitioning
o All transaction isolation levels defined in the SQL standard, including
Serializable
o Just-in-time (JIT) compilation of expressions
● Reliability, Disaster Recovery
o Write-ahead Logging (WAL)
o Replication: Asynchronous, Synchronous, Logical
KJSCE/IT/SYBTech/SEM III/DMS/2024-25
PostgreSQL offers two types for storing JSON data: json and jsonb. To implement
efficient query mechanisms for these data types PostgreSQL also provides
the jsonpath data type
The json and jsonb data types accept almost identical sets of values as input. The
major practical difference is one of efficiency. The json data type stores an exact
copy of the input text, which processing functions must reparse on each execution;
while jsonb data is stored in a decomposed binary format that makes it slightly
slower to input due to added conversion overhead, but significantly faster to process,
since no reparsing is needed. jsonb also supports indexing, which can be a
significant advantage.
__________________________________________________________________________
Procedure:
1. Create a repository of documents containing six family member of yours(including
yourself), with minimum seven attributes each, in POSTGRES
2. Perform selection and projection queries with different criterias on the created relation
3. Export the relation to json document
4. Import the document to MongoDB
5. Perform Insert, Search, Update, and Delete operations on the collection using
i. MongoDB Compass
ii. MongoDB Shell
Use link
https://drive.google.com/drive/folders/12QEkVpHVRgWtgKdyxx-x1v9sznyk
KnEv
___________________________________________________________________________
Results: (Queries depicting the above said activity performed individually and snapshots of
the results (if any))
USE COURIER NEW FONT WITH SIZE = 10 FOR QUERY STATEMENTS
___________________________________________________________________________
KJSCE/IT/SYBTech/SEM III/DMS/2024-25
Outcomes:
___________________________________________________________________________
KJSCE/IT/SYBTech/SEM III/DMS/2024-25
Questions:
Answers:
Ans 1.
Ans 2.
● db.collection.aggregate(): Performs aggregation operations on documents using a pipeline.
● db.collection.findOne(): Returns a single document that matches the query criteria.
● db.collection.updateMany(): Updates multiple documents matching the query criteria.
● db.collection.deleteMany(): Deletes multiple documents matching the query.
● db.collection.distinct(): Returns an array of distinct values for a specified field across
documents.
___________________________________________________________________________
Grade: AA / AB / BB / BC / CC / CD /DD
1. https://www.mongodb.com/basics
2. https://www.postgresql.org/about/
3. https://www.postgresql.org/docs/13/datatype-json.html