Design a Database Schema Visually: Tables, Foreign Keys & SQL in DbSchema
Design a database schema without writing SQL by hand. In under two minutes, you'll create a table on a DbSchema diagram, link it to another table with a foreign key by simply dragging one column onto another, and let DbSchema generate the CREATE TABLE and foreign key statements for PostgreSQL.
What you'll see:
• Creating a table from the diagram's right-click menu
• Adding columns with data types, a primary key and NOT NULL
• Creating a foreign key by drag and drop
• Generating the SQL for the new table and its foreign key
The design in this video is offline: no database connection is needed until you're ready to deploy.
Try DbSchema free at https://dbschema.com/?utm_source=youtube&utm_medium=organic_video&utm_campaign=youtube_channel&utm_content=SN7b3jAPv_w
Chapters:
0:00 Introduction
0:09 Create a table
0:21 Add the columns
0:59 Link with a foreign key
1:15 Generate the SQL
1:31 Summary
#DbSchema #DatabaseDesign #PostgreSQL #SQL #DataModeling #ERDiagram
Closed Caption:
In the next minute, you'll design a new
table, link it with a foreign key, and
let DB Schema write the SQL for you.
Here's a small shop, customers and
products.
Purchases are missing, so right-click
the diagram and pick create table.
Call it purchases.
Now the columns. Click add purchase ID,
a serial, and the primary key.
Buyer ID, an integer that can't be
empty.
And purchased at, a timestamp.
Click okay.
And purchases lands right on the
diagram.
Every purchase has a buyer, and buyers
are [music] customers.
So drag buyer ID onto the key of
customers.
DB Schema fills in the foreign key for
you. Press enter.
And there's the relationship.
Need the SQL?
Right-click purchases and pick build
SQL, then create statement.
There it is.
The create table and the foreign key,
ready for PostgreSQL.
Design it visually and let DB Schema
write the SQL.
Video Length: 01:41
Uploaded By: DbSchema Database Designer
Published: 10/8/2026
View Count: 76