Home → Active Query Builder → Designing user-friendly query building environment → Alternate database object and field names
4.1. Alternate database object and field names
The Alternate Names feature for both database objects and their fields lets completely substitute real names of objects for clearer descriptive names. So it's possible to simplify understanding of database structure and consequently building of queries to end users. 'Complete substitution' means substitution of objects names in both user interface, SQL expressions and in the query text which can be edited manually by end user along with visual query building. Active Query Builder lets assign an alternate name to every object and field of the database object loaded to the metadata container. On parsing a query, the component is able to recognize both real and alternate names of fields. Therefore this component is able to build visual presentation of a query with both types of names. This allows represent to an end user clearer presentation of existing queries.
Generation of the query text may be made using both real and alternative names; the UseAltNames property of PlainTextSQLBuilder component determines what names to use. Whereas several PlainTextSQLBuilder components may be connected to one QueryBuilder component, you may get two variants of query text simultaneously: one for an end user and another for executing query on the server. The same named property of the QueryBuilder component is responsible for displaying of real or alternate names in user interface.
Some customers even use this peculiarity for refactoring in database structure running the suite of existing queries through the component and getting as a result queries with new names of fields and objects.
It is possible to assign alternate names in several ways.
Save metadata into XML file, add alternate names into it (manually using the "alt_name" tag for fields and objects or with the help of the metadata editor) and then load metadata from this file instead of retrieving metadata from the connection with database.
Use the QueryBuilder.MetadataContainer MetadataObjectLoaded and ObjectMetadataLoaded events to assign alternate names to objects and their fields (respectively) during their loading to the metadata container. For example, you may use descriptions of the objects being loaded by the component from database as alternate names.