Collection Contents Index Design overview Publication design for Adaptive Server Anywhere pdf/chap7.pdf

Data Replication with SQL Remote
   PART 2. Replication Design for SQL Remote
     CHAPTER 7. SQL Remote Design for Adaptive Server Anywhere       

Creating publications


This section describes how to create simple publications consisting of whole tables, or of column-wise subsets of tables.

For Info     Simple publications are also discussed in the chapter A Tutorial for Adaptive Server Anywhere Users.

Top of page  Creating publications for Adaptive Server Anywhere using Sybase Central

You can add a publication to a database from within the SQL Remote folder of Sybase Central.

  To create a publication from Sybase Central:
  1. Open the SQL Remote folder for your database, which is inside the database container.

  2. Click the Publications folder.

  3. Double-click Add Publication. The Publication Wizard is displayed.

  4. Follow the instructions in the Wizard.

For Info     For more information on how to use Sybase Central, see the Sybase Central online Help.

With Sybase Central, you do not need to know the SQL syntax in order to create publications. The remainder of this section discusses different kinds of publication that can be created. It describes the SQL syntax needed for these publications. However, each of the publications can also be created from Sybase Central.

To send SQL statements to an Adaptive Server Anywhere database, you can use the Interactive SQL utility.

Top of page  Publishing a whole table

The simplest publication you can make consists of a single article, which consists of a single, entire, table.

  To create a publication that includes all the rows and columns of a single table:
  1. Execute a create publication statement specifying the table you wish to publish. The syntax is as follows:

    CREATE PUBLICATION publication_name (
       TABLE table_name
    )

Example 

Top of page  Publishing some of the columns in a table

Partitioning tables 

An article that contains only some of the columns of a table can be called a column-wise partitioning of the table. An article that contains only some of the rows of a table can be called a row-wise partitioning of the table. Articles can be both column-wise and row-wise partitions of a table.

For Info     Only column-wise partitioning is described in this section. For information on row-wise partitioning of tables, see Publishing some of the rows from a table.

You create a publication that contains all the rows, but only some of the columns, of a table by specifying a list of columns in the CREATE PUBLICATION statement.

For Info     Any article must conform to the requirements listed in Conditions for valid articles.

  To create a publication that includes all the rows and some of the columns of a table:
  1. Enter a CREATE PUBLICATION statement that includes the column names you wish to include. The syntax is as follows:

    CREATE PUBLICATION publication_name (
       TABLE table_name ( column_name, ... )
    )

Example 

Top of page  Publishing a set of tables

When publishing a set of tables, a separate article is required for each table in the publication. The following statement creates a publication including all columns and rows in each of a set of tables from the Adaptive Server Anywhere sample database:

CREATE PUBLICATION sales (
   TABLE customer,
   TABLE sales_order,
   TABLE sales_order_items,
   TABLE product
)

Not all the tables in the database have been published. For example, subscribers receive the sales_order table, but not the employee table.

Notes 

Top of page  Publishing some of the rows from a table

There are two ways of including only some of the rows in a publication:

You can combine a WHERE clause and a subscription expression in an article.

When to use WHERE and subscription expressions 

You should use a Subscription expression when different subscribers to a publication are to receive different rows from a table. The Subscription expression is the most powerful method of partitioning tables.

The WHERE clause is used to exclude a set of rows from all subscriptions to a publication.

Top of page  Publishing a subset of rows using a WHERE clause

The following is a single-article publication sending relevant order information to Samuel Singer, a sales rep:

CREATE PUBLICATION pub_orders_samuel_singer (
   TABLE sales_order WHERE sales_rep = 856
)

In Sybase Central, the Publication Wizard guides you through creating a WHERE clause for an article.

  To create a publication using a WHERE clause:
  1. Enter a CREATE PUBLICATION statement that includes the rows you wish to include in a WHERE clause. The syntax is as follows:

    CREATE PUBLICATION publication_name (
       TABLE table_name ( column_name, ... )
          WHERE search-condition
    )

Example 

Top of page  Publishing a subset of rows using a subscription expression

In a mobile workforce situation, a sales publication may be wanted where each sales rep subscribes to their own sales orders, enabling them to update their sales orders locally and replicate the sales to the consolidated database.

Using the WHERE clause model, a separate publication for each sales rep would be needed: the following publication is for sales rep Samuel Singer: each of the other sales reps would need a similar publication.

CREATE PUBLICATION pub_orders_samuel_singer (
   TABLE sales_order 
      WHERE sales_rep = 856
)

To address the needs of setups requiring large numbers of different subscriptions, SQL Remote allows a subscription expression to be associated with an article. Subscriptions receive rows depending on the value of a supplied expression.

Benefits of subscription expressions 

Publications using a subscription expression are more compact, easier to understand, and provide better performance than maintaining several WHERE clause publications. The database server must add information to the transaction log, and scan the transaction log to send messages, in direct proportion to the number of publications. The subscription expression allows many different subscriptions to be associated with a single publication, whereas the WHERE clause does not.

  To create an article using a subscription expression:
  1. Enter a CREATE PUBLICATION statement that includes the expression you wish to use as a match in the subscription expression. The syntax is as follows:

    CREATE PUBLICATION publication_name (
       TABLE table_name ( column_name, ... )
          SUBSCRIBE BY expression
    )

Example 

Users can subscribe to more than one publication, and can have more than one subscription to a single publication.

For more information 

Top of page  Dropping publications

Publications can be dropped using the DROP PUBLICATION statement. The following statement drops the publication named pub_orders.

DROP PUBLICATION pub_orders

Dropping a publication has the side effect of dropping all subscriptions to that publication.

Top of page  Notes on publications

Top of page  

Collection Contents Index Design overview Publication design for Adaptive Server Anywhere pdf/chap7.pdf