The column element

Columns in C-Phrase correspond exactly to the SQL notion of a column. From the Products table from northwind.cphrase, consider the column element:

    <column id="unitprice"
        type="int"
        notnull="true"
        lex="unit price,unit prices,price,prices"
        units="USD"/>
    

More abstractly column elements have the following DTD-based definition:

<!ELEMENT column (value|set_value|max|min|map)*>
<!ATTLIST column
          id CDATA #REQUIRED
          type CDATA #REQUIRED
          lex CDATA #IMPLIED
          select CDATA #IMPLIED
          properties CDATA #IMPLIED
          notnull CDATA #IMPLIED
          default CDATA #IMPLIED
          units CDATA #IMPLIED
          alive CDATA #IMPLIED
          description CDATA #IMPLIED>

id is the exact identifier of the column in the underlying database table (e.g. unitprice in table products).

type is the type of the column. In C-Phrase this may be one of: text, int, real, memo, boolean, date, timestamp or file.

lex is a comma separated set of phrases that are attached to the column. The first phrase gives the preferred singular form (e.g. 'unit price') while the second gives the preferred plural form (e.g. 'unit prices'). Additional phrases after the second can then be specified in any order. We say 'preferred' because C-Phrase will use the first two phrases when generating paraphrases of queries.

select determines whether the column can be selected (in the SQL sense) via natural language. Defaulting to "true", the value "false" means that select is disabled. Note if you wish to update attribute values, this must be "true". Typically, foreign keys and attributes not of interest to users will have select turned off.

properties gives a specification of what types of conditions may be posed over the column as well as how references to column values should be handled. This specification is a comma separated sequence of properties with special meanings defined below.

notnull defaults to "false" but, if "true", signals that the value can not be NULL in the underlying database.

default gives the SQL-based expression which expresses what the default value of the column is. In SQLite for literals, this is just the bare value, but for expressions this must be enclosed in parentheses. So default="2" for attribute priority, but default="(date('now'))" for the column posted.

units is the measure associated with a numerical value. The value of "USD" will present the numbers as currency values in US dollars.

Sub-elements

Columns may contain literal values, set values, as well as min/max values as sub-elements. There is also a special, but only rarely used, map element which builds synonyms to column values via SQL executed at load-time from the underlying database.

Column Properties

Much of the nuance in C-Phrase is captured by setting specific properties on columns. Here we describe how to set these properties and what type of behaviors they specify.

All the properties on columns are atomic and are turned on or off via +property or -property respectively. For example:

    <column id="date" type="date" properties="+inequalities,+value-stands-for-column,-superlatives"/>

A properties specification is processed from left to right adding or taking away a given property. This is all done relative to the default column properies set in the parameters of an NLI (specifically see the Lexicon parameters). A special keyword "none" turns off all the properties which may then be followed by a turning some properties back on. For example:

    <column id="id" type="int" properties="none,+value-stands-for-column,+equalities"/>
Condition properties

Condition properties control what type of natural language conditions can be expressed over the column. This usually determines what type of conditions can be built in the WHERE clause of the query, but it also includes whether you can group on certain columns.

The following table shows the set of condition properties applicable for each type:

NUMERIC
(int,real)
TEXT BOOLEAN TEMPORAL
(date,timestamp)
MEMO FILE
comparisons,
equalities,
grouping,
inequalities,
nulls,
sets,
superlatives,
totalling
comparisons,
equalities,
grouping,
inequalities,
like,
nulls,
quotes,
sets
equalities,
inequalities,
nulls
comparisons,
equalities,
grouping,
inequalities,
nulls,
sets,
superlatives
like,
nulls
equalities,
inequalities,
nulls
Reference properties

Reference properties determine how columns and their values may be referenced by the user.

The following table shows the set of reference properties applicable for each type:

NUMERIC
(int,real)
TEXT BOOLEAN TEMPORAL
(date,timestamp)
MEMO FILE
aggregation,
column-stands-for-table,
project,
value-stands-for-column
column-stands-for-table,
completions,
materialization,
menu,
plurals,
project,
value-stands-for-column,
value-stands-for-table
project
column-stands-for-table,
project,
value-stands-for-column
column-stands-for-table,
project
column-stands-for-table,
project,
value-stands-for-column