Lesson 2: Set up your MobiLink consolidated database

Your MobiLink consolidated database is a central repository of data and includes MobiLink system tables and stored procedures used to manage the synchronization process. With direct row handling, you synchronize with a data source other than a consolidated database, but you still need a consolidated database to maintain information used by the MobiLink server.

In this lesson, you:

  • Create a database and define an ODBC data source.

  • Add data tables to synchronize to remote clients.

  • Install MobiLink system tables and stored procedures.

Note

If you already have a MobiLink consolidated database set up with MobiLink system objects and a DSN, you can skip this lesson.

Create your consolidated database

In this tutorial, you create a SQL Anywhere database using the Sybase Central Create Database Wizard.

To create your SQL Anywhere RDBMS
  1. Click Start » Programs » SQL Anywhere 11 » Sybase Central.

  2. Click Tools » SQL Anywhere 11 » Create Database.

  3. Click Next.

  4. Click Next.

  5. In the Save The Main Database File To The Following File field, type the file name and path for the database. For example, c:\MLobjexcel\MLconsolidated.db.

  6. Follow the remaining instructions in the Create Database Wizard and accept the default values. On the Connect To Database page, clear Stop The Database After Last Disconnect.

  7. Click Finish.

    The MLconsolidated database appears in Sybase Central.

Define an ODBC data source for the consolidated database.

Use the SQL Anywhere 11 driver to define an ODBC data source for the MLconsolidated database.

To define an ODBC data source for the consolidated database
  1. Start Sybase Central.

  2. Click Tools » SQL Anywhere 11 » Open ODBC Administrator.

  3. Click the User DSN tab, and click Add.

  4. On the Name list, click SQL Anywhere 11. Click Finish.

  5. In the ODBC Configuration For SQL Anywhere 11 window, do the following:

    1. Click the ODBC tab.

    2. In the Data Source Name field, type mlexcel_db.

    3. Click the Login tab.

    4. In the User ID field, type DBA.

    5. In the Password field, type sql.

    6. Click the Database tab.

    7. In the Server Name field, type MLconsolidated.

    8. In the Database File field, type c:\MLobjexcel\MLconsolidated.db.

    9. Click OK.

  6. Click OK.

Create tables for synchronization

In this procedure, you create the RemoteOrders table in the MobiLink consolidated database. The RemoteOrders table contains the following columns:

Column

Description

order_id

A unique identifier for orders.

product_id

A unique identifier for products.

quantity

The number of items sold.

order_status

The order status.

last_modified

The last modification date of a row. You use this column for timestamp based downloads, a common technique used to filter rows for efficient synchronization.

To create the RemoteOrders table
  1. Connect to your database using Interactive SQL.

    At a command prompt, run the following command:

    dbisql -c "dsn=mlexcel_db"
  2. Run the following command in Interactive SQL to create the RemoteOrders table.

    CREATE TABLE RemoteOrders
    (
     order_id           integer not null,
     product_id         integer not null,
     quantity           integer,
     order_status       varchar(10) default 'new',
     last_modified      timestamp default current timestamp,
     primary key(order_id)
    )

    Interactive SQL creates the RemoteOrders table in your consolidated database.

    Stay connected in Interactive SQL for the following procedure.

Run MobiLink setup scripts

You can find setup scripts for each supported consolidated database in the MobiLink/setup subdirectory of your SQL Anywhere 11 installation.

In this procedure you set up a SQL Anywhere consolidated database. You do this using the syncsa.sql setup script. Running syncsa.sql creates a series of system tables and stored procedures prefaced with ml_. The MobiLink server works with these tables and stored procedures in the synchronization process.

To install MobiLink system tables
  1. Connect to your consolidated database in Interactive SQL if you are not already connected.

    Run the following command:

    dbisql -c "dsn=mlexcel_db"
  2. Run the following command in Interactive SQL to create MobiLink system tables and stored procedures. Replace c:\Program Files\SQL Anywhere 11\ with the location of your SQL Anywhere 11 installation.

    read "c:\Program Files\SQL Anywhere 11\MobiLink\setup\syncsa.sql"

    Interactive SQL applies syncsa.sql to your consolidated database.

Stay connected in Interactive SQL for the next lesson.

Further reading

For information about creating SQL Anywhere databases, see Initialization utility (dbinit).

For information about creating tables, see CREATE TABLE statement.

For information about setting up MobiLink consolidated databases, see MobiLink consolidated databases.