Tools Guide



Chapter 5   Table Designer

The Table Designer is a powerful graphical interface that enables you to create and update tables in a relational database.

You can use the Table Designer to:

This page describes the following:

Concepts you should know   Top of page

The following are concepts you should know before you use the Table Designer.

Table   Top of page

A table contains data relating to a specific subject, such as Employees. It is composed of columns and rows. Each entry in the table represents one data item. There are no duplicate data items.

Column   Top of page

A column is an area inside a database table where data is stored. A column contains one piece of the information that make up the table's subject. For example, in a table called Employees, standard columns could include Employee ID, Employee Name, and Hire Date. Each column must have a unique name. All of the data contained in one column must be of the same type.

Row   Top of page

A row is a structure within a table representing a unique instance of the table subject. It consists of all the columns contained in a table. Using the table named Employees as an example, a typical row would look like this:

Employee ID

Employee name

Social Security number

Job description

Work phone

12345678

LanFranc, Bishop

041827788

Data Analyst

6177891234

All of the employee information for Bishop LanFranc constitutes one row in the table. Each row in the table can be identifiable by a primary (unique) key.

Primary key   Top of page

A primary key is a column or set of columns in a table that uniquely identifies each row in that table. For example, in the Employees table, each employee has a different Employee ID. This makes employee ID a candidate to be the primary key.

Once you create a table using SilverStream and save it to the server, you cannot change any of the primary key's properties.

    For more information, see Specifying the primary key.

Index   Top of page

An index is a database structure designed to optimize the management of data. You cannot create indexes within the Table Designer; you create table indexes using your DBMS's tool.

Full-text indexing   Top of page

In SilverStream, when you mark a table column as full-text searchable, the server indexes that table automatically every time records are inserted, updated, or deleted.

    For more information, see Making a table full-text searchable.

Versioning   Top of page

Versioning is a way of keeping track of modifications made to data in a table. You can set up versioning through the Table Designer using the Property Inspector. When you mark a table for version control, a mirror table is created. This is the version table. It contains the same columns as the primary table, plus three additional columns containing the following information:

Each primary table must have a primary key, otherwise the version table cannot be updated correctly when the primary table is modified. Any table that has a primary key can be versioned. SilverStream automatically creates a primary key for the version table when you create it. The version table primary key is a combination of the primary table's primary key and the version number.

Whenever a row in a primary table is changed, the new version is also copied to the version table. The Table Designer offers both automatic and manual version control. Manual version control is not allowed for a new or existing primary table containing auto-increment columns. When you switch versioning off (by selecting None in the Property Inspector), the version table is deleted from the server and you lose all of your history for the primary table. You cannot delete a version table using the Delete command.

You can apply versioning at any time. You can also turn it off at any time. The default version table name is derived from the primary table, but you can change this name. Once you have created the version table and saved it to the server, you cannot change its name. You can insert, delete, and update columns in the version table. Be very careful when updating a version table, because you are updating the versioning history.

    To learn how to create a version table, see Creating version tables.

Table Designer keyboard shortcuts   Top of page

Use these keyboard shortcuts:

Keystroke

Description

Ctrl+S

Save

Ctrl+Z

Undo

Ctrl+Y

Redo

Ctrl+X

Cut

Ctrl+C

Copy

Ctrl+V

Paste

F1

Open Help

F4

Open Property Inspector

Editing an existing table   Top of page

It is important to keep the following in mind before you create or modify tables:

To edit an existing table from the SilverStream Designer:

  1. Select the Tables icon from the left pane.

    If tables already exist in the database you selected, a list of them appears in the right pane.

  2. To modify an existing table, double-click the table.

    The Table Designer displays.

  3. Make your changes as described below.

Creating tables   Top of page

It is important to keep the following in mind before you create or modify tables:

To create a table:

  1. Select the database where you will store your table by selecting a database icon in the left pane of the SilverStream Designer.

  2. Select the Tables icon.

    A list of available tables displays in the right pane.

  3. Select the New icon ( ) from the action gallery that appears at the bottom of the right pane.

    The Table Designer displays. No columns are defined.

    For information about creating columns, see Creating and modifying columns.

Specifying the primary key   Top of page

It is a good idea for a table to have a primary key. Primary keys are not required unless the table is versioned or full text searchable. A primary key is a column or group of columns in a table that uniquely identifies all the records in a table. For example, in the Employees table in the SilverBooks sample application shipped with SilverStream, the column iEmployeeId is the primary key. If you decide to create a table with a primary key, you must specify which column(s) is the primary key before you save the table to the database.

If you want to make a table full text searchable, the primary key for the table cannot contain integer or decimal values. If you change the primary key's data type to varchar, then you can make the table full text searchable.

Primary keys cannot contain null values.

    For more information about primary keys, see Primary key.

NOTE   Once you save your table to the database, you cannot change the primary key in SilverStream.

To specify the primary key for your new table:

  1. Select the Property Inspector either from the View menu or select the icon from the Table Designer toolbar.

  2. Select the Table property tab.

  3. Select the ellipses that appear in the Primary key column. The Edit Property: Primary Key dialog box appears. It contains two panes. The left pane lists the table columns.

  4. Select the column(s) you want to use as the primary key and select the > button. The column name(s) appears in the right pane.

  5. Select OK to return to the Table Designer.

Creating and modifying columns   Top of page

Adding columns   Top of page

To add columns to a table:

  1. Select the Tables icon from the SilverStream Designer. A list of tables associated with the database you selected appears in the right pane.

  2. Open the table you want to use by double-clicking on it.

    The Table Designer opens. The table you selected is displayed.

  3. To insert a new column, select the Insert column icon from the Table Designer toolbar. A column labeled "Untitled" appears.

    To insert a preformatted column, select one of the icons in the Table Designer gallery that appears in the left margin of the Table Designer window.

Assigning column properties   Top of page

Use the Property Inspector to specify column properties and defaults.

To assign properties to a column:

  1. Select the Property Inspector button from the Table Designer toolbar.

    The Property Inspector appears. It contains a property tab for the table as well as one for the column you just created.

  2. You can edit the column name by entering a name in the Name field. It appears on the column in the Table Designer.

  3. Specify the column type by selecting the down arrow in the Type field. Specifying the column type determines the kind of data the column contains.

  4. Specify information about the column, as described in the following table.

    Property type

    Description

    Applicable column type

    Column Width

    The maximum number of characters that can appear in the column.

    Character

    Varchar

    Binary

    Numeric

    Decimal

    Required

    Whether the column must always have a value. Specify that the column is required by selecting the Required check box. This is enforced by the DBMS, which returns an error message if a user tries to leave a required column blank.

    You cannot make a column required once you have saved the table in the database because doing so could invalidate certain records in the table. For the same reason, you cannot turn the Required flag on for a new column that you inserted into an existing table. You can, however, turn the Required flag off for a column after the table has been saved.

    Character

    Varchar

    Longvarchar

    Bit

    Binary

    Varbinary

    Longvarbinary

    Time

    Timestamp

    Date

    UUID

    Full Text Searchable

    Whether the column can be searched using full-text search. Specify that the column be full-text searchable by selecting the Full text searchable check box. The indexer reads all of the columns in the table that are marked as full-text searchable and creates its own table containing the indexed columns. It saves this table in its own database.

    For more information, see Making a table full-text searchable.

    Character

    Varchar

    Longvarchar

    Bit

    Binary

    Varbinary

    Longvarbinary

    Date

    Time

    Timestamp

    Decimal

    UUID

    Auto-increment

    Whether the column always receives a unique value supplied by the database. There are database-specific restrictions. You cannot have more than one auto-increment column in a table.

    Numeric

    Integer

    Tinyint

    Smallint

    Bigint

    Real

    Float

    Double

    Scale

    Indicates the number of digits that appear after a decimal point.

    Numeric

    Decimal

  5. Select the plus sign next to the word Defaults to view or edit the default values for the table. For more information, see Specifying default values.

Assigning column defaults   Top of page

Use the Property Inspector and the Expression Builder to specify the defaults for the table columns. There are two types of defaults in SilverStream:

    To learn more about the Expression Builder, see Expression Builder.

Specifying default values

Include default data in a table when you want a column to contain data regardless of whether a user has entered anything.

You can specify a default value expression for any column. The SilverStream Server evaluates the default expression whenever a new record is inserted or an existing record is updated and the user does not provide a value for the column.

It is important to keep the following in mind when assigning defaults:

To specify default values:

  1. Select an existing column or insert a new column. Double-click the column or select the Property Inspector button from the Table Designer toolbar. The property tabs for the table and the column you specified appear.

  2. Select the Column property tab.

  3. Select the plus sign that appears next to Defaults to see a list.

  4. Select the ellipses that appear in the Value column. The Expression Builder displays.

    Use the Expression Builder to create validation rules or aggregate data in a column. For example, if you wanted to add a column that contains the total price for an order, you would create an expression that combines the values of two other columns in your table. The expression would look something like this:

      orderdetails.unitprice * orderdetails.quantity  
    
  5. Select Verify when you finish creating your expression to make sure it is valid. Select OK to return to the Property Inspector. The expression you created appears in the Value: column.

Specifying display defaults

Display defaults determine how a data column appears when you use it in a form or view.

To specify the default settings for a column:

  1. Select an existing column or insert a new column. Double-click the column or select the Property Inspector icon from the Table Designer toolbar. The property tabs for the table and the column you specified appear.

  2. Select the Column property tab.

  3. Select the plus sign that appears next to Defaults to see a list of the properties to use to create the defaults for the column.

  4. Specify the default column control by selecting a control type from the list that appears when you select the down arrow in the Control Type property. Choose one of the following:

  5. Specify the default format for the column in the Display Format field. Select the down arrow to see a list of data formats that you can use.

        For more information about the formats, see the page listing formats in the help system.

  6. Specify the default column label in the Label field. The column label appears in the column list once you enter it.

  7. To create a tooltip that appears when users pass their cursors over the control, enter the tool tip text in the Tooltip field.

Creating validation rules for tables   Top of page

Use the Expression Builder to ensure data integrity by creating validation rules for your table. Keep the following in mind:

To create a validation rule:

  1. Select the Property Inspector button from the Table Designer toolbar. The Property Inspector appears.

  2. Select the Table property tab.

  3. Select the plus sign that appears next to the Validation Expressions column.

  4. Select Add New Expression. A validation clause control appears.

  5. Select the ellipses that appear in the Validation column.

    The Expression Builder displays.

  6. Use the Expression Builder functions and operators to create a validation rule for your column. For example, if you have a quantity column in your table, you can create an expression similar to the following to prevent users from entering a negative value:

      orderitem.quantity > 0 
    
  7. Enter the message that you want to appear as an error message in the Expression Builder's Validation Failed Message column.

  8. Click Verify to test your expression when you finish building it. If there is a syntax error, a message box appears.

  9. Select OK to save your expression (if it is correct) and return to the Table Designer.

What happens

The SilverStream Server evaluates these table-defined validation rules whenever an attempt is made to insert a new row or update a row in the database. This happens when an updateRows() method is called (typically, when the user clicks the Save button).

If one or more values fail validation, an AgoInvalidDataException is raised. You should handle this exception in your code.

NOTE   You can also create validation rules directly on form fields; these rules are evaluated on the client (form). For more information, see Creating validation rules for form fields.

Creating version tables   Top of page

NOTE   To learn more about version tables, see Versioning.

To create a version table:

  1. Select the Property Inspector icon from the Table Designer toolbar. The Property Inspector appears.

  2. Select the Table property tab.

  3. Select the down arrow that appears in the Versioning Mode field to see a list of versioning options. Choose one of the following:

  4. Enter the name of the version table in the Version Table column or accept the default name.

Setting table security   Top of page

Every database maintains a list of its tables. This list is referred to as the table directory. You can set security for the table directory. When you set security for the table directory, you have the option of applying those permissions to all the tables in the directory. You can specify who has:

You can also specify read/modify/set permissions authority on individual tables.

In addition, you can specify security permissions for individual rows in a table.

    For more information, see the security chapter in the Administrator's Guide.

Making a table full-text searchable   Top of page

You can mark one or more columns in a table to be full-text searchable so users of your applications can use powerful full-text search to find information.

    For more information on using full-text search in your applications, see Full Text Search.

Using Blobs and Clobs   Top of page

JDBC 2 supports Blobs and Clobs. If the JDBC driver you are using supports Blobs and Clobs (for example, the SilverStream Oracle 8 JDBC driver does), you can use Blobs and Clobs. You can:






Copyright © 2000, SilverStream Software, Inc. All rights reserved.