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

Academy 3T

  • Explore our courses
    • MongoDB 101: Getting Started
    • MongoDB 201: Querying MongoDB Data
    • MongoDB 301: Aggregation
  • Get certified

Exercise 1: Setting up a reschema unit that includes lookup data

MongoDB 301: Aggregation Working with Reschema for MongoDB Exercise 1: Setting up a reschema unit that includes lookup data

In this exercise, you’ll launch the Reschema tool and set up a reschema unit based on the customers_top collection. You’ll then add lookup data from the customers_svcs collection. You’ll also configure the insertion mode for the reschema unit.

The customers_top and customers_svcs collections are based on the customerscollection in the sales database. This is the same collection you’ve been working with throughout this course. The customers_top collection includes only those documents with over 50 transactions, and the customers_svcs collection reflects the different types of services that customers have received.

To create these two collections, you’ll need to download the customers_top.json file and customers_svcs.json file. The first section in this course demonstrated how to create the sales database and import the customers collection. Refer to that section as necessary for information about setting up a collection.

To set up the reschema unit and pull in the lookup data

  1. Launch Studio 3T and connect to MongoDB Atlas.
  2. In the Connection Tree, expand the sales database node and, if necessary, expand the Collections node. 
  3. Right-click the customers_top collection node, and then click Reschema. Studio 3T opens the Reschema tool in its own tab and launches the Add new reschema unit dialog box, shown in the following figure.

You need to select a scan method before you can proceed. Your choice will determine how Studio 3T will scan the source documents when identifying the schema. As you can see in the figure, you can choose from one of three scan methods:

  • Quick scan. Scans the first 200 documents in the target collection.
  • Full scan. Scans all documents in the collection. Only this option ensures that you capture all schema elements.
  • Custom scan. Scans a specified number of first, last, or random documents.
  1. Select the Full scan option and then click Finish. Studio 3T runs a full scan and displays the schema in the top left panel of the Reschema unit #1 tab, as shown in the following figure. The schema includes one Object field (address) and one Array field (interests).

You should also see a message box in the bottom right corner. The message provides details about the scan that was just performed. You can either accept the scan or choose a different method.

  1. In the message box, click Dismiss.
  2. Go to the Reschema overview tab of the main Reschema window. The tab should list the reschema unit you just created, as shown in the following figure. The Target cell should have a value of 0 configurations because you have not yet defined any target collections. The Insertion Mode cell should show the value Insert with new _id if _id exists, which is the default.
  1. In the row for the reschema unit, double-click the Insertion Mode cell. The cell changes to a drop-down list.
  2. From the drop-down list, select the Overwrite documents with same _id option. This will ensure that Studio 3T replaces existing duplicate documents, rather than adding new documents.
  3. Go to the Reschema unit #1 tab and click the Change/merge source option above the top left panel. This launches the Change/Merge source wizard, shown in the following figure.
  1. Select the Merge another collection option, and then click Next. This advances the wizard to the Select local and foreign fields panel, shown in the following figure.
  1. In the Select local field box that lists the fields, select email.
  2. From the Select foreign field drop-down list to the far right, select the customers_svcs option as the target lookup collection. This will populate the Select foreign field box beneath the drop-down list.
  3. In the Select foreign field box, select email. 
  4. In the Target field text box, type services. The Select local and foreign fields panel should now look like the following figure.
  1. Click Next to advance the wizard to the Scan method panel. Another scan is required to identify the schema in the lookup collection.
  2. Select the Full scan option and click Next. The wizard advances to the Merge preview panel, shown in the following figure.

The panel provides a preview of the documents in the source collection, which now include the lookup data from the customers_svcs collection. The lookup data is in the services array.

  1. Click Finish. Studio 3T runs the scan and displays a message box that provides details about the scan.
  2. In the message box, click Dismiss. The top left panel should now show the schema with the services array included, as shown in the following figure. All the lookup data is included in the array’s 0 element.
  1. Leave the Reschema tab and reschema unit in place for the next exercise. 
Previous Lesson
Back to Lesson
Next Topic
  • Course Home Expand All
    Building a Basic Aggregation
    4 Topics | 1 Quiz
    Exercise 1: Filtering the documents in the aggregation pipeline
    Exercise 2: Grouping the documents in the aggregation pipeline
    Exercise 3: Sorting the documents in the aggregation pipeline
    Exercise 4: Adding processing options to the aggregation
    Building a Basic Aggregation: Test your skills
    Introducing the Aggregation Editor
    4 Topics | 1 Quiz
    Exercise 1: Importing an aggregate statement into the Aggregation Editor
    Exercise 2: Replace a field in the aggregation pipeline
    Exercise 3: Reorder the fields in the aggregation pipeline
    Exercise 4: Changing the sort order in the aggregation pipeline
    Introducing the Aggregation Editor: Test your skills
    Working with Arrays in the Aggregation Pipeline
    5 Topics | 1 Quiz
    Exercise 1: Using expression operators to filter input documents
    Exercise 2: Unwinding an array to create individual documents
    Exercise 3: Grouping array values and generating a document count for each group
    Exercise 4: Writing pipeline results to a new collection
    Working with Arrays in the Aggregation Pipeline: Test your skills
    MongoDB 301 Mid-Course Feedback
    Adding Lookup Data to the Aggregation Pipeline
    4 Topics | 1 Quiz
    Exercise 1: Adding lookup data to the aggregation pipeline
    Exercise 2: Converting string values in one of the lookup fields to integers
    Exercise 3: Adding a computed ratio field based on the converted lookup field
    Exercise 4: Limiting the number of returned documents
    Adding Lookup Data to the Aggregation Pipeline: Test your skills
    Working with Reschema for MongoDB
    4 Topics | 1 Quiz
    Exercise 1: Setting up a reschema unit that includes lookup data
    Exercise 2: Defining a target collection in the reschema unit
    Exercise 3: Adding and scheduling a task to create the target collection
    Exercise 4: Running an aggregate statement against the target collection
    Working with Reschema for MongoDB: Test your skills
    Reporting with Studio 3T Aggregations
    3 Topics | 1 Quiz
    Exercise 1: Creating a view based on an aggregation query
    Exercise 2: Exporting a collection as a .csv file for use by a third-party tool
    Exercise 3: Visualizing collection data in MongoDB Charts
    Reporting with Studio 3T Aggregations: Test your skills
    Course Extras
    Return to MongoDB 301: Aggregation
  • 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

    Reddit

    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