Lesson 5: Connecting to the Database  Lesson 7: Creating an Employee List


Look at table definitions in the ASA Demo DB database

Note

Now you look at the definitions for the Customer and Product tables in the ASA Demo DB database. This helps you become familiar with the Database painter and the tables you will use in this lesson.

What happens when you connect To look at the table definitions, you have to connect to the database. When you connect to a database in the development environment, PocketBuilder writes the connection parameters to the Windows registry.

Each time you connect to a different database, PocketBuilder overwrites the existing parameters in the registry with those for the new database connection. When you open a PocketBuilder painter that accesses the database, you automatically connect to the last database used. PocketBuilder determines which database this is by reading the registry.

  1. Click the Database button in the PowerBar.

    Database button

    PocketBuilder connects to the database and the Database painter opens. The Database painter title bar identifies the active database connection.

    The Objects view of the Database painter displays all existing database profiles in a tree view under the Installed Database Interfaces heading. The ASA Demo DB database is visible under the ODB ODBC node in the tree view.

    NoteIf the Objects view is not open The Objects view is part of the default view layout scheme. To reset to this scheme, select View>Layouts>Default. You can also open an Objects view by selecting View>Objects from the menu bar.

  2. Expand the ASA Demo database node in the Objects view.

    Notice the folders under the ASA Demo database node.

    Shown is the expanded E A S Demo D B V 10 database node in the Objects view. It has folders for Driver Information, Groups, Metadata Types, Tables, Users, and Views.
  3. Expand the Tables folder.

    You see the list of tables in the database.

    NoteTable names might have a prefix The table names in the Select Tables dialog box might have a prefix such as dba or dbo. This depends on the login ID you are using. You can ignore the prefix.

  4. Right-click the customer table and select Add To Layout from the pop-up menu

    or

    Drag the customer table from the Objects view to the Object Layout view.

    NoteDragging an object from one view to another When you start dragging an object from the Objects view to another view, the pointer changes to a barred circle. If you continue moving the cursor to a view that can accept the object, the barred circle changes back to a pointer with an additional arrow symbol in a small box. When you see this symbol, you can release the object.

  5. Repeat step 4 for the product table.

    NoteWidening the Object Layout view You can widen the Object Layout view by dragging its separator bars toward the painter frame. If the Object Layout view is part of a stack, you might find it easier to separate it from the stack before you change its size.

    The Object Layout view shows the two tables you selected.

    Shown is the Object Layout view for the customer and product tables, listing all the column names and their descriptions, and showing icons that designate which columns are primary and foreign keys.

    NoteViewing table data types, comments, keys, and indexes In the Object Layout view, you can see a description for each column, as well as icons for keys and indexes. If you do not see this, right-click a blank area inside the view and select Show Referential Integrity and Show Index Keys from the pop-up menu. If you select Show Datatypes, you also see the data type for each column in the selected tables.

  6. Right-click the title bar of the customer table in the Object Layout view and select Alter Table from the pop-up menu

    or

    Right-click the customer table in the Objects tree view and select Alter Table from the pop-up menu.

    The Columns view displays the column definitions for the table.

  7. Right-click a column in the customer table in the Object Layout view.

    Select Properties from the pop-up menu.

    In the Database painter, the Properties view is also called the Object Details view.

    The title bar and tab headings for the Object Details view change dynamically depending on the current object selection. The title bar gives the object type, the database connection, and the object identifier.

    The Object Details view for a column has five tabs, one for general database properties and the others for column extended attributes.

    Shown is the Object Details view for the id column of the customer table. There are five tabs labeled General, Headers, Display, Validation, and Edit Style. The General tab page is open. It shows the Table and column names and includes column details such as column Number, Data Type, whether the column is nullable, the Default value, and comments.

    NoteAbout extended attributes PocketBuilder stores extended attribute information in system tables of the database. Extended attributes include headers and labels for columns, initial values for columns, validation rules, and display formats.

    You can define new extended attributes or change the definitions of existing extended attributes from the pop-up menus of items in the Extended Attributes view of the Database painter.

  8. Close the Database painter.





Copyright © 2004. Sybase Inc. All rights reserved. Lesson 7: Creating an Employee List

View this book as PDF