Creating an Alpha Anywhere Database

Description

The Creating an Alpha Anywhere Database topic describes techniques appropriate for Alpha Anywhere database users. To create or modify an Alpha Anywhere database, you must leave the Web Projects Control Panel and open the Alpha Anywhere Control Panel.

Key Terms and Concepts

Below are some key terms and concepts to help you get a basic understanding of how Alpha Anywhere stores and organizes data. Review and become familiar with the terms and concepts described in the following table.

  • Database

    A collection of data used for sorting, retrieving, or in some other way, manipulating stored information in a data-management solution. Information in a database is stored in several different files called tables.

  • Table

    A collection of data about a specific subject or a distinct topic. A database can contain one or more tables. A table is made up of rows ( records ) and columns ( fields ).

  • Record

    A collection of related data fields about a single entity, such as a person, an item, or an event. For example, a table of employees would contain records of individual employees.

  • Field

    A portion of a record containing a single piece of information. For example, an employee first name might be one field in the employee record.

  • Set

    A collection of logically related tables, linked together according to a specified criteria.

Using the Control Panel

The Control Panel is the Alpha Anywhere main menu and core user interface. By default, it has the following tabs: Tables/Sets, Forms, Browses, Reports, Letters, Labels, Operations, and Code. You can hide or show a Control Panel tab by right-clicking on it, and selecting or de-selecting it.

If your Alpha Anywhere Control Panel is not displaying the tabs shown above, right-click on the Tables/Sets tab, and select to display the other tabs.

The following table presents a list database object types and describes them.

  • Table

    Stores and arranges information in a database. A table is made up of rows (records) and columns (fields).

    images/Table_icon.gif
  • Set

    A collection of data from related tables, linked together in a logical way.

    images/Set_icon.gif
  • Form

    A page-like layout in which you view, enter, and change data.

    images/Form_icon.gif
  • Browse

    Displays data in a tabular format of rows and columns, like a spreadsheet layout. Also used to view and edit data.

    images/Browse_icon.gif
  • Report

    A flexible layout used to output data. Report data can be sorted, grouped, calculated, summarized, and contain graphics.

    images/Report_icon.gif
  • Letter

    A layout used for printing traditional mail-style letters. Letters can reference data from a table or a set, and contain personalized text.

    images/Letter_icon.gif
  • Label

    A layout generally used to generate small labels, such as mailing labels, file folder labels, identification cards, and name tags, based on data from a table or a set.

    images/Label_icon.gif
  • Operation

    A process you define that modifies data, performs calculations, imports data from different programs, exports data to a different file format, or generally manipulates data.

    images/Operation_icon_1.gif
    images/Operation_icon_2.gif
    images/Operation_icon_3.gif
    images/Operation_icon_4.gif
  • Code

    A series of steps that Alpha Anywhere can use to perform actions or customize your data.

    images/Script_icon.gif
    images/Toolbar_icon.gif
    images/Menu_icon.gif
    images/Function_icon.gif

In the Control Panel, you can right-click on a database object to set properties or perform some actions, using the pop-up menu. For example, if you right-click on a table object, you can use the menu to open the table Default Form and Default Browse, edit the table structure and field rules, rename the table, and perform other actions. You can use the Alpha Anywhere standard toolbar to create a new database, open and close a database, add or remove tables from a database, change the database object icon view, and close an Alpha Anywhere application.

images/Control_Panel_Toolbar_Commented.gif

If you forget which command a toolbar button executes, position your mouse pointer over it. Alpha Anywhere displays Bubble Help, pop-up text that describes its function. The following figure shows the Alpha Anywhere version 6 standard toolbar and lists its functions. The Version 5 toolbar does not have the Application Server and Web Projects entries.

images/Control_Panel_menu_commented.gif

Control Panel Buttons

Using the Control Panel buttons, you can create, manage, and manipulate database objects, modify selected objects, preview or activate objects, or delete them. The following table shows the Control Panel buttons and describes their action.

  • Access to commonly used commands (similar to the right-click menu).

    images/buttonMenu.gif
  • Modify the design of a selected database object.

    images/buttonDesign.gif
  • Create a new database object.

    images/buttonNew.gif
  • Delete a selected database object.

    images/buttonDelete.gif
  • View data in a Browse, Form, Report, Letter, or Label.

    images/buttonView.gif
  • Preview data in a report, email, printer, or file.

    images/buttonPreview.gif
  • Execute an Operation or code (script).

    images/buttonRun.gif

Alpha Anywhere File Types

Alpha Anywhere database objects, such as tables and indexes, are stored in associated files. Refer to Alpha Anywhere File Types for a list and description of Alpha Anywhere file types.

Creating a New Database

To create a new database:

  1. Start Alpha Anywhere.

  2. Select File > New Database from the menu bar. The Create New Database dialog box appears.

  3. Navigate to the location where you want to create the AlphaMovies folder and click . Name the folder "AlphaMovies".

    images/Folder_New.gif
  4. Navigate into the AlphaMovies directory.

  5. Enter the filename, "AlphaMovies.adb".

  6. Click Save. An empty, AlphaMovies Control Panel appears.

In the following procedures, you create tables for AlphaMovies and define their fields.

Creating Tables

Alpha Anywhere tables store and arrange information in a database. Methods for creating tables include:

  • Using the Table Editor in Design Mode

  • Using the Set Editor in Design Mode

  • Entering field definitions in Text Mode (version 6 and above)

  • Entering sample data in Example Mode (version 6 and above)

  • Using the New Table/Set Genie.

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

To take a quick look at the New Table/Set Genie :

  1. Click the New button in the AlphaMovies Control Panel, and select Create Using Genie.

  2. Select a template and click Preview to see the field definitions and indexes.

  3. Click Cancel to exit.

Using the Table Editor

To create a new table using the Table Editor :

  1. In the AlphaMovies Control Panel, click New Table (Design Mode). The Table Editor window appears. Additionally, Alpha Anywhere displays the Table Design toolbar.

    images/Table_Design_Toolbar_Commented.gif

The following table lists the table design toolbar buttons and describes their functions.

  • Save the table structure.

    images/Save_button.gif
  • Save the table structure to a new filename or location.

    images/Save_As_button.gif
  • Remove the selected information and copies it to the clipboard.

    images/Cut_button.gif
  • Copy the selected information to the clipboard.

    images/Copy_button.gif
  • Insert clipboard contents at the cursor position.

    images/Paste_button.gif
  • Delete the selected information.

    images/Delete_button.gif
  • Display table records in Default Browse view.

    images/Browse_View_button.gif
  • Display the Field Rules Editor , for you to view, edit, or define filed rules. Only available when the table has been saved.

    images/Field_Rules_button.gif
  • Display the Index Builder , for you to view, edit, or create indexes. Only available after a table is saved.

    images/Index_Builder_button.gif
  • Indicates the active window.

    images/Design_Mode_button.gif
  • Create or modify global calculated fields. Alpha Anywhere calculates global calculated field values as they are used.

    -
  • Create or modify global variables (variables that exist throughout an Alpha Anywhere application).

    images/Variables_button.gif
  • Display the Control Panel.

    images/Control_Panel_button.gif
  • Close the Table Editor.

    images/Close_button_2.gif

You use the Table Editor to describe table data, not for entering table data. In the Table Editor, each row creates one data field and defines its properties.

Defining Data Fields

Each Alpha Anywhere table can contain an almost unlimited number of records while each record can contain up to 1,024 fields storing individual bits of data. For more information, refer to Database Maximums. A data field can contain up to 32 characters. Each field name must be unique, begin with a letter, and cannot contain spaces. If you enter a space in the field name, Alpha Anywhere converts the space to an underscore.

  • Name

    Name for each field in the table.

  • Type

    Type of data stored in the field, selected from a drop-down list of values. For more information, see the Field Types table.

  • Width

    Maximum number of characters allowed in the field. When specifying Date, Time, Short Time, Logical, Memo, RTF Memo, JPEG, Bitmap, Active X, and OLE data types, Alpha Anywhere assigns the correct width.

  • Decimal

    Number of decimal places for a Numeric data field type.

  • Indexed?

    Indicates that Alpha Anywhere create an index on the field.

In addition to assigning field names, data types, width, decimal places, and indexing, you can define other field properties using the Field Rules Editor, which is explained later in the lesson. Alpha Anywhere supports thirteen field types. For more information on these types, refer to Create a New Table.

Numeric Data Fields

When you create a numeric field that contains decimal places, the width must include the 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, you enter five in the Width column, and two in the Decimal column. Store numeric information that is not used for numerical calculations, such as, zip codes and phone numbers, in a character field instead of a numeric field. A character field accepts zeros and formatting characters. For example, you could not enter a phone number, such as (617) 555-1212, in a numeric field, because it includes non-numeric characters. A zip code, such as 01803, would get stored as 1803 in a numeric field, because the first digit, zero, would be removed.

Indexing Data Fields

Use the Indexed? column in the Table Editor to specify whether to index a particular field. If you are modifying a table, or when defining an index expression or filters, use the Index Builder.

Creating Tables for AlphaMovies

In the next lesson, you create tables for AlphaMovies. For the first table, you use the Table Editor to define the data fields for your film inventory information. You opened the Table Editor previously. In the Table Editor :

  1. Enter the following information in the blank Table Editor window.

    images/atable.png
  2. Click the Save button on the toolbar. The Specify Table Name dialog box appears.

    images/Specify_Table_Name_dialog.gif
  3. Enter "Inventory" in the Table Name field, and click OK. Alpha Anywhere saves the table in the AlphaMovies directory. The Inventory table object appears in the AlphaMovies Control Panel. To create a customer information table, you use the New Table Genie.

  4. In the AlphaMovies Control Panel, click the New button, and select Create Using Genie. The New Table/Set Genie appears.

    images/New_Table_Set_Genie_dialog.gif
  5. Select the "Contacts-Customers" template, check Include sample Layouts and Field Rules and Include sample data, and click Next. The Genie displays the Table Name, whether to save the table in the same directory as the database, and the Existing Tables in the Database.

    images/tableNewGenie2.gif
  6. Change the Table Name to "Customers", and click Finish. The table structure closes and the Customers table appears in the AlphaMovies Control Panel. Note that the Customers table has forms, reports, and labels.

  7. Select the Customers table in the Control Panel, click the Design button, and select Table Structure. The Customers table field data structure appears.

    images/tableFieldsCustomers.gif
  8. Click the Indexes button on the toolbar to see the indexed Customers table fields.

  9. Click the Field Rules button on the toolbar. The Field Rules Editor appears. In the next section, you learn about field rules and define some for the Inventory table.

Defining Field Rules

Field rules are a valuable but non-essential part of Alpha Anywhere. In other words, you can build a database without field rules, but if you use them field rules will enhance your finished product. Field rules govern how you enter data in a table, and help ensure that data entry is accurate, consistent, and complete. You use field rules to control the information that you can enter in a field. You can use field rules to perform the following tasks:

  • Insert calculations or incrementing values

  • Validate, format, and insert field values

  • Change field entry case, and define auto-expanding abbreviations

  • Ensure reasonable and accurate values

  • Create table lookups for filling-in data

  • Post data from one table to another

  • Define Xbasic scripts for different events

For more information on field rules, refer to Types of Field Rules. To define field rules:

  1. First, look at the field rules defined for the Customers table in the Field Rules Editor.

    • You use the drop-down list box at the top, to switch between data fields, and the tabs, to switch between field rules. Data fields with check marks have field rules associated with them. In the Customers table, the Customer_ID field employs the auto-increment field rule. The Company_Name field employs a transformation rule, which converts all letters to lowercase, and gives words initial capital letters.

    images/fieldRulesCust1.gif
  2. Close the Field Rules Editor.

  3. Right-click the Inventory table in the Control Panel, and select Edit Field Rules to open the Field Rules Editor. The Inventory table's Tape_ID field appears in the Field Rules Editor.

  4. In Extended Field Types select the Auto-increment option.

    images/fieldRulesInv1.gif

When you define a Character, Numeric, or Date field with the Auto-Increment rule, Alpha Anywhere supplies an incremental and editable field value when you create a new record. If you overwrite the default value, successive records are incremented from the value you enter. Auto-Increment fields are useful for assigning unique identification numbers for invoices, parts, products, and customers. By default, Character fields are incremented using numbers, for example 0001, 0002.

Use the Default Value Rule on the Data Entry tab to specify the starting value for an empty table.
  1. Enter a Default Descriptive Name, such as "Tape ID", and a Field Description.

  2. Click the Data Entry tab.

    images/fieldRulesInv6.gif
  3. Select "Simple default expression" from the Default Mode drop-down list box.

  4. Enter "00001" in the Default Value text box.

  5. Check the Set default value at start of data entry check box.

  6. Enter ".T." into the Skip text box, to keep the value unchanged and unavailable for editing.

  7. Select the Title data field, click the Transformations tab, and select "Low&Word" from the Case Convert list.

    images/fieldRulesInv2.gif
  8. Select the Genre data field, and click the Lookups tab.

    images/fieldRulesInv3.gif
  9. Select "Simple list" in the Lookup styles drop-down list box, and enter the following list values: "Action", "Comedy", "Drama", "Mystery", and "Sci-Fi".

  10. Keep the default values for Display as Drop-down list box, Allow exceptions, and Auto popup.

  11. Repeat steps 7, 8, and 9 for the Rating field, but enter the following simple list values: "G", "PG", "PG-13", "R", "NC-17".

  12. Select the Language data field, and click the Lookups tab.

  13. Select "Simple list" in the Lookup styles drop-down list box, and enter the following list values: "English", "French", "Spanish", "Italian", and "Other".

    images/fieldRulesInv4.gif
  14. Keep the default value for Display as Drop-down list box, but select "Force closest match" in Allow Exceptions, and "Pop-up on entrance" in Auto popup.

  15. Click the Save button on the toolbar, and close the Field Rules Editor.

    • Now, you can open a Default Browse or Default Form for the Inventory and Customers tables, and enter new data records. Double-click on the Inventory table, and enter the following data:

    • images/atable2.png
    • Examine how the field rules govern data entry. Try applying some of the following field rules to see their effect.

  16. Apply a simple mask to the Customers table phone_number data field or postal_code field.

    images/fieldRulesCust3.gif
  17. Make data entry required for some data fields.