In this exercise, you’ll add a target collection to the reschema unit that you set up in the previous exercise. You’ll then modify the schema in the target collection by adding, changing, and removing fields.
To define the target collection
- On the Reschema unit #1 tab of the Reschema window, click the Add target collection option above the top right panel. This launches the Add target collection wizard, with the Select target collection panel displayed, as shown in the following figure. The panel lists your connection’s databases.
- Expand the sales database node, select the Collections node, and click the Add collection option on the toolbar.
- In the Add New Collection dialog box, type customers_merged, and then click OK. This returns you to the Select target collection panel.
- Click Next to advance the wizard to the Select fields to add panel.
- In the field list, expand the
addressfield and clear the check boxes associated with the
zip_codefield. The field list should now look like the following figure.
- Click Finish. This returns you to the Reschema unit #1 tab. The top right panel should now include the schema for the target collection (customers_merged). The collection itself has not yet been created, only the schema definition. The following figure shows the top right panel with the new schema.
The bottom panel provides a sample of the documents that will be added to the collection when it is created. The following figure shows the first document in the collection.
As you can see, the document includes the
services array. In addition, the
address field now includes only the
- Click the Add new field button above the top right panel. This launches the Add new field dialog box, shown in the following figure. You’ll be adding an empty field configured with the
- In the Select field name text box, type contact.
- Ensure that the Create blank new field option is selected.
- From the Select field type drop-down list, select Object, and then click OK. The new field is added to the list of fields in the top right panel.
- Drag the
contactfield up the list and drop it below the
contactis the second field.
- Drag the following fields up the list and drop them on the contact field to make them embedded fields:
Double-click the user_name field (to change its name), type username in the active box, and then press Enter. The contact field should now look like the following figure.
- Right-click the
addressfield and then click Flatten selected object/array. Studio 3T moves the
statefields to the top schema level and removes the
- Drag the
servicesfield up the list and drop it just below the
- Right-click the
servicesfield and then click Change type. You’ll be changing the type to
Objectin preparation for simplifying the field’s structure.
- In the Change type dialog box, select Object from the New field type drop-down list, and then click OK.
- Expand the services field node, right-click the
0value, and click Flatten selected object/array. Studio 3T changes the services field to a simple embedded document.
- Expand the
servicesfield if necessary, right-click the
_idfield, and click Delete selected field. Repeat the process for the
servicesfield should now look like the following figure.
You could have removed the
- Leave the Reschema tab and reschema unit in place for the next exercise.