A worked example, rendered from real sample data. Sign in to run the tool on your own input.
users
posts
comments{
"diagram": "erDiagram\n USERS ||--o{ POSTS : writes\n USERS ||--o{ COMMENTS : makes\n POSTS ||--o{ COMMENTS : receives\n USERS ||--o{ LIKES : gives\n POSTS ||--o{ LIKES : receives\n USERS {\n int id PK\n string email UK \"unique\"\n string username UK \"unique\"\n string password_hash\n datetime created_at\n datetime updated_at\n }\n POSTS {\n int id PK\n int user_id FK\n string title\n text content\n int view_count\n datetime published_at\n }\n COMMENTS {\n int id PK\n int post_id FK\n int user_id FK\n text content\n datetime created_at\n }\n LIKES {\n int id PK\n int post_id FK\n int user_id FK\n datetime created_at\n }",
"format": "mermaid",
"title": "Database Schema (ER Diagram)",
"tables": [
"users",
"posts",
"comments",
"likes"
],
"relationships": [
"users-posts",
"users-comments",
"users-likes",
"posts-comments",
"posts-likes"
]
}
Generate database schema diagrams with tables, relationships, and field definitions. Part of the DevTools Surf developer suite. Browse more tools in the Diagrams & Workflows collection.