Creation from a relational database

Since version 3.1.0-KickOff, Ontologies have been referred to as "Entities" in the Control Panel. This does not alter any functionality; the nomenclature has simply been changed for a better understanding of the concept.

User Interface: 5.3.2-Ultimate

Introduction

In this tutorial we are going to see how to create an Entity from an external relational database table.

Steps

Create the Entity

From the Control Panel, navigate to the Development > My Entities menu.

image-20240403-142732.png

This will take us to the list of available Entities. To create the Entity, click on the "+" button at the top right of the screen.

image-20240227-121951.png

From the different Entities that we will be able to create, we will select the "Creation from Relational Database" one:

Fill in the general information

This will open the Entity creation wizard, where you will have to enter some basic information:

  • Select a Database Connection: select the database you want to connect to from the drop-down menu. If there is none available, you will have to create a connection by clicking on the "My external database connections" button (more information).

  • Select a Database: this option appears when a database connection has been selected. In the drop-down list, you will have to choose which database to use.

  • Create table: checking this option will allow you to create a new table in the relational database. If it is not checked, you will have to select one of the existing tables in the database.

 

  • Identification: the unique name with which to identify the Entity.

  • Meta-Information: tags to characterize the Entity, which will be used for filtering when searching.

  • Description: extended descriptive text of the Entity, such as its use, properties, characteristics, etc.

In addition, we have some more options to characterize the Entity:

  • Active: so that the Entity works or is blocked.

  • Public entity: if we want the Entity to be public, or if we want it to be private.

Once the Entity's general information and options have been defined, click on the "Continue" button to access the Entity's schema definition.

Define the Entity's scheme

Depending on whether you have checked the option to create table or not, this window will be displayed differently.

Selecting a pre-existing table

In case you have chosen a table already existing in the database, this screen will display the table schema.

We will have the possibility to define which will be the identification field of the table, by checking the "Associate ID" option and selecting the field to be used as identifier from the drop-down menu.

In case the table has a field to store geospatial information (a "geometry" field in a PostGIS table), the "Associate Geometry" option will be checked and the corresponding field will be selected.

Once these options are configured, click on the "Create" button to finish creating the Entity.

Create table

If, on the other hand, the option to create table has been checked, this screen will then display a field creation wizard, similar to the one for the current Entities of the Platform, but which will correspond to the header of the table to be created in the database.

Adding fields

You can create as many fields as you need. The fields that we want our entity to contain will be added one by one using the available interface:

Adding constraints

Constraints are properties assigned to a column or set of columns in a table that prevent certain types of inconsistent data values from being assigned to that column.

They follow the database specifications, so you have to know the characteristics of the database constraints before adding them.

Generate the SQL code

Once the fields and constraints are configured, it is time to update the SQL code that will be executed in the table creation process. To do this, click on the "Update SQL" button.

This SQL code can be modified as required to change the default behavior.

When the SQL code is ready, we can update the schema to save it. To do this, click on the "Generate schema" button.

Next we will see the schema code in JSON format with all the changes:

In addition, if everything went well, a notification will be displayed at the top right of the screen.

As a detail, in the Entity schema you will see a property named "sqlStatement", where the SQL code is defined.


Once this is done, click on the "Create" button to complete the creation of the Entity.

A window will then be displayed with the available options to be performed with the Entity created.

Clicking on the "Close" button will take you back to the Entities list, where the newly created Entity will appear.

 If a new table is being created, it can be viewed in the database using a database manager.

Â