Can we create schema in shell itself for multiple backend like node js/java

i have multiple existing backends like (java,cms,kafka) connecting to SQL database. I want to migrate all the data to mongo DB now. How can I achieve that ?

Hello @swadhin_ranjan_nayak, welcome to the MongoDB Community forum!

I have some information, and hope its useful to you in some way.

The data is being migrated from relational/SQL database to MongoDB. The present data is in normalized form and it is most likely to be in de-normalized form (that is one of the great advantages of MongoDB).

One of the main features of MongoDB data is its flexible schema. This also means you can have different structures for documents within a collection. There is also an optional feature called as Schema Validation, which allows define the structure of the collection’s document up front. You can define validation rules (or constraints) at collection level. These validation rules will get applied during insert and update operations.

You can also create document structure from the command-line mongo shell or the newer mongosh. For example, you can use DDL commands to create collections, views and indexes from the shell.

You can also create a collection (and the database) as you insert the first document into a non existing database and collection. This way, when you import data into a collection the first time, your data as well as collections and the database can be created.

Lets take a Java application as an example. Java uses POJO class objects to represent MongoDB document data. You can also apply the Schema Validation from the Java application. Java applications use MongoDB Java Driver to work with the database.

You can migrate data using the mongoimport command-line tool to import data into the MongoDB database. This allows importing data from CSV and JSON files into the database. For a more customized approach, you can write your own applications or use data migration tools.

Finally, as you are planning to migrate from a SQL database to a NoSQL document based database, one of the things to consider upfront is the data models / data design for the new database.

Also see this handy reference:

1 Like