Creating a New Table

Description

Typically, you create new database tables by defining their data field structure in the Table Editor window. Other methods for creating tables include:

  • Using the Alpha Anywhere New Table/Set Genie?.

  • Importing database files from other programs, such as Microsoft Access, Excel, Outlook, and Visual FoxPro.

From the Tables/Sets tab on the Control Panel, click the New button and select New Table (Design mode).

images/UG_Table_create_menu.png

The Table Editor opens, where you define the structure of the new table.

images/UG_Create_Table.png

The Table Editor looks like a spreadsheet (and a bit like an Alpha Anywhere table). In the Table Editor, you define the type of information that will be stored in your table, in contrast to entering the information to be stored in the table. Using the Table Editor you describe the Fields that make up the new table. Each row in the Table Editor creates a Field and defines the properties of the Field. For the checkbook register, there are four fields: Transaction Number, Date, Payee, and Amount. Therefore, four rows are filled in the Table Editor, one for each field. Each of these fields will appear as Columns in the resulting table.

Field Names

Start by entering a field Name, which can be up to 32 characters. The field name must start with a letter, and can contain the characters A-Z, 0-9, and the underscore character (_). If you use a space in the field name, Alpha Anywhere inserts an underscore in place of the space.

Any name longer than 10 characters is actually saved in the data dictionary since the .dbf format only supports 10 characters. If the data dictionary becomes corrupted, these long names can be lost and then the fields would appear to be "dropped". Most developers use names of 10 characters or less. If you use more than 10 characters, then the first 9 characters should never be the same.

Field Types

In the Type column you specify the type of information the field will contain. You select the field type from drop-down list of preset values. Alpha Anywhere recognizes the selected field type and understands how to handle information in the field. In the checkbook example, the Date column is designated as a date field, while the Transaction Amount is stored as a numeric field. Some things to keep in mind about field types when creating a table: When you create a numeric field and use decimal places, the width you enter needs to include numbers on both sides of the decimal point and the decimal point itself. For example, if the largest value you want to store is 99.99, enter 5 in the Width column and 2 in the Decimal column. Numeric information that won't be used to perform numerical calculations (e.g. ZIP codes or phone numbers) should be stored in a character field instead of a numeric field. This lets you add zeros and formatting characters. For example, the ZIP code 01803 becomes 1803 when stored in a numeric field and (617) 555-1212 won't be accepted in a numeric field because of the non-numeric characters. Alpha supports the following eleven field types. Note that there are variable data types that are not supported as field types.

  • Bitmap

    Stores bitmap (.bmp) image files as Data in the table.

  • Character

    The most common field type, Character allows any combination of alphanumeric characters. Maximum of 255 characters.

  • Date

    Contains a date only. Alpha Anywhere automatically sets the width to 8 for all date fields. Valid dates are 01-01-0000 through 12-31-9999.

  • Exponent Numeric

    A fixed precision decimal number.

  • Image File Reference

    A field that links to and displays an image (.jpg or .bmp) without storing it in the table.

  • JPEG Image

    Stores JPEG (.jpg) image files as data in the table. Refer to Creating a Bitmap Image Field and Creating a JPEG Image Field.

  • Logical

    Contains a single character, signifying TRUE or FALSE. You can display logical fields as Check boxes.

  • Memo

    Contains a 10-character pointer to a special memo field file, which can contain a virtually unlimited number of characters. Memos are stored internally as either character or binary (blob) data.

  • Numeric

    Contains numbers, including a decimal point, any decimal places, and a negative sign. A number can contain up to 14 decimal places. Maximum of 19 characters.

  • OLE

    Contains an OLE object, such as a spreadsheet or text file. (OLE is short for object linking and embedding, a method of integrating information that's processed in other applications.)

  • Rich Text Memo

    Similar to a memo field except you can change the font, alignment, color, and size.

  • Short Time

    Contains a time. Sets the width to 9 for all short time fields.

  • Time

    Contains a date and time. Sets the width to 17 for all time fields.

Field Width

The number of characters allowed in the field. Adjust the field width to suit your needs. Some field widths are pre-defined, such as Date (8), Memo (10), and Logical (1).

If you change a field width after you have placed it onto a form, the form will not show the modified width. You will have to edit the field on the form to display the new field width.

Decimal

The number of decimal places allowed for numeric fields. The Decimal specification is only available for Numeric field types.

Indexed?

Create a simple one-field index (alphabetical or numerical) to speed up querying. Alpha Anywhere automatically creates indexes for fields you specify Ascending or Descending in the Indexed? column. For example, if you are creating a table to store customer information, you might want to create an index for a Customer_ID field, since it is likely you'll want to order and select records based on the Customer_ID. By creating an index, you speed up queries and other operations that use the indexed field.

Creating indexes on every field is likely to slow down data entry, as each index gets updated whenever a record is entered and changed. You should only build indexes for fields that will be used for ordering and querying.

Global Calculated Fields

Clicking the 'x-y' icon displays the Define Calculated Fields dialog box. This dialog allows you to define calculations (know as Calculated fields) that will be available to all layouts based on this table. Refer to Calculated Fields for more information.

Session or Global Variables

Clicking the 'v' icon displays the Define Variable dialog box. This dialog allows you to define session or global variables. Refer to Define Variable Dialog Box for more information.

Saving a Table

When you finish defining the table structure, click the 'save' button or select File > Save to save the table in the database.

See Also