Subscription Schema Examples
When you define a subscription class, you can define the schema for subscription data. This topic shows several examples of which fields you might define in different scenarios. For more information about subscription schemas, see Defining the Subscription Schema.
Note
The following examples show the values that are used to define subscription class fields. Exactly how you define the fields depends whether you are using XML or NMO to define the application.
Per-Subscription Devices and Locales
This schema is for a weather application. When a subscriber creates a subscription, the subscriber must specify the city for weather forecast notifications. The subscriber must also select a device and a locale for notification delivery.
The schema for this scenario contains three fields: DeviceName, SubscriberLocale, and City.
Field name | Field type | Field modifiers |
---|---|---|
DeviceName |
nvarchar(255) |
NOT NULL |
SubscriberLocale |
nvarchar(10) |
NOT NULL |
City |
nvarchar(35) |
NOT NULL |
Pre-Defined Device Name and Locale
This schema is for a flight application. When a subscriber creates a subscription, the subscriber must specify the code for the city of origin, the code for the destination, and a trigger price for notifications. The subscriber can also specify a carrier. If no carrier is specified, the subscriber will receive notifications for all carriers.
This application supports only one device and one locale. Therefore, the device name and locale can be specified in the Transact-SQL query that is used to generate notifications. There is no need for DeviceName and SubscriberLocale fields in the subscription schema, unless there are plans to support multiple devices and locales in the future.
Field name | Field type | Field modifiers |
---|---|---|
LeavingFrom |
nvarchar(6) |
NOT NULL |
GoingTo |
nvarchar(6) |
NOT NULL |
Carrier |
nvarchar(255) |
|
Price |
float |
NOT NULL |
Per-Subscription Device, Pre-Defined Locale
If the flight application is changed to support multiple devices, but not multiple locales, you would add a DeviceName field to the schema definition.
Field name | Field type | Field modifiers |
---|---|---|
DeviceName |
nvarchar(255) |
NOT NULL |
Origin |
nvarchar(6) |
NOT NULL |
Destination |
nvarchar(6) |
NOT NULL |
Carrier |
nvarchar(255) |
|
Price |
float |
NOT NULL |
Note
If you alter a subscription class and update the application, the existing subscription tables are renamed and new subscription tables are created. You can migrate subscription data from the old to the new tables. For more information, see Updating an Application.
No Custom Fields
The following field definitions are for a subscription class that either sends the same notification to everyone, or supports condition actions in which subscribers define complex conditions over event fields. The user does not provide values for any WHERE clause parameters, but must select a device and a locale.
Field name | Field type | Field modifiers |
---|---|---|
DeviceName |
nvarchar(255) |
NOT NULL |
SubscriberLocale |
nvarchar(10) |
NOT NULL |
If an application does not have custom fields and does not support multiple devices and locales, the subscription class has no schema.
See Also
Reference
Concepts
Defining the Subscription Schema
Other Resources
Data Types (Database Engine)
CREATE TABLE (Transact-SQL)
FieldTypeMods Element for SubscriptionClass/Schema/Field (ADF)
FieldType Element for SubscriptionClass/Schema/Field (ADF)
Schema Element for SubscriptionClass (ADF)