once:radix open source downloads | once:radix open source documentation
once:technologies
  • Home
  • Software
  • Services
  • News
  • Testimonials
  • Contact
 

once:radix Documentation

  • once:radix
    • Overview
    • Getting started
    • Fundamentals
    • oADMIN
    • oCLI
    • oED
    • Database
    • Scripting
    • Models
    • Directories
    • Technical Notes

once:editor Database Manager

once:radix is based on PostgreSQL – The world's most advanced open source database. There are several excellent texts written about PostgreSQL, so this section will focus only on issues that are specific to the once:radix platform.

The system is distributed with a minimal database, which includes security, system administration and enough contact data to register users. To this basic database you can build a system to be as simple or as complex as you wish.

Before we begin, it is worth noting that you can build quite advanced applications without knowing much about database design, using the power of blocks and subblocks. So a cursory readthrough of the basic concepts introduced here will get you up and running.

The Glossary at the end of this section introduces some basic database terms, as they apply to once:radix:

Database Basics

A single database table is similar in concept to the rows and columns of a spreadsheet. While this can be used for basic forms design, it is limited when building even simple data structures.

Example: To store details for an invoice, one row could hold all of the customer name, address details, invoice number, date, invoice total, etc. But if you want to store the transaction details for each item (e.g. description, quantity, unit cost and total item cost), the spreadsheet needs a set of four extra columns for each line item. This is fine if you know that you will never have more than, say, eight items per invoice. You could add eight sets of extra columns (in this example, a total of 32 extra fields).

There are two obvious disadvantages to this approach: Firstly, you can't have nine (or more) items on an invoice. Secondly, there will be a lot of wasted space. e.g. If the average number of items per invoice is three, that would leave (on average) 20 empty fields per record.

A relational ratabase solves this problem: By creating a second table to hold the transaction lines, ANY number of items can be attached to each invoice. Also, storage is far more efficient; though relational databases do have some small storage overheads: A field is added to each table of the database (the primary key) and in this example, there will also need to be an extra field added to the transaction lines (a foreign key). Despite these extra fields, a relational database is far more compact than a 'flat' data file.

In this example, the header data (primary key, customer's address details, invoice number, date, invoiced total) are stored in the parent table (invoiceheader). The item details (primary key, foreign key, description, quantity, unit cost and total item cost) are stored in the child table (invoiceitem), as one record per item.

The primary key in each record of a table is unique. By storing a copy of the primary key of the parent record in the foreign key of each child record, a link (or relationship) can be created between the parent and all of its child records.

A typical request to the database could be: "SELECT the UNIQUE invoiceheader record whose primary key = 1001 and SELECT ALL invoiceitem records whose foreign key = 1001".

This example would return one parent record (assuming that there is an invoice header record with a primary key of 1001) appended to each of four child records that have their foreign key fields set to 1001. It would look something like this:

1001Joe Smith11 Smith St1/4/08123.00153.8912310011black widget123.00123.00
1001Joe Smith11 Smith St1/4/08123.00153.89124100111red widget11.00121.00
1001Joe Smith11 Smith St1/4/08123.00153.89125100110blue widget9.9099.00
1001Joe Smith11 Smith St1/4/08123.00153.891261001100tan widget9.99999.00

There are several ways to link tables in a relational database, once:radix supports four of these: Inner Join, Left Outer Join, Right Outer Join and Full Outer Join. This example would use a left or right outer join.

Left Outer Join

The PostgreSQL statement for this example would be:

SELECT *
FROM "accounts"."invoiceheader" LEFT OUTER JOIN "accounts"."invoiceitem"
ON ("accounts"."invoiceheader"."primary" = "accounts"." accounts"."invoiceitem"."fkinvoice")
WHERE ("invoiceheader"."primary" = '1001')

SELECT * means: 'Return all fields in the tables invoiceheader and invoiceitem of the records that meet the search criteria of the WHERE clause.'

In a Left Outer Join all records in the table on the left side of the join statement that meet the join criteria are returned, regardless of whether there are related records on the right hand side. So, in this case, if an invoice had been created but no transaction items had been entered, the parent records would still be returned.

FROM ... LEFT OUTER JOIN ... ON ... describes the link between the two tables.

Right Outer Join

The right outer join is a mirror image of the left outer join. This same select example would be:

SELECT *
FROM " accounts"."invoiceitem"RIGHT OUTER JOIN " accounts"."invoiceheader"
ON ("accounts"."invoiceitem"."fkinvoice" = "accounts"."invoiceheader"."primary")
WHERE ("invoiceitem"."fkinvoice" = '1001')

SELECT * means: 'Return all fields in the tables invoiceheader and invoiceitem of the records that meet the search criteria of the WHERE clause.'

In a Right Outer Join all records in the table on the right side of the join statement that meet the join criteria are returned, regardless of whether there are related records on the left hand side. So, in this case, if an invoice had been created but no transaction items had been entered, the parent records would still be returned.

FROM ... RIGHT OUTER JOIN ... ON ... describes the link between the two tables.

While the right join performs exactly the same function as the left join, most database textbooks recommend (for consistency and ease of troubleshooting) to always use the Left Outer Join.

Inner Join

Though less commonly used than the Left Outer Join, the Inner Join can be useful where records in one table are linked to one (and only one) record in another table.

For example: To find all records for every person who is a member of an organisation (while excluding people who are not members of an organization) in the database distributed with the once:radix package , there is an inner join between the person and personmember tables. It is done this way because every person is linked to an organization through the personmember table.

SELECT *
FROM "personmember" INNER JOIN"person"
ON ("personmember"."fkperson" = "person"."primary")
WHERE ("personmember "."fkperson" IS NOT NULL)

SELECT * means: 'Return all fields in the tables personmember and person of the records that meet the search criteria of the WHERE clause.'

That is, only those records in the table on the left side of the join that link to one (and only one) record on the right side are returned. So, in this case, only people who are members of an organisation would be returned.

FROM ... INNER JOIN ... ON ... describes the link between the two tables.

Full Outer Join

Most database textbooks recommend that the Full Outer Join should never be used as it usually indicates a poorly designed database. There may be situations where use of this join is justified, however it is beyond the scope of this introductory text.

Conclusion

once:radix supports four join types. Of these, the Left Outer Join is used more than 90% of the time.

The Inner Join is most often used when filtering is needed (e.g. Only return contact records for people who are members of an organization.)

Avoid using the Right Outer Join and Full Outer Join.

In once:radix database relationships are not required between blocks and subblocks. They are only used to link tables or restrict search results within a block.

In the next section Metamodel Relationships are introduced. It is through their use that systems are constructed. Except when creating new Schema (Refer oADMIN for details.) or the creation of Functions and Triggers (an advanced feature of PostgreSQL), no direct SQL is needed.

Getting Started

The Database Manager palette is opened by selecting Database Manager... in the oED Tools palette.

Metamodels and Models

once:radix employs a system of Metamodels and Models to represent tables, fields and relationships.

Database Relationships are stored in Metamodels. Tables are referred to indirectly in these Metamodel Relationships as Models. Fields are referred to as Aliases. However none of these are direct equivalents as the metadata elements perform extra functions as are described below. Refer to the Glossary at the end of this section for a more detailed description.

The example screen (below) shows many features of a typical metamodel relationship, as viewed in the Database Manager. In particular, it shows models, field aliases and joins.

The main area of the palette shows an example of an Entity-Relationship (E-R) diagram of one of the Metamodel Relationships stored in a metamodel file (../once/model/metamodel.met).

As well as the five links joining models shown on screen, there are four links leading to models that are hidden from view.

The Metamodel.Relationship name is shown on the left-hand side of the command line at the bottom of the screen (in this example: contacts.person).

If a metamodel and relationship were selected in the Block Setup palette prior to opening the Database Manager, the relationship is displayed as shown in this example:

Otherwise, the window will be blank as shown below:

To open an existing metamodel and relationship other than the one currently displayed, click Open on the right-hand side of the control strip at the bottom of the screen.

Select a metamodel name from the list. A full list of relationships from the selected metamodel is displayed. Select a relationship from the list then click Open. The relationship is displayed on screen, as shown in the example above.

Models

Each block in the E-R diagram represents a model. The model name is also its file name, stored on the server (../once/model/data/model.mdl).

Below the model name are three sets of square brackets, representing: Allow Inserts, Allow Updates and Allow Deletes.

[+] means: Allow the operation to be performed.
[-] means: Do not allow the operation.

For example: [+] [+] [-] means allow inserts and updates in the table associated with the model, but do not allow records to be deleted.

The remainder of the model is a list of field aliases and their data types, sorted in alphabetical order. Field aliases in a model are similar to their associated database field names but they are also used to automatically assign labels when fields are added to a layout (using the Insert Datasource palette).

For example: The database field 'faxnumber' might have the alias 'Fax_Number' which would be rendered on the screen as the label 'Fax Number' (as each underscore is automatically replaced by a space). Alias data types and their associated PostgreSQL data types include:

      Alias   Field
   boolean      boolean
   datetimestamp
   floatnumeric
   integerinteger
   string char, text, varchar

Main Model

Models are added to a Metamodel Relationship in the order they are added to the Database Manager screen. If a model is deleted, other models will be renumbered to take its place. However one model has special characteristics:

The Main Model is usually associated with the parent block. It refers to the Primary Table - the first table to be actioned in INSERT, UPDATE and DELETE operations. It is identified in a metamodel file as 'model1' in the relationship. In the Database Manager, it is coloured green.

Any model can be made the Main Model: Click on the model diagram to select it (Models change colour to blue when selected.), then click the Main Model checkbox on the command line at the bottom of the screen. When this is done, its colour changes to green, highlighting its special place in the Relationship.

Creating a Table

All tables are associated with at least one model. Create a table by first clicking Create Model on the control panel at the bottom of the Database Manager screen. This opens the Model Editor palette,.

Have you made a backup?
Before proceeding, make a backup. Refer oADMIN for details. If you make a mistake and cause irreparable damage to your database, don't say you weren't warned!

Click Create Table. The Table Editor palette is displayed.


The Table Editor palette is arranged in sections: Below the table name and schema is a list of all fields defined for the table. Click to create a new field. Click on a field name in the list then click Edit to alter its attributes or Delete to remove it from the table.

Below the list of fields is the Field Details section. Enter details, as appropriate:

SchemaA Schema describes the way tables are organized. To create a new table it must have a suitable Schema defined. Refer to the oADMIN section of this guide to learn how to create a new schema.

Select a name from the Schema dropdown list.

NameEnter the Name of the new table. Duplicate table names in a schema are not permitted. Spaces are not valid. By convention, it is advisable to use only lower case letters and numbers.

To add a field to the table, click Add. The Field Details section becomes active.

When creating a new table, ALWAYS create the primary field and ownerorganisation fields BEFORE creating other fields. The settings should be:

Nameprimary       ownerorganisation
Typeintegertext
Not Null         checkdon't check
NameEnter the field Name. Duplicate field names in a table are not permitted. Spaces are not valid. By convention, it is advisable to use only lower case letters and numbers.
TypeSelect the data Type from the dropdown list.

  • boolean values are stored as TRUE or FALSE.
  • integer values are whole numbers. Key fields are always integers.
  • numeric values are floating point numbers.
  • text values store all entries (including numbers) as characters or strings.
  • timestamp without timezone values are stored as date/time entries.
Not NULL If a field MUST contain a valid entry, set the Not NULL checkbox. Should a user attempt to submit a record without populating a field with this option set, an error message is returned.
Default Value The contents of a field can be set to a Default Value should no value be entered manually. (e.g. Set the Country field in the Address to your own country's name if no country is entered.)
Comment The Comment is an optional entry that can be useful for future maintenance. You may enter a description of the purpose of the field here.
Value Check If the Value Check checkbox is set, the database performs data validation based on the test entered in the Condition field. The condition could be something like: exchangerate > 0.

The final section of this palette is used to set foreign keys. Before continuing, click OK to commit the entry. Also, note that the primary key field MUST be created before the foreign key section will activate.

Foreign Key If the field is a foreign key, set the Foreign Key checkbox. The Foreign Key section becomes active.
Table Select the name of the parent Table that is associated with delete and update actions.
Field Select the name of the link Field in the parent table that is associated with delete and update actions. This is usually the primary key field.

Select an item from the On Update and On Delete events to define what action should be taken when the parent record is updated or deleted:

NO ACTION This option prevents a record in the parent table from being deleted or updated if there are related records in the child table(s). This is similar to Restrict however it does attempt to delete or update the parent, then rolls back to the previous state. Finally it returns an error message. This option is chosen for advanced database design where a Stored Function is Triggered by a delete or update event, even if the actual delete or update operation fails. For normal applications, the Restrict option is recommended.
RESTRICT This option prevents a record in the parent table from being deleted or updated if there are related records in the child table(s). The operation fails and an error message is returned. This is the preferred method for protecting parent-child related records. (See also No Action).
CASCADE If the Cascade option is chosen, all related records in a child table are deleted automatically when the related record in the parent table is deleted.
SET NULL If a record in the parent table is deleted or updated, this option causes the foreign key field in the child records to be set to NULL.
SET DEFAULT Similar to SET NULL, If a record in the parent table is deleted or updated, this option causes the the foreign key values in the child records to be set to the column default. If no Default value is specified, the foreign key fields are set to NULL.
Once all fields have been defined for the table, click OK at the bottom of the palette to complete the operation. The SQL that will create the table (or edit an existing table) is displayed in a text editor (Expert Mode). If you wish, you may edit the text before committing it to the database. However it should not need changing and should only be attempted if you are experienced with SQL syntax. An example SQL Editor view is shown below:
BEGIN TRANSACTION;

CREATE TABLE contacts.jobcount ( );

ALTER TABLE contacts.jobcount ADD COLUMN "primary" int4;
ALTER TABLE contacts.jobcount ADD COLUMN "ownerorganisation" text;
ALTER TABLE contacts.jobcount ALTER COLUMN "primary" SET NOT NULL;
ALTER TABLE contacts.jobcount ADD COLUMN "fkjobcounter" int4;
ALTER TABLE contacts.jobcount ALTER COLUMN "fkjobcounter" SET NOT NULL;
ALTER TABLE contacts.jobcount ADD CONSTRAINT "fkjobcounter"
  FOREIGN KEY ("fkjobcounter") REFERENCES mail.header("primary")
  ON UPDATE RESTRICT
  ON DELETE CASCADE;

COMMIT TRANSACTION;

To complete the operation, click OK. The database is updated, ready for the next stage: Creating a model for the table. The Table Editor palette closes, returning to the Model Editor. The next step is to create one or more models to represent the table.

Create Model

Enter a valid model Name, then select the Table name from the dropdown list. The Add and Import buttons become active. Click Import. All fields in the table that are not yet included in the model are added to the list with [+] in front of the field alias.

Click Save to create the entries in the model. The [+] symbols are removed from the field names to indicate completion of the import process.

Edit Aliases

Aliases not only define field names in a model, they also set default Label names when fields are placed on a layout using the Insert Datasource and Change Datasource palettes.

Aliases created for each imported field use the field name. e.g. A field called 'homephone' would import into a model with the Alias also set to 'homephone'.

If the standard label for this field should be 'Home Phone', change the Alias to 'Home_Phone'. (Spaces are not allowed but underscores convert to spaces.)

To edit an alias name, click on the current name in the Model Editor palette, then click Edit. The Alias Editor palette is displayed with the selected field highlighted.

The Type dropdown list defines the Java data type of the field in the model. It must match the data type in the database. Options include: string, integer, float, date, boolean, binary, password and other. A comparative list of the fields is shown below. The data types should not need to be changed as this is set from the table definition.

JavaSQL Description
boolean booleanValues are stored as TRUE or FALSE.
integerinteger Values are whole numbers. Key fields are always integers.
floatnumericValues are floating point numbers.
stringtextValues store all entries (including numbers) as characters or strings.
datetimestamp without timezoneValues are stored as date/time entries.
binary Not used.
passwordtextThis instructs oCLI to display the field as asterisks (*), one for each character.
other Not used.

The Nature section of the Alias Editor palette allows calculations to be performed on the contents of the field, then to return the result of that calculation, rather than the field's contents. To enable this function, set the Is Calculated checkbox then select one of the following selections from the Calculation function dropdown list:

  • Average
  • Count
  • Maximum
  • Minimum
  • Sum

The Database Info section of the Alias Editor palette displays the name of the table and its fields. The Edit Table button provides access to the table editor.

Take care when making changes to a table. They are not automatically updated in all models associated with that table.

Edit Model

To amend an existing model, highlight the model on the relationship diagram, then click the Edit Model button on the control strip at the bottom of the Database Manager palette. The Model Editor palette opens. Making changes to existing models is similar to creating a new model. Refer to the previous section for details.

Add Model

To add a model to a metamodel relationship, click Add Model. The Open Model palette is displayed.

Select a model name from the list, then click Open. The model is added to the layout.

Delete Model

To remove a model from a metamodel relationship, click on the model diagram to select it. Its colour changes to blue, showing that it is the active model. Click Delete Model on the control strip at the bottom of the Database Manager palette.to remove the model from the E-R diagram.

Kill Model

To remove a model from a metamodel relationship and to delete the model file completely from the server, highlight the model on the relationship diagram, then click the Kill Model button on the control strip at the bottom of the Database Manager palette..

Take care when executing this command. Models are not automatically updated in all associated metamodels.

Links

In once:radix a link is one or more joins between models. Four types of joins that can be created using the Database Manager were introduced in the Database Basics section: inner, left outer, right outer and full outer join.

This section shows how to apply these joins to metamodel relationships.

Crow's Foot Notation

In once:radix these joins are represented using Crow's Foot notation which represents relationships with connecting lines between entities, and pairs of symbols at the ends of those lines to represent the number of records that can/must be returned when a database SELECT operation is performed:

  • The double bar appears at the child end of every inner join, regardless of whether it is a primary or foreign key.
    When a SELECT is made, each record in the parent table that satisfies the search criteria will return one (and only one) record from the linked child record.
    For example: A contact record with an inner join to a driver's licence table would only return records for contacts who have a driver's licence.
  • The ring with single bar appears at the child end of a left or right outer join when it is connected to a primary field.
    When a SELECT is made, each record in the parent table that satisfies the search criteria may also return one record from the linked child record (Since each primary key is unique, only one child record can be returned. But being an outer join, parent records with no child record are also returned.
  • The ring with bar and crow's foot appears at the child end of a left or right outer join when it is connected to a foreign key field.
    When a SELECT is made, each record in the parent table that satisfies the search criteria may also return any number of records from the linked child record (Since there is no limit to the number of records that can be assigned the same value in the foreign key field, any number of child records can be returned. But being an outer join, parent records with no child record are also returned.
    This also appears at BOTH ends of a full outer join. In this case, records that meet the search criteria at both ends of the join are returned, regardless of whether there are linked records at the other end.

Link Editor

Links are lines joining field aliases in one (self join) or two models. They consist of a line with three drag points, terminated at one or both ends with crows foot symbols, as described above. The join colour indicates its current state:

Single Joins between models are displayed in cyan. Complex Join are shown in yellow. Both single and complex joins change colour to blue when selected.

The simplest way to create a join is to place the cursor over the field alias of the left side of the join (e.g. fk_currency in the model: contacts_personmember), then click and drag to the field alias of the right side of the join (e.g. primary in the model: accounts_currencyadj).

The Link Editor palette will open, displaying the selected model and field alias names. Select the join Type from the drop down list, then click OK to confirm the link. If the models are linked in a Single Join, click OK at the bottom of the palette to save the link.

If the models are linked in a complex join, click Add to append another join. This time, select all details in the Join Info section of the Link Editor by selecting Model 1, Model 2, Alias 1, Alias 2 and Type, then click OK to add the line to the Available Joins section of the Link Editor. Available joins can be changed by selecting the join, then clicking Edit or removed from the link by clicking Delete.

Once all joins are added, click OK at the bottom of the palette to save the link, and to display the changes on the E-R diagram.

Control Strip

Some of the functions of the Control Strip on the bottom of the Database Manager palette have been introduced earlier. This section provides a summary of all functions, including a few not yet covered.
Note: Some of the buttons described here are context sensitive. e.g. The Edit Model button is active only when a model is selected.

Metamodel.Relationship
NameThis field usually displays the name of the Metamodel Relationship associated with the block currently being edited. However it can be changed using the Open and Save As functions.
ConditionWhen searching the database, the WHERE clause is constructed from a number of sources:

  • A madatory restriction that limits the data returned to those records associated with the current owner organization. This allows multiple organization to share the same server.
  • A mandatory restiction set by user security access privileges.
  • Restrictions set in this Condition clause.
  • Search parameters entered in Find mode or by scripting (in oCLI).
This field displays any condition which is added automatically to all searches on tables in the relationship. e.g.
"contacts_person"."Position"IS NOT NULL AND "person_small"."Class"="Staff"
Edit ConditionWhen this button is clicked, the Condition Editor palette is displayed.

Build the condition using a combination of model names (from the Models drop down list), field aliases (from the list of Aliases for the selected model) and operators (Valid arithmetic, logical and summary operators are listed in the Operations list.) These include:
+, -, *, /Add, subtract, multiply and divide the contents of numeric fields and constants.
=Is equal to...
<>Is not equal to...
<=Is less than or equal to...
>=Is greater than or equal to...
<Is less than...
>Is greater than...
ANDLogical AND
ORLogical AND
NOTLogical AND
ISIs True
IS NOTIs False
NULLField is empty.
(...)A metamodel.relationship.model placeholder
SUM(...)Calculate the total of a field for all records in the found set.
MAX(...)Find the largest value in a field for all records in the found set.
MIN(...)Find the smallest value in a field for all records in the found set.
AVG(...)Calculate the average of a field for all records in the found set.

Models
Main ModelDisplayed when the selected model is the first model in a relationship.
Allow InsertsAllow the selected model to be included in insert operations for the relationship.
Allow UpdatesAllow the selected model to be included in update operations for the relationship.
Allow DeletesAllow the selected model to be included in delete operations for the relationship.
Create Model
Add ModelOpen the Model Editor palette.
Edit ModelOpen the Model Editor palette with the currently selected model displayed.
Delete ModelRemove the currently selected model from the relationship.
Kill ModelRemove the currently selected model from the relationship and permanently delete the model file from the server.

Links
Add LinkOpen the Link editor to add a link to the relationship.
Edit LinkOpen the Link editor to edit the selected link.
Delete LinkRemove the selected link from the relationship.

Misc.
Select AllSelect ALL models in the relationships. This is useful when repositioning models on screen.
UndoUndo the last operation. One level of undo is supported.
Arrange Model   Reposition all models to 'clean up' the layout.
Arrange LinksReposition all twists from links to take the shortest possible path between models, as shown in the example below:
Before Rearranging Links                                  After Rearranging Links
  

Actions
NewCreate a new relationship in the currently selected metamodel.
OpenOpen a new metamodel relationship.
ReopenRevert to saved version of the currently displayed relationship.
SaveSave the currently displayed relationship, overwriting the version on the server.
Save AsSave the currently displayed relationship with a new relationship name. A new metamodel name may also be specified. See example below:

CancelClose the Database Manager palette without saving changes to the currently displayed relationship.

Context Menus

As with other applications in once:radix, the Database Manager features a set of context sensitive menus. Most of these features are also available through the control strip at the bottom of the screen and have been described earlier in this section of the guide. A summary list of the menus and their functions are included here. The first two options are:

UndoCtrl+ZCreate a new metamodel.relationship.
Select AllCtrl+NOpen an existing metamodel.relationship.
File Menu
NewCtrl+N)Create a new metamodel.relationship.
Open ... Ctrl+OOpen an existing metamodel.relationship.
Revert to Saved Reopen the current metamodel.relationship, after discarding any changes made since it was last loaded.
SaveCtrl+SSave the current relationship to its parent metamodel.
Save As... Save the current relationship to a new parent metamodel.
Insert Menu
New Model... Create a new model then add it to the relationship.
Model ... Add an existing model to the current metamodel.relationship.
Link... Add a Link to the current metamodel.relationship.
Edit Menu
Model... Open the Model Editor palette to alter the currently selected model.
Link ... Open the Link Editor palette to alter the currently selected link.
Condition... Open the Condition Editor palette to alter the condition of the currently displayed relationship.
Delete Menu
Model... Remove the currently selected model from the displayed relationship.
Link ... Remove the currently selected Link from the displayed relationship.
Kill Model... Remove the currently selected model from the displayed relationship and remove the model file permanently from the server.
Arrange Menu
Models Repositions all of the models on screen to a simplified layout.
Links Removes all twists from links, taking the shortest path between models.

Glossary of Database Terms

TermDescription
DatabaseA Database is a collection of data, arranged for ease of access.
SQLStructured Query Language is the most common standard for communicating with a database. once:radix handles most of the interaction with the database, however there are a few SQL concepts that you will need to understand when creating an application. They are described in this section.
TableThis is where actual data are stored. (e.g. as customers, orders, products, etc.) Think of a table like a spreadsheet arranged in rows or records (horizontal) and columns (vertical).
SchemaA schema describes the way data are organized into the tables of a database. In once:radix schema are described by performing SQL CREATE statements in oADMIN.
FieldA field is a single unit of data stored as part of a database record. Each record is made up of one or more fields, which correspond to the columns in a database table. Fields are often also referred to as attributes.

Record,
Row or Tuple
Though there can be subtle differences in their meanings, these three terms are often used to describe the same concept. A row is a set of associated entries for all fields in a single record. i.e. If a table has 10 columns, there would be 10 fields per row.
Primary KeyA column whose values uniquely identify each row in a table.
Foreign KeyA column whose values are utilized to cross-reference data in related tables.
RelationshipRelationships define the association between two or more entities (usually tables).
For example, the relationship between ORDERS and CUSTOMERS tables could be that an order is placed by ONE AND ONLY ONE customer, while a given customer MAY HAVE placed ONE OR MORE orders. A link between the orders and customers tables would enforce that relationship.
Link A link exists between two database tables when a field in one table (usually a foreign key) references a field of another table (usually its primary key). Thus, several records in one table could link to a single (parent) record in another, simply by storing the value of the parent's primary key in the foreign key field of each child record.
JoinThe SQL JOIN statement is used to link the data contained in one table or two related tables based on a common attribute.
If the link is between two separate tables, it is called an INNER, OUTER or FULL JOIN. Links in the same table are called a SELF JOIN.
The join is usually performed by relating the columns which contain specific foreign key values in one table with the same value in a primary key of the same or another table. e.g. If fkOrganization (a foreign key field) in certain person records in the person table contained the value 101 while the primary field in the organization table had one record whose value is 101. These person records can be linked by a JOIN relationship to the one matching organization record
ConditionA condition in a relationship defines an SQL WHERE clause. This is used to specify selection criteria that restrict the found set returned in a SELECT records operation from one or more tables.
It could be used, for example, to limit a list of contact records displayed to those people who are clients.
once:radix allows multiple organisations to share the same database. When a user logs on, he or she is assigned to only one Owner Organisation at a time. All tables have an in-built Condition on the ownerorganisation field so that only records associated with that current ownerorganisation are returned.
ModelIn once:radix tables are referred to by a set of models. A model contains some or all of the fields of its associated table.
Each table may be defined by any number of models. A master model contains a list of all fields in the table. Other models contain subsets of the full table – designed to improve performance by returning only those fields required to populate a screen layout.
Metamodel In once:radix, a metamodel contains a collection of relationships. Though it would be quite acceptable to have only one metamodel for the whole database, it is good design practice to create one metamodel for each schema

Format of a Metamodel Relationship

The term 'relationship' has a broader meaning in metamodels than the conventional definition for databases, as described above. A Metamodel Relationship defines the behaviour of one or more tables (through references to models). It describes the order of creation, deletion and updating of records.
Management of metamodels, relationships, models and tables is handled by the Database Manager. However it is useful to understand how relationships are constructed. Here is an example of a simple relationship:
[relationship_name]
model1 = data/model_name
condition =
And here is a more complex example:
[relationship_name]
model1 = data/model_name_1
model2 = data/model_name_2
model3 = data/model_name_3
model4 = data/model_name_4
model5 = data/model_name_5
insert1 = data/model_name_1
insert2 = data/model_name_3
insert3 = data/model_name_4
update1 = data/model_name_1
update2 = data/model_name_3
update3 = data/model_name_4
update4 = data/model_name_5
delete1 = data/model_name_1
condition =  "model_name_1.field_alias" = 'inventory'
join = "model_name_1" LEFT OUTER JOIN "model_name_2" 
ON ("model_name_2"."primary" = "model_name_3"."fk_key_1")
LEFT OUTER JOIN "model_name_2"
ON ("model_name_4"."primary" = "model_name_5"."fk_key_2")
designer = 8:8;200:32;411:38;831:257;1023:281;611:30; 
778:202,788:259,798:316;970:372,980:370,990:369; 
970:372,980:370,990:369;583:126,576:120,569:115; 379:100,368:121,357:142;168:135,158:106,148:78;
A Metamodel Relationship defines collections of some or all of the following:
[relationship_name]
Must be unique to the metamodel and must not contain spaces.
modeln = data/any_model_name
Must be unique to the relationship and must not contain spaces.
insertn
An insert statement specifies the order that records are created in the database. e.g. If a relationship refers to three models (tables) and no insert statement is included, records will be created in all three tables whenever a create new record (INSERT) operation is performed.
In the example above, the relationship contains five models, but records are added to only three tables when an INSERT is performed.
updaten
An update statement specifies the order that records are modified in the database. e.g. If a relationship refers to three models (tables) and no update statement is included, records will be changed in all three tables whenever changes are saved to existing records.
In the example above, the relationship contains five models, but records are updated in only four tables when an UPDATE is performed.
deleten
A delete statement specifies the order that records are deleted in the database. e.g. If a relationship refers to three models (tables) and no delete statement is included, records will be removed from all three tables whenever a delete record command is performed.
In the example above, the relationship contains five models, but records are deleted in only one table when a DELETE is performed.
condition
The condition is applied in the WHERE clause of all SELECT operations. It must be a valid SQL statement. e.g. It must conform to the correct data types and must refer to valid field aliases that are referenced in the models of the relationship.
join
This forms the JOIN clause of all INSERT operations. It must be a valid SQL statement. e.g. It must refer to valid field aliases that are referenced in the models of the relationship.
designer
This section defines how models and joins are positioned by the Database Manager.
The database is pre-loaded with tables and fields that are critically important for the operation of once:radix. You may add additional fields to these tables but do not remove fields or change their properties as this could render the security system inoperable.
Stored Function Stored functions contain advanced SQL code placed in the database itself. They are used to give greater performance on UPDATE, INSERT and DELETE operations. Due to a current limitation in PostgreSQL, stored functions must be managed through an external database application such as PGAdmin.
TriggerA trigger is an event handler that causes a stored procedure to execute. It 'fires' when BEFORE/AFTER and INSERT/UPDATE/DELETE operations are perfomed on that table.
© 2006 once:technologies Pty Ltd
46 Roseneath St, North Geelong VIC 3215 Australia
Phone: + 61 3 5278 6699, Fax: + 61 3 5278 6166
Privacy policy | Terms of use | Site Map