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).

  •  Set

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

  •  Form

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

  •  Browse

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

  •  Report

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

  •  Letter

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

  •  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.

  •  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.

  •  Code

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

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.

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.

 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).

  • Modify the design of a selected database object.

  • Create a new database object.

  • Delete a selected database object.

  • View data in a Browse, Form, Report, Letter, or Label.

  • Preview data in a report, email, printer, or file.

  • Execute an Operation or code (script).

 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".

  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.

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

  • Save the table structure.

  • Save the table structure to a new filename or location.

  • Remove the selected information and copies it to the clipboard.

  • Copy the selected information to the clipboard.

  • Insert clipboard contents at the cursor position.

  • Delete the selected information.

  • Display table records in Default Browse view.

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

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

  • Indicates the active window.

  • 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).

  • Display the Control Panel.

  • Close the Table Editor.

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.

  2. Click the Save button on the toolbar. The Specify Table Name dialog box appears.

  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.

  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.

  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.

  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.

  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.

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.

  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.

  8. Select the Genre data field, and click the Lookups tab.

  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".

  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:

    • 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.

  17. Make data entry required for some data fields.