Tables
Create and manage PostgreSQL tables using the visual editor or SQL commands.
Creating a Table
DYPAI provides an intuitive visual interface for creating tables without writing SQL.
Navigate to Database
Go to the Database section in your project dashboard and click "New Table".
Define Table Name
Enter a name for your table. Use lowercase letters and underscores (e.g., user_profiles).
Add Columns
Define each column with its name, data type, and constraints. Click "Add Column" to add more.
Set Primary Key
Select which column will be the primary key. DYPAI recommends using id with type uuid.
Save Table
Click "Create Table" to save. DYPAI automatically generates REST endpoints for the new table.
Column Options
Each column can be configured with the following options:
| Option | Description |
|---|---|
| Name | Column identifier (lowercase, no spaces) |
| Type | PostgreSQL data type |
| Default Value | Value when no data is provided |
| Primary Key | Unique identifier for rows |
| Nullable | Allow NULL values |
| Unique | Enforce unique values |
| Array | Store multiple values |
Example: Users Table
Here's a complete example of creating a users table:
-- SQL equivalent of visual editor creation
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT UNIQUE NOT NULL,
full_name TEXT,
avatar_url TEXT,
role TEXT DEFAULT 'user',
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Enable Row Level Security
ALTER TABLE users ENABLE ROW LEVEL SECURITY;Editing Tables
To modify an existing table:
- Select the table from the sidebar
- Click on the column you want to edit
- Modify the settings and save
Deleting Tables
To delete a table:
- Select the table from the sidebar
- Click the delete icon or use the dropdown menu
- Confirm the deletion
Relationships
Create relationships between tables using foreign keys:
-- Example: Posts table with user relationship
CREATE TABLE posts (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
title TEXT NOT NULL,
content TEXT,
published BOOLEAN DEFAULT false,
created_at TIMESTAMPTZ DEFAULT NOW()
);