Contents Index Lesson 3: Check your work Summary

Introducing SQL Anywhere Studio
   Tutorial: Designing Databases with PowerDesigner

Lesson 4: Save changes and generate database


In PowerDesigner, models that depict the physical components of your database design, including tables and columns, are called Physical Data Models (PDM). PowerDesigner stores these in files with the extension .PDM.

To save the physical data model (PDM)

  1. Choose File > Save As.

  2. Type a file name with the extension .PDM and select a location.

  3. Click OK.

You can use PowerDesigner to generate a SQL script that implements all the components of your model. You can then use the SQL script to generate a database.

To generate a SQL script to create your new database

  1. Choose Database > Generate Database.

    The Database Generation dialog appears:

    The PowerDesigner Database Generation dialog.
  2. Type NewDemo.SQL in the File Name box and choose a convenient directory.

  3. Ensure that Script Generation is selected.

  4. Click the Database tab, and ensure that Create Database is selected.

    Explore the other tabs to observe options that give you control over many other properties of the generated script.

  5. Click OK.

    When the script is created, the Result dialog appears.

  6. Click Edit to view the script.

    Check that your changes are reflected in the script. For example, the definition of the new office table appears below.

    /* ========================================= */
    /*   Table: office                           */
    /* ========================================= */
    create table office
    (
       id            integer         not null
          default autoincrement
          check (
             id >= 100),
       name          char(15)        not null,
       street        char(30)        not null,
       city          char(20)        not null,
       state         char(2)         not null,
       zip           char(5)         not null,
       phone         char(10)                ,
       fax           char(10)                ,
       primary key (id)
    );
  7. When you are finished, close the dialog: in the Result dialog, click Close.

You can now create your new database from Interactive SQL.

To create the new database

  1. Start Interactive SQL.

  2. Connect to the sample database. You can use the same ODBC connection.

  3. Create an empty database:

  4. Close the connection to the sample database by clicking SQL > Disconnect.

  5. Connect to the new database by clicking SQL > Connect.

  6. Use the read statement. Remember that this statement demands that you enclose the file name in double quotes.

You can use these basic steps to modify other databases.


Contents Index Lesson 3: Check your work Summary