Skip to main content

52 docs tagged with "database"

View All Tags

Data Structures - Indices

Indices are key components of any database. In the Genesis platform, every table must have at least one index: the primary key. This is vital for controlling how data is read by an application.

Data Structures - Tables

Typically, such as in relational databases, a table is a data structure that organises data into rows and columns.

Data types

The following objects and classes encapsulate your data within your Genesis application, so that you can process it and add value as you see fit.

Data types - DbRecord

Using DbRecord instead of entities will circumvent compile-time validation of database interactions. This means that errors might not appear until runtime or might lead to unexpected results.

Data types - Index entities

Index entities are nested in table and view entities. The name will be based on the index name. The entity can be constructed by passing in the field values in order. The first field of the index must always be provided, and the others are optional.

Data types - Table entities

Table entities are classes generated by Genesis that match your applications's data model. The generated entity name is based on the table name, but will be camel case.

Data types - Views entities

View entities are classes generated by Genesis, which match your application's data model. The name of the view entity that is generated will be the name specified in its definition, but it is converted from snake case to camel case; for example, VIEW_NAME becomes ViewName. All table/view entities implement a common interface called DbEntity.

Database concepts

This section provides you with details on various database concepts.

Database concepts - Optimistic Concurrency

Optimistic Concurrency helps prevent users from updating or deleting a stale version of a record. To do this, we need to know what the intended version of the record to update or delete is. Internally, we use the record's timestamp field as its version.

Database concepts - Read

Genesis supports a number of different read operations. Although the specifics vary between the different interfaces, the underlying principles remain the same. This page explains these principles, without going into specific calls. Details of how to implement these calls, along with examples and sample code, can be found in the Database Interface section of the documentation.

Database concepts - Subscribe

Subscribe operations enable code to react to database changes, rather than polling for changes. Code can either listen to changes, or use a combined read/subscribe operation. These mixed read/subscribe operations are useful.

Database concepts - Write

Genesis supports a number of different write operations. This page explains the underlying principles, without going into specific calls. Details of how to implement these calls can be found in the Database Interface section of the documentation.

Database interface

Genesis supports different ways of interacting with the database. Regardless of the interface used, the operations remain the same. The recommended way of accessing the database is via the EntityDb.

Database interface - generated repositories

IMPORTANT! From GSF version 7.0.0 onwards, code generation for database repositories is disabled by default. To re-enable code generation, change the generateRepositories setting inside the build.gradle.kts files for the genesis-generated-dao and genesis-generated-view modules, as shown below:

Database interface - RxDb

Using RxDb instead of entityDb or generated repositories will circumvent compile-time validation of database interactions. This means that errors might not appear until runtime or might lead to unexpected results.

Database technology - overview

Your Genesis application data model can be configured without any concern about the database technology used to store the model and the data.

Database technology - SQL

If you want to use an SQL database for your Genesis application, the following technologies are supported:

Generating DAOs

The fields, tables and views you define must be turned into DAOs (Database Access Objects).

Helper classes

Helper classes allow you to access common functionality and domain state within the Genesis platform.

Operations - DbMon

DbMon is the Genesis database client. It provides a set of commands that enable you to view and change the database as necessary. DbMon hides the details of the specific database technology, so this does not affect your usage.

Operations - Remap

Remap is a schema-migration tool that applies the current schema (defined in the deployed field and table GPAL dictionaries) to the underlying database layer.

Server set-up - config management

This document describes the recommended uses of config management with Genesis frameworks. Readers must have some Linux system administration experience.

Server set-up - preparing the host

This section is for users with experience of Linux system administration. Here we describe preparing a host to run applications built with the Genesis low-code platform.

Subscription - Bulk

Bulk objects are published to listeners of mixed read/subscribe operations. Like Record Update, Bulk is a sealed Kotlin class. It has the following class hierarchy:

Tables - basics

In your application's tables-dictionary.kts file, you need to define every table that your application needs. Let us look at a very simple example definition. This contains a single table with three fields in it.

Types of API - AsyncEntityDb

The Genesis low-code platform relies on Kotlin coroutines for providing high-performance applications. The Async API is the preferred API for accessing the database in Kotlin. The RxJava API is also available. If you use Java, the asynchronous API is not available.

Types of API - RxEntityDb

RxJava is a Java implementation of reactive extensions. The Genesis database uses this library to represent asynchronous database operations in java.