ELEMENT view (description?, grant*, field+, select*)> ATTRIBUTE name string readonly bool tables string where string orderby string sorting string checkoption string title string
Attributes | Type | Mandatory | Default | Description |
---|---|---|---|---|
name | string | yes | n/a | An unique name that identifies this view. It should be lowercased and a valid XML and SQL identifier. |
readonly | bool | - | no | You may set the view to be read-only to prevent any changes. A view that is "read-only" is not updatable. |
tables | nmtokens | - | n/a | A comma-separated list of tables used in the current view. If the list contains more than one table, the first is the base table and all other tables are joined to this. For don't forget to define a where-clause for all joined tables. |
where | string | - | n/a | This is a generic information. It sets the where-clause of the view. |
orderby | string | - | n/a | A comma-separated list of columns, after whose the output is sorted. By default the table-output is ordered by it's primary-key. |
sorting | string | - | ascending |
|
checkoption | string | - | none |
|
title | string | - | n/a | The title is a label text that should be displayed in the UI when viewing this object. |
The "view" element defines the name, documentation and generic properties of a database view. These are it's base tables, where-clause and other information, which should allow an application to map elements of the view to elements of real tables. This should enable an implementation to simulate simple and updatable view for such DBMS, that don't support this feature. An implementation may use the generic information for the simulation of views. The implementation may throw an error message, if it is not possible to simulate the view and the DBMS doesn't support the requested feature.
The software must consider a view to be "updatable", unless the attribute "readonly" is set to "yes". It may however decide that the view is not updatable, if a required primary key is missing. Where applicable the implementation may automatically add a primary key column to the generic query, to make the view updatable. For DBMS that don't support updatable views, the implementation may simulate these by generating insert or update statements based on the given generic information. The implementation may throw an error if the user tries to update a view for such DBMS and it is unable to simulate the desired behavior.
The attribute "where" defined the where-clause of the view. This information must be taken into account when simulating the views. The implementation may define the required syntax of this element itself. Note! The following example is not recommended "time < now()" since the function "now()" may not be compatible between various DBMS. However, you may define explicit SQL-statements for any target-DBMS of your choice. The syntax for generic where-clauses, as supported by the Yana Framework, is: {[column]=[value]{ AND [column]=[value]}*}.
The attribute "checkoption" influences the evaluation of the where-clause. The difference between 'local' and 'cascaded' applies only to situations, where a view is built recursively upon another view and the parent view declares a check-option itself. If this is the case, the setting 'local' will prevent the DBS from recursively evaluating the check option(s) of the parent view(s). Note that this is not supported by all DBMS.
For example, MySQL and PostgreSQL both support this feature, while MSSQL does not.
ELEMENT select (#PCDATA) ATTRIBUTE dbms string
Attributes | Type | Mandatory | Default | Description |
---|---|---|---|---|
dbms | string | - | generic | The name of the target DBMS. The value "generic" means that the definition is suitable for any DBMS. Usually this is used as a fall-back option for DBMS you haven't thought of when creating the database structure or for those that simply doesn't have the feature in question. |
The "select" element is a DBMS-dependent SQL-statement. It must comply with the defined names of the base tables, fields and other properties of the view. For simple views the generic information may already be enough, so that no additional select elements need to be defined. Thus you should avoid the select element where possible.
ELEMENT field EMPTY ATTRIBUTE table string column string alias string
Attributes | Type | Mandatory | Default | Description |
---|---|---|---|---|
table | string | - | n/a | Name of base table |
column | string | - | n/a | Name of base column |
alias | string | - | n/a | optional alias |
A column reference, that identifies the name of a column in the view (see attribute "alias") with the names of the physical table and column it is based on.
Thomas Meyer, www.yanaframework.net