Skip to end of metadata
Go to start of metadata

By default, each class in the database creates a separate table that stores all those properties whose only parameter is an object of this class. The key in this table is a field that stores a unique object ID. For properties with several parameters, a table will be created with the IDs of parameter objects as keys.

To explicitly specify a table in which all properties with one parameter of this class will be stored, we can use the following construct:

1
2
3
4
 CLASS Animal 'Animal';
TABLE animal(Animal);

name 'Name' = DATA STRING[50] (Animal);

With a standard field naming policy, a <Namespace>_animal table will be created within the database, with a key key0 with the internal ID of an animal and a <Namespace>_name_Animal field storing its name.

For properties with multiple parameters, we can create a table as follows:

1
2
3
4
 CLASS Country 'Country';

TABLE animalCountry (Animal, Country);
population 'Number' = DATA INTEGER (Animal, Country);

In this case we create a <Namespace>_animalCountry table with two keys: key0 for the animal and key1 for the country. It will also have a <Namespace>_population_Animal_Country field.

All other properties with signature (Animal, Country) will also be placed in this table. If some property needs to be placed in a separate table, then the following technique can be used:

1
2
 TABLE ageAnimalCountry (Animal, Country);
averageAge 'Average age' = DATA NUMERIC[8,2] (Animal, Country) TABLE ageAnimalCountry;

This table will only store properties for which it is explicitly specified. All others will go into the first table declared with the necessary signature.

Computed properties that need to be stored permanently in the table need to be marked with the keyword MATERIALIZED :

1
 totalPopulation 'Total number' (Animal a) = GROUP SUM population(a, Country c) MATERIALIZED;

The table in which this field will be stored will be selected according to the same algorithm as for data properties. In this case, it will go into the table <Namespace>_animal.

  • No labels