Like tables and indexes, data dictionaries can be created at runtime from your client applications. However, most developers will create their data dictionaries at design time as part of their overall database design process. You use the Advantage Data Architect to create data dictionaries at design time.
The following steps will instruct you to save your data dictionary in the same directory where you copied the sample tables for this book. (See Appendix B for information on accessing these tables if you have not yet installed them.) This is being done for convenience. In short, as long as you can refer to the location where a table is stored using a UNC (universal naming convention) path from the location of the data dictionary, the data dictionary will have no problem accessing your table.
The following steps demonstrate how to create a data dictionary. This data dictionary will be used in this and future chapters to demonstrate data dictionary features.
Select Database | New Database from the Advantage Data Architect main menu. In response, the Advantage Data Architect opens the Advantage Database Manager shown in Figure 4-1. You are only required to provide information for the fields identified by an asterisk (*). However, most developers provide additional information.
Figure 4-1: The data dictionary properties dialog box in the Advantage Database Manager
At the Name field, enter DemoDictionary. This is the name of the data dictionary. The Advantage Database Manager creates several files using this filename, including DemoDictionary.ADD, DemoDictionary.AI, and DemoDictionary.AM. The ADD file contains the fixed-length data dictionary metadata, and the AM file contains the variable-length metadata.
Only the ADD and AM files should be deployed. ADS will re-create the AI file the first time it accesses the data dictionary. If you were to deploy the AI file, and there are collation sequence differences between the ADS server to which you are deploying and the server against which the ADD file was created, you will have problems.
Next, set the Alias field to DemoDD. This alias provides a shorthand reference to the data dictionary. Many of the Advantage Data Architect’s utilities permit you to connect to a data dictionary using an alias, so this definition will come in handy later. Aliases are stored in a file named ADS.INI.
In the Paths section, set the Database field to the directory in which you previously stored the CUSTOMER.ADT table. This is the directory in which the Advantage Database Manager will store the DemoDictionary.ADD and related files. If you are using Windows and you stored this table in the directory suggested in Appendix B, this path will be c:\Program Files\Extended Systems\ Advantage\ADSBook.
Leave the Default and the Temp fields blank in the Paths section. When these fields are left blank, ADS uses the Database directory as both the default directory and the temp directory. The default directory defines the location where new database tables are created. The temp directory is where temporary files, such as those generated by the Advantage SQL engine, are created and stored. You use these two fields when you want these files to be stored in a location other than where the data dictionary is located.
Skip the User Access section at this point. The User Access section is used to control how the tables, stored procedures, and views of the data dictionary can be accessed by client applications. These features are discussed later in this chapter.
In the Data Dictionary Encryption section, check the Enable Data Dictionary Encryption checkbox. When you encrypt a data dictionary, the data dictionary files (ADD and AM) are encrypted, and cannot be viewed without using the proper password from the Advantage Data Architect. This is the only opportunity that you will have to encrypt the data dictionary. After creating the data dictionary, you cannot go back and enable encryption.
Skip the Table Encryption section. Table encryption can be enabled only after you create the data dictionary so its checkbox is disabled at this point. We will come back to this option later in this chapter.
You use the Database Description field to provide a description of the data dictionary. In this case, enter Sample ADS Data Dictionary.
You use the Internet Access section to configure whether or not your database can be accessed over the Internet. We are not going to enable Internet access in this example, but to do so, you check the Enabled checkbox in the Internet Access section.
If you enable the Internet Access option, you will also want to set the Security Level option to Level 0, Level 1, or Level 2. Security Level 0 provides no authentication or encryption and is recommended only for intranet access. Security Level 1 requires authentication, but the data is not encrypted before it is transferred across the network. Security Level 2 provides both authentication and 160-bit encryption, which is most appropriate when transmitting sensitive data across the Internet. If you set the Security Level option to Level 1 or Level 2, then you can use the Max Login Attempts field to disable a user’s Internet access privileges if they fail to log on after the specified number of attempts.
In addition to enabling Internet access for a data dictionary and the database itself, you must enable Internet access for individual data dictionary users, as well as for the ADS server. Enabling Internet access for individual users is described later in this chapter. You enable Internet access for ADS by defining an Internet IP Port via the Advantage Configuration Utility. This utility is described briefly in Chapter 1. See the ADS documentation for additional information on the Advantage Configuration Utility.
Finally, set the Major Version and Minor Version fields. Set Major Version to 1 and Minor Version to 0.
At first you will see a message indicating that the data dictionary was created. Accept this dialog box. Next, the following message is displayed:
Click Yes to assign a password to the data dictionary administrator’s account. Assigning a password to the ADSSYS user name of the data dictionary prevents unauthorized people from changing the data dictionary definitions. Set the password for the ADSSYS user name to password. (If this were a real database that you were adding a password to, you would use a more secure password than this one.)
Passwords for data dictionaries are case sensitive. If you attempt to access this data dictionary using the administrative user name, and the Advantage Data Architect reports that your user name or password is not correct, check to see if your CAPS LOCK key is on.
Once you have entered the password twice and click Save to accept the Change Password dialog box, you will see the following dialog box, informing you of the name of the data dictionary:
After you accept this final dialog box, the Advantage Data Architect displays the new data dictionary in the Advantage Database Manager, as shown in Figure 4-2.
Figure 4-2: The DemoDictionary data dictionary in the Advantage Database Manager
As you can see in Figure 4-2, the Advantage Database Manager is roughly divided into two sections. On the left side is a tree view that displays the various elements of a data dictionary. The pane on the right side is used for displaying the various dialog boxes for configuring the object selected on the left. There is also a toolbar along the top that provides you with easy access to a number of the Advantage Database Manager features.
The Advantage Database Manager is also where you can enable the display of additional confirmation dialog boxes that are shown while you are working with the Advantage Data Architect. These additional dialog boxes are not displayed, by default. If you would like the additional confirmation dialog boxes displayed, which will give you more feedback while you are working with the Advantage Data Architect, select Yes for the Message Dialogs option, which is located at the top right of the Advantage Database Manager shown in Figure 4-2. At a later time, you can set the Message Dialogs option to No to once again suppress the display of these additional confirmation dialog boxes.
When you first create a data dictionary, it contains only a single definition, a user named ADSSYS, which is the data dictionary administrator’s user name. This user name cannot be changed.
When you created this data dictionary, you had the option of assigning an alias to this data dictionary. An alias simplifies the process of connecting to ADS data. Not only can aliases be associated with data dictionaries, but they can also be associated with file directories containing ADS tables. Aliases also simplify your configuration of Advantage TDataSet Descendants. To create an alias for a directory, select Tools | Alias Configuration from the Advantage Data Architect main menu. The Alias Configuration Utility permits you to create, update, and remove aliases. All alias information is stored in the ADS.INI file.