Quick Start
Get up and running with zxwdb in 5 minutes. This tutorial will walk you through creating your first database schema.
Step 1: Install and Start
# Install globally
npm install -g @fiqihbadrian/zxwdb
# Start zxwdb
zxwdbOpen your browser at http://localhost:20256
Step 2: Connect to Database
- Click "Connect to Database"
- Enter your credentials:
- Host:
localhost - Port:
3306 - Username:
root - Password:
your_password - Database:
test_db(or create new)
- Host:
- Click "Connect" (or press Enter)
Step 3: Create Your First Table
Using the Visual Designer
- Click "+ Add Table" button (or press Cmd+N / Ctrl+N)
- Fill in table details:
Table Name: users Columns: - id INT PRIMARY KEY, AUTO_INCREMENT - username VARCHAR length: 50, NOT NULL - email VARCHAR length: 100, NOT NULL - created_at TIMESTAMP - Click "Create Table"
Your table appears on the canvas! 🎉
Step 4: Create Related Table
Let's create a posts table related to users:
- Press Cmd+N to add another table
- Configure the table:
Table Name: posts Columns: - id INT PRIMARY KEY, AUTO_INCREMENT - user_id INT NOT NULL - title VARCHAR length: 200, NOT NULL - content TEXT - created_at TIMESTAMP - Click "Create Table"
Step 5: Create Relationship
Now let's connect posts.user_id to users.id:
Drag-and-Drop Method
- Click on the right handle of
posts.user_idcolumn - Drag to the left handle of
users.idcolumn - Release to create the foreign key
You'll see a visual line with a N:1 badge! 🔗
Alternative: Edit Table
- Click on
poststable - Click "Edit Table" in the right panel
- Add relationship manually through FK fields
Step 6: Add Sample Data
Let's add some data to test:
- Click on
userstable - Click "Browse Data" button (or press Cmd+B)
- Click "Add Row"
- Fill in the data:
username: johndoe email: john@example.com - Click "Save"
Repeat for a few more users!
Step 7: Insert Related Data
Now add posts for your users:
- Click on
poststable - Click "Browse Data"
- Click "Add Row"
- Fill in:
user_id: 1 (the user you just created) title: My First Post content: This is my first post! - Click "Save"
Step 8: View Relationships
See the relationship in action:
- In the
postsdata browser - Click "Related" button next to a post
- It shows the parent user from
userstable! 🎯
Step 9: Run SQL Query
Let's run a JOIN query:
- In the "Browse Data" modal, click "Query" tab
- Try this query:sql
SELECT posts.*, users.username FROM posts JOIN users ON posts.user_id = users.id - Click "Run Query"
You'll see posts with usernames! 📊
Step 10: Preview SQL
See the generated DDL:
- Press Cmd+P (or click Preview SQL in toolbar)
- View the complete SQL schema
- Copy for version control or documentation
What You've Learned
✅ Connect to MySQL/MariaDB database
✅ Create tables visually
✅ Add columns with constraints
✅ Create foreign key relationships
✅ Browse and edit table data
✅ Navigate related records
✅ Run custom SQL queries
✅ Preview DDL schema
Next Steps
Explore More Features
- Undo/Redo: Press Cmd+Z to undo, Cmd+Shift+Z to redo
- Delete Table: Select table and press Delete key
- Fit View: Press F to fit all tables in view
- Keyboard Shortcuts: Hold Cmd/Ctrl to see all shortcuts
- Theme Toggle: Click Sun/Moon icon to switch themes
Common Workflows
Import Existing Schema
Already have a database?
- Connect to your database
- zxwdb automatically imports:
- All tables
- All columns with types
- Primary keys
- Foreign key relationships
- Start editing visually!
Design New Schema
Starting from scratch?
- Create new database
- Add tables one by one
- Create relationships by dragging
- Test with sample data
- Export SQL for production
Document Existing Database
Need documentation?
- Import existing schema
- Arrange tables nicely on canvas
- Take screenshot (built-in)
- Preview SQL for documentation
Tips and Tricks
Keyboard Navigation
Cmd+N / Ctrl+N - New Table
Cmd+B / Ctrl+B - Browse Data
Cmd+P / Ctrl+P - Preview SQL
Cmd+Z / Ctrl+Z - Undo
Cmd+Shift+Z - Redo
F - Fit View
Delete - Delete Selected Table
ESC - Close Modal/DeselectQuick Actions
- Double-click table to edit structure
- Right-click canvas for context menu
- Scroll to zoom in/out
- Drag canvas to pan
- Hold Cmd to see shortcuts overlay
Data Browser Tips
- Use Search to filter rows
- Click Related to navigate FKs
- Use Query Templates for common JOINs
- Ctrl+Enter to run queries quickly
Common Patterns
One-to-Many (1:N)
users (1) ----< posts (N)
users.id ----< posts.user_idUser has many posts.
Many-to-Many (N:N)
users --< user_roles >-- roles
users.id --< user_roles.user_id
roles.id --< user_roles.role_idUse junction table for many-to-many.
Self-Referencing
employees
- id
- name
- manager_id (references employees.id)Employees can have managers (who are also employees).
Troubleshooting
Table not appearing?
- Check console for errors (F12)
- Refresh the page
- Re-import schema
Relationship not creating?
- Ensure data types match (INT -> INT)
- Check both columns exist
- Verify no conflicting constraints
Data not saving?
- Check database connection
- Verify user permissions
- Check for constraint violations
Example Schemas
Blog System
users
- id (PK)
- username
- email
posts
- id (PK)
- user_id (FK -> users.id)
- title
- content
comments
- id (PK)
- post_id (FK -> posts.id)
- user_id (FK -> users.id)
- contentE-Commerce
customers
- id (PK)
- name
- email
orders
- id (PK)
- customer_id (FK -> customers.id)
- order_date
order_items
- id (PK)
- order_id (FK -> orders.id)
- product_id (FK -> products.id)
- quantity
products
- id (PK)
- name
- priceVideo Tutorial
🎥 Watch the video walkthrough: (Coming soon)
Need Help?
What's Next?
Now that you know the basics, explore advanced features:
Happy designing! 🚀