yo

First Database Tables with
DBeaver

  • Jesse Madsen | October 15, 2022
  • 20 min

If you have never made a database scheme or Table before this is the quick start guide for you. This guide will not teach you database theory, but it will only get you up and going with DBeaver(open source) interface.

    Pre-requisite
  • Database that you can connect to.
  • DBeaver is installed.
If you don't have the Pre-requisites, don't worry my quick start Docker and Postgres tutorial can get you up and going in 20min. Clicking below.

Blog Images


Check your DBeaver connection

Right click postgres-sample and Edit the Connection.

DBeaver


You will get a connection screen, confirming a good connection.

DBeaver


Create a Schema

Right click your database and drill down unitl you can create new Schema.

DBeaver

Name the Schema.

DBeaver

Create a new Table

Expand your Schema and right click to create new Table.

DBeaver

Name the Table.

DBeaver



Create a new Column

Right click on table to Create a New Column.

DBeaver



I am creating my primary key(PK) name ID with a serial(auto-fill number) datatype. Also, because it is a the primary key, I activated the Not Null check.

DBeaver



Now we have our column structure set. Note nothing has been committed/save to the database yet.

DBeaver



I added two more columns to the Table, and now its time to save it.

DBeaver



DBeaver will give you the SQL syntax of the Table creation. Select persist to save the Table

DBeaver



Create another table

I created another table for the team. The SQL syntax of the new table creation table.

DBeaver



Link tables together

We have created two tables, but they are not connected to each other. On the team table, I made a player_id with the anticipation of connecting the player table with the team table with a foreign key relationship.

DBeaver

No link between them



Double-click the player table to open it back up for editing. We need to lable a constraint(assign which column is the primary key). Open the Constraints tab on the right and right click to create New Constraint.

DBeaver

DBeaver

Set id as our primary key.

DBeaver

Set Forgien key Relationship

Double-click the team table and select the Foreign Keys tab. Right Click in an open area to add New Foreign Key Constraint.

DBeaver



Select the player on the top reference table. Ok, then save changes.

DBeaver



Now the tables are connected.

DBeaver

In this tutorial, we learned how to make tables and connect them with the foreign key relationship. If you have any comments, please leave a reply.

Leave a Reply