---
title: "How to create ontologies on PostgreSQL from scratch"
canonical: "https://onesaitplatform.refined.site/space/DOCT/2220831947/How%20to%20create%20ontologies%20on%20PostgreSQL%20from%20scratch"
format: markdown
---
## Introduction

In this tutorial we will cover the complete process to deploy a PostgreSQL database in Onesait Platform in order to use it to create ontologies on it.

The steps to follow are:

- Deploy a PostgreSQL database (you can skip this step if you have one already).
- Create a JDBC connection with the database deployed.
- Create an Ontology and its table in the database.

## Deploy a PostgreSQL database

We will deploy a docker container with PostgreSQL.

![image](media://2990d82e-e9c4-4178-b972-13bd0102415f)

We set the image [from dockerhub](https://hub.docker.com/_/postgres?tab=description) and its properties.

![image](media://16f44a6a-3317-4981-b1e9-f3ba182a93fe)

Ports are only set if we need conection from outside docker network.

![image](media://9ed57777-1e85-4e92-8aae-62463677fb7d)

Then we press **CREATE** button.

You can see the service in the stack.

![image](media://7d3da565-32f0-4613-8f91-6398ee665355)

Now we create a database from command line (inside container) where we create tables with the following steps:

![image](media://b8fad047-a23b-4096-aaeb-3a6d429937a4)

The commands executed are:

```shell
psql -U postgres
\l
create database test
\l
```

Then you can see the created database:

![image](media://ae0d9e84-9fd8-41bf-8a6d-e00ec35ba339)

## Create a JDBC connection with the database deployed

Once the service is running (no matter if port is exposed because we are inside network), we can create a JDBC connection to the database.

![image](media://7fd57e2c-4b36-45b6-ab52-cf1bc6456679)

## Create an Ontology and its table over the database

For this last step you can follow the tutorial: [https://onesaitplatform.atlassian.net/wiki/spaces/DOCT/pages/2220831823](https://onesaitplatform.atlassian.net/wiki/spaces/DOCT/pages/2220831823) 

Also, an example is shown:

![image](media://797082e6-aa4f-45c4-a7aa-1b33dd5729f1)

![image](media://5bc0c952-adc3-49df-b16a-b651daadbc7f)

![image](media://8ddcb4a3-959e-403c-bbfe-a7a00a7a657b)

You can see the ontology, and the table with a database client (PgAdmin in this case).

![image](media://31f0d6df-88e9-4d44-b2f4-bfe1f75bd856)

![image](media://ae063139-616c-4b98-a3f1-fe7123026832)