<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Matheus Agnes Dias</title>
    <description>The latest articles on Forem by Matheus Agnes Dias (@matheusagnes).</description>
    <link>https://forem.com/matheusagnes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3790171%2Fe18a8da2-1d4f-418d-8e03-844dc98a1731.png</url>
      <title>Forem: Matheus Agnes Dias</title>
      <link>https://forem.com/matheusagnes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/matheusagnes"/>
    <language>en</language>
    <item>
      <title>What is Data Modeling and Why It Matters</title>
      <dc:creator>Matheus Agnes Dias</dc:creator>
      <pubDate>Fri, 27 Feb 2026 13:36:49 +0000</pubDate>
      <link>https://forem.com/matheusagnes/what-is-data-modeling-and-why-it-matters-1npl</link>
      <guid>https://forem.com/matheusagnes/what-is-data-modeling-and-why-it-matters-1npl</guid>
      <description>&lt;p&gt;Data modeling is the process of creating a visual representation of your database structure. Learn why it's a critical step in software development and how it prevents costly mistakes down the road.&lt;/p&gt;




&lt;p&gt;Every software application that stores data relies on a database — and every database relies on a well-thought-out structure. Data modeling is the discipline of designing that structure before writing a single line of code. Think of it as the blueprint of your application's data layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Data Modeling Matters
&lt;/h2&gt;

&lt;p&gt;Without a data model, developers often make decisions on the fly: adding columns when needed, creating tables without considering relationships, and duplicating data across multiple places. This leads to inconsistencies, performance bottlenecks, and bugs that are expensive to fix later.&lt;/p&gt;

&lt;p&gt;A proper data model forces you to think about your domain upfront. What entities exist? How do they relate to each other? What constraints should the database enforce? Answering these questions early saves countless hours of refactoring.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conceptual, Logical, and Physical Models
&lt;/h2&gt;

&lt;p&gt;Data modeling typically happens in three layers. The conceptual model is the highest level — it identifies the main entities and their relationships without worrying about implementation details. For example: "Users have Orders, and Orders contain Products."&lt;/p&gt;

&lt;p&gt;The logical model adds more detail: column names, data types, primary keys, and foreign keys. This is where you define the actual schema your application will work with. Tools like ER Flow operate at this level, letting you visually design and refine your schema.&lt;/p&gt;

&lt;p&gt;The physical model is database-specific. It includes indexes, partitioning strategies, storage engines, and other performance optimizations. While important, these decisions are often made after the logical model is solid.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Cost of Skipping Data Modeling
&lt;/h2&gt;

&lt;p&gt;Teams that skip data modeling often end up with schemas that are hard to query, hard to maintain, and hard to evolve. Common symptoms include: tables with dozens of nullable columns, circular foreign key dependencies, duplicated data across tables, and migrations that break production.&lt;/p&gt;

&lt;p&gt;By investing 30 minutes in a visual data model before coding, you can avoid weeks of refactoring later. The ROI is enormous.&lt;/p&gt;

&lt;h2&gt;
  
  
  How ER Flow Helps
&lt;/h2&gt;

&lt;p&gt;ER Flow makes data modeling accessible to every developer. Instead of drawing diagrams in a generic tool or writing schemas in a text file, you can visually design your database with a purpose-built editor. Add tables, define relationships, generate migrations — all in one place.&lt;/p&gt;

&lt;p&gt;Whether you're a solo developer planning a side project or a team designing a complex multi-service architecture, data modeling is the foundation everything else is built on. Start with a model, and everything downstream becomes easier.&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
        &lt;div class="c-embed__cover"&gt;
          &lt;a href="https://erflow.io/en/blog/what-is-data-modeling" class="c-link align-middle" rel="noopener noreferrer"&gt;
            &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ferflow.io%2Fog-image.png" height="auto" class="m-0"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://erflow.io/en/blog/what-is-data-modeling" rel="noopener noreferrer" class="c-link"&gt;
            What is Data Modeling and Why It Matters | ER Flow
          &lt;/a&gt;
        &lt;/h2&gt;
          &lt;p class="truncate-at-3"&gt;
            Data modeling is the process of creating a visual representation of your database structure. Learn why it's a critical step in software development and how it prevents costly mistakes down the road.
          &lt;/p&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ferflow.io%2Ffavicon.svg"&gt;
          erflow.io
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;




</description>
      <category>database</category>
      <category>webdev</category>
      <category>programming</category>
      <category>ai</category>
    </item>
    <item>
      <title>AI-Powered Database Design with MCP Server</title>
      <dc:creator>Matheus Agnes Dias</dc:creator>
      <pubDate>Tue, 24 Feb 2026 19:18:30 +0000</pubDate>
      <link>https://forem.com/matheusagnes/ai-powered-database-design-with-mcp-server-59p4</link>
      <guid>https://forem.com/matheusagnes/ai-powered-database-design-with-mcp-server-59p4</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fojklzco370h9e9nzgxue.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fojklzco370h9e9nzgxue.png" alt=" " width="800" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We've all been there: you're starting a new project, and the first thing you need is a database schema. You open a text editor, start typing &lt;code&gt;CREATE TABLE users (...)&lt;/code&gt;, then &lt;code&gt;CREATE TABLE orders (...)&lt;/code&gt;, then you realize you forgot a foreign key, go back, fix the constraint names, wonder if you should use &lt;code&gt;UUID&lt;/code&gt; or &lt;code&gt;BIGINT&lt;/code&gt;... and 45 minutes later you have 6 tables and a headache.&lt;/p&gt;

&lt;p&gt;What if you could just &lt;em&gt;describe&lt;/em&gt; what you need in plain English and have your schema appear visually — tables, columns, relationships, and all?&lt;/p&gt;

&lt;p&gt;That's exactly what I've been doing for the past few months, and in this post I'll walk you through the workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with Traditional Database Design
&lt;/h2&gt;

&lt;p&gt;Most developers design databases in one of two ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;SQL-first&lt;/strong&gt;: Write &lt;code&gt;CREATE TABLE&lt;/code&gt; statements by hand, run them, realize you forgot something, write an &lt;code&gt;ALTER TABLE&lt;/code&gt;, repeat.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GUI tools&lt;/strong&gt;: Open MySQL Workbench or pgAdmin, click through dozens of dialogs to create each column one by one.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Both approaches share the same problem: &lt;strong&gt;they're slow and disconnected from your actual development workflow&lt;/strong&gt;. Your schema lives in one place, your code lives in another, and your migrations are a third thing you need to keep in sync manually.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter MCP: The Protocol That Changed Everything
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://modelcontextprotocol.io/" rel="noopener noreferrer"&gt;MCP (Model Context Protocol)&lt;/a&gt; is an open standard that lets AI coding assistants interact with external tools. Think of it as a universal plug that connects your AI assistant to any service — databases, APIs, design tools, you name it.&lt;/p&gt;

&lt;p&gt;Here's what this means in practice: &lt;strong&gt;your AI assistant can read, create, and modify your database schema directly&lt;/strong&gt;, and you see the changes visually in real-time.&lt;/p&gt;

&lt;p&gt;I use &lt;a href="https://erflow.io" rel="noopener noreferrer"&gt;ER Flow&lt;/a&gt; as my database design tool. It provides an MCP Server that exposes 25+ tools for schema management. When connected to an AI coding assistant like Cursor, the workflow looks like this:&lt;/p&gt;

&lt;h2&gt;
  
  
  The Setup (2 Minutes)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create a data model on &lt;a href="https://app.erflow.io" rel="noopener noreferrer"&gt;ER Flow&lt;/a&gt; and copy the MCP Server URL from the settings panel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Add this to your project's &lt;code&gt;.cursor/mcp.json&lt;/code&gt; (or equivalent for your AI tool):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"erflow"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://app.erflow.io/api/mcp/YOUR_UUID_HERE"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. No packages to install, no API keys to configure, no Docker containers to spin up.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Workflow in Action
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Designing a SaaS Schema from Scratch
&lt;/h3&gt;

&lt;p&gt;Here's a real example. I'm building a project management SaaS and I tell Cursor:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Create the database schema for a project management app. I need: users with email and password, organizations that users belong to, projects within organizations, tasks within projects with status, priority, assignee, and due date. Add proper indexes and foreign keys."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The AI reads the current schema (empty), then calls the ER Flow batch operations tool to create everything at once. Within seconds, I see this on my ER Flow canvas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;users&lt;/strong&gt; table with &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt;, &lt;code&gt;password_hash&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;created_at&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;organizations&lt;/strong&gt; table with a pivot table &lt;code&gt;organization_user&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;projects&lt;/strong&gt; table with &lt;code&gt;organization_id&lt;/code&gt; FK&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;tasks&lt;/strong&gt; table with &lt;code&gt;project_id&lt;/code&gt; and &lt;code&gt;assignee_id&lt;/code&gt; FKs, &lt;code&gt;status&lt;/code&gt; enum, &lt;code&gt;priority&lt;/code&gt;, &lt;code&gt;due_date&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;All foreign keys with proper &lt;code&gt;ON DELETE CASCADE&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Indexes on &lt;code&gt;email&lt;/code&gt;, &lt;code&gt;status&lt;/code&gt;, &lt;code&gt;assignee_id&lt;/code&gt;, &lt;code&gt;due_date&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The entire schema appears visually with relationship lines connecting the tables. No typing &lt;code&gt;CREATE TABLE&lt;/code&gt;. No clicking through dialogs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Iterating on the Design
&lt;/h3&gt;

&lt;p&gt;The real power shows up when you iterate:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Add a comments system to tasks. Users should be able to comment on tasks, and comments should support threading (replies to other comments)."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The AI checks the existing schema, understands the relationships, and adds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;task_comments&lt;/strong&gt; table with &lt;code&gt;task_id&lt;/code&gt;, &lt;code&gt;user_id&lt;/code&gt;, &lt;code&gt;parent_comment_id&lt;/code&gt; (self-referencing for threads), &lt;code&gt;body&lt;/code&gt;, &lt;code&gt;created_at&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Foreign keys to &lt;code&gt;tasks&lt;/code&gt;, &lt;code&gt;users&lt;/code&gt;, and self-referencing FK&lt;/li&gt;
&lt;li&gt;Index on &lt;code&gt;task_id&lt;/code&gt; for fast comment loading&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Catching Mistakes Before They Happen
&lt;/h3&gt;

&lt;p&gt;What I love most is that the AI can &lt;em&gt;see&lt;/em&gt; my existing schema before making changes. So if I ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Add a notifications table"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It won't just create a generic table. It'll see my existing &lt;code&gt;users&lt;/code&gt; and &lt;code&gt;organizations&lt;/code&gt; tables and create something like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;user_id&lt;/code&gt; FK pointing to my actual &lt;code&gt;users&lt;/code&gt; table&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;notifiable_type&lt;/code&gt; and &lt;code&gt;notifiable_id&lt;/code&gt; for polymorphic relations (if it sees that pattern in my schema)&lt;/li&gt;
&lt;li&gt;Proper indexes based on the queries it anticipates&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Generating Migrations
&lt;/h2&gt;

&lt;p&gt;Once my schema looks right on the ER Flow canvas, I create a checkpoint and generate migrations. ER Flow supports &lt;strong&gt;Laravel&lt;/strong&gt; and &lt;strong&gt;Phinx&lt;/strong&gt; migration formats with both &lt;code&gt;up()&lt;/code&gt; and &lt;code&gt;down()&lt;/code&gt; methods.&lt;/p&gt;

&lt;p&gt;The checkpoint-based diffing detects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Table creates, drops, and renames&lt;/li&gt;
&lt;li&gt;Column additions, modifications, and removals&lt;/li&gt;
&lt;li&gt;Index and foreign key changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I design visually, iterate with AI, and export production-ready migration files. No manual migration writing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Beats Other Approaches
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Schema Visibility&lt;/th&gt;
&lt;th&gt;AI Integration&lt;/th&gt;
&lt;th&gt;Collaboration&lt;/th&gt;
&lt;th&gt;Migrations&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Raw SQL files&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Copy-paste&lt;/td&gt;
&lt;td&gt;Git conflicts&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pgAdmin / Workbench&lt;/td&gt;
&lt;td&gt;Local GUI&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Not real-time&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;dbdiagram.io&lt;/td&gt;
&lt;td&gt;Visual&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;View-only&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ER Flow + MCP&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Visual, real-time&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Native (25+ tools)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Real-time (CRDTs)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Auto-generated&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sign up&lt;/strong&gt; at &lt;a href="https://app.erflow.io/register" rel="noopener noreferrer"&gt;erflow.io&lt;/a&gt; (free plan available)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create a data model&lt;/strong&gt; and choose your database engine (PostgreSQL, MySQL, Oracle, SQL Server, or SQLite)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Copy the MCP URL&lt;/strong&gt; from your model settings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add it to your AI tool&lt;/strong&gt; (&lt;code&gt;.cursor/mcp.json&lt;/code&gt;, Windsurf config, or Claude Code MCP settings)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Start describing your schema&lt;/strong&gt; in natural language&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The MCP Server works with any MCP-compatible AI tool: &lt;strong&gt;Cursor, Windsurf, Claude Code&lt;/strong&gt; (Claude's official CLI), and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips for Better Results
&lt;/h2&gt;

&lt;p&gt;After months of using this workflow, here are my tips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Start broad, then refine.&lt;/strong&gt; Describe the full schema first, then iterate on specific tables.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be specific about constraints.&lt;/strong&gt; Say "email should be unique" or "cascade delete on tasks when project is deleted" — the AI will set the right constraints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use &lt;code&gt;get-data-model-dbml&lt;/code&gt; explicitly&lt;/strong&gt; if the AI seems confused about the current state. This tool returns the full schema in DBML format.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch operations are your friend.&lt;/strong&gt; For creating multiple tables at once, the AI should use &lt;code&gt;batch-operations&lt;/code&gt; instead of individual &lt;code&gt;create-table&lt;/code&gt; calls.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>database</category>
      <category>ai</category>
      <category>mcp</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
