Value Type, Database, and Data Association Model Elements
Figure 2 illustrates the value type, database, and data association element categories that are located in the Data Dictionary
node in the AOT. Configuration key elements can be associated with base
enumeration and extended data type elements as well as with table,
view, and map elements. Table, view, and map application elements can
also be associated with security key elements.
Value Type Model Elements
A base enumeration element (sometimes shortened to enum)
defines a name for a group of symbolic constants that are used in X++
code statements. For example, an enumeration with the name WeekDay can be defined to name the group of symbolic constants that includes Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday.
An extended data type element
can extend a base enumeration by providing a new name for a group of
symbolic constants that includes the base enumeration elements. An
extended data type element can also extend the string, boolean, int, real, date, time, UtcDateTime, int64, guid, and container types. An extended data type definition can also comprise a set of
application parameters that define how the Dynamics AX runtime renders
user interface controls. For example, an extended data type representing
an account number extends a string value type, restricts its length to 10 characters, and sets its user interface label to “Account number.”
Extended data types
also support inheritance. For example, an extended data type that
defines an account number can be specialized by other extended data
types defining customer and vendor account numbers. The specialized
extended data type inherits properties, such as string length, label,
and help text. You can override some of the properties on the
specialized extended data type. You constrain the possible values of an
extended data type and define a database table association by adding a
relationship from the extended data type to a table field element. The
Dynamics AX runtime automatically ensures that the values of the
extended data type are consistent with this relationship. The runtime
also uses the defined relationship to navigate between rich client and
Web client main table forms when a user selects the Go To The Main Table
Form menu item. This menu item appears when a user right-clicks a form
data grid column that is mapped to a table element field whose type is
an extended data type with a defined relationship.
Database Model Elements
Database model elements
are database table and view definitions that correspond to database
server entities and relationships as well as query elements that define
database query statements. The MorphX IDE synchronizes table and view
element definitions with database schema definitions. This feature
allows Dynamics AX to use either Microsoft SQL Server or Oracle database
server as an application database. MorphX synchronizes only those
database elements that have configuration keys enabled and corresponding
valid license keys.
Database element keys
and indexes are used to create database entity keys and indexes, but
data element interrelationships are not used to create integrity
relationships in a database. Instead, they validate data entries to
automatically join and select database data as a user navigates between
forms, and they join data sources associated with a form. For example, a
user sees confirmations only for the selected sales orders when
navigating from a sales order form to a sales order confirmation form.
Moreover, MorphX automatically converts between X++ programming value
types such as string, enum, and boolean and their corresponding database data types, such as nvarchar and int. For example, an X++ string defined to have a maximum length of 10 characters is stored as a database nvarchar data type defined to have a maximum length of 10 characters.
A table element can also
define table field groups, menu item references, table relationships,
delete actions, and methods that are used by the Dynamics AX runtime
when it renders data entry presentation controls and ensures the
referential integrity of the database. The X++ editor also uses these
elements to support developers with IntelliSense when they write X++ statements
that create, read, update, and delete data in the database. You can
also use the AOT to associate table elements with data source elements
on forms, reports, queries, and views.
View elements define
database table view entities and are synchronized with the application
database. View elements can include a query that filters data in a table
or data joined from multiple tables. View element definitions also
include table field mappings and methods. Views are read-only and
primarily provide an efficient method for reading data. View elements
can be associated with form and report data sources and are instantiated
in X++ variable declarations.
Query elements
define a database query structure that can be executed from X++
statements, particularly X++ statements used in classes that derive from
the RunBase
class. You add tables to query element data sources and specify how they
should be joined. You also specify how data is returned from the query,
such as by using sort order and range specifications.
Note
You
don’t have to use the query element as form and report data sources
because these data sources have a similar built-in query specification
capability. |
Data Association Model Elements
Map elements
don’t define database entities, so they’re not synchronized with the
database. They actually define X++ programming elements that wrap table
objects at run time. Map elements associate common fields and methods
for tables that are not in third-normal form. For example, the CustTable and VendTable table elements in the Dynamics AX application model are mapped to the AddressMap map element so that developers can use one AddressMap
object to access common address fields and methods. The MorphX compiler
validates that table variables assigned to map variables are defined as
valid element mappings.
Note
Maps
provide a useful common interface to data entities and prevent the need
to duplicate methods on denormalized tables, but you should use maps
only when normalization isn’t an option. |
Table collection
elements define groups of tables that can be shared by two or more
Dynamics AX companies that share virtual company accounts. The
application administrator creates a virtual company and then adds table
collections to it. The administrator also adds the virtual company
accounts to an actual Dynamics AX company’s accounts. The Dynamics AX
runtime uses the virtual company data area identifier instead of the
actual company data area identifier when it inserts or reads data in the
tables in the table collection.
Caution
The
tables placed in a table collection shouldn’t have foreign key
relationships with tables outside the table collection unless specific
extensions are written to maintain the relational integrity of the
database. |
Perspective elements
define views on the Dynamics AX database model by grouping related
tables. Perspectives are used to design and generate ad hoc reports in
Microsoft SQL Server Reporting Services.
Class Model Elements
Class elements
define the structure and behavior of business logic types that work on
ERP reference data and business transaction data. These elements
comprise object-oriented type definitions that instantiate business
objects at run time. You define type declaration headers and methods by
using the X++ programming language. You associate rich client and Web
client menu item elements in the AOT with class element methods by using
the property sheet in MorphX. This allows the Dynamics AX runtime to
instantiate corresponding business logic objects when users select
action, display, or output menu item controls on a user interface.
The Dynamics AX
runtime also invokes business object methods when they overload event
handlers on tables, forms, and reports. Class elements are also defined
for application integration scenarios that aren’t driven by a user
interface.