<?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: Roxana Maria Haidiner</title>
    <description>The latest articles on Forem by Roxana Maria Haidiner (@roxana_haidiner).</description>
    <link>https://forem.com/roxana_haidiner</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%2F2224346%2F437869c9-b515-4969-bf9c-782de882fb75.png</url>
      <title>Forem: Roxana Maria Haidiner</title>
      <link>https://forem.com/roxana_haidiner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/roxana_haidiner"/>
    <language>en</language>
    <item>
      <title>You should give it a try! 
VisuaLeaf is a very good MongoDB tool!</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Thu, 16 Apr 2026 14:49:47 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/you-should-give-it-a-try-visualeaf-is-a-very-good-mongodb-tool-28o9</link>
      <guid>https://forem.com/roxana_haidiner/you-should-give-it-a-try-visualeaf-is-a-very-good-mongodb-tool-28o9</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/visualeaf/a-faster-way-to-build-mongodb-queries-visually-4b0p" class="crayons-story__hidden-navigation-link"&gt;A Faster Way to Build MongoDB Queries Visually&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/visualeaf" class="crayons-avatar  crayons-avatar--l  "&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%2Fuser%2Fprofile_image%2F3818324%2F6cb54fe1-a36c-4f1a-a7b5-fa360f5daf8a.png" alt="visualeaf profile" class="crayons-avatar__image" width="150" height="150"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/visualeaf" class="crayons-story__secondary fw-medium m:hidden"&gt;
              VisuaLeaf
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                VisuaLeaf
                
              
              &lt;div id="story-author-preview-content-3460497" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/visualeaf" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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%2Fuser%2Fprofile_image%2F3818324%2F6cb54fe1-a36c-4f1a-a7b5-fa360f5daf8a.png" class="crayons-avatar__image" alt="" width="150" height="150"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;VisuaLeaf&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/visualeaf/a-faster-way-to-build-mongodb-queries-visually-4b0p" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 6&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/visualeaf/a-faster-way-to-build-mongodb-queries-visually-4b0p" id="article-link-3460497"&gt;
          A Faster Way to Build MongoDB Queries Visually
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/mongodb"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;mongodb&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/database"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;database&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/nosql"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;nosql&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/data"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;data&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/visualeaf/a-faster-way-to-build-mongodb-queries-visually-4b0p" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;8&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/visualeaf/a-faster-way-to-build-mongodb-queries-visually-4b0p#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              1&lt;span class="hidden s:inline"&gt; comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            6 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Highly recommended!</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Thu, 16 Apr 2026 14:49:00 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/highly-recommended-4ndg</link>
      <guid>https://forem.com/roxana_haidiner/highly-recommended-4ndg</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/visualeaf/visualeaf-as-a-mongodb-compass-alternative-blm" class="crayons-story__hidden-navigation-link"&gt;VisuaLeaf as a MongoDB Compass Alternative&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/visualeaf" class="crayons-avatar  crayons-avatar--l  "&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%2Fuser%2Fprofile_image%2F3818324%2F6cb54fe1-a36c-4f1a-a7b5-fa360f5daf8a.png" alt="visualeaf profile" class="crayons-avatar__image" width="150" height="150"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/visualeaf" class="crayons-story__secondary fw-medium m:hidden"&gt;
              VisuaLeaf
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                VisuaLeaf
                
              
              &lt;div id="story-author-preview-content-3511025" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/visualeaf" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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%2Fuser%2Fprofile_image%2F3818324%2F6cb54fe1-a36c-4f1a-a7b5-fa360f5daf8a.png" class="crayons-avatar__image" alt="" width="150" height="150"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;VisuaLeaf&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/visualeaf/visualeaf-as-a-mongodb-compass-alternative-blm" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 16&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/visualeaf/visualeaf-as-a-mongodb-compass-alternative-blm" id="article-link-3511025"&gt;
          VisuaLeaf as a MongoDB Compass Alternative
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/mongodb"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;mongodb&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/nosql"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;nosql&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/database"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;database&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/visualeaf/visualeaf-as-a-mongodb-compass-alternative-blm" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;5&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/visualeaf/visualeaf-as-a-mongodb-compass-alternative-blm#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            5 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Thu, 19 Mar 2026 13:22:57 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/-393k</link>
      <guid>https://forem.com/roxana_haidiner/-393k</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/visualeaf" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F3818324%2F6cb54fe1-a36c-4f1a-a7b5-fa360f5daf8a.png" alt="visualeaf"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/visualeaf/mongodb-aggregation-pipeline-explained-step-by-step-1of4" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;MongoDB Aggregation Pipeline Explained Step by Step&lt;/h2&gt;
      &lt;h3&gt;VisuaLeaf ・ Mar 18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#mongodb&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#nosql&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#database&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>mongodb</category>
      <category>nosql</category>
      <category>database</category>
      <category>beginners</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Tue, 30 Sep 2025 11:20:47 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/-5b91</link>
      <guid>https://forem.com/roxana_haidiner/-5b91</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/roxana_haidiner" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F2224346%2F437869c9-b515-4969-bf9c-782de882fb75.png" alt="roxana_haidiner"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/roxana_haidiner/sql-group-by-explained-with-examples-2l21" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;SQL GROUP BY Explained with Examples&lt;/h2&gt;
      &lt;h3&gt;Roxana Maria Haidiner ・ Sep 24&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#sql&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#database&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#mysql&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#postgres&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>sql</category>
      <category>database</category>
      <category>mysql</category>
      <category>postgres</category>
    </item>
    <item>
      <title>How to Create Custom Data Types in DbSchema</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Tue, 30 Sep 2025 11:20:10 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/how-to-create-custom-data-types-in-dbschema-2j0p</link>
      <guid>https://forem.com/roxana_haidiner/how-to-create-custom-data-types-in-dbschema-2j0p</guid>
      <description>&lt;p&gt;Custom data types in &lt;strong&gt;DbSchema’s Logical Design&lt;/strong&gt; help architects enforce consistent column definitions across large models (e.g., all usernames use the same length everywhere).&lt;br&gt;
&lt;strong&gt;Important:&lt;/strong&gt; these types are &lt;em&gt;design-time abstractions&lt;/em&gt;. When you deploy to a real database (e.g., MySQL), DbSchema generates the &lt;strong&gt;native DBMS type&lt;/strong&gt; (such as &lt;code&gt;VARCHAR(150)&lt;/code&gt;), not the custom name (&lt;code&gt;UserName&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Open Data Type Settings
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open your project in DbSchema.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;Model → Settings → DBMS Specific → Data Types&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;DBMS&lt;/strong&gt; selector, choose &lt;strong&gt;Logical Design&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&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%2F7n4jb206g2rqf4gfxkwh.webp" 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%2F7n4jb206g2rqf4gfxkwh.webp" alt="Custom data types" width="720" height="665"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Define a Custom Data Type
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;+ Add New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Give the type a clear, descriptive name and set its length:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;MoneyAmount&lt;/code&gt; → &lt;code&gt;DOUBLE&lt;/code&gt;, then mapped in Conversion Dictionary to DECIMAL(19,4).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CustomerCode&lt;/code&gt; → &lt;code&gt;CHAR(10)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CreatedAt&lt;/code&gt; → &lt;code&gt;TIMESTAMP&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt; to save.&lt;/li&gt;
&lt;/ul&gt;

&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%2Fbabwamzcm5chggmbx66k.webp" 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%2Fbabwamzcm5chggmbx66k.webp" alt="Create a Logical Design custom data type with a set length" width="673" height="202"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Map the Type for Deployment
&lt;/h2&gt;

&lt;p&gt;Your Logical Design type needs a mapping so that, on deployment, DbSchema generates the correct native DBMS type and precision.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Model → Conversion Dictionary&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;+Data Type&lt;/strong&gt;, and choose the data type created earlier. (MoneyAmount)&lt;/li&gt;
&lt;li&gt;Choose the target DBMS (e.g., MySQL).&lt;/li&gt;
&lt;li&gt;Map it to the native type and set the exact precision (e.g., &lt;code&gt;DECIMAL(19,4)&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Save.&lt;/li&gt;
&lt;/ol&gt;

&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%2Fdbp2zmnfxxcm98quvahx.webp" 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%2Fdbp2zmnfxxcm98quvahx.webp" alt="Custom Data Type" width="461" height="582"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Use the Custom Type in Your Model
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In the &lt;strong&gt;column editor&lt;/strong&gt;, select your custom type (e.g., &lt;code&gt;MoneyAmount&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;When you &lt;strong&gt;generate SQL&lt;/strong&gt; or &lt;strong&gt;deploy&lt;/strong&gt;, DbSchema applies the mapping and emits the native DBMS type.&lt;/li&gt;
&lt;/ul&gt;

&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%2Fqya4ccekhee5ejkr6dze.webp" 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%2Fqya4ccekhee5ejkr6dze.webp" alt="Precision Data Type" width="594" height="561"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;The Logical Design types are now mapped, so deployment emits native DBMS types.&lt;/p&gt;

&lt;h2&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%2Fvpai5yncz5n6i2sdghzn.webp" alt="Custom Data Type" width="604" height="538"&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  What Happens at Deployment?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;In the model:&lt;/strong&gt; you work with logical names like &lt;code&gt;MoneyAmount&lt;/code&gt;, &lt;code&gt;CustomerCode&lt;/code&gt;, &lt;code&gt;CreatedAt&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On deployment:&lt;/strong&gt; DbSchema &lt;strong&gt;automatically&lt;/strong&gt; converts each logical type to the mapped &lt;strong&gt;native DBMS type&lt;/strong&gt; (e.g., &lt;code&gt;MoneyAmount → DECIMAL(19,4)&lt;/code&gt;, &lt;code&gt;CustomerCode → CHAR(10)&lt;/code&gt;, &lt;code&gt;CreatedAt → TIMESTAMP&lt;/code&gt; in MySQL).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No extra steps:&lt;/strong&gt; the SQL generator uses your &lt;strong&gt;Conversion Dictionary&lt;/strong&gt;; you can preview the exact DDL in &lt;strong&gt;Schema Compare / Generate SQL&lt;/strong&gt; before applying.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In the database:&lt;/strong&gt; developers will see only the &lt;strong&gt;native types&lt;/strong&gt; (e.g., &lt;code&gt;DECIMAL(19,4)&lt;/code&gt;, &lt;code&gt;CHAR(10)&lt;/code&gt;, &lt;code&gt;TIMESTAMP&lt;/code&gt;) produced by these mappings.&lt;/li&gt;
&lt;/ul&gt;

&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%2Fpuhmsd0s6z30kxj0j4ri.webp" 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%2Fpuhmsd0s6z30kxj0j4ri.webp" alt="Convert to Physical Design" width="564" height="430"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;“Length required” prompts in MySQL UI:&lt;/strong&gt; expected &lt;em&gt;only&lt;/em&gt; if you use a DBMS-specific type. For Logical Design types, set the length in the type definition and the exact DBMS length in the &lt;strong&gt;Conversion Dictionary&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom name not visible in DB:&lt;/strong&gt; by design. Logical Design names are &lt;em&gt;model-level abstractions&lt;/em&gt;. The DB stores native types.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create custom types in &lt;strong&gt;Logical Design&lt;/strong&gt; to standardize columns.&lt;/li&gt;
&lt;li&gt;Use the &lt;strong&gt;Conversion Dictionary&lt;/strong&gt; to map each type to the exact native DBMS type (MoneyAmount → to DECIMAL(19,4) in MySQL).&lt;/li&gt;
&lt;li&gt;On deployment, DbSchema converts Logical Design names to &lt;strong&gt;native types&lt;/strong&gt;, ensuring consistency without leaking modeling abstractions into the database.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Next Step
&lt;/h2&gt;

&lt;p&gt;Want to try this out yourself?&lt;br&gt;
&lt;a href="https://dbschema.com/download.html" rel="noopener noreferrer"&gt;&lt;strong&gt;Download DbSchema Free Trial&lt;/strong&gt;&lt;/a&gt; and start designing with custom data types today.&lt;/p&gt;

&lt;p&gt;You may also find these guides helpful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/blog/design/design-a-relational-database-schema/"&gt;Design a Relational Database Schema&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/blog/design/logical-design-for-databases/"&gt;Logical Design for Databases&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>database</category>
      <category>sql</category>
      <category>mysql</category>
      <category>logicaldesign</category>
    </item>
    <item>
      <title>SQL GROUP BY Explained with Examples</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Wed, 24 Sep 2025 10:43:14 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/sql-group-by-explained-with-examples-2l21</link>
      <guid>https://forem.com/roxana_haidiner/sql-group-by-explained-with-examples-2l21</guid>
      <description>&lt;p&gt;When you work with databases, you often want &lt;strong&gt;summaries&lt;/strong&gt; instead of just raw rows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How many orders did each customer make?&lt;/li&gt;
&lt;li&gt;What are the total sales per department?&lt;/li&gt;
&lt;li&gt;What is the average grade per student?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where &lt;strong&gt;SQL GROUP BY&lt;/strong&gt; is useful.&lt;br&gt;
It allows you to group rows that share the same value and then apply functions like &lt;code&gt;COUNT()&lt;/code&gt;, &lt;code&gt;SUM()&lt;/code&gt;, or &lt;code&gt;AVG()&lt;/code&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  What You’ll Learn
&lt;/h2&gt;

&lt;p&gt;In this guide, we’ll cover the main &lt;code&gt;GROUP BY&lt;/code&gt; functions step by step:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;COUNT() - Count number of rows&lt;/li&gt;
&lt;li&gt;SUM() - Add up values&lt;/li&gt;
&lt;li&gt;AVG() - Calculate averages&lt;/li&gt;
&lt;li&gt;HAVING - Filter grouped results&lt;/li&gt;
&lt;li&gt;JOIN - Use names instead of IDs&lt;/li&gt;
&lt;li&gt;MIN() - Find the smallest value&lt;/li&gt;
&lt;li&gt;MAX() - Find the largest value&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Example Tables
&lt;/h2&gt;

&lt;p&gt;Let’s use a simple shop database with customers and their orders.&lt;/p&gt;

&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%2Fzu5rcac207cwau702xds.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%2Fzu5rcac207cwau702xds.png" alt="Customers and Orders Table" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;a id="count"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  GROUP BY with COUNT
&lt;/h3&gt;

&lt;p&gt;Count how many orders each customer has placed.&lt;/p&gt;

&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%2Fx2atfi7vx0pdmbfoi1ll.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%2Fx2atfi7vx0pdmbfoi1ll.png" alt="GROUP BY with COUNT" width="430" height="368"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT customer_id, COUNT(*) AS order_count
FROM Orders
GROUP BY customer_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Result:&lt;br&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%2Fe9lg2xg1vslu0u871704.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%2Fe9lg2xg1vslu0u871704.png" alt="Results" width="344" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each &lt;code&gt;customer_id&lt;/code&gt; is grouped, and the number of orders is counted.&lt;/p&gt;



&lt;p&gt;&lt;a id="sum"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  GROUP BY with SUM
&lt;/h3&gt;

&lt;p&gt;Now, let’s find the total spending of each customer.&lt;/p&gt;

&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%2Fc7c3d9rdvli6t1cotey6.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%2Fc7c3d9rdvli6t1cotey6.png" alt="GROUP BY with SUM" width="430" height="368"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT customer_id, SUM(total_amount) AS total_spent
FROM Orders
GROUP BY customer_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Result:&lt;br&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%2Fic2ale24270j7wwm3kp1.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%2Fic2ale24270j7wwm3kp1.png" alt="GROUP BY with SUM" width="365" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each &lt;code&gt;customer_id&lt;/code&gt; is grouped, and the &lt;code&gt;SUM(total_amount)&lt;/code&gt; gives the total money they spent.&lt;/p&gt;


&lt;h2&gt;
  
  
  Customers Table
&lt;/h2&gt;

&lt;p&gt;To make our reports more readable, let’s also create a &lt;code&gt;Customers&lt;/code&gt; table with names for each customer:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;customer_id&lt;/th&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Sarah James&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Mark White&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Olivia Reed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This table can be joined with &lt;code&gt;Orders&lt;/code&gt; using &lt;code&gt;customer_id&lt;/code&gt;.&lt;br&gt;
From now on, we’ll use JOINs so results will display &lt;strong&gt;names instead of IDs&lt;/strong&gt;.&lt;/p&gt;



&lt;p&gt;&lt;a id="avg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  GROUP BY with AVG
&lt;/h3&gt;

&lt;p&gt;You can also compute the &lt;strong&gt;average order value&lt;/strong&gt; per customer (showing names via JOIN).&lt;/p&gt;

&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%2Fw71jonzch54dp1qu33a9.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%2Fw71jonzch54dp1qu33a9.png" alt="GROUP BY with AVG" width="741" height="371"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT c.name, AVG(o.total_amount) AS avg_order
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id
GROUP BY c.name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Result:&lt;/p&gt;

&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%2Fm4eubrisho8qljszqtnh.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%2Fm4eubrisho8qljszqtnh.png" alt=" The Result" width="335" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sarah placed two orders worth 50 and 70 → the average is &lt;strong&gt;60&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;&lt;a id="having"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GROUP BY with HAVING
&lt;/h3&gt;

&lt;p&gt;Sometimes, you want to filter &lt;strong&gt;after&lt;/strong&gt; grouping.&lt;br&gt;
This is where &lt;code&gt;HAVING&lt;/code&gt; comes in (not &lt;code&gt;WHERE&lt;/code&gt;).&lt;/p&gt;

&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%2Fjena7htfm03w6vnmigcf.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%2Fjena7htfm03w6vnmigcf.png" alt="GROUP BY with HAVING" width="761" height="376"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT c.name, SUM(o.total_amount) AS total_spent
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id
GROUP BY c.name
HAVING SUM(o.total_amount) &amp;gt; 50;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Result:&lt;/p&gt;

&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%2Fnvsp913i4tvoimse1pix.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%2Fnvsp913i4tvoimse1pix.png" alt="The Result" width="350" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Only customers with spending over &lt;strong&gt;50&lt;/strong&gt; are included.&lt;/p&gt;




&lt;p&gt;&lt;a id="join"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GROUP BY with JOIN
&lt;/h3&gt;

&lt;p&gt;JOIN helps you show &lt;strong&gt;labels instead of IDs&lt;/strong&gt; in grouped results.&lt;/p&gt;

&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%2F4uk6nzg1twjq3i8vr0qu.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%2F4uk6nzg1twjq3i8vr0qu.png" alt="GROUP BY with JOIN" width="761" height="376"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT c.name, SUM(o.total_amount) AS total_spent
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id
GROUP BY c.name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Result:&lt;/p&gt;

&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%2F00dl49sglqghklb8c9cu.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%2F00dl49sglqghklb8c9cu.png" alt="The Result" width="340" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use JOIN whenever you want &lt;strong&gt;readable names&lt;/strong&gt; in your reports.&lt;/p&gt;




&lt;p&gt;&lt;a id="min"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GROUP BY with MIN
&lt;/h3&gt;

&lt;p&gt;Find the &lt;strong&gt;smallest order amount&lt;/strong&gt; per customer (names via JOIN).&lt;/p&gt;

&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%2F0fgapms4m9fcpmlv97ie.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%2F0fgapms4m9fcpmlv97ie.png" alt="GROUP BY with MIN" width="761" height="376"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT c.name, MIN(o.total_amount) AS min_order
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id
GROUP BY c.name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Result:&lt;/p&gt;

&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%2Fmyv9pzj77lq9h8ch2ns9.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%2Fmyv9pzj77lq9h8ch2ns9.png" alt="The Result" width="361" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This returns the &lt;strong&gt;lowest&lt;/strong&gt; order amount for each customer.&lt;/p&gt;




&lt;p&gt;&lt;a id="max"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GROUP BY with MAX
&lt;/h3&gt;

&lt;p&gt;Find the &lt;strong&gt;largest order amount&lt;/strong&gt; per customer (names via JOIN).&lt;/p&gt;

&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%2Fzjbx8w6r06xduq7s356j.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%2Fzjbx8w6r06xduq7s356j.png" alt="GROUP BY with MAX" width="761" height="376"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT c.name, MAX(o.total_amount) AS max_order
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id
GROUP BY c.name;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Result:&lt;/p&gt;

&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%2F5dqmyyapts7jd7iu8jew.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%2F5dqmyyapts7jd7iu8jew.png" alt="The Result" width="348" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This returns the &lt;strong&gt;highest&lt;/strong&gt; order amount for each customer.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to Do This Visually in DbSchema
&lt;/h2&gt;

&lt;p&gt;With &lt;a href="https://dbschema.com/" rel="noopener noreferrer"&gt;DbSchema&lt;/a&gt;, you don’t need to type SQL from scratch - you can build &lt;code&gt;GROUP BY&lt;/code&gt; queries visually in the &lt;a href="https://dbschema.com/documentation/query-builder.html" rel="noopener noreferrer"&gt;Query Builder&lt;/a&gt;:&lt;/p&gt;

&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%2F8yqecgves7itfjd24o2f.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%2F8yqecgves7itfjd24o2f.png" alt="SQL Aggregation Functions" width="800" height="677"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Drag your tables (&lt;strong&gt;Customers&lt;/strong&gt; and &lt;strong&gt;Orders&lt;/strong&gt;) into the canvas.&lt;/li&gt;
&lt;li&gt;Connect them by their &lt;strong&gt;foreign key&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the columns you want to display (e.g., &lt;code&gt;name&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Right-click on a numeric column (like &lt;code&gt;total_amount&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Aggregate → SUM, COUNT, AVG, MIN, MAX&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;DbSchema automatically adds the &lt;code&gt;GROUP BY&lt;/code&gt; for you and shows the generated SQL alongside the diagram.&lt;br&gt;
This makes it much easier to &lt;strong&gt;learn SQL&lt;/strong&gt; because you see both the visual structure and the query code at the same time.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GROUP BY&lt;/code&gt; groups rows with the same value.&lt;/li&gt;
&lt;li&gt;Combine with &lt;code&gt;COUNT&lt;/code&gt;, &lt;code&gt;SUM&lt;/code&gt;, &lt;code&gt;AVG&lt;/code&gt;, &lt;code&gt;MIN&lt;/code&gt;, &lt;code&gt;MAX&lt;/code&gt; to summarize data.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;HAVING&lt;/code&gt; to filter groups &lt;strong&gt;after&lt;/strong&gt; aggregation.&lt;/li&gt;
&lt;li&gt;Perfect for totals, averages, and category-based reports.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Learn More
&lt;/h2&gt;

&lt;p&gt;Check out more SQL tutorials here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dbschema.com/blog/tutorials/sql-joins-explained/" rel="noopener noreferrer"&gt;SQL Joins Explained&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dbschema.com/blog/tutorials/sql-aggregate-functions/" rel="noopener noreferrer"&gt;SQL Aggregate Functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dbschema.com/blog/tutorials/" rel="noopener noreferrer"&gt;All SQL Tutorials&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>mysql</category>
      <category>postgres</category>
    </item>
    <item>
      <title>Handle Large PostgreSQL Schemas with a GUI Tool</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Thu, 18 Sep 2025 13:24:51 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/handle-large-postgresql-schemas-with-a-gui-tool-16e0</link>
      <guid>https://forem.com/roxana_haidiner/handle-large-postgresql-schemas-with-a-gui-tool-16e0</guid>
      <description>&lt;p&gt;When a database is small, everything looks simple.&lt;br&gt;
You open the diagram, see a few tables, and it all makes sense.&lt;/p&gt;

&lt;p&gt;At first, a database looks simple.&lt;br&gt;
But as projects grow, so do the tables.&lt;br&gt;
Soon, the schema feels heavy, and even small changes become hard to track.&lt;/p&gt;

&lt;p&gt;This is where &lt;a href="https://dbschema.com/" rel="noopener noreferrer"&gt;DbSchema&lt;/a&gt; makes the work easier.&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Organize With Multiple Diagrams
&lt;/h2&gt;

&lt;p&gt;DbSchema lets you split a big schema into smaller &lt;a href="https://dbschema.com/documentation/diagram.html" rel="noopener noreferrer"&gt;diagrams&lt;/a&gt;.&lt;br&gt;
For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one diagram for &lt;code&gt;Orders &amp;amp; Transactions&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;another for &lt;code&gt;Customers &amp;amp; Billing&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;one more for &lt;code&gt;HR&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The database is the same, but you look only at the part you need.&lt;br&gt;
This keeps things clear even if the schema has more than 10,000 tables.&lt;/p&gt;

&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%2Fxfba1i5zzaaks71qv13n.webp" 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%2Fxfba1i5zzaaks71qv13n.webp" alt="Multiple Diagrams" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  2. Connect to Multiple Databases
&lt;/h2&gt;

&lt;p&gt;Most projects don’t have only one database.&lt;br&gt;
You usually work with Dev, Stage, and Prod.&lt;/p&gt;

&lt;p&gt;In DbSchema, you can save &lt;a href="https://dbschema.com/documentation/postgresql/" rel="noopener noreferrer"&gt;all connections&lt;/a&gt; in the same project and switch between them easily.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company_dev
company_stage
company_prod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One click, and you are connected to the right place.&lt;br&gt;
No need to remember passwords or JDBC URLs each time.&lt;/p&gt;

&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%2Fnq9w6kfbf23168vzt7eu.webp" 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%2Fnq9w6kfbf23168vzt7eu.webp" alt="Multiple Databases" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Make Safe Changes
&lt;/h2&gt;

&lt;p&gt;Changing a big schema is stressful.&lt;br&gt;
Instead of running &lt;code&gt;ALTER TABLE&lt;/code&gt; directly in production, do it step by step:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change the table visually in the diagram.&lt;/li&gt;
&lt;li&gt;Use &lt;a href="https://dbschema.com/documentation/schema-synchronization.html" rel="noopener noreferrer"&gt;Schema Compare&lt;/a&gt; to see what changed between the model and the database.&lt;/li&gt;
&lt;li&gt;Let DbSchema generate a &lt;strong&gt;migration script&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example migration:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ALTER TABLE company.orders
ADD COLUMN discount NUMERIC(5,2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Review it, test in Dev, then apply in Prod.&lt;br&gt;
This makes changes predictable and safe.&lt;/p&gt;

&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%2F192u31n8vdiio3hc27hd.webp" 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%2F192u31n8vdiio3hc27hd.webp" alt="Schema Compare" width="800" height="656"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  4. Documentation Everyone Can Read
&lt;/h2&gt;

&lt;p&gt;Large schemas confuse not only developers but also analysts and new colleagues.&lt;br&gt;
DbSchema can generate &lt;a href="https://dbschema.com/documentation/schema-documentation.html" rel="noopener noreferrer"&gt;HTML5 documentation&lt;/a&gt; that is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Complete&lt;/strong&gt; - includes tables, columns, indexes, and foreign keys&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visual&lt;/strong&gt; - shows diagrams for better understanding&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interactive&lt;/strong&gt; - you can click and navigate between tables&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Searchable&lt;/strong&gt; - quickly find a column or table by name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shareable&lt;/strong&gt; - publish it on an internal site for the whole team&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This way, everyone can explore the schema without asking you each time.&lt;/p&gt;
&lt;h2&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%2Fstyhiydtik174xghtva1.png" alt="HTML5 Docs" width="800" height="630"&gt;
&lt;/h2&gt;
&lt;h2&gt;
  
  
  5. Automation Scripts
&lt;/h2&gt;

&lt;p&gt;Large databases often need repetitive tasks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;creating new partitions every month,&lt;/li&gt;
&lt;li&gt;checking if important indexes exist,&lt;/li&gt;
&lt;li&gt;exporting schema snapshots for backups,&lt;/li&gt;
&lt;li&gt;or cleaning up old data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In DbSchema you can write &lt;a href="https://dbschema.com/documentation/automation-api.html" rel="noopener noreferrer"&gt;&lt;strong&gt;Automation Scripts&lt;/strong&gt; in Groovy&lt;/a&gt;.&lt;br&gt;
They run directly from the project, so you don’t have to manage external tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: create next month’s partition automatically&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;
&lt;span class="kt"&gt;def&lt;/span&gt; &lt;span class="n"&gt;nextMonth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;LocalDate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;now&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;plusMonths&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kt"&gt;def&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nextMonth&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;withDayOfMonth&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kt"&gt;def&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;plusMonths&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="kt"&gt;def&lt;/span&gt; &lt;span class="n"&gt;sql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"""
CREATE TABLE company.transactions_${start.getYear()}_${String.format("%02d", start.getMonthValue())}
PARTITION OF company.transactions
FOR VALUES FROM ('${start}') TO ('${end}');
"""&lt;/span&gt;

&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;execute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;println&lt;/span&gt; &lt;span class="s2"&gt;"Partition for ${start.getMonth()} ${start.getYear()} created."&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With scripts like this, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;keep partitions up to date,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;schedule routine checks,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;or generate data exports with a single click.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrap-Up
&lt;/h2&gt;

&lt;p&gt;Large PostgreSQL databases are not easy to handle.&lt;br&gt;
But with DbSchema you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;split diagrams into smaller views,&lt;/li&gt;
&lt;li&gt;work with multiple environments,&lt;/li&gt;
&lt;li&gt;apply changes safely,&lt;/li&gt;
&lt;li&gt;generate documentation,&lt;/li&gt;
&lt;li&gt;and automate routine tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This workflow keeps the database clear and manageable, even when it grows beyond &lt;strong&gt;10,000 tables&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Try it yourself for free with DbSchema. &lt;a href="https://dbschema.com/download.html" rel="noopener noreferrer"&gt;Download here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>postgressql</category>
      <category>database</category>
      <category>sql</category>
    </item>
    <item>
      <title>Create MySQL ER Diagrams with a Free Design Tool</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Wed, 27 Aug 2025 14:06:51 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/create-er-diagrams-for-mysql-with-a-free-gui-tool-2j4o</link>
      <guid>https://forem.com/roxana_haidiner/create-er-diagrams-for-mysql-with-a-free-gui-tool-2j4o</guid>
      <description>&lt;p&gt;When learning or working with a database, the first step is to &lt;strong&gt;see how the tables connect&lt;/strong&gt;. For &lt;a href="https://www.mysql.com/" rel="noopener noreferrer"&gt;MySQL&lt;/a&gt; users, the easiest way to do that is with an &lt;strong&gt;Entity-Relationship Diagram (ERD)&lt;/strong&gt;.&lt;br&gt;
Instead of reading long SQL scripts, an ER diagram gives you a clear picture of tables, keys, and relationships.&lt;/p&gt;

&lt;p&gt;In this guide, I’ll use &lt;a href="https://dbschema.com/" rel="noopener noreferrer"&gt;DbSchema&lt;/a&gt; - a free design tool for creating ER diagrams.&lt;br&gt;
It also includes extra features such as HTML5 documentation (for up to 12 tables in the free edition) and Git integration if you try the &lt;a href="https://dbschema.com/features.html" rel="noopener noreferrer"&gt;PRO version&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We’ll look at two main cases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reverse engineer an existing MySQL database&lt;/li&gt;
&lt;li&gt;Build a new schema visually&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  What Is an ER Diagram?
&lt;/h2&gt;

&lt;p&gt;An ER diagram is a drawing of your database.&lt;br&gt;
It shows tables (entities), their columns, and how they are connected with primary and foreign keys.&lt;/p&gt;

&lt;p&gt;It usually includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Table names and their columns&lt;/li&gt;
&lt;li&gt;Keys (primary and foreign)&lt;/li&gt;
&lt;li&gt;Relationships between tables&lt;/li&gt;
&lt;li&gt;Notes, data types, and indexes&lt;/li&gt;
&lt;/ul&gt;

&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%2F3kfzwtctvjw9yuqkgo5g.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%2F3kfzwtctvjw9yuqkgo5g.png" alt="MySQL ER Diagram" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why is this useful?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can understand the database structure at a glance&lt;/li&gt;
&lt;li&gt;It’s easier to explain it to others&lt;/li&gt;
&lt;li&gt;Missing or wrong relationships become obvious&lt;/li&gt;
&lt;li&gt;New colleagues can get onboarded faster&lt;/li&gt;
&lt;li&gt;It helps when documenting or keeping track of changes&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  If You Already Have a Database
&lt;/h2&gt;

&lt;p&gt;With DbSchema, you don’t need to draw everything by hand.&lt;br&gt;
You can &lt;strong&gt;reverse engineer your MySQL database&lt;/strong&gt;: the tool connects to your schema, reads the tables and foreign keys, and builds a diagram automatically.&lt;/p&gt;

&lt;p&gt;Here’s an example of a MySQL schema as an ER diagram:&lt;/p&gt;

&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%2Fhaf868ct1sgzrquzcaq6.webp" 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%2Fhaf868ct1sgzrquzcaq6.webp" alt="ER Diagram for MySQL" width="800" height="573"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Want step-by-step instructions?&lt;br&gt;
&lt;a href="https://dbschema.com/documentation/diagram.html" rel="noopener noreferrer"&gt;Check the documentation here&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Designing a Schema Visually
&lt;/h2&gt;

&lt;p&gt;Sometimes you don’t have a database yet, you just have an idea.&lt;br&gt;
Instead of starting with &lt;code&gt;CREATE TABLE&lt;/code&gt; statements, you can draw it out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add new tables with a click&lt;/li&gt;
&lt;li&gt;Define columns, data types, and keys using simple forms&lt;/li&gt;
&lt;li&gt;Drag lines between tables to create relationships&lt;/li&gt;
&lt;li&gt;Rearrange the diagram for clarity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When ready, you can generate the SQL code automatically.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dbschema.com/blog/design/design-a-relational-database-schema/" rel="noopener noreferrer"&gt;Learn more about designing schemas visually&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  1. Organize with Multiple Layouts
&lt;/h4&gt;

&lt;p&gt;If your database only has a few tables, one diagram might be enough.&lt;br&gt;
But once you start adding more, things can get messy.&lt;/p&gt;

&lt;p&gt;In DbSchema, you can create &lt;strong&gt;multiple layouts&lt;/strong&gt; of the same schema.&lt;br&gt;
For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A diagram showing &lt;strong&gt;user and authentication tables&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;A separate one for &lt;strong&gt;products and orders&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Another one for &lt;strong&gt;reporting or logs&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All layouts still point to the same schema, but splitting them up keeps them &lt;strong&gt;clear and readable&lt;/strong&gt;.&lt;br&gt;
This is especially useful in large MySQL databases where hundreds of tables exist.&lt;/p&gt;




&lt;h4&gt;
  
  
  2. Keep It Synchronized
&lt;/h4&gt;

&lt;p&gt;Databases are never static - columns get added, constraints change, and indexes are tuned.&lt;/p&gt;

&lt;p&gt;With DbSchema’s &lt;strong&gt;Schema Compare&lt;/strong&gt; feature, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compare the diagram with the live MySQL database&lt;/li&gt;
&lt;li&gt;See exactly what changed (new tables, dropped columns, altered constraints)&lt;/li&gt;
&lt;li&gt;Choose whether to update the diagram or apply changes back to the database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This prevents surprises and ensures the diagram and the real database stay in sync.&lt;br&gt;
It’s like a two-way mirror - you can decide which side becomes the source of truth.&lt;/p&gt;

&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%2Fmy7lni37kymsyogg15ga.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%2Fmy7lni37kymsyogg15ga.png" alt="Schema Compare" width="800" height="594"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  3. Use Git for Version Control
&lt;/h4&gt;

&lt;p&gt;Your diagram is saved in a &lt;strong&gt;project file (.dbs)&lt;/strong&gt;.&lt;br&gt;
This file can be committed to Git just like code, which means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can &lt;strong&gt;track every change&lt;/strong&gt; (e.g., when a column is renamed or a new table is added)&lt;/li&gt;
&lt;li&gt;Work in a team without overwriting each other’s changes&lt;/li&gt;
&lt;li&gt;Roll back to earlier versions if a design decision didn’t work out&lt;/li&gt;
&lt;li&gt;Keep schema design history alongside your application code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes database design a &lt;strong&gt;collaborative process&lt;/strong&gt;, not just a one-person job.&lt;/p&gt;

&lt;h2&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%2Ffx8xe6nz1cpfzd7c887b.png" alt="Git Integration in MySQL" width="800" height="544"&gt;
&lt;/h2&gt;

&lt;h4&gt;
  
  
  4. Share with HTML5 Documentation
&lt;/h4&gt;

&lt;p&gt;Not everyone on your team knows SQL, but they might still need to understand the database.&lt;/p&gt;

&lt;p&gt;With DbSchema, you can export your ER diagram as &lt;a href="https://dbschema.com/documentation/schema-documentation.html" rel="noopener noreferrer"&gt;interactive HTML5 documentation&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Opens in any browser (no installation required)&lt;/li&gt;
&lt;li&gt;Tables are clickable - you can see all the details from the columns and constraints&lt;/li&gt;
&lt;li&gt;Notes and comments are included&lt;/li&gt;
&lt;li&gt;Great for sending to managers, analysts, or clients&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s like publishing your schema online in a &lt;strong&gt;clickable, explorable form&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&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%2Fvcb3qm4k2wno7nexkdcs.png" alt="HTML5  Docs for MySQL" width="800" height="676"&gt;
&lt;/h2&gt;

&lt;h4&gt;
  
  
  5. Notes and Comments
&lt;/h4&gt;

&lt;p&gt;Sometimes a diagram isn’t enough. People want to know &lt;em&gt;why&lt;/em&gt; something is designed in a certain way.&lt;/p&gt;

&lt;p&gt;In DbSchema, you can add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Notes on tables&lt;/strong&gt; (e.g., "This table stores archived orders older than 2 years")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Notes on relationships&lt;/strong&gt; (e.g., "One customer can have multiple addresses")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comments on columns&lt;/strong&gt; (e.g., "This column is auto-incremented for IDs")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These annotations are not just helpful for your teammates. They also &lt;strong&gt;show up in the exported HTML docs&lt;/strong&gt;, making your schema easier to understand for anyone who reads it.&lt;/p&gt;

&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%2Faiwlm00a4nmop9rpjbg3.webp" 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%2Faiwlm00a4nmop9rpjbg3.webp" alt="Comments and Tags in MySQL" width="786" height="505"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Export Options
&lt;/h4&gt;

&lt;p&gt;Once you’re done, you can export your design in different ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Images (PNG, PDF)&lt;/strong&gt; for reports or presentations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SQL scripts&lt;/strong&gt; to deploy your schema&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interactive HTML5&lt;/strong&gt; for easy sharing with teammates&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Benefits of Using DbSchema for MySQL ER Diagrams
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Free Version Available&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Create diagrams without a license&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Visual Interface&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Build schemas without typing SQL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Offline Mode&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Work even without a live MySQL connection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Schema Compare&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Spot differences between model and database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;HTML5 Documentation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Generate clickable docs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Git Integration&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Keep track of schema changes in teams&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Multi-Database Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Works with PostgreSQL, Oracle, SQL Server, and more&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;For MySQL users, ER diagrams are the easiest way to understand and manage a schema.&lt;br&gt;
They make relationships clear, reduce mistakes, and improve teamwork.&lt;/p&gt;

&lt;p&gt;Whether you’re documenting an old database or planning a new one, drawing it visually makes the job simpler.&lt;/p&gt;

&lt;p&gt;You can try all of this with the &lt;strong&gt;free version of DbSchema&lt;/strong&gt; – a straightforward tool to design, organize, and share MySQL databases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dbschema.com/download.html" rel="noopener noreferrer"&gt;Download DbSchema here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>mysql</category>
      <category>database</category>
      <category>tooling</category>
    </item>
    <item>
      <title>SQL Joins Explained - INNER, LEFT, RIGHT, FULL</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Fri, 22 Aug 2025 19:31:45 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/sql-joins-explained-inner-left-right-full-1ofc</link>
      <guid>https://forem.com/roxana_haidiner/sql-joins-explained-inner-left-right-full-1ofc</guid>
      <description>&lt;p&gt;When working with databases, your data is often stored in more than one table.&lt;br&gt;
But how can you bring the data together?&lt;/p&gt;

&lt;p&gt;This is what SQL JOINs are for.&lt;br&gt;
A JOIN helps you combine rows from two tables based on a related column, usually a column that appears in both.&lt;/p&gt;
&lt;h2&gt;
  
  
  Types of SQL JOINs
&lt;/h2&gt;

&lt;p&gt;Here are the most common types of JOINs and what they do:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;JOIN Type&lt;/th&gt;
&lt;th&gt;What it returns&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;INNER JOIN&lt;/td&gt;
&lt;td&gt;Only rows that exist in both tables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LEFT JOIN&lt;/td&gt;
&lt;td&gt;All rows from the left table and matching rows from the right table&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RIGHT JOIN&lt;/td&gt;
&lt;td&gt;All rows from the right table and matching rows from the left table&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FULL JOIN&lt;/td&gt;
&lt;td&gt;All rows from both tables&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  What Is a SQL JOIN?
&lt;/h2&gt;

&lt;p&gt;Let’s say you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One table with a list of &lt;strong&gt;employees&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Another table with a list of &lt;strong&gt;departments&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each employee works in a department. If we want to know &lt;strong&gt;who works where&lt;/strong&gt;, we need to connect the tables using a JOIN.&lt;/p&gt;

&lt;p&gt;The JOIN compares values in both tables and brings the matching rows together.&lt;/p&gt;


&lt;h2&gt;
  
  
  Example Tables
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Table: Employees
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;employee_id&lt;/th&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;department_id&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Sarah James&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Mark White&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Olivia Reed&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  Table: Departments
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;department_id&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Engineering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;Sales&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;


&lt;h2&gt;
  
  
  INNER JOIN
&lt;/h2&gt;

&lt;p&gt;Returns only employees who are assigned to a department.&lt;/p&gt;

&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%2Fgod0npmk54twlr1znl6r.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%2Fgod0npmk54twlr1znl6r.png" alt="INNER JOIN" width="200" height="200"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT name, department_name
FROM Employees
INNER JOIN Departments
ON Employees.department_id = Departments.department_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;➝&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sarah James&lt;/td&gt;
&lt;td&gt;Engineering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mark White&lt;/td&gt;
&lt;td&gt;Sales&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Employees without a department, and departments with no employees, are not shown.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  LEFT JOIN
&lt;/h2&gt;

&lt;p&gt;Returns all employees, even if they don’t belong to any department.&lt;/p&gt;

&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%2Figzlm2s34if92cl9bf3x.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%2Figzlm2s34if92cl9bf3x.png" alt="LEFT JOIN" width="200" height="200"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT name, department_name
FROM Employees
LEFT JOIN Departments
ON Employees.department_id = Departments.department_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;➝&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sarah James&lt;/td&gt;
&lt;td&gt;Engineering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mark White&lt;/td&gt;
&lt;td&gt;Sales&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Olivia Reed&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You get &lt;strong&gt;all employees&lt;/strong&gt;.&lt;br&gt;
If they have no department, the result will show &lt;code&gt;NULL&lt;/code&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  RIGHT JOIN
&lt;/h2&gt;

&lt;p&gt;Returns &lt;strong&gt;all departments&lt;/strong&gt;, even if no employee is assigned to them.&lt;/p&gt;

&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%2Fbdfxz7yfr4cpr1kx5t4j.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%2Fbdfxz7yfr4cpr1kx5t4j.png" alt="RIGHT JOIN" width="200" height="200"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT name, department_name
FROM Employees
RIGHT JOIN Departments
ON Employees.department_id = Departments.department_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;➝&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sarah James&lt;/td&gt;
&lt;td&gt;Engineering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mark White&lt;/td&gt;
&lt;td&gt;Sales&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You get &lt;strong&gt;all departments&lt;/strong&gt;.&lt;br&gt;
If no one works there, the result shows &lt;code&gt;NULL&lt;/code&gt; for the name.&lt;/p&gt;


&lt;h2&gt;
  
  
  FULL JOIN
&lt;/h2&gt;

&lt;p&gt;Returns &lt;strong&gt;all employees&lt;/strong&gt; and &lt;strong&gt;all departments&lt;/strong&gt;.&lt;br&gt;
If they match, they are shown together.&lt;br&gt;
If not, one side will be &lt;code&gt;NULL&lt;/code&gt;.&lt;/p&gt;

&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%2Fgui4dnu9xw2gs8peqs6o.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%2Fgui4dnu9xw2gs8peqs6o.png" alt="FULL JOIN" width="200" height="200"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT name, department_name
FROM Employees
FULL JOIN Departments
ON Employees.department_id = Departments.department_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;➝&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sarah James&lt;/td&gt;
&lt;td&gt;Engineering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mark White&lt;/td&gt;
&lt;td&gt;Sales&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Olivia Reed&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This gives you the &lt;strong&gt;full picture&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use INNER JOIN&lt;/strong&gt; when you want only matching data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use LEFT JOIN&lt;/strong&gt; when you want all rows from the first table&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use RIGHT JOIN&lt;/strong&gt; when you want all rows from the second table&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use FULL JOIN&lt;/strong&gt; when you want everything, matched or not&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to Do This Visually in DbSchema
&lt;/h2&gt;

&lt;p&gt;You can use &lt;a href="https://dbschema.com/" rel="noopener noreferrer"&gt;DbSchema&lt;/a&gt; to build JOINs without writing any SQL.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Drag the two tables into the canvas&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect them by dragging from one column to the other, to create a &lt;a href="https://dbschema.com/blog/tutorials/what-is-a-foreign-key/" rel="noopener noreferrer"&gt;foreign key&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&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%2Fvjvi7aisecuknwxwm7ua.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%2Fvjvi7aisecuknwxwm7ua.png" alt="Foreign Key in DbSchema" width="627" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the &lt;a href="https://dbschema.com/documentation/query-builder.html" rel="noopener noreferrer"&gt;Query Builder&lt;/a&gt; and cascade related tables&lt;/li&gt;
&lt;/ol&gt;

&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%2Flxnbuzdum6q1r33f6a55.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%2Flxnbuzdum6q1r33f6a55.png" alt="Query Builder in DbSchema" width="507" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Right-click the line to select the &lt;strong&gt;JOIN type&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose the columns you want to display&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&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%2Fhkri05pzowdpcm6zf2v6.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%2Fhkri05pzowdpcm6zf2v6.png" alt="Query Builder in DbSchema" width="569" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run the query and see the results&lt;/li&gt;
&lt;/ol&gt;

&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%2Fvt5ov03ctyss978d464f.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%2Fvt5ov03ctyss978d464f.png" alt="Query Builder in DbSchema" width="703" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a great way to &lt;strong&gt;learn how JOINs work&lt;/strong&gt;, because &lt;a href="https://dbschema.com/download.html" rel="noopener noreferrer"&gt;DbSchema&lt;/a&gt; auto-generates SQL code for you!&lt;/p&gt;

&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%2Fd22yjuvqycap94bz0op3.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%2Fd22yjuvqycap94bz0op3.png" alt="Query Builder in DbSchema" width="587" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The JOIN types shown in the menu depend on the database you are connected to.&lt;br&gt;
Some databases (like SQLite) do not support &lt;code&gt;RIGHT JOIN&lt;/code&gt; or &lt;code&gt;FULL JOIN&lt;/code&gt;.&lt;br&gt;
In these cases, DbSchema will only show the join types supported by your database.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Learn More
&lt;/h2&gt;

&lt;p&gt;If you're learning SQL and want more examples, visit our full SQL Tutorial here:&lt;br&gt;
[&lt;a href="https://dbschema.com/blog/tutorials/" rel="noopener noreferrer"&gt;https://dbschema.com/blog/tutorials/&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>mysql</category>
      <category>postgres</category>
    </item>
    <item>
      <title>How to Design a PostgreSQL Schema Visually (Step-by-Step)</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Wed, 20 Aug 2025 11:14:15 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/how-to-design-a-postgresql-schema-visually-step-by-step-2d6a</link>
      <guid>https://forem.com/roxana_haidiner/how-to-design-a-postgresql-schema-visually-step-by-step-2d6a</guid>
      <description>&lt;h2&gt;
  
  
  1. What is a Schema?
&lt;/h2&gt;

&lt;p&gt;In &lt;a href="https://www.postgresql.org/docs/current/ddl-schemas.html" rel="noopener noreferrer"&gt;PostgreSQL&lt;/a&gt;, a schema is just a folder inside your database where you keep your tables, views, and other objects. You can even have the same table name in different schemas. It’s best to name it after your app so it’s easy to keep things organized.&lt;/p&gt;

&lt;p&gt;In our case, we’ll create a schema called school.&lt;/p&gt;

&lt;p&gt;Example in SQL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE SCHEMA school;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;a href="https://dbschema.com/" rel="noopener noreferrer"&gt;DbSchema tool&lt;/a&gt;, you can create it following these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. Start a new schema from scratch in the "Welcome Screen".&lt;/li&gt;
&lt;li&gt;2. Select the &lt;strong&gt;PostgreSQL&lt;/strong&gt; database and name the project (model) as you wish.&lt;/li&gt;
&lt;li&gt;3. Right-click in the database tree → &lt;strong&gt;Create → Schema&lt;/strong&gt; → give it a name, like &lt;code&gt;school&lt;/code&gt;, in our case.&lt;/li&gt;
&lt;/ul&gt;

&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%2Fnkwxa9dbtbo1omaktf68.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%2Fnkwxa9dbtbo1omaktf68.png" alt="Create Schema Visually" width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Why Visual Design Helps?
&lt;/h2&gt;

&lt;p&gt;When you design visually a ER diagram:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You see all the tables and how they connect&lt;/li&gt;
&lt;li&gt;Which columns are keys or have constraints&lt;/li&gt;
&lt;li&gt;You can drag to create foreign keys (relationships)&lt;/li&gt;
&lt;li&gt;The tool writes the SQL for you&lt;/li&gt;
&lt;/ul&gt;

&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%2F6k0hwj4991ew5r3xehwb.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%2F6k0hwj4991ew5r3xehwb.png" alt="Create ER Diagram Visually" width="634" height="491"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Example Database
&lt;/h2&gt;

&lt;p&gt;For our example, let’s design a database for a school system.&lt;br&gt;
We’ll start with three main tables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;students&lt;/strong&gt; - information about students&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;courses&lt;/strong&gt; - information about courses&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;enrollments&lt;/strong&gt; - which student is in which course&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When adding columns, choose &lt;strong&gt;PostgreSQL-specific data types&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SERIAL&lt;/code&gt; - auto-incrementing integers, often used for primary keys&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;VARCHAR(n)&lt;/code&gt; - variable-length text&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DATE&lt;/code&gt; - calendar dates&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;BOOLEAN&lt;/code&gt; - true/false values&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  1. Creating a Table with SQL
&lt;/h4&gt;

&lt;p&gt;Usually, when working directly in PostgreSQL, you would create a table by writing SQL in the SQL editor.&lt;br&gt;
For example, here’s how we can create a &lt;code&gt;students&lt;/code&gt; table inside the &lt;code&gt;school&lt;/code&gt; schema:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: students table&lt;/strong&gt;&lt;/p&gt;

&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%2Fkpttaw4z2dc0acnnjfmb.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%2Fkpttaw4z2dc0acnnjfmb.png" alt="Create Table SQL Tool" width="444" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why &lt;code&gt;school&lt;/code&gt;.students?&lt;br&gt;
You write the schema name first &lt;code&gt;(school)&lt;/code&gt; because you can have multiple schemas in the same database, and this keeps your tables organized.&lt;/p&gt;

&lt;p&gt;After running this SQL, DbSchema will show the table visually in the diagram, with all columns, keys, and data types.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Creating the Second Table Visually
&lt;/h4&gt;

&lt;p&gt;For the next table, let’s use &lt;a href="https://dbschema.com/blog/postgresql/create-er-diagrams/" rel="noopener noreferrer"&gt;DbSchema’s visual design&lt;/a&gt; instead of writing SQL:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Right-click&lt;/strong&gt; in the diagram area&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Create Table&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Type the table name – for example, &lt;code&gt;courses&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add columns:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;course_id&lt;/code&gt; – Primary Key&lt;/li&gt;
&lt;li&gt;&lt;code&gt;course_name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;start_date&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;end_date&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Mark the primary key column&lt;/li&gt;
&lt;/ol&gt;

&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%2Fsk32g0alqim9xmt6hi1v.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%2Fsk32g0alqim9xmt6hi1v.png" alt="Create Table Visually" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The best part:&lt;/strong&gt;&lt;br&gt;
While you work visually, DbSchema shows you the SQL code it generates in real time. You can copy or run that code directly if needed.&lt;/p&gt;

&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%2Fbqibdrl6twman0jwl8eq.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%2Fbqibdrl6twman0jwl8eq.png" alt="View SQL Auto-generated code" width="737" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Creating a Foreign Key in DbSchema
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Creating a Foreign Key Using SQL
&lt;/h3&gt;

&lt;p&gt;You can create a foreign key directly in the SQL Editor.&lt;br&gt;
For example, linking &lt;code&gt;enrollments.student_id&lt;/code&gt; to &lt;code&gt;students.student_id&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example for a cascade rule:&lt;/strong&gt;&lt;/p&gt;

&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%2F96ar4wzwe103oa37jt23.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%2F96ar4wzwe103oa37jt23.png" alt="Create a Foregin Key in PostgreSQL" width="609" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you run this command, DbSchema will update the diagram so you can see the foreign key visually.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Creating a Foreign Key Visually
&lt;/h3&gt;

&lt;p&gt;You can also create foreign keys without writing SQL, using the diagram:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Drag&lt;/strong&gt; from the &lt;code&gt;student_id&lt;/code&gt; column in the &lt;code&gt;enrollments&lt;/code&gt; table&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Drop&lt;/strong&gt; onto the &lt;code&gt;student_id&lt;/code&gt; column in the &lt;code&gt;students&lt;/code&gt; table&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Edit Foreign Key&lt;/strong&gt; dialog:

&lt;ul&gt;
&lt;li&gt;Give the foreign key a name (e.g., &lt;code&gt;fk_enrollments_students&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Verify the referring and referred columns&lt;/li&gt;
&lt;li&gt;Optionally set &lt;strong&gt;On Delete&lt;/strong&gt; or &lt;strong&gt;On Update&lt;/strong&gt; actions&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The foreign key line will appear in the diagram, and DbSchema will generate the SQL automatically in the background.&lt;/p&gt;

&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%2Fnobcxcelrheag42yxmxv.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%2Fnobcxcelrheag42yxmxv.png" alt="Create a Foregin Key in PostgreSQL" width="724" height="748"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Add Comments and Tags
&lt;/h2&gt;

&lt;p&gt;While designing your schema in DbSchema, you can add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Comments&lt;/strong&gt; to tables or columns to explain their purpose&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tags&lt;/strong&gt; to group related tables or mark certain objects for review&lt;/li&gt;
&lt;/ul&gt;

&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%2Fjq528pcs2u6rih0yutl4.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%2Fjq528pcs2u6rih0yutl4.png" alt="Create a COMMENT in PostgreSQL" width="743" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These notes are saved in your model and can be included in the generated documentation.&lt;br&gt;
This is useful when working in teams, so everyone understands the meaning of each table and column.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Synchronize Schema Changes
&lt;/h2&gt;

&lt;p&gt;If you are connected to your PostgreSQL server from the start, DbSchema will apply changes immediately as you create or edit tables.&lt;/p&gt;

&lt;p&gt;If you design &lt;strong&gt;offline&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Complete your schema design&lt;/li&gt;
&lt;li&gt;Go online and connect to PostgreSQL&lt;/li&gt;
&lt;li&gt;Open the &lt;strong&gt;Synchronization&lt;/strong&gt; dialog&lt;/li&gt;
&lt;li&gt;Review the differences between your model and the database&lt;/li&gt;
&lt;li&gt;Choose which changes to apply to PostgreSQL&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This way, you can work without affecting the live database until you’re ready.&lt;/p&gt;

&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%2Fbs9jhf4z11yk2rx6zlr1.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%2Fbs9jhf4z11yk2rx6zlr1.png" alt="Synchronize Schema Changes" width="800" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Save and Share Your Schema
&lt;/h2&gt;

&lt;p&gt;Once your schema is ready, you can save it as a &lt;strong&gt;model&lt;/strong&gt; file (&lt;code&gt;.dbs&lt;/code&gt;).&lt;br&gt;
This file is XML and contains your entire project, including tables, relationships, comments, and tags.&lt;/p&gt;

&lt;h3&gt;
  
  
  Working in a Team
&lt;/h3&gt;

&lt;p&gt;You can store this &lt;code&gt;.dbs&lt;/code&gt; file in a &lt;a href="https://www.dbschema.com/documentation/git.html" rel="noopener noreferrer"&gt;Git repository&lt;/a&gt; so multiple team members can work on the same schema.&lt;br&gt;
DbSchema has &lt;strong&gt;Git Integration&lt;/strong&gt; built in, making it easy to pull updates, merge changes, and keep everyone in sync.&lt;/p&gt;

&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%2Fm2vffr1evyxp7dgsgjws.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%2Fm2vffr1evyxp7dgsgjws.png" alt="Git integration Schema Changes" width="800" height="598"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Sharing the Design
&lt;/h3&gt;

&lt;p&gt;You can share your work easily:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Export as interactive &lt;a href="https://dbschema.com/blog/dbschema-features/generate-database-documentation/" rel="noopener noreferrer"&gt;HTML5 documentation&lt;/a&gt;&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Includes your ER diagram and all schema details&lt;/li&gt;
&lt;li&gt;Displays table structures, relationships, and comments&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;No DbSchema required&lt;/strong&gt; for viewers

&lt;ul&gt;
&lt;li&gt;SVG image, which is interactive and low in size&lt;/li&gt;
&lt;li&gt;Team members or stakeholders can open it directly in their browser&lt;/li&gt;
&lt;li&gt;They can explore the diagram and table details interactively&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&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%2Fdxg0ogvyxe7tdpzs8zly.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%2Fdxg0ogvyxe7tdpzs8zly.png" alt="Generate HTML5 Documentation" width="800" height="630"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A PostgreSQL schema is a way to organize your tables and other database objects so everything stays clear and structured.&lt;br&gt;
You can create it with SQL commands or design it visually for a more intuitive experience.&lt;/p&gt;

&lt;p&gt;If you want to try designing a PostgreSQL schema visually for free, &lt;a href="https://dbschema.com/download.html" rel="noopener noreferrer"&gt;download DbSchema&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>postgressql</category>
      <category>postgres</category>
      <category>sql</category>
      <category>database</category>
    </item>
    <item>
      <title>What Is a Primary Key in SQL? Learn with Examples</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Fri, 08 Aug 2025 14:49:52 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/what-is-a-primary-key-in-sql-learn-with-examples-4bbl</link>
      <guid>https://forem.com/roxana_haidiner/what-is-a-primary-key-in-sql-learn-with-examples-4bbl</guid>
      <description>&lt;p&gt;A &lt;strong&gt;primary key&lt;/strong&gt; is a column in a database table that uniquely identifies each row.&lt;br&gt;&lt;br&gt;
That means no two rows can have the same value in this column, and it can’t be left empty.&lt;/p&gt;

&lt;p&gt;It’s the most important way to organize your data and avoid duplicates.&lt;/p&gt;

&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%2Fb42qhdtehc1a5q8y8ked.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%2Fb42qhdtehc1a5q8y8ked.png" alt="Primary Key" width="539" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each table can have only ONE primary key.&lt;br&gt;&lt;br&gt;
It can be just one column or a few columns joined together to make each row unique.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Is It Important?
&lt;/h2&gt;

&lt;p&gt;The primary key is essential for a few key reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It makes sure each row is unique&lt;/li&gt;
&lt;li&gt;It helps the database work faster when searching or linking data&lt;/li&gt;
&lt;li&gt;It allows other tables to connect to this one through &lt;strong&gt;foreign keys&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;It prevents duplicate or missing records&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without a primary key, there’s no reliable way to know which row is which.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example: Primary Key with Countries and Cities
&lt;/h2&gt;

&lt;p&gt;Let’s look at a simple example using two tables: one for countries and one for cities.&lt;/p&gt;
&lt;h4&gt;
  
  
  Table 1: Countries
&lt;/h4&gt;

&lt;p&gt;Each country has a short code (like "US" or "CH") that is unique. That code is used as the primary key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Countries (
  country_code CHAR(2) PRIMARY KEY,
  name VARCHAR(100),
  continent VARCHAR(50)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, country_code is the primary key. It identifies each country uniquely.&lt;/p&gt;

&lt;h4&gt;
  
  
  Table 2: Cities
&lt;/h4&gt;

&lt;p&gt;Now, let’s say you want to store information about cities. Each city will belong to a country, and we’ll include a country_code column so we know where the city is located.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Cities (
  city_id INT PRIMARY KEY,
  name VARCHAR(100),
  population INT,
  country_code CHAR(2)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, city_id is the &lt;strong&gt;primary key&lt;/strong&gt; for the Cities table. Each city gets a unique ID number, like 1, 2, 3, and so on.&lt;/p&gt;

&lt;p&gt;Later, we can use the &lt;strong&gt;country_code&lt;/strong&gt; in the Cities table to create a &lt;strong&gt;foreign key&lt;/strong&gt; that connects each city to a real country, but that only works if the Countries table has a clear &lt;strong&gt;primary key&lt;/strong&gt; defined.&lt;/p&gt;

&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%2Fo5jnzjj53jzz915x67px.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%2Fo5jnzjj53jzz915x67px.png" alt="Foreign Key" width="605" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to learn more about how foreign keys work, check out this article:&lt;br&gt;
&lt;a href="https://dbschema.com/blog/tutorials/what-is-a-foreign-key/" rel="noopener noreferrer"&gt;What Is a Foreign Key&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  What Makes a Good Primary Key?
&lt;/h3&gt;

&lt;p&gt;There are two main rules:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;It must be unique - no two rows can have the same value&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It must not be null - every row must have a value&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you try to insert a duplicate or missing value, the database will return an error.&lt;/p&gt;

&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%2Fykzeucgi8qin3q4vesk3.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%2Fykzeucgi8qin3q4vesk3.png" alt="Primary Key Duplicate" width="567" height="275"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Composite Primary Keys
&lt;/h3&gt;

&lt;p&gt;Sometimes a single column isn’t enough to uniquely identify a row. In that case, you can use a composite primary key, which is made of two or more columns.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE CarRegistrations (
  country_code CHAR(2),
  plate_number VARCHAR(10),
  registration_date DATE,
  PRIMARY KEY (country_code, plate_number)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, a car’s license plate isn’t unique on its own - the same plate could exist in multiple countries.&lt;br&gt;
But the combination of &lt;code&gt;country_code&lt;/code&gt; and &lt;code&gt;plate_number&lt;/code&gt; &lt;strong&gt;is unique&lt;/strong&gt;, so it makes a perfect composite &lt;strong&gt;&lt;em&gt;primary key&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;
This structure ensures no duplicates and keeps everything clearly linked.&lt;/p&gt;

&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%2F23fixdcxwat6c98adi97.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%2F23fixdcxwat6c98adi97.png" alt="Composite Primary Key " width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Adding a Primary Key Later
&lt;/h3&gt;

&lt;p&gt;You can also define a primary key after creating the table, using ALTER TABLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ALTER TABLE Countries
ADD PRIMARY KEY (country_code);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is useful if you forget to define it at the beginning or need to apply it to existing data.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Work with Primary Keys in DbSchema
&lt;/h2&gt;

&lt;p&gt;If you’re using &lt;a href="https://dbschema.com/" rel="noopener noreferrer"&gt;DbSchema&lt;/a&gt;, you can define primary keys without writing any SQL.&lt;/p&gt;

&lt;h3&gt;
  
  
  Here’s how:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create or import your table&lt;/li&gt;
&lt;li&gt;Double-click on the column you want to set as the primary key&lt;/li&gt;
&lt;li&gt;Click “Set as Primary Key”&lt;/li&gt;
&lt;li&gt;You’ll see a small key icon on that column in the diagram&lt;/li&gt;
&lt;/ol&gt;

&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%2Frdyonts7a7ew7kdb4c51.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%2Frdyonts7a7ew7kdb4c51.png" alt="DbSchema Primary Key " width="773" height="481"&gt;&lt;/a&gt;&lt;br&gt;
DbSchema also supports &lt;strong&gt;composite keys&lt;/strong&gt;. Just select multiple columns when defining the key.&lt;/p&gt;

&lt;p&gt;Working visually helps you understand your design faster, especially when working with multiple tables.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;primary key&lt;/strong&gt; uniquely identifies each row in a table&lt;/li&gt;
&lt;li&gt;It must be &lt;strong&gt;unique&lt;/strong&gt; and &lt;strong&gt;NOT NULL&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Other tables can link to it using &lt;strong&gt;foreign keys&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;You can define it during table creation or later using &lt;code&gt;ALTER TABLE&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Visual tools like &lt;a href="https://dbschema.com/download.html" rel="noopener noreferrer"&gt;DbSchema&lt;/a&gt; make it easy to design and understand primary keys&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding primary keys is the first step toward building well-structured, reliable databases.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>data</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>Free SQL Tool to Understand Your Database Visually</title>
      <dc:creator>Roxana Maria Haidiner</dc:creator>
      <pubDate>Fri, 08 Aug 2025 14:44:54 +0000</pubDate>
      <link>https://forem.com/roxana_haidiner/free-sql-tool-to-understand-your-database-visually-4485</link>
      <guid>https://forem.com/roxana_haidiner/free-sql-tool-to-understand-your-database-visually-4485</guid>
      <description>&lt;p&gt;You might already know how to write basic SQL.&lt;br&gt;&lt;br&gt;
Let’s say you’ve written something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE customers (
  customer_id INT
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s great, you've created a table.&lt;br&gt;
&lt;strong&gt;But do you understand how it looks in the database?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is it linked to another table?&lt;/li&gt;
&lt;li&gt;What kind of data goes into that column?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - What happens when you add more fields or relationships?
&lt;/h2&gt;

&lt;p&gt;This is where most people get stuck - you write code, but you don’t see the full picture.&lt;/p&gt;

&lt;p&gt;That’s why tools like &lt;a href="https://dbschema.com/" rel="noopener noreferrer"&gt;DbSchema&lt;/a&gt; include a free &lt;a href="https://dbschema.com/editions.html" rel="noopener noreferrer"&gt;Community Edition&lt;/a&gt;, so you can learn faster by seeing how your SQL shapes the database in real time.&lt;/p&gt;

&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%2Fr8bgggy3ys8lxmdjvu0h.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%2Fr8bgggy3ys8lxmdjvu0h.png" alt="Real-Time SQL to Diagram in DbSchema" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Real-Time Diagram Updates
&lt;/h3&gt;

&lt;p&gt;As you write or modify SQL code, &lt;a href="https://dbschema.com/" rel="noopener noreferrer"&gt;DbSchema&lt;/a&gt; updates the &lt;strong&gt;ER diagram&lt;/strong&gt; automatically.  &lt;/p&gt;

&lt;p&gt;Instead of scrolling through raw SQL code or switching between tabs, you can see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Which table connects to which&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What foreign keys are in place&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How is your schema structured as a whole&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is especially helpful when working with large databases, collaborating in teams, or just trying to get a quick understanding of how everything fits together.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Smart Autocomplete &amp;amp; Syntax Highlighting
&lt;/h3&gt;

&lt;p&gt;DbSchema’s SQL editor helps you write better and faster:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Autocomplete suggestions as you type (table names, columns, commands)&lt;/li&gt;
&lt;li&gt;Syntax highlighting so you can easily spot errors&lt;/li&gt;
&lt;li&gt;Helpful tooltips and validation when something’s off&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This reduces typos and lets you focus on logic, not memorization.&lt;/p&gt;

&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%2Foi43mg31kxxj283sd199.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%2Foi43mg31kxxj283sd199.png" alt="Real-Time SQL to Diagram in DbSchema" width="694" height="428"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Explore Your Data Easily
&lt;/h3&gt;

&lt;p&gt;Query results don’t just appear as plain text.&lt;br&gt;&lt;br&gt;
DbSchema shows them in a clean, spreadsheet-style grid.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Run queries&lt;/strong&gt; and view results instantly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edit data&lt;/strong&gt; directly in the table&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sort and filter&lt;/strong&gt; columns just like in Excel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Perfect for exploring datasets and testing results.&lt;/p&gt;

&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%2Fbk0iztty3vvg3me30c57.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%2Fbk0iztty3vvg3me30c57.png" alt="Query Result Grid in DbSchema" width="746" height="391"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Save Results to File
&lt;/h3&gt;

&lt;p&gt;Need to export your query results?&lt;/p&gt;

&lt;p&gt;Just click the &lt;strong&gt;save&lt;/strong&gt; button in the result panel.&lt;br&gt;&lt;br&gt;
DbSchema will rerun the query and write the &lt;strong&gt;full dataset&lt;/strong&gt; to a file, even if it's too large to display on screen.&lt;/p&gt;

&lt;p&gt;Ideal for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reports&lt;/li&gt;
&lt;li&gt;Data backups&lt;/li&gt;
&lt;li&gt;Sharing with colleagues&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&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%2F3waunstc5v6oavfd3v3u.png" alt="Query Export in DbSchema" width="576" height="425"&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5. Instant SQL Generation from Diagrams
&lt;/h3&gt;

&lt;p&gt;Already designed your schema visually?&lt;br&gt;&lt;br&gt;
You don’t have to write the SQL manually.&lt;/p&gt;

&lt;p&gt;DbSchema automatically generates the full SQL script for each table or relationship.&lt;br&gt;&lt;br&gt;
You can copy, inspect, or tweak it any time, perfect for learning or reusing structures.&lt;/p&gt;

&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%2F8movgccvkvqwg7mm010l.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%2F8movgccvkvqwg7mm010l.png" alt="Auto-Generated SQL from Visual Design in DbSchema" width="800" height="502"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  6. Execute Groovy and JavaScript in the SQL Editor
&lt;/h3&gt;

&lt;p&gt;Yes, really - you can run both &lt;strong&gt;Groovy&lt;/strong&gt; and &lt;strong&gt;JavaScript&lt;/strong&gt; right inside the editor.&lt;/p&gt;

&lt;p&gt;There’s a drop-down in the SQL editor where you can switch between &lt;strong&gt;SQL&lt;/strong&gt;, &lt;strong&gt;Groovy&lt;/strong&gt;, and &lt;strong&gt;JavaScript&lt;/strong&gt; modes.&lt;/p&gt;

&lt;p&gt;You can write scripts to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetch or manipulate data&lt;/li&gt;
&lt;li&gt;Generate reports or exports&lt;/li&gt;
&lt;li&gt;Automate tasks or workflows using the language you're most comfortable with&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;DbSchema even includes built-in &lt;strong&gt;code samples&lt;/strong&gt; to help you get started faster, just check the &lt;strong&gt;Help&lt;/strong&gt; menu inside the application.&lt;/p&gt;

&lt;h2&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%2Fdh7lbvjddpj976g2rqji.png" alt="Generate Scripts using Groovy" width="641" height="425"&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Most SQL editors just let you type queries.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;DbSchema helps you understand&lt;/strong&gt; your database while you write it.&lt;/p&gt;

&lt;p&gt;From diagrams to scripts, from autocompletion to real data editing - it’s all built-in.&lt;/p&gt;

&lt;p&gt;If you're still learning SQL and want to get more confident,&lt;br&gt;&lt;br&gt;
 we’ve also prepared a full &lt;strong&gt;SQL tutorial&lt;/strong&gt; with all the syntax you need:&lt;br&gt;&lt;br&gt;
&lt;a href="https://dbschema.com/blog/tutorials/" rel="noopener noreferrer"&gt;&lt;strong&gt;Learn SQL - The Complete Syntax Guide&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ready to try it yourself?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://dbschema.com/download.html" rel="noopener noreferrer"&gt;Download DbSchema Free&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>tooling</category>
      <category>mysql</category>
    </item>
  </channel>
</rss>
