Skip to content
Studio 3T - The professional GUI, IDE and client for MongoDB
  • Tools
    • Aggregation Editor
    • IntelliShell
    • Visual Query Builder
    • Export Wizard
    • Import Wizard
    • Query Code
    • SQL Query
    • Connect
    • Schema Explorer
    • Compare
    • SQL ⇔ MongoDB Migration
    • Data Masking
    • Task Scheduler
    • Reschema
    • More Tools and Features
  • Solutions
  • Resources
    • Knowledge Base
    • MongoDB Tutorials & Courses
    • Tool/Feature Documentation
    • Blog
    • Community
    • Testimonials
    • Whitepapers
    • Reports
  • Contact us
    • Contact
    • Sales Support
    • Feedback and Support
    • Careers
    • About Us
  • Store
    • Buy Now
    • Preferred Resellers
    • Team Pricing
  • Download
  • My 3T
search

Studio 3T Knowledge Base

  • Documentation
  • Tutorials
  • Workshops
Take the fastest route to learning MongoDB. Cover the basics in two hours with MongoDB 101, no registration required.
Start the free course

Check MongoDB Schema with Schema Explorer

Posted on: 18/06/2018 (last updated: 28/06/2021) by Dakota Karlsson
tl;dr
Shortcuts

Schema Explorer makes it easy to find schema anomalies and spot data outliers in your MongoDB schema, and generate schema documentation which can be exported as a Word or CSV file. Download it here.

Are shortcuts.

One of the great things about MongoDB is that it’s schema-less, which makes adapting applications to changing requirements a breeze.

That said, data will often have a fixed implicit schema, e.g. each document in a Customers collection will likely always have a first and last name field, which makes checking that documents indeed contain certain fields a good idea.

Likewise, having the power to dynamically add new or discontinue old fields in documents can often lead to a proliferation of unwanted “versions”, which makes getting a feel for how often a certain field occurs quite helpful.

Schema Explorer provides an easy way of exploring MongoDB schema and checking its health, finding any outliers and anomalies, and visualizing data distributions.

Open Schema Explorer

To open Schema Explorer:

  • Right-click – Right-click on any connection in the Connection Tree and choose Analyze Schema
  • Button – Select a collection and click on Schema in the global toolbar

In this tutorial, we’ll be using the Customers collection which can be downloaded here.

Need to update your collection’s schema altogether, before cleaning up field values? Reschema for MongoDB is a handy tool for moving an existing collection to a different collection that conforms to the schema you configure. 

Configure the schema analysis

Before running the analysis, a configuration view will appear where users can set the document sample size, query criteria for the analysis, and more.

Default configuration of schema analysis.

Document sample size

Under Analysis source, choose how Studio 3T should read the documents: Random, First, Last, or All. By default, Studio 3T reads the documents at random.

Also choose how many documents should be read for the analysis. In this tutorial, we will look at 1,000 documents.

Analysis options

Here, comments and settings from existing reports can be imported.

By default, Studio 3T will not analyze the elements of any array fields when it encounters them. This behavior can be overridden by unchecking the tick-box.

Query criteria

To filter the document sample size further, a query can be defined. In this tutorial, we will use an empty query which will return all documents in the collection.

Run the schema analysis

To run the schema analysis, click on the Run analysis button in the toolbar:

Configure schema analysis

Analyze schema results

The analysis results page will show the following:

The Schema Tree and Schema Visaulization pane.
  • The schema tree on the left, which shows all discovered fields, its global probability (which percentage of documents were found to contain that field), and its discovered field type(s)
  • The schema visualization on the right under the Charts tab, and additional information under the Statistics and Comments tabs

Discover missing fields

The schema tree on the left shows all discovered fields, making it easy to spot documents missing crucial fields.

In our example collection Customers, we expect certain fields to be present across all documents, like first. But as the schema analysis reveals, it is only appearing in 99.1% of the fields.

Discover missing fields.

To explore documents missing a field like first:

  • Right-click on the field and choose Explore documents not containing selected field
Right click to further explore documents.

This will open a new query tab that shows all documents that do not contain the field email. It is important to note that this query will honor the base query criteria of the analysis but will bring up all matching documents in the collection, not just in the (limited) sample set.

Discover duplicates, misspellings, and other unexpected fields

Finding missing fields is just one scenario where Schema Explorer can be valuable. Another is finding unexpected fields, such as unintentional duplicates and misspellings.

An overview of fields in the Customers collection.

This is the case with the field user_name, which appears in around 94% of the documents, but so do two other variants: the hyphenated user-name and single word username.

Here, exploring documents containing a selected field comes in handy to easily fix the unwanted duplicates.

  • Right-click on an incorrectly-spelled variant (e.g. user-name)
  • Choose Explore documents containing selected field 
Explore Documents to fix inconsistencies.

This will open a new query tab showing all documents containing the selected field (“user-name”).

  • Right-click the field to rename it
  • choose “All documents in collection” in the ensuing dialog to rename all occurrences in the collection:
Rename entire fields.

Discover incorrect field types

Studio 3T also makes it easy to spot incorrect field types, like dates stored as string values.

In the Customers collection, the field address.street is stored as an embedded object, but the MongoDB schema analysis shows a few outliers where the field is stored as type String:

Compare inconsistant field types.

Clicking on the field shows the four incorrect entries:

Inspect fields by double or right clicking.

To inspect the documents containing the incorrect field type:

Double-click
Right-click

Double-click on the field

Right-click on the field and choose Explore documents with selected field of type String

Exploring data distributions

The Charts tab in Schema Explorer displays various charts depending on the data type selected.

Value histograms

For numeric fields, the Value Histogram chart shows the most frequent values found within the document set.

Looking at the field transactions, it looks like most customers have had around 50 transactions.

Top values

For many field types, the Top Values chart shows the top values found for that particular type across the document set.

For example, clicking on the package field – which is of type String – will show the top values (e.g. Standard), but also indicators of a potential backend glitch (e.g. Beginner).

See the top values for a particular document.

Date distributions

For date fields, Schema Explorer shows the detailed distributions on an hourly, daily, monthly, weekly, and all-time basis.

Looking at the field registered_on and its monthly value distribution, customer registration seems to be particularly strong in the summer as well as in January, potentially a valuable insight for marketing and sales teams.

Generate documentation

The schema analysis charts and results can easily be exported to a Word or CSV file.

After running the analysis, simply click the Generate documentation button.

Generate entire Schema Documentation in a CSV or Word file.

How helpful was this article?
This article was hideous
This article was bad
This article was ok
This article was good
This article was great
Thank you for your feedback!

About The Author

Dakota Karlsson

New to the world of databases, Dakota hails from a rural town in Texas and is learning just how exciting databases can be. After brief stops in the Big Sky state and a few years in Scandinavia, he now calls Berlin home and spends his spare time involved in the Berlin music scene and experiencing the art of German cuisine.

Article navigation

Related articles

  • Want to Find Slow Queries? Check MongoDB Current Operations
  • How do I clean up a dataset and schema with Studio 3T? – #Studio3T_AMA
  • More Dataset And Schema Clean Ups With Studio 3T – #Studio3T_AMA
  • How do I analyze the schema of some of my documents. #Studio3T_AMA
  • MongoDB Tutorial: Learn MongoDB in 2 Hours

Studio 3T

MongoDB Enterprise Certified Technology PartnerSince 2014, 3T has been helping thousands of MongoDB developers and administrators with their everyday jobs by providing the finest MongoDB tools on the market. We guarantee the best compatibility with current and legacy releases of MongoDB, continue to deliver new features with every new software release, and provide high quality support.

Find us on FacebookFind us on TwitterFind us on YouTubeFind us on LinkedIn

Education

  • Free MongoDB Tutorials
  • Connect to MongoDB
  • Connect to MongoDB Atlas
  • Import Data to MongoDB
  • Export MongoDB Data
  • Build Aggregation Queries
  • Query MongoDB with SQL
  • Migrate from SQL to MongoDB

Resources

  • Feedback and Support
  • Sales Support
  • Knowledge Base
  • FAQ
  • Reports
  • White Papers
  • Testimonials
  • Discounts

Company

  • About Us
  • Blog
  • Careers
  • Legal
  • Press
  • Privacy Policy
  • EULA

© 2023 3T Software Labs Ltd. All rights reserved.

  • Privacy Policy
  • Cookie settings
  • Impressum

We value your privacy

With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data.

By clicking “Accept all”, you consent to the storage of cookies and the processing of personal data for these purposes, including any transfers to third countries. By clicking on “Decline all”, you do not give your consent and we will only store cookies that are necessary for our website. You can customize the cookies we store on your device or change your selection at any time - thus also revoking your consent with effect for the future - under “Manage Cookies”, or “Cookie Settings” at the bottom of the page. You can find further information in our Privacy Policy.
Accept all
Decline all
Manage cookies
✕

Privacy Preference Center

With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data. Please choose for which purposes you wish to give us your consent and store your preferences by clicking on “Accept selected”. You can find further information in our Privacy Policy.

Accept all cookies

Manage consent preferences

Essential cookies are strictly necessary to provide an online service such as our website or a service on our website which you have requested. The website or service will not work without them.

Performance cookies allow us to collect information such as number of visits and sources of traffic. This information is used in aggregate form to help us understand how our websites are being used, allowing us to improve both our website’s performance and your experience.

Google Analytics

Google Ads

Bing Ads

Facebook

LinkedIn

Quora

Hotjar

Functional cookies collect information about your preferences and choices and make using the website a lot easier and more relevant. Without these cookies, some of the site functionality may not work as intended.

HubSpot

Social media cookies are cookies used to share user behaviour information with a third-party social media platform. They may consequently effect how social media sites present you with information in the future.

Accept selected