Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.0 » MobiLink - Getting Started » MobiLink Tutorials » Tutorial: Introduction to direct row handling

 

Lesson 6: Set up your MobiLink client database

In this lesson, you use a SQL Anywhere database for your consolidated database and your MobiLink client. For tutorial purposes your MobiLink client, consolidated database, and MobiLink server all reside on the same computer.

To set up the MobiLink client database, you create the RemoteOrders and OrderComments tables. The RemoteOrders table corresponds to the RemoteOrders table on the consolidated database. The MobiLink server uses SQL-based scripts to synchronize remote orders. The OrderComments table is only used on client databases. The MobiLink server processes the OrderComments tables using special events.

You create a synchronization user, publication, and subscription on the client database after creating the tables. Publications identify the tables and columns on your remote database that you want synchronized. These tables and columns are called articles. A synchronization subscription subscribes a MobiLink user to a publication.

 To set up your MobiLink client database
  1. Create your MobiLink client database using the dbinit command line utility.

    Run the following command:

    dbinit -i -k remote1

    The -i and -k options omit jConnect support and Watcom SQL compatibility views, respectively.

  2. Start your MobiLink client database using the dbeng12 command line utility.

    Run the following command:

    dbeng12 remote1
  3. Connect to your MobiLink client database using Interactive SQL.

    Run the following command:

    dbisql -c "server=remote1;uid=DBA;pwd=sql"
  4. Create the RemoteOrders table.

    Run the following SQL script in Interactive SQL:

    CREATE TABLE RemoteOrders (
        order_id           INTEGER NOT NULL,
        product_id         INTEGER NOT NULL,
        quantity           INTEGER,
        order_status       VARCHAR(10) DEFAULT 'new',
        PRIMARY KEY(order_id)
    )
  5. Create the OrderComments table.

    Run the following SQL script in Interactive SQL:

    CREATE TABLE OrderComments (
        comment_id         INTEGER NOT NULL,
        order_id           INTEGER NOT NULL,
        order_comment      VARCHAR(255),
        PRIMARY KEY(comment_id),
        FOREIGN KEY(order_id) REFERENCES RemoteOrders(order_id)
    )
  6. Create your MobiLink synchronization user, publication, and subscription.

    Run the following SQL script in Interactive SQL:

    CREATE SYNCHRONIZATION USER ml_sales1;
    CREATE PUBLICATION order_publ (TABLE RemoteOrders, TABLE OrderComments);
    CREATE SYNCHRONIZATION SUBSCRIPTION TO order_publ FOR ml_sales1
     TYPE TCPIP ADDRESS 'host=localhost'
    Note

    You specify how to connect to the MobiLink server using the TYPE and ADDRESS clauses in the CREATE SYNCHRONIZATION SUBSCRIPTION statement.

    You can use publications to determine what data is synchronized. In this case you specify the entire RemoteOrders and OrderComments tables.

Stay connected in Interactive SQL for the next lesson.

 Further reading