Monday, November 11, 2024

Oracle Database API for MongoDB - Part II

In this blogpost, we will see about how to configure Oracle Database API for mongo DB using Oracle database 23ai. We will be using Oracle Virtual box image, that comes with ORDS with Oracle Database API for mongo DB enabled by default. The Oracle database version and ORDS version for this demo is listed below.
 
demo@FREEPDB1> select banner_full from v$version;
 
BANNER_FULL
--------------------------------------------------------------------------------
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.5.0.24.07
 
 
demo@FREEPDB1> select ords.installed_version ;
 
INSTALLED_VERSION
---------------------
24.3.0.r2620924
 
 
let’s create a database user account with minimal privileges required to perform the work and REST enable it (REST enabling schema is needed, for the database to accept the connections from Mongo Shell)
 
sys@FREEPDB1> grant DB_DEVELOPER_ROLE,unlimited tablespace
  2     to mdb_test2 identified by mdb_test2 ;
 
Grant succeeded.
 
sys@FREEPDB1> conn mdb_test2/mdb_test2@freepdb1
Connected.
mdb-test2@FREEPDB1> declare
  2    pragma autonomous_transaction;
  3  begin
  4      ords.enable_schema(p_enabled => TRUE,
  5                         p_schema => 'MDB_TEST2',
  6                         p_url_mapping_type => 'BASE_PATH',
  7                         p_url_mapping_pattern => 'mdb_test2',
  8                         p_auto_rest_auth => FALSE);
  9      commit;
 10  end;
 11  /
 
PL/SQL procedure successfully completed.
 
mdb-test2@FREEPDB1>
 
to connect using the Mongo Shell from command prompt we can use the following URI
 
C:\Users\Rajeshwaran>mongosh --tls --tlsAllowInvalidCertificates "mongodb://mdb_test2:mdb_test2@localhost:27017/mdb_test2?authMechanism=PLAIN&authSource=$external&ssl=true&retryWrites=false&loadBalanced=true"
Current Mongosh Log ID: 672f715fbd9017c3be86b01c
Connecting to:          mongodb://<credentials>@localhost:27017/mdb_test2?authMechanism=PLAIN&authSource=%24external&ssl=true&retryWrites=false&loadBalanced=true&serverSelectionTimeoutMS=2000&tls=true&tlsAllowInvalidCertificates=true&appName=mongosh+2.3.2
Using MongoDB:          4.2.14
Using Mongosh:          2.3.2
 
For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/
 
mdb_test2>
 
mdb_test2> show collections;
 
to connect using the MongoDB Compass we use the following URI

 
After the connection got established, we can see something like this.



 
  
After this we can insert data and retrieve information (either from the MongoDB or SQL commands) from the Collection that will be created on MongoDB. In the next blogpost, we will see about creating Json Collections / documents through Oracle database API for Mongo DB and not only access your data using NoSQL approach, but you can also use SQL based approach on the same JSON collections. 

In the next blogpost we will see how to manipulate these collections using SQL and MongoDB commands.

Friday, November 8, 2024

Oracle Database API for MongoDB - Part I

Today modern application uses lot of different types of data, structured, unstructured, geospatial data, or different representation (like graphs) to speed up analytical queries, they use sometimes either use relational or schemeless approach and so on.
 
Very often we have to choose between different products to reach what we really want to get with our applications and fit business needs. Use different vendor product means a bit more effort to full the gaps of all different technologies and the biggest problem arrives when we need to Join the data that are distributed on heterogeneous products and engine, because it is not possible to transform different models of data into a specific model while the application is up and running, or we don’t want to duplicate or move the data.
 
To address these requirements, we need a data platform that can manage all types of data in the same engine, and bring out the value of data when needed, and able to support new types of data when application/business evolves, so to use the same engine which can handle all types of data it is possible with Oracle database today. The Oracle database is an example of a database can manage all types of data with the same engine, and so it makes easier to bring out the value of your data when you need.
 


 

We can use for Instance Oracle database for spatial or graph database, or have another Oracle database for NoSQL based approach with collections and JSON documents, or another database for relational data and exploit it for analytics columnar queries at the same time performs well for transactional system, have an Oracle database on-premise,  cloud@customer, on Oracle cloud Infrastructure (OCI) and have the best PaaS service(Autonomous database) or in a generic hyperscale (like AWS, Azure), with Oracle database you can also have  the data where they reside, for example you can map data (as Avro, ORC, Parquet,  Json, Excel, CSV or any delimited files ) that are on file system or on different Object storage buckets by External tables and realize a modern LakeHouse or a Datamesh solution.
 
To achieve all these we can use one Oracle database for each type of semantics or use different Oracle database for each of them, the decision is upto the Implementation team, because it is not necessary to activate any parameters or licenses, the Oracle database is already ready to manage all this type of data. And if we decide to use Oracle database for each model of data, Oracle implemented a multi-Tenant architecture to facilitate the operations, allowing you to manage many Oracle database like One database (extremely useful when using on-prem or not In PassS model). Also Oracle supports vertical and horizontal scaling and not only using RAC but also using Sharding configuration, and you can also decide to deploy Oracle database on Kubernetes using Oracle operator.
 
In conclusion, with Oracle it is extremely simple to obtain a complete DATA platform for any Type(s) of data.
 
But if you have already developed many applications on other competitor products, such as MongoDB – because at first time, my application only needed to store JSON documents, but now if you need to use ML algorithms on the same data to predict my customers behaviours, (or) I need to speed up the performance for analytics reports and dashboard using a columnar format over JSON keys, (or) if the application need to use JSON, spatial and relational data all together, then how can I solve this ? do we need to rewrite all the application code and re-test it ?
 
Not at all, there is a simpler solution, Oracle rolled out Oracle database API for MongoDB (using Oracle database and ORDS )  that let you run your applications built with MongoDB API on Oracle database and after that, you will be free to use all the potential capabilities that  Oracle database can offer about managing all kind of semantics, performance, availability, scaling and security.  
 
Oracle offers these features not only on Oracle Cloud, but wherever you want and talking about no lock-in products, Oracle also has a great tool called Oracle Golden Gate to feed or synchronize data between different Oracle databases or to other competitors products.
 
In the next blogpost, I’ll show you how to configure and use Oracle Database API for MongoDB.