MongoSQL schemas are JSON schemas that describe data as it exists in MongoDB, including its polymorphism, sparseness, and nested, structured data. Atlas Data Federation can automatically generate a schema by sampling data from documents in your collection or view. MongoSQL schemas are necessary when connecting SQL-based tools to Atlas data sources.
MongoSQL leverages Atlas Data Federation as its query engine. Configure MongoSQL schemas on the federated database level.
After creating a SQL Connection, verify that an MongoSQL schema is in place. For Quick Start MongoSQL set up, Atlas Data Federation automatically generates a schema by sampling data from documents in your collection or view. For advanced configuration set up of MongoSQL, generate an MongoSQL for any Atlas Data Federation collection you wish to analyze from a SQL-based tool.
If you rename a collection or view that already has a schema, the schema is also renamed.
In addition, for wildcard (*) collections, Atlas Data Federation generates a
schema when it discovers the collections in the namespace catalog for the wildcard (*) collections.
Manage Schemas
You can manually generate schemas for all collections and views,
set or schedule updates for schemas,
and view stored schemas using the UI or mongosh.
You can also schedule recurring schema updates.
You can manually delete a schema for a collection or view by running
the Edit Schema Using mongosh command with an empty schema document.
Data Federation automatically removes the schema for a collection or view when
you:
Drop the collection or view from the storage configuration.
Modify the storage configuration to remove the collection or view from the storage configuration.
Drop the database that contains the collection or view from the storage configuration.
In addition, for a wildcard (*) collection, Atlas Data Federation deletes the
schema when it discovers that the collection has been removed from the
namespace catalog.
JSON Schema Format
The schema for a collection is a document with two fields:
jsonSchema and version.
"schema" : { "version" : NumberLong(1), "jsonSchema" : <JSON Schema object> }
The version field represents the version of the schema format that
the document uses. The value is always 1. The jsonSchema field
is a document that describes the schema of the namespace.
Supported JSON Schema Fields
MongoSQL supports the following JSON schema fields:
bsonTypeitemspropertiesadditionalPropertiesrequired
Note
You can provide a single document or an array of documents for the
items field. When you retrieve the schema, the items field
shows the form that you used for setting the schema.
To learn more about these fields, see JSON Schema Keywords.