Schemas are described with different terms in StreamBase, depending on context and intended use:
- Private Schemas
-
Private schema is StreamBase Studio's term for unnamed schemas. In Studio, you create a private schema when using the Edit Schema tab in the Properties view for a component.
- Anonymous Schemas
-
Anonymous schema is StreamSQL's term for unnamed schemas. Private schemas and anonymous schemas are the same concept, seen in different contexts. You can create anonymous schemas in StreamSQL as part of defining a stream, query table, or lock set with an unnamed schema definition. In the following example,
inventoryis the name of the stream being created. The stream's schema is defined without a name:CREATE INPUT STREAM inventory (id int, item string(20), price double);
- Named schemas
-
Named schemas are schemas defined as part of an EventFlow or StreamSQL application. Named schemas can be referenced from any element of the EventFlow or StreamSQL application in which they are defined. When you modify a named schema, all components that reference it automatically see those changes. You create named schemas in the Named Schemas tab of the EventFlow editor, or with the CREATE SCHEMA statement in StreamSQL. Named schemas are further discussed in Using Named Schemas.
- Saved schemas
-
Saved schemas are schemas you save as part of your StreamBase Studio workspace. You can copy a saved schema into any EventFlow application in any project in your workspace. You create saved schemas in the Saved Schemas view in Studio. You typically save a schema in order to share it between projects in your workspace. However, if you modify a saved schema, any copies of that schema in applications are not automatically modified. Saved schemas are further discussed in Using Saved Schemas.
- Nested schemas
-
A nested schema is a field of type tuple contained in a schema. In EventFlow applications, only named schemas can be used as nested schemas.
In StreamSQL, you can nest schemas with a named schema, or you can use an unnamed schema definition inline. The following examples show both methods:
CREATE STREAM itemprice (item string(20), price double); CREATE INPUT STREAM inventory (id int, itemprice);
or
CREATE INPUT STREAM inventory (id int, (item string(20), price double) );
- Imported and exported schemas
-
Exported schemas are schemas you save in XML format to your computer's file system, outside of the Studio workspace. Imported schemas are schemas you import from an XML file in your file system that were saved by exporting a schema.
You can only export schemas you have saved in the Saved Schemas view in Studio. You typically export schemas from StreamBase Studio on one computer in order to import them into another instance of Studio on another computer. You might also export schemas from a previous release of Studio in order to import them into a newer release. See Importing and Exporting Resources for further information.
The following comparisons further clarify the differences between schema types.
- Private vs Named Schemas
-
In StreamBase Studio, use private schemas for components in small EventFlow applications, or for components with a different schema than other components in your application. Defining a private schema does not mean the schema is restricted to the component for which it is defined. As with all schemas in StreamBase, private schemas are automatically inherited by all downstream components.
Use named schemas for three main reasons:
-
For developer convenience, especially in large EventFlow applications. When editing the schema of a new component, you can specify the name of a named schema instead of re-typing the same schema definition.
-
For automatic updating of a schema in wide use in your application. When you define new schemas as an instance of a named schema, you only need to update the schema in one place. You edit the named schema once, and all instances of that schema are automatically updated.
-
To define a nested schema. Certain data streams have hierarchical layers, where the second layer is best described as a schema within the primary schema. You can create such a nested schema by using the name of a named schema as a data type when defining a new schema. In the following example, we are defining a three-field schema whose third field is a named schema. Notice that the application's named schemas show up in the dropdown list of data types:
-
- Anonymous vs Named Schemas
-
The discussion above applies equally well to StreamSQL applications. Use anonymous schemas for streams or tables in simple applications. Use named schemas so you can re-use the name in large applications, for automatic updating of all instances of a named schema, and to define nested schemas.
- Named vs Saved Schemas
-
Named schemas are visible only in the EventFlow or StreamSQL application in which they are defined. When you change a named schema, all copies of that schema in the same application are automatically updated.
Saved schemas are visible to any EventFlow application and can be copied from application to application. However, if you change the definition of a saved schema, you must re-copy the changed schema into your applications. If you have a schema you want to re-use in multiple EventFlow applications in your workspace, use a procedure like the following:
-
Define the schema as a saved schema in the Saved Schemas view.
-
Create copies of the saved schema as a named schema in the Named Schema tab of the EventFlow editor for each application that needs it.
-
In each application, use the named schema to define the schema for each component that needs that schema.
-
If you subsequently need to modify this schema, edit the saved version in the Saved Schemas view. Then re-copy the saved schema to the Named Schema tab of each EventFlow application that uses it.
-
StreamBase provides support for schemas with large event messages on streams, including large string and blob fields. The theoretical maximum for large fields is around two gigabytes, but the practical limit is much smaller. See Using Large Fields for important steps you must take before defining large fields in your schemas.
StreamBase Server enforces a default maximum event message size of 1 MB.
If you define a schema that exceeds 1 MB in total size for all fields, the server
does not start. However, you can set a lower or higher server threshold for maximum
event size in the StreamBase Server configuration file. For details, see
the pagepool topic in the StreamBase Server Configuration XML
reference page.
For general ideas about tuning StreamBase applications, see Tuning Applications.
