|
Documentation Programming With Andromeda Defining a Database
|
Previous: Predefined Columns
Next: Foreign Keys
Reusing and Renaming ColumnsAndromeda allows you to modify the name of a column when it is placed in a table. This is useful because you can define a basic column over and over, or use a predefined column over and over. The example below adds suffixes to the price column to work up an order total. It uses entirely predefined columns. Don't worry so much about all of the automated stuff going on in this example, that is all explained later on. The important idea here is how the columns names are being extended. The basic mechanism in the example is the "suffix" property. It tells the parser to clip off the end of the column name when it looks for the base column definition. In these examples the base columns are "price" and "pct". table orders:
module: sales
description: Orders
# Begin with the price of the orders
column price_lines:
suffix: _lines
automation_id: SUM
auto_formula: order_lines.price_final
column pct_discount:
suffix: _discount
column price_discount:
suffix: _discount
chain calc:
test 00:
return: @price_lines * pct_discount .01
column price_final:
suffix: _final
chain calc:
test 00:
return: @price_lines - @price_discount
column pct_tax:
suffix: _tax
automation_id: FETCH
auto_formula: customers.pct_tax
Previous: Predefined Columns
Next: Foreign Keys
|
