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.
To set up the reschema unit and pull in the lookup data
- Launch Studio 3T and connect to MongoDB Atlas.
- In the Connection Tree, expand the sales database node and, if necessary, expand the Collections node.
- 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.
- 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
address) and one
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.
- In the message box, click Dismiss.
- 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.
- In the row for the reschema unit, double-click the Insertion Mode cell. The cell changes to a drop-down list.
- 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.
- 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.
- 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.
- In the Select local field box that lists the fields, select email.
- 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.
- In the Select foreign field box, select email.
- In the Target field text box, type services. The Select local and foreign fields panel should now look like the following figure.
- Click Next to advance the wizard to the Scan method panel. Another scan is required to identify the schema in the lookup collection.
- 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.
- Click Finish. Studio 3T runs the scan and displays a message box that provides details about the scan.
- In the message box, click Dismiss. The top left panel should now show the schema with the
servicesarray included, as shown in the following figure. All the lookup data is included in the array’s
- Leave the Reschema tab and reschema unit in place for the next exercise.