Using Saved Schemas

Use the Save Schema dialog to save a schema for possible reuse by other applications in your workspace. All your saved schemas are stored in the Saved Schemas view, where they are available to be copied into any application in any project in your workspace.

You can save a schema from any application component that has a private schema (such as an input stream, output stream, intermediate stream, query table, or input adapter). Alternatively, you can create a new saved schema.

Note

The contents of your Saved Schemas view are saved as internal metadata in your workspace when you exit StreamBase Studio. This is different from exported schemas, which you save as XML files in your file system. Saved schemas are also different from named schemas, which are defined at the application level and are available only within an application. See Schema Overview for the differences between different types of schemas.

Saving a Schema

Choose one of these methods to save a schema:

  • In an EventFlow Editor:

    1. Open an EventFlow application.

    2. In the EventFlow Editor, select the component or arc whose schema you want to save.

    3. Right-click the selected component and choose Save Schema.

    4. The Save schema dialog shows the name and fields of the schema. Optionally, you can change the schema name used in the Saved Schemas view. For example, you might want the saved schema to have a more general name than the original one, and leave the original schema unmodified. The schema fields cannot be modified in the Save schema dialog.

    5. Click OK to add the schema to your Saved Schemas view.

  • In a StreamSQL application's Outline view:

    1. Open a StreamSQL application.

    2. Open the Outline view. (If not already open, use WindowShow ViewOutline.)

    3. Expand the Outline view to display the individual component whose schema you want to save, and select the component. For example, instead of selecting the Input Streams container, select one of the streams within that category.

    4. Right-click the selected component and choose Save Schema.

    5. Optionally, change the schema name used in the Saved Schemas view.

    6. Click OK to add the schema to your Saved Schemas view.

  • In the Saved Schemas view:

    1. Open the Saved Schemas view. (If not already open, use WindowShow ViewSaved Schemas.)

    2. Either click the Add button in the view's toolbar, or right-click in the view and select Add.

    3. In the Edit Saved Schema dialog, enter a schema name.

    4. Populate the schema fields using one of these methods:

      • To define the fields manually, use the Add button at the top of the tab to add a row for each schema field. Enter values for the Field Name and Type, and if necessary, the Size. The Description is optional. For example:

        Field Name Type Size Description
        symbol string 10 Stock symbol
        quantity int 4 Number of shares

        The name must begin with an alphabetic character or an underscore, can contain only alphabetic characters, numbers, and underscores, and cannot contain hyphens or other special characters.

        The type must be one of the supported StreamBase Data Types. The editor fills in the size for data types with fixed sizes, but you must enter a valid size for strings and blobs, which are variable-length.

      • You can reuse an existing schema whose fields are appropriate for this component and your application. It can be a schema that you previously saved, one that you imported from your file system (as described in Importing and Exporting Resources), or one that exists in another application. To do so, click the Copy Schema button. If prompted to save the application at this point, click Yes to continue.

        In the Copy Schema dialog, identify the schema you want. See Copying Schemas for details.

        The schema fields are loaded in your Fields table.

        Tip

        Alternatively, you can drag a saved schema from the Saved Schemas view and drop it onto the schema table in the Edit Schema tab. If you already have entries in the table, StreamBase prompts for permission to replace them with the contents of the schema you are copying.

      In addition to the Add button, you can use the Remove, Move Up, and Move Down buttons to edit and order your schema fields. If you have copied a schema, remember that this is a local copy: Any changes you make here do not affect the original schema that you copied.

    5. Click OK to add the schema to the Saved Schemas view.

Tip

You cannot directly save a named schema. However, you can save the private copy of a named schema that you previously included in a component.

Copying a Saved Schema into an EventFlow

If you have saved a schema, you can use it in an EventFlow application in the following ways:

While defining a private schema
  1. Open the Properties view of a component that takes a schema.

  2. Open the Edit Schema tab.

  3. Choose the Private Schema option.

  4. Copy a schema using one of these methods:

    • Click the Copy Schema from existing component button. Use the Copy Schema dialog to select a schema, as described in Copying Schemas.

    • Open the Saved Schemas view. Navigate to the schema you want, and drag it into the Fields table in the Properties view.

      Tip

      Additional drag-and-drop operations are described in Saved Schemas View.

While defining a named schema
  1. Open an application in the EventFlow Editor.

  2. Open the Named Schemas tab.

  3. Click Add to create a new named schema, or Edit to overwrite an existing one.

  4. In the Edit Named Schema dialog, Click the Copy Schema from existing component button. Use the Copy Schema dialog to select a schema.

Note

Although you can save a schema from a StreamSQL application (as described earlier in this topic), Studio does not provide a facility to copy a saved schema into a StreamSQL application.