Accessing Databases

Accessing Databases
The following sections describe how to set up your ActiveGrid Application to access databases.
About Database Access
ActiveGrid Applications can access a variety of different databases, including MySQL, PostgreSQL, Oracle, DB2 and MS SQL Server. A SQLite database is installed by default with the ActiveGrid Studio for testing purposes. For a complete list of supported databases, refer to the ActiveGrid Installation and Deployment Guide.
In order to interact with this wide spectrum of databases seamlessly, the ActiveGrid Studio provides the Data Model. The Data Model is based on XML Schema and you work with it in the Data Model Editor. The Data Model Editor provides a standard interface for creating and editing database tables, columns, keys and so on.
The Data Model provides a logical description of the data in a particular data source. The data source is a named connection to a specific database. ActiveGrid Applications use a Data Model based on the XML schema standard. The Data Model files in your application end with the .xsd suffix.
You can export your Data Model to your database and you can also import your database structures to your Data Model. So you can make changes in both the Data Model and the database, and then export or import them.
Data Sources
Each Data Model has an associated data source, that identifies the specific database referenced by the data model. When you create a new Data Model, you can use any data source that is currently registered in the ActiveGrid Studio or you can add a new data source through the Data Sources configuration tab (Tools > Options > Data Sources).
How the Data Model Relates to the Database
ActiveGrid’s Data Model uses complex types to represent the tables in a relational database . A complex type is a data structure that can contain multiple elements, each with its own data type. Complex types are part of the XML Schema standard. Each element in a complex type can itself be a simple type (representing a column in the table) or a complex type (representing a relationship to another complex type).
In addition to complex types, the Data Model uses elements, keys and key references from the XML schema standard to represent the database structure. The following table shows how the database structure is represented in the Data Model.L Schema, provides a logical description of the data in a database. This allows ActiveGrid Applications to access the data from different databases generically. The Data Model represents a database as shown in the following table.
 
 
In general, we will refer to items in the Data Model according to database, rather than schema terminology. However, where this might be misleading, we will use schema terminology.
The Data Service
The ActiveGrid Data Service is a special service for making database calls. The Data Service is different from other services in ActiveGrid Application because it does not have a Service Definition or defined input and output messages.
The Data Service provides a variety of operations for manipulating data, including save, commit, rollback, delete and insert. The Data Service also includes the getObject and getObjects operations. The getObject and getObjects operations return a single complex type (getObject) or a list of complex types (getObjects). For a full reference to the Data Service API, refer to “API to the Data Layer: The DataService Class” on page 99.
You can call the Data Service in one of these ways:
Click the Data Service button when setting a default value for the Page Message (“Page Message” on page 5) or a Page Variable (“Page Variables” on page 6).
Defining a Data Source
ActiveGrid applications use data sources to access databases. A data source is simply a named reference to a particular database connection. To define a new data source, follow these steps:
1.
In the ActiveGrid Studio select Options... from the Tools menu. The Options Tabs appear.
2.
Click the Data Sources tab. The Data Sources panel appears. Here you can view and edit existing data sources or define new ones.
3.
Click the Add button. A new data source, named Untitled, appears in the Data Sources list.
4.
Fill out the fields under Selected Data Source:
Data Source Name: Type in a name for the data source. Note that this is not the server hostname, but simply an arbitrary name that you use to access the data source from the ActiveGrid Studio.
Database Type: Select the type of database from the pull-down list. The list contains all supported databases. Some of the other fields in the Selected Data Source area might be disabled once you select your database type. This is because different database types require different connection information. Similarly, the value you type in the Connection String field is different for different databases.
User Name: For all databases except SQLite, you should type in the user name that you use to access this database. SQLite databases do not require authentication so this field is disabled for SQLite.
Password: For all databases except SQLite, you should type in the password that you use to access this database. SQLite databases do not require authentication so this field is disabled for SQLite.
Connection String and Database Name: These fields identify the database instance. The exact values for these two fields depend on the type of database to which you’re connecting. The following table describes the connection string and database name for each database type.
 
 
Optional. If provided it is the Oracle TNS name that identifies the database. The TNS name is defined in the tsnames.ora file for the Oracle database. The tsnames.ora file is typically located in the ${ORACLE_HOME}/network/admin directory.
 
Optional. If provided it is the network address for the PostgreSQL database. Default value is localhost.
 
When you add a Data Source of type SQLite, a new database (a new file) is created for you, if one does not already exist. The Database Name field is the path to this file, relative to the root directory.
MS SQL Server
The connection string depends on the platform on which you’re running the MS SQL Server:
Windows (PHP):ODBC datasource (the name of the configured Windows ODBC data source)
Max Pooled Connections: The maximum number of connections to keep open to the database.
Define data sources for all the databases that you plan to use using during development.
Working with the Data Model Editor
The Data Model Editor provides a uniform interface for working with all the databases that your application accesses. To see the Data Model Editor, open an ActiveGrid Application and double-click on the Data Model file (.xsd) for the application.
In addition to the Project Panel, which displays all the files for the project, the Data Model Editor contains four major panels that allow you to work with different aspects of the Data Model:
Tree View Panel: Shows and allows you to select items in the Data Model, such as tables, columns, keys and so on. When you select an element in the Tree View, its properties are displayed in the Property Editor. You can select primary and foreign keys in the Tree View and then edit their properties in theProperty Editor. (The Tree View Panel).
Data Model Editor: Displays the tables and columns. Shows relationships as lines between items. If you select a table or an element, the properties for that item appear in the Property Editor (The Data Model Editor).
Message Panel: Displays messages from the Server.
Property Editor: Allows you to view and edit the properties for the selected item.
The Data Model Editor
Each main box in the Data Model Editor represents a table. The smaller boxes within the table represent the columns for that table. The following items are represented with icons in the Data Model Editor:
Relationships: Relationships are depicted as lines between tables. An arrow indicates the “to-many” side of a relationship.
The Tree View Panel
The Tree View provides a hierarchical view of the Data Model. Click the plus icons (+) to expand an item and the minus icons (-) to collapse an item. All the keys for a particular table are listed under keys.
When you select an item in the Tree View, its properties appear in the Property Editor.
The Property Editor
The Property Editor shows the properties for the currently selected item. You can select items either in the Tree View Panel or in the Data Model Editor.
To see the properties for the Data Model itself, select the Data Model (.xsd) file in the Tree View Panel.
Data Model Properties
The Data Model has the following properties:
 
The name of the source file containing the implementation for elements bound to high level source.
You can edit these properties in the Property Editor.
Generating a Data Model
You can create a Data Model from scratch or you can use the ActiveGrid Studio to automatically generate a Data Model. Once you have a Data Model, you can modify it and then can export your modifications back to the database. You can also update the Data Model with changes in the database.
How to Generate or Update a Data Model for a Database (Import Database)
To generate a Data Model from a data source (or to update an existing Data Model from the data source), select Tools > Import Database... from the ActiveGrid Studio main menu. This launches the Import Database wizard, which walks you through the steps of naming the Data Model, selecting a data source, and selecting which tables to import.
Database Schemas
The Import Database wizard allows you to import different database schemas (for databases that support schemas) such as Oracle, DB2 and PostgreSQL. By default, the Import Database wizard imports the database schema associated with the connection information you specified when you defined the data source (Defining a Data Source).
If you want to import a different schema, or multiple schemas, click the Change Database Schema button on the first screen of the Import Database Wizard. Enter a comma-delimited list of the schemas you want to import. Complete the Import Database wizard.
Note: Database schemas are different from the schema files that ActiveGrid uses to represent data sources. Database schemas are defined within the database itself and are supported by a subset of the databases that ActiveGrid supports.
Stored Procedures
ActiveGrid Applications use standard WSDL documents to describe the stored procedures available in the database. Each stored procedure is represented by a web service operation. The input parameters are defined by a request message. The output parameters and cursors are defined by a response message.
Updating the Database from the Data Model (Export Database)
You can use the ActiveGrid Studio to update the database with changes to the Data Model. To update the database with changes from the Data Model, select Tools > Export Database... from the ActiveGrid Studio main menu. This launches the Select Data Source wizard, which walks you through the steps of naming the Data Model, selecting a data source, and selecting which types to import.
Creating Tables in the Data Model
The Data Model Editor allows you to create, delete and edit tables. You can then export your changes back to the database. Tables in the Data Model can have a different name from the corresponding table in the database.
To create a table in the Data Model, right-click in the Data Model Editor and select Insert Table... from the resulting pop-up menu. The Table Properties screen appears. Name the table and type in Plural and Singular labels for it, then click Finish. The table appears in the Data Model.
Data Model Table Properties
Data Model tables have the following properties, which you can set in the Property Editor.
 
Label that appears in forms that include this table. By default this is populated with the table’s name.
Creating Keys in the Data Model
To create a key on a table, right-click in the Data Model Editor and select Insert Key... from the resulting pop-up menu. The Key Description screen appears:
Name the key and select the table to which it belongs. If this is a primary key, click the Primary Key check box. Click Next.
The Key Fields sccreen appears. In the Available Fields list, select the Data Model columns on which you want to base the key. Use the arrow button to move these columns to the Key Fields list. You can use the up and down buttons to order fields in the Key Fields list.
Click Finish.
Data Model Key Properties
To see the properties for a key, select the key in Tree View of the Data Model Editor. You can set the following properties for keys in the Property Editor:
 
Creating Foreign Keys
Foreign keys establish a relationship between two tables. In order to create the foreign key, each table must have a key of its own.
To see the properties for a foreign key, select the key in Tree View of the Data Model Editor. You can set the following properties for foreign keys in the Property Editor:
 
The name of the key of the foreign table that contains the fields to which this key’s fields are related.
Creating Columns in the Data Model
The columns that you can create in the Data Model do not have to be database columns. The Data Model allows you to create pseudo-columns that are not written back to the database. When you create a new column, you choose what kind of column you want:
Database Columns: A column in the Data Model that gets its value from a column in the database or from a computation involving an column or columns from the underlying table. Select: Database column or expression.
Computed columns: A column that is populated by a performing a calculation on data in another column. Computed Columns can be read-write or read only. Computed Columns are stored in the Data Model but are not part of the database. There are three types of computed column.
Computed with an XPath expression: A Computed Column that derives its value from an XPath expression. Computed Columns are stored in the Data Model but are not part of the database.
Computed with Custom Code: A Computed Column that uses a Python or PHP method to compute its value. Computed Columns are stored in the Data Model but are not part of the database.
Computed relationship to Another Table: This computed column uses a custom method to produce the result. It is also a relationship type column, but you don’t need a foreign key to link the tables for this type of column.
Relationship columns: A column that is populated with data from another table. In the Data Model Editor, relationship columns are indicated by a green double-arrow icon. Relationship Columns are stored in the Data Model but are not part of the database.
Relationship to another complex type: You can add this type of relationship column only after you create a foreign key linking the two tables.
Database Columns
Database columns are columns in your Data Model that correspond directly to either a column in your database column or to an expression involving columns in your database.
Database Column
In the Data Model, a Database Column represents a column in the associated database. The column in the Data Model does not have to have the same name as the column in the database. Name the column anything you want in the Data Model and then use the Binding Property to bind the column to a specific column in the database.
The Binding property specifies the column in the database to which this (Data Model) corresponds. When you set the Binding property, be sure to type in the name of the column exactly as it appears in the database.
To create a new Database Column in the Data Model, follow these steps:
1.
In the Data Model Editor, right-click and select Insert Column... from the resulting pop-up menu. The Column Description screen appears.
2.
In the Column Name field, type in the name for this column in the Data Model. This name does not have to match the name of the corresponding database column.
3.
From the Table pull-down menu, select the Data Model table to which this column belongs.
4.
For Column Kind, click the Database Column or Expression radio button.
5.
From the Column Type pull-down menu, select the type of data that this Data Model column contains.
6.
Click Next. The Column Properties screen appears. Here you set the properties for this Data Model Column. These properties are described in Database Column Properties. At a minimum, you need to set the SQL Type, Length and Binding properties.
For Binding, type in the name of the column (as it appears in the database) to which this Data Model column corresponds.
Database Expression Column
In the Data Model, a Database Expression Column represents a calculation based on one or more columns in the associated database. Use the Binding Property to specify the database columns and operations.
When you set the Binding property, you can type in any of the following to build your expression:
To create a new Database Expression Column, follow thes steps for creating a Database Column in the Data Model. Then, for the Binding type your expression, including the names of any column that appear in the database.
For example, suppose you have a database table called itemDB that is represented in the Data Model by a table, called itemDM. The itemDB table contains two columns, called price and cost. But the itemDM table actually contains three elements: ListPrice (bound to the price column) UnitCost (bound to the cost column) and Margin (bound to the price and cost columns).
 
Data Model Columns
 
The Margin column in the Data Model is actually a calculation on the two database columns, price and cost.
Database Column Properties
The following properties can be set in the Property Editor:
 
XML schema type of the column. Used to determine the implementation language type (for example, PHP, Python).
The SQL 2003 data type of the column to which this element is bound. Used when creating DDL statements and when converting values read from/written to the database.
For fixed precision or floating point type elements describes the total number of digits of precision stored in the database for the column to which this element is bound. This property is optional and only appears for fixed precision or floating point type elements.
For fixed precision or floating point type elements describes the number of digits allowed after the decimal point in the database for the column to which this element is bound. This property is optional and only appears for fixed precision or floating point type elements.
The type of binding for this element. Will be “database”. Database elements can be converted to XPath elements by switching this to “XPath”.
Label used in forms including this element. By default this is populated with the element’s name but may be overridden by the user.
The default value to which this element should be set when creating new instances of the object implementing the complex type.
XPath-Computed Columns
This type of Data Model column derives its value from an expression involving other columns in the Data Model, (rather than database columns). XPath-computed columns are stored in the Data Model only. You cannot export them to the database. Use the Binding Property to specify the XPath expression.
When you set the Binding property, you can type in any of the following to build your expression:
The name of any column in the current table (the table to which you’re adding the column)in the Data Model .
XPath to a column in a different table (OtherTable/SelectedColumn). You can do this only if there is a relationship between the current table and the table that contains the column you’re referencing.
Any valid non-aggregate SQL function supported by your database (for example, upper, lower, trim, abs, concat, and so on).
The following table lists valid XPath expressions and operations for XPath-Computed Columns:
 
*
-
Note: To do null comparisons, use the null() function combined with = or !=.
To create a new XPath-computed Column in the Data Model, follow these steps:
1.
In the Data Model Editor, right-click and select Insert Column... from the resulting pop-up menu. The Column Description screen appears.
2.
In the Column Name field, type in the name for this column in the Data Model.
3.
From the Table pull-down menu, select the Data Model table to which this column belongs.
4.
For Column Kind, click the Computed with an XPath Expression radio button.
5.
From the Column Type pull-down menu, select the type of data that this Data Model column contains.
6.
Click Next. The Column Properties screen appears. Here you set the properties for this Data Model Column. These properties are described in Database Column Properties. At a minimum, you need to set the SQL Type, Length and Binding properties.
For Binding, you can type in Data Model columns from the current table, XPath to columns from a related table, and XPath expressions.
For example, suppose you have a Data Model that contains two tables called item and product. Each of these tables has a column that represents a column in the database:
 
Now you want to add an column called ListPrice to the item table. The ListPrice item is the product of the UnitMarkup column from the product table and the UnitCost column from the item table. Since the calculation involves a column from another table, you need to use XPath to represent that column.
The computation for ListPrice on the item table now looks like this:
 
Notice that the binding for ListPrice references the markup column of the related product table. In order for this to work, the item table must have a column named product that is a relationship type (Creating Keys in the Data Model).
Finally, if you want to add a calculated column that includes a binding to your XPath column, that new column must also be an XPath column. For example, suppose you create an column called Margin, equal to the difference between the ListCost and the UnitMarkup. The Margin column must be bound to an XPath expression. This is because Margin must now be calculated with the ListPrice column, which is itself bound to an XPath expression.
 
The XPath expression is evaluated outside of the database and can make use of one-to-one relationships defined on the table containing the column. XPath columns are read-only.
XPath -Computed Column Properties
The following properties can be set in the Property Editor:
 
Name of the element. Used as the name of the attribute in the object which holds the value of the element at run-time.
The XML schema type of the element. Used to determine the implementation language (e.g. PHP, Python) type.
The SQL 2003 data type of the column to which this element is bound. Used when creating DDL statements and when converting values read from/written to the database.
The XPath expression which computes the value of the element. Any other element in the complex type may be used in the expression except those that reference other complex types with a multiplicity greater than 1 (i.e. max occurs > 1).
The type of binding for this element. Will be “XPath”. XPath elements can be converted to database elements by switching this to “database”.
Label used in forms including this element. By default this is populated with the element’s name but may be overridden by the user.
The default value to which this element should be set when creating new instances of the object implementing the complex type.
Custom-Code Computed Columns
This type of column is computed by a Python or PHP method defined in a separate file associated with the Data Model. When you create a computed column the, Data Model Editor creates a method prototype for you in a Python or PHP file.
In the Dependent Columns: field, list all the elements that are used to compute the value. This is a comma-separated list of XPath expressions. For example, suppose the computation uses the UnitCost element from this complex type and the UnitMarkup element, from the prod complex type. In the Dependent Columns field, you would type the following:
UnitCost, prod/UnitMarkup
The code file has the same name as the Data Model file, but with the suffix xsd.py or xsd.php. So, for example, if the name of the Data Model is MyDataModel.xsd, then the code file is either MyDataModelxsd.py or MyDataModelxsd.php, depending on which language you selected. (Python files have the .py suffix and PHP files have the .php suffix).
The name of the method is name of the complex type and the name of the element, separated by an underscore (complexTypeName_elementName).
The method is always passed an object filled with the values from the complex type on which the element is defined. For example, if the name of the complex type is item and the name of the element is ListPrice, the method prototype in Python would look like this:
def item_ListPrice(item):
return None
Fill in the method implementation and save the code file. For example, your Python method might look something like this:
if (item.cost < 10.5):
return item.UnitCost * (item.product.Markup * 2) + 1.25
elif (item.cost < 50):
return item.UnitCost * (item.product.Markup * 1.5)
+ (item.product.Markup * 5.25) + 1.25
else:
return item.UnitCost * item.product.Markup
+ (item.product.Markup * 25) + 1.25
Properties for Custom-Code Computed Columns
The following properties can be set in the Property Editor:
 
Name of the element. Used as the name of the attribute in the object which holds the value of the element at run-time.
The XML schema type of the element. Used to determine the implementation language (e.g. PHP, Python) type.
For fixed precision or floating point type elements describes the total number of digits of precision stored in the database for the column to which this element is bound. This property is optional and only appears for fixed precision or floating point type elements.
For fixed precision or floating point type elements describes the number of digits after the decimal point stored in the database for the column to which this element is bound. This property is optional and only appears for fixed precision or floating point type elements.
A comma separated list of XPath expressions identifying which elements will be used by the function performing the computation.
The type of binding for this element. Will be “High Level Language”. This is a read-only attribute.
Label used in forms including this element. By default this is populated with the element’s name but may be overridden by the user.
Computed-relationship Columns
This is like a computed column as it has a custom method you implement to produce the result. The difference is that the type can be another table type, like a relationship.
To create a new Computed-relationship Column in the Data Model, follow these steps:
1.
In the Data Model Editor, right-click and select Insert Column... from the resulting pop-up menu. The Column Description screen appears.
2.
In the Column Name field, type in the name for this column in the Data Model.
3.
From the Table pull-down menu, select the Data Model table to which this column belongs.
4.
For Column Kind, click the Computed Relationship to Another Table radio button.
5.
From the Column Type pull-down menu, select the type of the table you’re referencing.
6.
Click Next. The Computed Relationship Properties screen appears. Here you set the properties for this Data Model Column:
In the Dependent Columns: field, list all the elements that are used to compute the value. This is a comma-separated list of XPath expressions. See Custom-Code Computed Columns.
In the Multiplicity: field, select the multiplicity of the relationship you’re creating.
7.
Click Finish. A code file opens with a skeleton method for the column. Complete the method and save the file.
For example, add a Computed Relationship column to the product table in the PetStore demo database. For the Dependent Columns field, type in:
items
For the method, use the following:
def getCheapestItem(product):
cheapestItem = None
cheapestPrice = sys.maxint
for item in product.items:
if item.listprice < cheapestPrice:
cheapestPrice = item.listprice
cheapestItem = item
return cheapestItem
getCheapestItem = staticmethod(getCheapestItem)
This returns the item with the lowest price.
Properties for Computed Relationship Columns
The following properties can be set in the Property Editor:
 
Name of the element. Used as the name of the attribute in the object which holds the value of the element at run-time.
The XML schema type of the element. Used to determine the implementation language (e.g. PHP, Python) type.
A comma separated list of XPath expressions identifying which elements will be used by the function performing the computation.
The type of binding for this element. Will be “High Level Language”. This is a read-only attribute.
Label used in forms including this element. By default this is populated with the element’s name but may be overridden by the user.
Working with Relationship Columns
The Relationship kind of column references another table in the Data Model. In this case the type of the element is that of the referenced complex type.
In order to create a relationship element, there must already exist a foreign key on the table. The choices of multiplicity depend on which side the foreign key is placed. See Creating a Relationship Between Tables.
To create a new Relationship Column in the Data Model, follow these steps:
1.
In the Data Model Editor, right-click and select Insert Column... from the resulting pop-up menu. The Column Description screen appears.
2.
In the Column Name field, type in the name for this column in the Data Model.
3.
From the Table pull-down menu, select the Data Model table to which this column belongs.
4.
For Column Kind, click the Relationship to Another Table radio button.
5.
From the Column Type pull-down menu, select the table you’re referencing.
6.
Click Next. The Relationship Properties screen appears. Here you set the properties for this Data Model Column:
In the Foreign Key: field, select the foreign key you’re using for this relationship.
In the Multiplicity: field, select the multiplicity of the relationship you’re creating.
7.
Click Finish.
The relationship column appears in the specified table.
Properties for Relationship Columns
The relationship element has the following properties:
 
Label used in forms including this element. By default this is populated with the element’s name but may be overridden by the user.
Specifies the maximum cardinality for this relationship. Should be 1 or -1. The value -1 is used to signify no upper bound.
Creating a Relationship Between Tables
To establish a relationship between tables, both tables must have keys and there must be a foreign key establishing a relationship between the two tables (Creating Foreign Keys). You can then create a relationship column (Working with Relationship Columns) in one table that references the other table.
For clarity, we’ll describe this process by example. Assume that we have a Data Model that contains two tables: Product and ProductCategory. Further, assume that the Product table contains the following columns and primary key:
 
 
Assume that the ProductCategory table contains the following columns and primary key:
 
 
We want to create a column called productsInCategory, in the productCategory table. The productsInCategory column contains the list of products that belong to this category. In order to populate this list, we establish a relationship between the two tables, productCategory and product:
1.
First we need to create a foreign key that joins the two tables. Create a foreign key called category_keyRef in the product table (Creating Foreign Keys). The category_keyRef foreign key should reference the category_pk key from the productCategory table.
2.
3.
Now you can insert a relationship column called products into the productCategory table. In the Column Description dialog, be sure to select the Column Kind, Relationship to another table.
This creates the products column in the ProductCategory table. The products column is actually a relationship column referencing the product table.
Generating Key Values
There are three ways to generate new key values:
Using the ActiveGrid Key Generation Service to Generate Key Values
To generate key values using the ActiveGrid Key Generation Service, follow these steps:
1.
Open the project file (.agp) in the ActiveGrid Studio.
2.
In the Project Panel, double-click on the .xsd file for the project. The file opens in the Data Model Editor.
3.
From the Tree View window in the bottom left-hand corner, expand the table that contains the key for which you want to generate values.
4.
5.
6.
The Inspecting:Fields screen appears.
7.
In the row for the field you want to populate with the key-generation service, double-click on Generation Type and select a generation type from the pull-down menu (Generation Types for the Key Generation Service).
8.
Key Generation Service configuration is now complete.
Generation Types for the Key Generation Service
ActiveGrid provides an embedded key generation service that supports three algorithms: random number, timestamp, and sequence:
Random number: The random algorithm generates a random number between the configured “minRandom” and “maxRandom” values. The number sequence can be initialized by specifying “randomSeed”.
Timestamp: The timestamp algorithm generates a value from the current UTC date/time using a format specification defined by the implementation language. For Python this is defined by the time.strftime function. For PHP this is defined by the date function.
An extension to the timestamp formatting directives is %q which formats the fractional seconds (microseconds) of the current time. The default format returns a number with year, Julian day, hour, minute, second, and microsecond.
Sequence: This is a database-generated unique sequence. The sequence algorithm retrieves the next value generated by the database sequence generator named by the “sequenceName” for the field. Databases supporting sequences include: Oracle, DB2, and PostgreSQL. For MySQL, you need to use AUTO_INCREMENT columns (“Generating New Key Values Using MySQL AUTO_INCREMENT Columns”).
A given key can use only one key generation service, but each field in the key can use a different algorithm.
Configuring the Key Generation Service at Deployment Time
The key generation service can be configured at deployment time, by editing the deployment file. Configuration parameters include the following:
 
 
Generating New Key Values Using MySQL AUTO_INCREMENT Columns
MySQL does not support database sequences to generate new key values. It does support AUTO_INCREMENT columns however. To generate key values using the AUTO_INCREMENT column, follow these steps:
1.
Open the project file (.agp) in the ActiveGrid Studio.
2.
In the Project Panel, double-click on the .xsd file for the project. The file opens in the Data Model Editor.
3.
From the Tree View window in the bottom left-hand corner, expand the table that contains the key you want to auto increment.
4.
5.
6.
In the Property Editor (located in the upper right of the ActiveGrid Studio, double click the Fields property. The Inspecting:Fields screen appears.
7.
In the row for the field you want to auto-increment, double-click on Generation Type and select auto-increment from the pull-down menu.
8.
AUTO_INCREMENT configuration is now complete.
 

ActiveGrid
Application Developer's Guide
Version 2.0