Skip to content
Private alpha
Documentation — Data

Documentation

Data

The Data tab describes the information the application keeps and the databases where it lives: sources (an SQL database, a MongoDB database, files, an API), entities (the tables) and their relations. One application can combine several sources; Khnoum then enforces the relations that cross them itself.

Data sources

A source has a name (by default "Principale"), a type, a connection and, if needed, the name of a variable that holds the password or token. The tab reminds you of the expected connection format for each type.

TypeConnection (example)Notes
SQLitedonnees/app.dbfile created on first launch
PostgreSQLpostgres://user@server:5432/database
MySQL / MariaDBmysql://user@server:3306/database
SQL Serverserver=tcp:server,1433;database=database;user=useradd TrustServerCertificate=true for an unrecognised certificate
MongoDBmongodb://user@server:27017/databaseeach entity is a collection
CSV filea folderone <table>.csv file per entity; comma or semicolon separator; the first line names the fields
JSON filea folderone <table>.json file per entity (array of objects)
REST APIthe base addressGET, POST, PUT, DELETE requests on /<table> and /<table>/<key>

A relative path (SQLite, CSV, JSON) refers to the application's data folder on the user's computer. Missing tables and collections are created on first access.

Passwords and tokens

Passwords are never stored in the project. The connection is written without a password, and the "Secret (variable)" field names the environment variable that will hold it on the machine where the application runs (for example CUSTOMERS_PASSWORD). The application reads it when it connects; if it is missing, the error names the variable and the source.

Entities and fields

An entity is a table (or a collection, a file, an API resource). It has:

  • a name and a label (translatable);
  • a source;
  • the name of its table; if empty, the entity's name.

A new entity gets an ID key, an auto-incremented integer.

Each field has a name, a type and options: Key, Auto (numbered automatically), Required, Unique, and the displayed label.

TypeContent
Integerwhole number
Realdecimal number
Decimalexact amount (12 digits including 2 decimals by default)
Text, Long textshort or long string
Booleanyes or no
Date, Date and time, Timepoints in time, in YYYY-MM-DD and HH:MM:SS format
Unique identifier (UUID)UUID
Binaryfile, image
JSON documentfree-form structured data

The diagram, in the center, shows the entities and their relations; "Show the SQL" displays the tables as they will be created.

Relations

A relation links a parent entity to a child entity through a field of each (for example Client.ID and Commande.Client_ID).

CardinalityMeaning
1 — 1one parent record, at most one child record
1 — none parent record, several child records (default)
n — nseveral on each side, through a link table created by Khnoum

The deletion rule ("On delete") says what happens to a child record when its parent is deleted:

RuleEffect
Forbidthe parent cannot be deleted while children refer to it (default)
Cascadethe children are deleted with the parent
Clearthe reference to the parent is cleared in the children

Relations across several sources

An application often combines data from several origins: a list of people in a PostgreSQL database, and the departments they are assigned to in a MongoDB collection. Khnoum allows this: each entity chooses its source, and a relation can link two entities from different sources.

There are two cases:

  • Relation handled by the database. Both entities are in the same relational database (SQLite, PostgreSQL, MySQL, SQL Server). The relation becomes a foreign key and the database enforces it.
  • Relation handled by the application. The entities are in two different sources, or in a source without constraints (MongoDB, CSV, JSON, REST API). No database can then guarantee the relation: the produced application enforces it. These relations are drawn in orange on the diagram.

For a relation handled by the application, the application checks at each operation:

  • when a child record is saved, that the parent record exists;
  • when a parent record is deleted, the deletion rule (forbid, cascade or clear), right into the other source;
  • for sources without constraints, required fields and unique values (unique fields and keys).

A refused operation writes nothing: the error explains the rule that prevented it.

These checks do not form a transaction between the two databases: if the connection to one of them drops in the middle of a cascading deletion, only some of the child records may have been deleted.

Using the data

Data is used without code thanks to bound controls and the actions of the Data category (see Interactions), or in Argile:

Client.new()
Client.Nom = SAI_Nom.value
Client.save()

if Client.load(42) then
    LIB_Ville.text = Client.Ville
end