How can I create a MongoDB based on MySQL schema? How can I create a MongoDB based on MySQL schema?

This is my schema:

productCode VARCHAR(15)
productName VARCHAR(70)
productLine VARCHAR(50)
productScale VARCHAR(10)
productVendor VARCHAR(50)
productDescription TEXT
quantityInStock SMALLINT(6)
buyPrice DOUBLE
MSRP DOUBLE
MongoDB uses flexible schema and you do not have to predeclare your field types in the database. MongoDB (as at 3.0) does not provide any server-side schema validation, so it's perfectly allowable to have a field with different types within the same collection or to have fields vary by document within the same collection.

Schema declaration &amp; validation is optional, but if you want to enforce types you would have to do so via your application logic. There are analogous MongoDB BSON field types for most RDBMS column types, but also obvious differences. For example, MongoDB has a String field which stores variable length text (up to ~16MB) rather than distinct VARCHAR(..) and TEXT types.

In general you will not want to use identical schema when exporting data from a relational database to MongoDB: you would instead consider how best to model your data to support common use cases. For a more complete overview including concepts and examples please refer to the Data Modeling section in the MongoDB manual.

You have many options to migrate data, for example:


using client drivers to read/write from your source &amp; target databases
exporting to a CSV or JSON format which can be read by the mongoimport command line tool
using an ETL tool