<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Relational Database - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Relational Database - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 23 Aug 2026 21:54:17 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/relational-database/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How Relational Database Constraints Work and Why They're Important ]]>
                </title>
                <description>
                    <![CDATA[ Databases are a crucial tool because they store the data that power our day-to-day lives. Databases are designed to match the real world as much as possible, so they store data of different forms, about different things, just as it is in the world. T... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-relational-database-constraints-work-and-why-theyre-important/</link>
                <guid isPermaLink="false">69681d224dcb07c08e435626</guid>
                
                    <category>
                        <![CDATA[ Databases ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Relational Database ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Zubair Idris Aweda ]]>
                </dc:creator>
                <pubDate>Wed, 14 Jan 2026 22:48:02 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768416017042/66390973-a4cb-4e7a-9161-2d737045bf7b.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Databases are a crucial tool because they store the data that power our day-to-day lives. Databases are designed to match the real world as much as possible, so they store data of different forms, about different things, just as it is in the world.</p>
<p>There are many rules that govern how entities interact with each other, to make things work. For example, a student can’t take a course that the school doesn’t offer. A soccer player can’t have a jersey number less than 1 or greater than 99. And a car must always have a plate number.</p>
<p>Relational databases are also able to represent and enforce these rules using <strong>constraints</strong>. And in this article, I’ll explain how constraints work with practical examples.</p>
<p>Whether you’re a beginner or just looking to refresh your knowledge, this article will help you learn the essentials. If you need some more background, you can read this article on the <a target="_blank" href="https://www.freecodecamp.org/news/learn-relational-database-basics-key-concepts-for-beginners/">basics of relational databases</a> before continuing.</p>
<h3 id="heading-what-well-cover">What We’ll Cover:</h3>
<ol>
<li><p><a class="post-section-overview" href="#heading-what-is-a-relational-database-constraint">What is a Relational Database Constraint?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-types-of-relational-database-constraints">Types of Relational Database Constraints</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-inherent-model-based-constraints-implicit-constraints">Inherent Model-based Constraints (Implicit Constraints)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-schema-based-constraints-explicit-constraints">Schema-based Constraints (Explicit Constraints)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-application-based-constraints-semantic-constraints">Application-based constraints (Semantic constraints)</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-testing-constraints">Testing Constraints</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-how-to-delete-a-record">How to Delete a Record</a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-summary">Summary</a></p>
</li>
</ol>
<h2 id="heading-what-is-a-relational-database-constraint">What is a Relational Database Constraint?</h2>
<p>Relational database constraints are a set of database rules that are used to define or determine what set of values are acceptable or valid in a database. They’re usually based on the many rules of the real world.</p>
<p>They are put in place to:</p>
<ul>
<li><p>Ensure data accuracy: only values that would be acceptable in real life should be acceptable in the database. Learn more about data accuracy <a target="_blank" href="https://www.ibm.com/think/topics/data-accuracy">here</a>.</p>
</li>
<li><p>Ensure data integrity: values in the database remain correct, accurate, complete, and valid as long as the database exists. Learn more about data integrity <a target="_blank" href="https://www.fortinet.com/uk/resources/cyberglossary/data-integrity">here</a>.</p>
</li>
<li><p>Ensure data consistency: values always maintain same agreed form throughout their lifetime.</p>
</li>
</ul>
<p>These rules limit what can be entered into a database or what can be deleted from it. They also limit data update to ensure validity after original creation.</p>
<blockquote>
<p>These integrity constraints help enforce business rules on data in the tables to ensure the accuracy and reliability of the data. - <a target="_blank" href="https://aws.amazon.com/rds/what-is-a-relational-database/">AWS</a></p>
</blockquote>
<h2 id="heading-types-of-relational-database-constraints">Types of Relational Database Constraints</h2>
<p>There are many ways to group or categorise database constraints, depending on how they’re applied or what they’re preventing. This article focuses on three popular types:</p>
<ul>
<li><p>Inherent model-based constraints (implicit constraints)</p>
</li>
<li><p>Schema-based constraints (explicit constraints)</p>
</li>
<li><p>Application-based constraints (semantic constraints)</p>
</li>
</ul>
<h3 id="heading-inherent-model-based-constraints-implicit-constraints">Inherent Model-based Constraints (Implicit Constraints)</h3>
<p>These rules are the base rules that come with the database and are enforced by the DMBS. Some of these rules are:</p>
<ul>
<li><p>Each row must be unique. This is with or without a <code>UNIQUE</code> or <code>PRIMARY KEY</code> constraint.</p>
</li>
<li><p>Columns can only store one value at a time. The value of a field like <code>age</code> will always be one value like 23, not 23 and 35.</p>
</li>
<li><p>Each column name in a table must be unique.</p>
</li>
<li><p>Columns exist for all rows. Every row will have the same number of columns. For some of the rows, the data might be empty, but the column will always be there.</p>
</li>
</ul>
<h3 id="heading-schema-based-constraints-explicit-constraints">Schema-based Constraints (Explicit Constraints)</h3>
<p>These constraints are expressed by the developer or database designer on database creation. They’re expressed directly in the database schemas, using the <a target="_blank" href="https://en.wikipedia.org/wiki/Data_definition_language">DDL</a>.</p>
<p>These can be further broken down into:</p>
<ul>
<li><p>Domain constraints</p>
</li>
<li><p>Key constraints</p>
<ul>
<li><p>Entity integrity constraint (Primary key)</p>
</li>
<li><p>Unique constraint (Unique key)</p>
</li>
<li><p>Referential integrity constraint (Foreign key)</p>
</li>
</ul>
</li>
</ul>
<h4 id="heading-1-domain-constraints">1. Domain Constraints</h4>
<p>These are used to define a range or set of possible values for an attribute of a database table. They help ensure that column values are valid and consistent by defining acceptable data types, formats, and ranges for an attribute. This prevents incorrect or illogical data entry and maintains data integrity.</p>
<p>You can define them simply by specifying a data type that the values must follow. For example, the <code>age</code> of a person can only be a number, or could be a number between 18-60 if the database is for a company, or a number between 5-65 if it’s for an amusement park.</p>
<p>The database will enforce this rule by rejecting age values outside of the given range or type. The DDL for the age would look like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> people (
    age <span class="hljs-built_in">INT</span>, <span class="hljs-comment">-- Any integer value is allowed</span>
    age <span class="hljs-built_in">INT</span> <span class="hljs-keyword">CHECK</span> (age <span class="hljs-keyword">BETWEEN</span> <span class="hljs-number">18</span> <span class="hljs-keyword">AND</span> <span class="hljs-number">60</span>), <span class="hljs-comment">-- Only allows ages between 18 and 60</span>
    age <span class="hljs-built_in">INT</span> <span class="hljs-keyword">CHECK</span> (age <span class="hljs-keyword">BETWEEN</span> <span class="hljs-number">5</span> <span class="hljs-keyword">AND</span> <span class="hljs-number">65</span>) <span class="hljs-comment">-- Only allows ages between 5 and 65</span>
);
</code></pre>
<p>The <code>INT</code> means only integer values are accepted, and the <code>CHECK</code> is used with the <code>BETWEEN</code> and <code>AND</code> keywords to specify the sub-domain or range of values.</p>
<p>Other <a target="_blank" href="https://www.w3schools.com/sql/sql_datatypes.asp">data types in SQL</a> include: <code>CHAR</code>, <code>BIT</code>, <code>DATE</code>, <code>VARCHAR</code> and so on. You can use all of them to define the acceptable domain for database values.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> employees (
    employee_id <span class="hljs-built_in">INT</span>,
    <span class="hljs-keyword">name</span> <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>),
    age <span class="hljs-built_in">INT</span> <span class="hljs-keyword">CHECK</span> (age <span class="hljs-keyword">BETWEEN</span> <span class="hljs-number">18</span> <span class="hljs-keyword">AND</span> <span class="hljs-number">60</span>)
);
</code></pre>
<p>As well as defining a range of acceptable values, you can also define the optionality of an attribute using the <code>NOT NULL</code> keyword. You’d use this in cases where the data must exist and must also be within the given range.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> employees (
    employee_id <span class="hljs-built_in">INT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-keyword">name</span> <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    age <span class="hljs-built_in">INT</span> <span class="hljs-keyword">CHECK</span> (age <span class="hljs-keyword">BETWEEN</span> <span class="hljs-number">18</span> <span class="hljs-keyword">AND</span> <span class="hljs-number">60</span>)
);
</code></pre>
<p>In this example, every employee record needs to have an <code>employee_id</code> and a <code>name</code> but not an <code>age</code>. This works for real life situations where, although the range of values is known, the actual value is either unknown or doesn’t exist. An example would be the minor course of study of a student at a university – many students only have majors, and as such, the minor course of study will be empty (NULL) for those students.</p>
<h4 id="heading-2-entity-integrity-constraint-primary-key">2. Entity integrity constraint (Primary key)</h4>
<p>This ensures that no primary key is NULL. The primary key is the one attribute or set of attributes that must be unique to each row in the database. It’s the primary value that uniquely identifies the rest of the data. This means that every row in the database will remain uniquely identifiable with a primary key.</p>
<p>A NULL primary key means that rows will not be unique, or identifiable, and the database can contain duplicates. Without the primary key, we can’t have data consistency.</p>
<p>For example, in a school, every student will have a unique student id number with which they can always be distinguished from other students. The government uses methods like passport numbers or tax ids to uniquely identify citizens.</p>
<p>In our example, it’s impossible to be a student without a student id number. You can implement this constraint by using the <code>PRIMARY KEY</code> keyword.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> employees (
    employee_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>,
    <span class="hljs-keyword">name</span> <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>),
    age <span class="hljs-built_in">INT</span> <span class="hljs-keyword">CHECK</span> (age <span class="hljs-keyword">BETWEEN</span> <span class="hljs-number">18</span> <span class="hljs-keyword">AND</span> <span class="hljs-number">60</span>)
);
</code></pre>
<h4 id="heading-3-unique-constraint-unique-key">3. Unique constraint (Unique key)</h4>
<p>This is similar to the <strong>Entity integrity constraint</strong> in that it only accepts unique values – but it’s different in that it accepts NULL values.</p>
<p>An example of this would be in a students table, every student must have a student id number that uniquely identifies them. This number cannot be NULL, and it must the unique. Students can also have an email address that the school can reach them on. This email must be unique for each student. But, not every student has to have an email. So the condition is: <strong>“If the value exists, it must be unique”</strong>.</p>
<p>You can implement this constraint using the <code>UNIQUE</code> keyword, like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> students (
    student_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>, <span class="hljs-comment">-- Must exist and must be unique</span>
    email <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">255</span>) <span class="hljs-keyword">UNIQUE</span> <span class="hljs-comment">-- Can be NULL, but must be unique if provided</span>
);
</code></pre>
<h4 id="heading-4-referential-integrity-constraint-foreign-key">4. Referential integrity constraint (Foreign key)</h4>
<p>This constraint guards the relationship between two related tables. It is used to maintain consistency in the relationship. It requires that data from one table, A, being referenced in another table, B, must exist in the original table, A. For example, a student can’t register for a course the school doesn’t have.</p>
<p>To enforce this, the <code>FOREIGN KEY</code> keyword is used with the <code>REFERENCES</code> to define the table being referenced, and what attribute is being referred to.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> courses (
    course_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>,
    course_name <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>
);

<span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> students (
    student_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>,
    student_name <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    course_id <span class="hljs-built_in">INT</span>,
    <span class="hljs-keyword">FOREIGN</span> <span class="hljs-keyword">KEY</span> (course_id) <span class="hljs-keyword">REFERENCES</span> courses(course_id)
);
</code></pre>
<p>In this example, every value provided in the <code>course_id</code> of the <code>students</code> must be in the <code>courses</code> table.</p>
<h3 id="heading-application-based-constraints-semantic-constraints">Application-based constraints (Semantic constraints)</h3>
<p>These can also be called <strong>business rules</strong>. They can’t be directly expressed in the database schema, so they’re often implemented the application layer instead.</p>
<p>These are logical constraints, like saying <strong>“a course cannot have more than 30 students enrolled”</strong> or <strong>“a customer cannot place an order if it would exceed their credit limit”</strong>.</p>
<p>These rules are best implemented in the application, because it would be too complex (or sometimes impossible) to implement them on the database itself.</p>
<h2 id="heading-testing-constraints">Testing Constraints</h2>
<p>To demonstrate the constraints we’ve discussed here, let’s look at this sample school database setup:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> courses (course_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>, course_name <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>, max_students <span class="hljs-built_in">INT</span> <span class="hljs-keyword">CHECK</span> (max_students &gt; <span class="hljs-number">0</span>));

<span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> students (student_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>, student_name <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>, email <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">UNIQUE</span>, age <span class="hljs-built_in">INT</span> <span class="hljs-keyword">CHECK</span> (age <span class="hljs-keyword">BETWEEN</span> <span class="hljs-number">5</span> <span class="hljs-keyword">AND</span> <span class="hljs-number">25</span>));

<span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> enrollments (
    enrollment_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>,
    student_id <span class="hljs-built_in">INT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    course_id <span class="hljs-built_in">INT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    enrollment_date <span class="hljs-built_in">DATE</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-keyword">FOREIGN</span> <span class="hljs-keyword">KEY</span> (student_id) <span class="hljs-keyword">REFERENCES</span> students (student_id),
    <span class="hljs-keyword">FOREIGN</span> <span class="hljs-keyword">KEY</span> (course_id) <span class="hljs-keyword">REFERENCES</span> courses (course_id)
);
</code></pre>
<p>This shows the creation of a sample school database with three tables: <code>courses</code>, <code>students</code>, and <code>enrollments</code>.</p>
<p>The <code>courses</code> table includes a primary key for course IDs, course names, and a constraint ensuring that the maximum number of students is greater than zero. The <code>students</code> table contains a primary key for student IDs, student names, unique email addresses, and an age constraint between 5 and 25. The <code>enrollments</code> table links students to courses with primary keys for enrollment IDs and foreign keys referencing the <code>students</code> and <code>courses</code> tables, along with a non-null enrollment date.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768410057148/ffe42706-4540-4ddb-8394-c157fe999b96.png" alt="DDL to create database tables" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>At this point, the tables are created, and setup with the constraints guiding them.</p>
<p>Now we’ll test a few queries:</p>
<ol>
<li>Insert courses, Mathematics and History, into the <code>courses</code> table:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> courses (course_id, course_name, max_students) <span class="hljs-keyword">VALUES</span> (<span class="hljs-number">1</span>, <span class="hljs-string">'Mathematics'</span>, <span class="hljs-number">30</span>);
<span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span>
    courses (course_id, course_name, max_students)
<span class="hljs-keyword">VALUES</span>
    (<span class="hljs-number">2</span>, <span class="hljs-string">'History'</span>, <span class="hljs-number">25</span>);
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768410234586/bb08fb52-9573-4f57-88d2-6383138ddc7f.png" alt="Query to insert courses" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768410261770/f974693c-25fc-4952-80c7-6db7f4959236.png" alt="Result of insert query" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>The query works perfectly, as the records get inserted.</p>
<ol start="2">
<li>Insert students, Alice and Bob, into the <code>students</code> table:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span>
    students (student_id, student_name, email, age)
<span class="hljs-keyword">VALUES</span>
    (<span class="hljs-number">101</span>, <span class="hljs-string">'Alice'</span>, <span class="hljs-string">'alice@example.com'</span>, <span class="hljs-number">20</span>);

<span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span>
    students (student_id, student_name, email, age)
<span class="hljs-keyword">VALUES</span>
    (<span class="hljs-number">102</span>, <span class="hljs-string">'Bob'</span>, <span class="hljs-literal">NULL</span>, <span class="hljs-number">18</span>);
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768410360967/92aee819-63fe-4b3c-af2b-b579d66e58a9.png" alt="Query to insert students" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768410407790/ec9893cf-ded6-4ec2-bac1-c78d430a84fb.png" alt="Result of query" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>The query works perfectly, as the records get inserted.</p>
<ol start="3">
<li>Enroll Alice into Mathematics:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span>
    enrollments (enrollment_id, student_id, course_id, enrollment_date)
<span class="hljs-keyword">VALUES</span>
    (<span class="hljs-number">1001</span>, <span class="hljs-number">101</span>, <span class="hljs-number">1</span>, <span class="hljs-string">'2026-01-14'</span>);
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768410510198/be229077-028c-4048-836c-fb7796b02f7d.png" alt="Query to insert enrollment" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768410543235/f546d371-da31-4f42-be3d-20bd2bb1aa3a.png" alt="Result of query" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>The query works perfectly, as the record gets inserted.</p>
<ol start="4">
<li>Insert a new student, Charlie, into the <code>students</code> table:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span>
    students (student_id, student_name, email, age)
<span class="hljs-keyword">VALUES</span>
    (<span class="hljs-number">103</span>, <span class="hljs-string">'Charlie'</span>, <span class="hljs-string">'charlie@example.com'</span>, <span class="hljs-number">30</span>);
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768410642880/0b9f038d-fb4f-49e1-a92f-3c1fd01c3fae.png" alt="Failed query to insert student" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>This fails because Charlie has an <code>age</code> value of 30, which is outside of the specified range of <code>age INT CHECK (age BETWEEN 5 AND 25)</code>. The record of Charlie never gets added.</p>
<p>Here’s a list of some other queries that will fail:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span>
    students (student_id, student_name, email, age)
<span class="hljs-keyword">VALUES</span>
    (<span class="hljs-number">104</span>, <span class="hljs-string">'David'</span>, <span class="hljs-string">'alice@example.com'</span>, <span class="hljs-number">19</span>); <span class="hljs-comment">-- Fails for duplicate email</span>

<span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span>
    students (student_id, student_name, email, age)
<span class="hljs-keyword">VALUES</span>
    (<span class="hljs-literal">NULL</span>, <span class="hljs-string">'Evra'</span>, <span class="hljs-string">'evra@example.com'</span>, <span class="hljs-number">20</span>); <span class="hljs-comment">-- Fails for NULL primary key</span>

<span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span>
    enrollments (enrollment_id, student_id, course_id, enrollment_date)
<span class="hljs-keyword">VALUES</span>
    (<span class="hljs-number">1002</span>, <span class="hljs-number">999</span>, <span class="hljs-number">1</span>, <span class="hljs-string">'2026-01-14'</span>); <span class="hljs-comment">-- Fails for invalid student reference</span>
</code></pre>
<p>In each case, the DBMS will provide a reason for the rejection or failure.</p>
<ol start="5">
<li>Delete Bob from the <code>students</code> table:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> students
<span class="hljs-keyword">WHERE</span>
    student_id = <span class="hljs-number">102</span>;
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768411198451/3e33efdb-68e9-4cf5-a809-d2053059c29d.png" alt="Query to delete student" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768411236739/50b24978-2612-4232-8169-3a24377b39a0.png" alt="Result of query" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>The query works perfectly, as the record gets deleted.</p>
<ol start="6">
<li>Delete Alice from the <code>students</code> table:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> students
<span class="hljs-keyword">WHERE</span>
    student_id = <span class="hljs-number">101</span>; <span class="hljs-comment">-- Fails for referential integrity constraint</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768411336408/8fc634c2-1f10-41f2-b413-4c6b5af22369.png" alt="Failed query to delete students" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>This fails because Alice, with <code>student_id</code> of 101, has an enrollment record in the <code>enrollments</code> table. Deleting the record would mean there will be an enrollment record for a non-existent student which should not be possible.</p>
<h3 id="heading-how-to-delete-a-record">How to Delete a Record</h3>
<p>In some cases, you do want to delete a record, even though it has records tied to it. There are two main ways to go about this:</p>
<h4 id="heading-cascade">CASCADE</h4>
<p>You can use this to define situations where, when a parent record is deleted, the child records cannot exist. All dependent (child) records in other tables are <strong>automatically deleted</strong>. You can use this to ensure that all enrollment records are deleted when the course is no longer available, or when a student is no longer in the school.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> enrollments (enrollment_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>, student_id <span class="hljs-built_in">INT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>, course_id <span class="hljs-built_in">INT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>, <span class="hljs-keyword">FOREIGN</span> <span class="hljs-keyword">KEY</span> (course_id) <span class="hljs-keyword">REFERENCES</span> courses (course_id) <span class="hljs-keyword">ON</span> <span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">CASCADE</span>);

<span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> courses
<span class="hljs-keyword">WHERE</span>
    course_id = <span class="hljs-number">1</span>;
</code></pre>
<h4 id="heading-set-null-or-set-default">SET NULL or SET DEFAULT</h4>
<p>You can use these methods to define situations where child records can still exist without the parent. All dependent (child) records in other tables are <strong>automatically set to null</strong> or <strong>automatically set to a defined default.</strong></p>
<p>A useful example is if a school had a mentor assigned to students, when the mentor leaves the school, you don’t want to delete the students – you want to set the mentor to NULL or a default staff.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> teachers (teacher_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>, teacher_name <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>);

<span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> students (student_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>, student_name <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>, mentor_id <span class="hljs-built_in">INT</span>, <span class="hljs-keyword">FOREIGN</span> <span class="hljs-keyword">KEY</span> (mentor_id) <span class="hljs-keyword">REFERENCES</span> teachers (teacher_id) <span class="hljs-keyword">ON</span> <span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">SET</span> <span class="hljs-literal">NULL</span>);
</code></pre>
<ol start="7">
<li>Update Alice’s details. Change her email to a new one, and increase her age:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">UPDATE</span> students
<span class="hljs-keyword">SET</span>
    email = <span class="hljs-string">'alice.new@example.com'</span>,
    age = <span class="hljs-number">22</span>
<span class="hljs-keyword">WHERE</span>
    student_id = <span class="hljs-number">101</span>;
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768411782761/0fe14052-2bbd-4c44-952d-a13ce30947ce.png" alt="Query to update student" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768411806702/651e9694-5821-4aa0-b606-98ab361a9637.png" alt="Result of query" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>The query works perfectly, as the record gets updated.</p>
<ol start="8">
<li>Update Alice’s age to 30:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">UPDATE</span> students
<span class="hljs-keyword">SET</span>
    age = <span class="hljs-number">30</span>
<span class="hljs-keyword">WHERE</span>
    student_id = <span class="hljs-number">101</span>;
</code></pre>
<p>This fails just like the 4th test for the same reason: the <code>age</code> is out of the stated range.</p>
<p>Here’s another query that will fail:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">UPDATE</span> enrollments
<span class="hljs-keyword">SET</span>
    course_id = <span class="hljs-number">999</span>
<span class="hljs-keyword">WHERE</span>
    enrollment_id = <span class="hljs-number">1001</span>;
</code></pre>
<p>This will fail because the new <code>course_id</code> does not exist in the <code>courses</code> table.</p>
<h2 id="heading-summary">Summary</h2>
<p>Databases are a pivotal part of everyday modern technology, and understanding their fundamental concepts can open doors to building and managing more accurate databases.</p>
<p>This article introduced you to what relational database constraints are, some of the different types, and how they’re enforced and violated. You should now have the essential knowledge to navigate the world of database constraints confidently.</p>
<p>If you’re curious to learn more, connect with me on <a target="_blank" href="https://www.linkedin.com/in/idris-aweda-zubair-5433121a3/">LinkedIn</a>, <a target="_blank" href="https://twitter.com/greatzubs">Twitter</a>, or <a target="_blank" href="https://github.com/Zubs">GitHub</a>. Let’s continue this journey together toward mastering database systems!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ freeCodeCamp's New Relational Databases Certification is Now Live ]]>
                </title>
                <description>
                    <![CDATA[ The freeCodeCamp community just published our new Relational Databases certification. You can now sit for the exam to earn the free verified certification, which you can add to your résumé, CV, or LinkedIn profile. Each certification is filled with h... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/freecodecamps-new-relational-databases-certification-is-now-live/</link>
                <guid isPermaLink="false">694595068a4df0c53d579475</guid>
                
                    <category>
                        <![CDATA[ freeCodeCamp.org ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Databases ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Certification ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Relational Database ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jessica Wilkins ]]>
                </dc:creator>
                <pubDate>Fri, 19 Dec 2025 18:10:14 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1765839442063/a5db9c4a-cb34-468b-b097-e4257803c29d.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>The freeCodeCamp community just published our new <a target="_blank" href="https://www.freecodecamp.org/learn/relational-databases-v9/">Relational Databases certification</a>. You can now sit for the exam to earn the free verified certification, which you can add to your résumé, CV, or LinkedIn profile.</p>
<p>Each certification is filled with hundreds of hours worth of interactive lessons, workshops, labs, and quizzes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764617660453/0be3ab2b-90e9-4881-be81-47af607de2df.png" alt="List of modules for the Relational Databases Certification." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-does-the-new-relational-databases-certification-work">How Does the New Relational Databases Certification Work?</h2>
<p>The new <a target="_blank" href="https://www.freecodecamp.org/learn/relational-databases-v9/">Relational Databases certification</a> will teach you core concepts including Bash scripting, SQL, Git, and more.</p>
<p>The certification is broken down into several modules that include lessons, workshops, labs, review pages, and quizzes to ensure that you truly understand the material before moving onto the next module.</p>
<p>The lessons are your first exposure to new concepts. They provide crucial theory and context for how things work in the software development industry.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764618152249/1b623cef-11d4-4ad2-9598-b273050db80f.png" alt="Example text from command line lesson" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>At the end of each lesson, there will be three comprehension check questions to test your understanding of the material from the lesson.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764618208440/7da0832d-b3a9-4e12-b21d-5215dcc48c13.png" alt="Example comprehension check question from the command line lesson." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>After the lesson blocks, you will do the workshops. These workshops are guided step-based projects that provide you with an opportunity to practice what you have learned in the lessons.</p>
<p>These workshops will not be done inside the regular freeCodeCamp editor in the browser. Instead you will need to do these workshops in one of three environments:</p>
<ul>
<li><p>GitHub Codespaces: This course runs in a virtual Linux machine using GitHub Codespaces.</p>
</li>
<li><p>Your own local environment: This course runs in a virtual Linux machine on your computer.</p>
</li>
<li><p>Ona: This course runs in a virtual Linux machine using Ona.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764639433422/09fb0695-42d6-4678-b2c1-1532eb840675.png" alt="Step 1 for the Build a Database of Video Game Characters workshop" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>After the workshop, you will complete a lab which will help you review what you have learned so far. This will give you chance to start building projects on your own, which is a crucial skill for a developer. You will be presented with a list of users stories and will need to pass the tests to complete the lab.</p>
<p>At the end of each module, there is a review page containing a list of all of the concepts covered. You can use these review pages to help you study for the quizzes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1765815540302/7ad0cadc-f94d-4b80-b35e-e46b756fd407.png" alt="Example review page from the Bash and SQL module" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>The last portion of the module is the quiz. This is a 20 question multiple choice quiz designed to test your understanding from the material covered in the module. You will need to get 18 out of 20 correct to pass.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1765815587496/8878215f-9799-4259-ae3f-44d7101fba72.png" alt="Sample question from the Git Quiz." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Throughout the certification, there will be five certification projects you will need to complete in order to qualify for the exam.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1765815626782/6839bfa8-1d6f-4425-8a6e-f4dfbd3f9581.png" alt="List of certification projects for the Relational Databases Certification." class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Once you’ve completed all 5 certification projects, you’ll be able to take the 50 question exam using our new open source exam environment. The freeCodeCamp community designed this exam environment tool with two goals: respecting your privacy while also making it harder for people to cheat.</p>
<p>Once you download the app to your laptop or desktop, you can take the exam.</p>
<h2 id="heading-frequently-asked-questions">Frequently Asked Questions</h2>
<h3 id="heading-is-all-of-this-really-free">Is all of this really free?</h3>
<p>Yes. freeCodeCamp has always been free, and we’ve now offered free verified certifications for more than a decade. These exams are just the latest expansion to our community’s free learning resources.</p>
<h3 id="heading-what-prevents-people-from-just-cheating-on-the-exams">What prevents people from just cheating on the exams?</h3>
<p>Our goal is to strike a balance between preventing cheating and respecting people's right to privacy.</p>
<p>We've implemented a number of reliable, yet non-invasive, measures to help prevent people from cheating on freeCodeCamp's exams:</p>
<ol>
<li><p>For each exam, we have a massive bank of questions and potential answers to those questions. Each time a person attempts an exam, they'll see only a small, randomized sampling of these questions.</p>
</li>
<li><p>We only allow people to attempt an exam one time per week. This reduces their ability to "brute force" the exam.</p>
</li>
<li><p>We have security in place to validate exam submissions and prevent man-in-the-middle attacks or manipulation of the exam environment.</p>
</li>
<li><p>We manually review each passing exam for evidence of cheating. Our exam environment produces tons of metrics for us to draw from.</p>
</li>
</ol>
<p>We take cheating, and any form of academic dishonesty, seriously. We will act decisively.</p>
<p>This said, no one's exam results will be thrown out without human review, and no one's account will be banned without warning based on a single suspicious exam result.</p>
<h3 id="heading-are-these-exams-open-book-or-closed-book">Are these exams “open book” or “closed book”?</h3>
<p>All of freeCodeCamp’s exams are “closed book”, meaning you must rely only on your mind and not outside resources.</p>
<p>Of course, in the real world you’ll be able to look things up. And in the real world, we encourage you to do so.</p>
<p>But that is not what these exams are evaluating. These exams are instead designed to test your memory of details and your comprehension of concepts.</p>
<p>So when taking these exams, do not use outside assistance in the form of books, notes, AI tools, or other people. Use of any of these will be considered academic dishonesty.</p>
<h3 id="heading-do-you-record-my-webcam-microphone-or-require-me-to-upload-a-photo-of-my-personal-id">Do you record my webcam, microphone, or require me to upload a photo of my personal ID?</h3>
<p>No. We considered adding these as additional test-taking security measures. But we have less privacy-invading methods of detecting most forms of academic dishonesty.</p>
<h3 id="heading-if-the-environment-is-open-source-doesnt-that-make-it-less-secure">If the environment is open source, doesn't that make it less secure?</h3>
<p>"Given enough eyeballs, all bugs are shallow." – Linus’s Law, formulated by Eric S. Raymond in his book <em>The Cathedral and the Bazaar</em></p>
<p>Open source software projects are often more secure than their closed source equivalents. This is because a lot more people are scrutinizing the code. And a lot more people can potentially help identify bugs and other deficiencies, then fix them.</p>
<p>We feel confident that open source is the way to go for this exam environment system.</p>
<h3 id="heading-how-can-i-contribute-to-the-exam-environment-codebase">How can I contribute to the Exam Environment codebase?</h3>
<p>It's fully open source, and we'd welcome your code contributions. Please read our general <a target="_blank" href="https://contribute.freecodecamp.org/intro/">contributor onboarding documentation</a>.</p>
<p>Then check out the <a target="_blank" href="https://github.com/freeCodeCamp/exam-env">GitHub repo</a>.</p>
<p>You can help by creating issues to report bugs or request features.</p>
<p>You can also browse open <code>help wanted</code> issues and attempt to open pull requests addressing them.</p>
<h3 id="heading-are-the-exam-questions-themselves-open-source">Are the exam questions themselves open source?</h3>
<p>For obvious exam security reasons, the exam question banks themselves are not publicly accessible. :)</p>
<p>These are built and maintained by freeCodeCamp's staff instructional designers.</p>
<h3 id="heading-what-happens-if-i-have-internet-connectivity-issues-mid-exam">What happens if I have internet connectivity issues mid-exam?</h3>
<p>If you have internet connectivity issues mid exam, the next time you try submit an answer, you’ll be told there are connectivity issues. The system will keep prompting you to retry submitting until the connection succeeds.</p>
<h3 id="heading-what-if-my-computer-crashes-mid-exam">What if my computer crashes mid-exam?</h3>
<p>If your computer crashes mid exam, you’ll be able to re-open the Exam Environment. Then, if you still have time left for your exam attempt, you’ll be able to continue from where you left off.</p>
<h3 id="heading-can-i-take-exams-in-languages-other-than-english">Can I take exams in languages other than English?</h3>
<p>Not yet. We’re working to add multi-lingual support in the future.</p>
<h3 id="heading-i-have-completed-my-exam-why-cant-i-see-my-results-yet">I have completed my exam. Why can't I see my results yet?</h3>
<p>All exam attempts are reviewed by freeCodeCamp staff before we release the results. We do this to ensure the integrity of the exam process and to prevent cheating. Once your attempt has been reviewed, you'll be notified of your results the next time you log in to freeCodeCamp.org.</p>
<h3 id="heading-i-am-deaf-or-hard-of-hearing-can-i-still-take-the-exams">I am Deaf or hard of hearing. Can I still take the exams?</h3>
<p>Yes! While some exams may include audio components, we do make written transcripts available for reading.</p>
<h3 id="heading-i-am-blind-or-have-limited-vision-and-use-a-screen-reader-can-i-still-take-the-exams">I am blind or have limited vision, and use a screen reader. Can I still take the exams?</h3>
<p>We’re working on it. Our curriculum is fully screen reader accessible. We're still refining our screen reader usability for the Exam Environment app. This is a high priority for us.</p>
<h3 id="heading-i-use-a-keyboard-instead-of-a-mouse-can-i-navigate-the-exams-using-just-a-keyboard">I use a keyboard instead of a mouse. Can I navigate the exams using just a keyboard?</h3>
<p>This is a high priority for us. We hope to add keyboard navigation to the Exam Environment app soon.</p>
<h3 id="heading-are-exams-timed">Are exams timed?</h3>
<p>Yes, exams are timed. We err on the side of giving plenty of time to take the exam, to account for people who are non-native English speakers, or who have ADHD and other learning differences that can make timed exams more challenging.</p>
<p>If you have a condition that usually qualifies you for extra time on standardized exams, please email support@freecodecamp.org. We’ll review your request and see whether we can find a reasonable solution.</p>
<h3 id="heading-what-happens-if-i-fail-the-exam-can-i-retake-it">What happens if I fail the exam? Can I retake it?</h3>
<p>Yes. You get one exam attempt per week. After you attempt an exam, there is a one-week (exactly 168 hour) “cool-down” period where you cannot take any freeCodeCamp exams. This is to encourage you to study and to pace yourself.</p>
<p>There is no limit to the number of times you can take an exam. So if you fail, study more, practice your skills more, then try again the following week.</p>
<h3 id="heading-do-i-need-to-redo-the-projects-if-i-fail-the-exam">Do I need to redo the projects if I fail the exam?</h3>
<p>No. Once you’ve submitted a certification project, you do not need to ever submit it again.</p>
<p>You can re-do projects for practice, but we recommend that you instead build some of our many practice projects in freeCodeCamp’s developer interview job search section.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764629117812/35c0c09a-3131-4c01-8b97-d5c101912f9e.png" alt="A screenshot of the &quot;Prepare for the developer interview job search&quot; section with lots of coding projects" width="600" height="400" loading="lazy"></p>
<h3 id="heading-what-happens-if-i-already-have-the-old-legacy-responsive-web-design-certification-should-i-claim-the-new-one">What happens if I already have the old Legacy Responsive Web Design certification? Should I claim the new one?</h3>
<p>The new certification has more theory and practice as well as an exam. So if you’re looking to brush up on your skills, then you can go through the new version of this certification.</p>
<h3 id="heading-what-will-happen-to-my-existing-coursework-progress-on-the-full-stack-certification-does-it-transfer-over-to-the-responsive-web-design-course">What will happen to my existing coursework progress on the Full Stack Certification? Does it transfer over to the Responsive Web Design course?</h3>
<p>If you’ve already started the <a target="_blank" href="https://www.freecodecamp.org/learn/full-stack-developer-v9/">Certified Full Stack Developer Curriculum</a>, all of your previously completed work should already be saved there.</p>
<p>To be clear, we’ve copied over all of the coursework from the full stack certification to this newer certification.</p>
<h3 id="heading-can-i-still-continue-with-the-current-full-stack-developer-certification-and-just-not-do-the-new-certification">Can I still continue with the current Full Stack Developer Certification and just not do the new certification?</h3>
<p>We’ve moved the coursework for the <a target="_blank" href="https://www.freecodecamp.org/learn/full-stack-developer-v9/">Full Stack Developer Certification</a> over and broken it up into smaller certifications. Currently there are seven courses available for you to go through. Here is the complete list:</p>
<ul>
<li><p><a target="_blank" href="https://www.freecodecamp.org/learn/responsive-web-design-v9/">Responsive Web Design Certification</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/learn/javascript-v9/">JavaScript Certification</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/learn/front-end-development-libraries-v9/">Frontend Libraries Certification</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/learn/python-v9/">Python Certification</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/learn/relational-databases-v9/">Relational Databases Certification</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/learn/back-end-development-and-apis-v9/">Backend JavaScript Certification</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/learn/full-stack-developer-v9/">Certified Full Stack Developer Certification</a></p>
</li>
</ul>
<p>The Certified Full Stack Developer Certification button will remain on the learn page for a short time to give people the opportunity to switch over to the new certifications. Over the next few months, though, this option will disappear.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1763050732251/0276ffab-bd3f-46fe-bac0-a654ddfafcb5.png" alt="List of all certifications on the freeCodeCamp learn page." width="600" height="400" loading="lazy"></p>
<h3 id="heading-will-my-legacy-certifications-become-invalid">Will my legacy certifications become invalid?</h3>
<p>No. Once you claim a certification, it’s yours to keep.</p>
<p>Also note that we previously announced that freeCodeCamp certifications would have an expiration date and require recertification. We don’t plan to implement this anytime soon. And if we do decide to, we will give everyone at least a year’s notice.</p>
<h3 id="heading-will-the-exam-be-available-to-take-on-my-phone">Will the exam be available to take on my phone?</h3>
<p>At this time, no. You’ll need to use a laptop or desktop to download the exam environment and take the exam. We hope to eventually offer these certification exams on iPhone and Android.</p>
<h3 id="heading-i-have-a-disability-or-health-condition-that-is-not-covered-here-how-can-i-request-accommodations">I have a disability or health condition that is not covered here. How can I request accommodations?</h3>
<p>If you need specific accommodations for the exam (for example extra time, breaks, or alternative formats), please email support@freecodecamp.org. We’ll review your request and see whether we can find a reasonable solution.</p>
<h2 id="heading-anything-else">Anything else?</h2>
<p>Good luck working through freeCodeCamp’s coursework, building projects, and preparing for these exams.</p>
<p>Happy coding!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Learn Relational Database Basics – Key Concepts for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ In today’s digital world, data is everywhere, and it’s at the heart of most modern applications. Databases are the unsung heroes that keep it all organised and accessible. Many sites use databases, from social media platforms to online shopping retai... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learn-relational-database-basics-key-concepts-for-beginners/</link>
                <guid isPermaLink="false">67853e7ede435f43fdeb589d</guid>
                
                    <category>
                        <![CDATA[ Databases ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Relational Database ]]>
                    </category>
                
                    <category>
                        <![CDATA[ SQL ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Beginner Developers ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Zubair Idris Aweda ]]>
                </dc:creator>
                <pubDate>Mon, 13 Jan 2025 16:25:34 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736785487594/67bc81b6-1af8-46a0-8a7a-489896879828.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In today’s digital world, data is everywhere, and it’s at the heart of most modern applications. Databases are the unsung heroes that keep it all organised and accessible. Many sites use databases, from social media platforms to online shopping retailers.  </p>
<p>But what exactly is a database, and how does it work? This article will give you a foundational understanding of core DB concepts like:</p>
<ul>
<li><p>What databases are</p>
</li>
<li><p>Different database models</p>
</li>
<li><p>Database Management Systems (DBMS)</p>
</li>
<li><p>How Relational Database models work</p>
</li>
<li><p>Basics of Structured Query Language (SQL)</p>
</li>
</ul>
<p>Whether you’re a beginner or just looking to refresh your knowledge, this article will help you learn the essentials.</p>
<h2 id="heading-what-is-a-database">What Is A Database?</h2>
<p>A database is a collection of information – information that’s preferably related, and preferably organised. This means that a database can be in any form or shape. It could be a pile of paper records in an office, or a large Excel sheet, or on a computer (most likely in this day and age). But in the most basic terms, a database just helps you store data – so ultimately you can decide what it is.</p>
<p>In the digital world, a database consists of physical files on your computer, or in a cloud computer. These files are installed (or downloaded) when you set up the database software on your computer.</p>
<p>A database allows you to record, organise, manage, retrieve, and update that data efficiently. A database is usually structured, organised, and containing related information, otherwise it will just be a pile of random data.</p>
<p>The structure of a database consists of two main parts, the <strong>data</strong> and the <strong>metadata</strong>.</p>
<ul>
<li><p><strong>data</strong> is the actual information stored in the database. So for example, a database of football players would contain information about players like their names, ages, clubs, and so on.</p>
</li>
<li><p><strong>metadata</strong> is the structural description of the data in a database. It describes the names of <strong>fields</strong> used to store data, the length of those fields (where applicable), and their <strong>datatypes</strong>. metadata gives structure and organisation to raw data.</p>
</li>
</ul>
<h2 id="heading-how-to-update-a-database">How to Update a Database</h2>
<p>You can make changes to the different parts of a database using various commands. There are two general types of commands:</p>
<h3 id="heading-data-definition-language-ddl"><strong>Data Definition Language (DDL)</strong></h3>
<p>First, we have Data Definition Language, or DDL. It’s made up of commands that define or alter the shape or structure of the data in the database. These commands affect the metadata part of a database.</p>
<p>You might make alterations like creating new tables in a relational database, changing the shape of documents in a document-based database by adding new fields, or removing an entire graph in a graph database. DDL might define a field as a specific data type, for example, the "date" type, ensuring only valid dates can be entered.</p>
<h3 id="heading-data-manipulation-language-dml"><strong>Data Manipulation Language (DML)</strong></h3>
<p>We also have Data Manipulation Language, or DML. It’s made up of commands that interact with the data stored in the database. These commands do not affect the structure of the data, but rather the data itself. These command only affect the data part of a database.</p>
<p>Some of the things you can do with DML include reading data from a database, adding new data to the database, editing data, and deleting data.</p>
<p>Applications like <a target="_blank" href="https://tableplus.com">TablePlus</a> let you see the data and the metadata in a database. For example, the data and metadata parts of a football application might look like the images below, respectively:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735566678439/3f33f183-ebe5-40a3-98d1-d8462dab9dbb.png" alt="database data" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735566701148/894a87f3-3bc7-43d9-908a-dbb2e92710c3.png" alt="database metadata" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>A <strong>datatype</strong> defines what type of information can be stored in a field. Datatypes help computers understand how to store, process, and use data efficiently.</p>
<p>So a field in a table with a datatype of <code>date</code> will only be able to store date records, and will throw an error if you try to store something else, like a name. The same goes for a field with a <code>number</code> datatype – it will only accept numbers, and can be set to accept values within a range or to a certain number of decimal points.</p>
<p>Common datatypes include <code>varchar</code> for data that might contain different characters (text + numbers), <code>date</code> for date values, <code>int</code> for whole numbers, and so on. You can find other common database datatypes <a target="_blank" href="https://teachcomputerscience.com/database-data-types/">here</a>.</p>
<h2 id="heading-what-is-a-database-model">What Is a Database Model?</h2>
<p>A database model is a concept used to describe the information stored on a database. Think of it as a building’s blueprint designed by an architect. It details all the tables, columns, and datatypes of the database. But it, in itself, is not a physical entity like the database. A database model determines how data is logically represented and accessed.</p>
<p>Database models define if data is stored in tables using rows and columns, or in JSON-like objects. They also define how data relates, how you can query it, and how you manage it. Database models are often chosen (and often developed) to suit specific data/application needs.</p>
<h3 id="heading-popular-database-models">Popular database models:</h3>
<p><strong>Relational Model</strong>: The Relational Model is the most popular database model. This model uses tables with rows and columns to store data. This model uses the SQL language to manage the data.</p>
<p>Examples of some relational databases include MySQL, PostgreSQL, and SQLite. This model is popularly used for general-purpose applications that require structured, and often related, data and complex queries. The rest of the article will focus on this model.</p>
<p><strong>Document Model</strong>: Data is stored as documents, often in JSON or XML format, in this model. Databases like MongoDB and CouchDB use this model. Document DBs promote flexibility with their JSON-like structures, and they’re commonly used in applications dealing with semi-structured data or hierarchical data, where flexibility is key.</p>
<p><strong>Key-Value Model</strong>: In this model, data is stored as simple key-value pairs, like in a map in programming. This model is used by Redis and DynamoDB. Due to the simplicity of this model, it is used in high-performance scenarios for simple lookups or caching.</p>
<p><strong>Graph Model</strong>: this model uses nodes (entities) and edges (relationships) to manage data. Neo4j and Amazon Neptune are examples of databases using this model. The shape of the nodes and edges in the graph model make it a common choice in applications involving relationships or connections between data points.</p>
<p>There are many more database models. You can find and study them <a target="_blank" href="https://www.lucidchart.com/pages/database-diagram/database-models">here</a> if you’d like more info.</p>
<h2 id="heading-how-do-relational-databases-work">How Do Relational Databases Work?</h2>
<blockquote>
<p>A relational database has the ability to establish links – or relationships – between information by joining tables, which makes it easy to understand and gain insights about the relationship between various data points. - <a target="_blank" href="https://cloud.google.com/learn/what-is-a-relational-database?hl=en">Google</a></p>
</blockquote>
<p>The relational database model was developed as an improvement to an older database model, the Hierarchical Database model. Relational databases build on it and improve some of its restrictions and relationships. The tables in a relational DB model are often called <strong>relations</strong>.</p>
<p>Each row in a database table represents a single <strong>record</strong> in the table. The row tells the full story of the data. It contains data for all the columns in that table for one specific entity.</p>
<p>For example, in a table storing information about football players, each row represents one player and will include player details like name, age, country, and so on. Rows are also sometimes referred to as <strong>records</strong> or <strong>tuples</strong> in database terminology.</p>
<p>Each column lists an attribute of the record in question, such as name, age, or country. The column only tells a small part of the story. Each column has a name and a datatype, and it applies to all rows in the table. These columns could also have constraints in addition to their datatypes. These constraints could be as simple as the <strong><em>NOT NULL</em></strong> constraint that says that the column can not be empty on any row, or as complex as you define it.</p>
<p>For example, in a table of football players, columns might include “name”, “age”, and “country”. All rows in the table will have values under these columns for their respective attributes. In some contexts, <strong>columns</strong> are also referred to as <strong>fields</strong>.</p>
<p>The “relational” part of the name Relational Databases is often attributed to the fact that this model focuses on how data relates with other data, and how tables relate to each other. For example, tables can be linked (related) together. Tables can also be independent.</p>
<p>Despite this flexibility with relationships, the data in a table can be accessed directly without having knowledge of related or unrelated tables. You can easily access <strong>records</strong> as long as you know what you’re looking for. <strong>Primary</strong> and <strong>Foreign</strong> keys are used in the relational model to manage these relationships.</p>
<h2 id="heading-what-is-a-database-management-system-dbms">What Is a DataBase Management System (DBMS)?</h2>
<p>A DataBase Management System (DBMS) is a collection of programs for managing and communicating with an underlying database engine. In simpler terms, a DBMS is the database engine coupled with whatever additional tools that come with it.</p>
<p>A DBMS helps you create, manage, and use databases. It provides an abstraction over the database engine and lets you more easily store, update, and retrieve data in a secure way.</p>
<p>The tools that come in a DBMS can include, but are not always limited to:</p>
<ul>
<li><p>frontend tools (like a query interface, or an administration panel) that help you run queries and visualise the resulting data in the database</p>
</li>
<li><p>backup and recovery tools that work in the background with little to no user interaction</p>
</li>
<li><p>security tools for user access management (roles and permissions)</p>
</li>
<li><p>and data import or export tools.</p>
</li>
</ul>
<p>And as you would imagine, DBMS are usually model-specific, so there are DBMS focused on the Relational Database Model called RDBMS, where the <strong>“R”</strong> is for Relational. Examples of popular RDBMS include MySQL, PostgreSQL, Oracle, and Microsoft SQL Server. RDBMS use <strong>SQL</strong> (Structured Query Language) to interact with the data.</p>
<h2 id="heading-sql-basics">SQL Basics</h2>
<blockquote>
<p>Structured query language (SQL) is a programming language for storing and processing information in a relational database. You can use SQL statements to store, update, remove, search, and retrieve information from a database. You can also use SQL to maintain and optimise database performance. - <a target="_blank" href="https://aws.amazon.com/what-is/sql/">Amazon</a></p>
</blockquote>
<p>It serves as the primary interface for interacting with databases, allowing users to perform various operations such as creating, modifying, querying, and deleting data and database structures. It’s the base upon which RDBMS like MySQL, PostgreSQL, and SQLite are built, with their own optimisations and extensions.</p>
<p>In this section, we’ll take a look at some basic SQL commands, with practical examples.</p>
<h3 id="heading-ddl-commands">DDL Commands</h3>
<h4 id="heading-1-create">1. <code>CREATE</code></h4>
<p>This is the SQL command used to create and define new database objects. It's a part of the <strong>Data Definition Language (DDL)</strong>, and its primary function is to establish the structure or schema of the database.</p>
<p>You can use this command to do the following (amongst many other uses):</p>
<ul>
<li><p>Create new databases</p>
</li>
<li><p>Create new tables</p>
</li>
<li><p>Create a new index in a table</p>
</li>
<li><p>Create views</p>
</li>
<li><p>Create a user with specific access rights</p>
</li>
</ul>
<p><code>CREATE</code> is most commonly used however to create a table in a database, or to create the database itself (although you usually do this using the GUI options the RDBMS provides).</p>
<p>This command has the following structure:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> OBJECT_TYPE object_name (optional_further_arguments)
</code></pre>
<p>The <code>ENTITY_TYPE</code> is a placeholder and could be <code>DATABASE</code>, <code>TABLE</code>, <code>VIEW</code>, and so on from the list of database objects. The <code>entity_name</code> defines the name for the object being created. And finally, the <code>optional_further_arguments</code> is used to show that some of the objects only need a name to be created, while others like tables need more context about the columns of the table.</p>
<p>So based on our example of a football application, creating the <code>football_db</code> database above would involve first creating the database, like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">DATABASE</span> football_db;
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736520482758/7231e225-2dcc-407a-95b4-0684eca078d6.png" alt="CREATE DATABASE" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>This command creates a new database with the provided name, <code>football_db</code>. Next up, using the <code>CREATE</code> command followed by the object type <code>TABLE</code>, you can create a <code>players</code> table, like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> <span class="hljs-string">`players`</span> (
    <span class="hljs-string">`id`</span> <span class="hljs-built_in">int</span> PRIMARY <span class="hljs-keyword">KEY</span> AUTO_INCREMENT,
    <span class="hljs-string">`name`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-string">`age`</span> <span class="hljs-built_in">int</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-string">`country`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-string">`level`</span> enum(<span class="hljs-string">'Academy'</span>, <span class="hljs-string">'Amateur'</span>, <span class="hljs-string">'SemiPro'</span>, <span class="hljs-string">'Professional'</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-string">`position`</span> enum(<span class="hljs-string">'Goalkeeper'</span>, <span class="hljs-string">'Defender'</span>, <span class="hljs-string">'Midfielder'</span>, <span class="hljs-string">'Striker'</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-string">`foot`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">6</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-string">`club`</span> <span class="hljs-built_in">varchar</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-string">`scores`</span> <span class="hljs-keyword">json</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    <span class="hljs-string">`jerseyNumber`</span> <span class="hljs-built_in">int</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>
);
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736522720503/57b09674-8058-4d86-80ea-4d942276bba0.png" alt="CREATE players TABLE" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>The command creates a table called <code>players</code>, and defines the columns (<code>id</code>, <code>name</code>, <code>age</code>, <code>country</code>, <code>level</code>, <code>position</code>, <code>foot</code>, <code>club</code>, <code>scores</code>, <code>jerseyNumber</code>) with their datatypes (<code>int</code>, <code>varchar</code>, <code>enum</code>, <code>json</code>). It also defines their constraints (<code>PRIMARY KEY</code>, <code>AUTO_INCREMENT</code>, <code>NOT NULL</code>).</p>
<h4 id="heading-2-alter">2. <code>ALTER</code></h4>
<p>This command modifies the structure of an existing table. This command is versatile and allows for a wide range of table modifications. These include adding, removing, modifying, and renaming columns, and managing constraints and indexes.</p>
<p>To add a new <code>height</code> column to the newly created <code>players</code> table, you can use the <code>ALTER</code> command like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> players
<span class="hljs-keyword">ADD</span> height <span class="hljs-built_in">INT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>;
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736523536743/e45d03ec-af8c-463f-ac2c-e34e36939ea1.png" alt="ALTER players TABLE" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>The command runs successfully and the new column, defined as an integer column, gets added.</p>
<h4 id="heading-3-drop">3. <code>DROP</code></h4>
<p>This command deletes an existing table or database. When you use the <code>DROP</code> command, it completely removes the object from the database, and this action is irreversible. You can use us to remove databases, tables, and indexes.</p>
<p>If you ever stop using the <code>players</code> table, you can easily delete it using the <code>DROP</code> command like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">DROP</span> <span class="hljs-keyword">TABLE</span> players;
</code></pre>
<h4 id="heading-4-truncate">4. <code>TRUNCATE</code></h4>
<p>This command removes all data from a table while preserving its structure. This same result can be achieved using the <code>DELETE</code> DML command.</p>
<h3 id="heading-dml-commands">DML Commands</h3>
<p>These DML commands are foundational for <strong>CRUD operations</strong>, which stand for <strong>Create, Read, Update, and Delete</strong> – the basic actions you perform with data in a database.</p>
<h4 id="heading-1-insert">1. <code>INSERT</code></h4>
<p>Adds a new record to the database. This is the Create part of CRUD.</p>
<p>The command has the structure like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> table_name (column1, column2, column3, ...)
<span class="hljs-keyword">VALUES</span> (value1, value2, value3, ...);
</code></pre>
<p>The <code>INSERT INTO</code> is the first part of the query, it is mandatory and followed by the name of the table to insert into. The name of the table to insert into is represented by the <code>table_name</code> placeholder. The name can then be followed by a list of columns to populate, or the <code>VALUES</code> keyword. In case when the columns to populate are listed, the list of values has to have the same length as the length of the columns provided, as each entry in both lists will be mapped. In case when the columns to populate are not listed, the items in the values list are mapped to the database columns, and every column will have to be provided. The command also allows for the insertion of multiple records at the same time, following same rules as singe insertions, just with comma-separated multiple lists of values to insert.</p>
<p>To add a few players to the <code>players</code> table to achieve a similar result as in the first screenshot, you can use a couple of insert commands like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span>
    <span class="hljs-string">`players`</span> (<span class="hljs-string">`id`</span>, <span class="hljs-string">`name`</span>, <span class="hljs-string">`age`</span>, <span class="hljs-string">`country`</span>, <span class="hljs-string">`level`</span>, <span class="hljs-string">`position`</span>, <span class="hljs-string">`foot`</span>, <span class="hljs-string">`club`</span>, <span class="hljs-string">`scores`</span>, <span class="hljs-string">`jerseyNumber`</span>, <span class="hljs-string">`height`</span>)
<span class="hljs-keyword">VALUES</span>
    (<span class="hljs-number">1</span>, <span class="hljs-string">'Christiano Ronaldo'</span>, <span class="hljs-number">36</span>, <span class="hljs-string">'Portugal'</span>, <span class="hljs-string">'Professional'</span>, <span class="hljs-string">'Striker'</span>, <span class="hljs-string">'Right'</span>, <span class="hljs-string">'Manchester United'</span>, <span class="hljs-string">'\"4, 3, 5, 2, 4\"'</span>, <span class="hljs-number">7</span>, <span class="hljs-number">187</span>),
    (<span class="hljs-number">2</span>, <span class="hljs-string">'Alisson Becker'</span>, <span class="hljs-number">31</span>, <span class="hljs-string">'Brazil'</span>, <span class="hljs-string">'Professional'</span>, <span class="hljs-string">'Goalkeeper'</span>, <span class="hljs-string">'Right'</span>, <span class="hljs-string">'Liverpool'</span>, <span class="hljs-string">'\"5, 6, 7, 8, 9\"'</span>, <span class="hljs-number">1</span>, <span class="hljs-number">193</span>),
    (<span class="hljs-number">3</span>, <span class="hljs-string">'John Stones'</span>, <span class="hljs-number">30</span>, <span class="hljs-string">'England'</span>, <span class="hljs-string">'Professional'</span>, <span class="hljs-string">'Defender'</span>, <span class="hljs-string">'Right'</span>, <span class="hljs-string">'Manchester City'</span>, <span class="hljs-string">'\"4, 5, 6, 7, 8\"'</span>, <span class="hljs-number">5</span>, <span class="hljs-number">188</span>),
    (<span class="hljs-number">4</span>, <span class="hljs-string">'Kevin DeBruyne'</span>, <span class="hljs-number">33</span>, <span class="hljs-string">'Belgium'</span>, <span class="hljs-string">'Professional'</span>, <span class="hljs-string">'Midfielder'</span>, <span class="hljs-string">'Right'</span>, <span class="hljs-string">'Manchester City'</span>, <span class="hljs-string">'\"9, 8, 7, 6, 5\"'</span>, <span class="hljs-number">17</span>, <span class="hljs-number">181</span>),
    (<span class="hljs-number">5</span>, <span class="hljs-string">'Erling Haaland'</span>, <span class="hljs-number">24</span>, <span class="hljs-string">'Norway'</span>, <span class="hljs-string">'Professional'</span>, <span class="hljs-string">'Striker'</span>, <span class="hljs-string">'Right'</span>, <span class="hljs-string">'Manchester City'</span>, <span class="hljs-string">'\"10, 9, 8, 7, 6\"'</span>, <span class="hljs-number">9</span>, <span class="hljs-number">194</span>),
    (<span class="hljs-number">6</span>, <span class="hljs-string">'Chris Waddle'</span>, <span class="hljs-number">20</span>, <span class="hljs-string">'England'</span>, <span class="hljs-string">'SemiPro'</span>, <span class="hljs-string">'Midfielder'</span>, <span class="hljs-string">'Left'</span>, <span class="hljs-string">'Tow Law Town'</span>, <span class="hljs-string">'\"3, 4, 5, 6, 7\"'</span>, <span class="hljs-number">11</span>, <span class="hljs-number">183</span>),
    (<span class="hljs-number">7</span>, <span class="hljs-string">'Ian Wright'</span>, <span class="hljs-number">25</span>, <span class="hljs-string">'England'</span>, <span class="hljs-string">'SemiPro'</span>, <span class="hljs-string">'Striker'</span>, <span class="hljs-string">'Right'</span>, <span class="hljs-string">'Greenwich Borough'</span>, <span class="hljs-string">'\"4, 5, 6, 7, 8\"'</span>, <span class="hljs-number">8</span>, <span class="hljs-number">175</span>),
    (<span class="hljs-number">8</span>, <span class="hljs-string">'Charlie Austin'</span>, <span class="hljs-number">34</span>, <span class="hljs-string">'England'</span>, <span class="hljs-string">'SemiPro'</span>, <span class="hljs-string">'Striker'</span>, <span class="hljs-string">'Right'</span>, <span class="hljs-string">'Poole Town'</span>, <span class="hljs-string">'\"5, 6, 7, 8, 9\"'</span>, <span class="hljs-number">9</span>, <span class="hljs-number">188</span>),
    (<span class="hljs-number">9</span>, <span class="hljs-string">'Troy Deeney'</span>, <span class="hljs-number">33</span>, <span class="hljs-string">'England'</span>, <span class="hljs-string">'SemiPro'</span>, <span class="hljs-string">'Striker'</span>, <span class="hljs-string">'Right'</span>, <span class="hljs-string">'Chelmsley Town'</span>, <span class="hljs-string">'\"6, 7, 8, 9, 10\"'</span>, <span class="hljs-number">9</span>, <span class="hljs-number">183</span>),
    (<span class="hljs-number">10</span>, <span class="hljs-string">'Rickie Lambert'</span>, <span class="hljs-number">39</span>, <span class="hljs-string">'England'</span>, <span class="hljs-string">'SemiPro'</span>, <span class="hljs-string">'Striker'</span>, <span class="hljs-string">'Right'</span>, <span class="hljs-string">'Macclesfield Town'</span>, <span class="hljs-string">'\"7, 8, 9, 10, 11\"'</span>, <span class="hljs-number">9</span>, <span class="hljs-number">187</span>);
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736525270444/ce1739aa-7fef-48d0-b61a-6cee1267ab1a.png" alt="INSERT INTO players TABLE" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h4 id="heading-2-select">2. <code>SELECT</code></h4>
<p>The <code>SELECT</code> command has the basic syntax:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> column1, column2, ...
<span class="hljs-keyword">FROM</span> table_name
<span class="hljs-keyword">WHERE</span> condition;
</code></pre>
<p>The command has the following parts:</p>
<ul>
<li><p><code>SELECT</code> is the mandatory keyword that begins every query,</p>
</li>
<li><p><code>column1, column2, …</code> is a placeholder for the list of columns to be retrieved. This is especially useful when dealing with large tables as you do not always want to display all columns every time. To display all columns, replace the list with the <code>*</code> character.</p>
</li>
<li><p><code>FROM</code> is another mandatory keyword that is followed by the name of the table to fetch the data from,</p>
</li>
<li><p><code>table_name</code> is the name of the table the data should come from.</p>
</li>
<li><p><code>WHERE condition</code> is one of the optional commands that can be attached to the <code>SELECT</code> command. It is used to filter the records by specific conditions.</p>
</li>
</ul>
<p>This is the Read part of CRUD. The simplest form of the <code>SELECT</code> command is used to view all records in a table (all columns and rows):</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> players;
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736526168218/a8b4c51c-afb6-4228-885b-2620bd99cf93.png" alt="SELECT ALL players" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h4 id="heading-3-update">3. <code>UPDATE</code></h4>
<p>The <code>UPDATE</code> command modifies existing records in the database. This is the Update part of CRUD.</p>
<p>To update the details of Christiano Ronaldo to be more accurate, you can use the <code>UPDATE</code> command like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">UPDATE</span> <span class="hljs-string">`players`</span>
<span class="hljs-keyword">SET</span>
    <span class="hljs-string">`name`</span> = <span class="hljs-string">'Cristiano Ronaldo'</span>,
    <span class="hljs-string">`age`</span> = <span class="hljs-number">38</span>,
    <span class="hljs-string">`club`</span> = <span class="hljs-string">'Al Nassr'</span>
<span class="hljs-keyword">WHERE</span>
    <span class="hljs-string">`id`</span> = <span class="hljs-number">1</span>;
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736526962015/55dd1f1d-a755-40fe-90d2-9975b8df7ba1.png" alt="UPDATE player record" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>This command changes his name slightly, his club from Manchester United to his current club of Al Nassr, and updates his age to 38.</p>
<h4 id="heading-4-delete">4. <code>DELETE</code></h4>
<p>The <code>DELETE</code> command removes records from the database. This is the Delete part of CRUD.</p>
<p>It is syntactically similar to the <code>SELECT</code> command, having a basic syntax like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> table_name
<span class="hljs-keyword">WHERE</span> condition;
</code></pre>
<p>In this structure,</p>
<ul>
<li><p>The <code>DELETE FROM</code> keyword is the mandatory start of any delete queries,</p>
</li>
<li><p>It is followed by the name of the table to be deleted, represented by the <code>table_name</code>.</p>
</li>
<li><p>The <code>WHERE condtion</code> is optional where all the rows of the table are to be deleted. But otherwise, it is used to specify the rows to be deleted by matching a condition.</p>
</li>
</ul>
<p>To remove players not playing at the professional level from the table, you can use a command like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> <span class="hljs-string">`players`</span>
<span class="hljs-keyword">WHERE</span> <span class="hljs-string">`level`</span> != <span class="hljs-string">'Professional'</span>;
</code></pre>
<p>These are the basic commands you’ll use to interact with databases. You can learn more about them <a target="_blank" href="https://www.freecodecamp.org/news/learn-sql-in-10-minutes/">in this SQL command cheatsheet</a>.</p>
<h2 id="heading-summary"><strong>Summary</strong></h2>
<p>Databases are a cornerstone of modern technology, and understanding their fundamental concepts can open doors to building and managing efficient, data-driven systems.</p>
<p>This article introduced you to the basics of what a database is and how relational database models work. You should now have the essential knowledge to navigate the world of databases confidently.</p>
<p>To deepen your understanding, consider exploring the following:</p>
<ul>
<li><p><strong>Hands-On Practice</strong>: Use tools like <a target="_blank" href="https://tableplus.com/">TablePlus</a> to interact with relational databases.</p>
</li>
<li><p><strong>Learning SQL</strong>: Start with beginner-friendly SQL tutorials like <a target="_blank" href="https://www.freecodecamp.org/news/learn-sql-full-course/">this course on freeCodeCamp’s YouTube channel</a> or <a target="_blank" href="https://www.freecodecamp.org/news/learn-sql-in-10-minutes/">this SQL command cheatsheet</a>.</p>
</li>
<li><p><strong>Experiment with Non-Relational Databases</strong>: Try <a target="_blank" href="https://www.freecodecamp.org/news/how-to-start-using-mongodb/">MongoDB</a> or <a target="_blank" href="https://www.freecodecamp.org/news/learn-neo4j-database-course/">Neo4j</a> to explore how other database models work.</p>
</li>
</ul>
<p>If you’re curious to learn more, connect with me on <a target="_blank" href="https://www.linkedin.com/in/idris-aweda-zubair-5433121a3/">LinkedIn</a>, <a target="_blank" href="https://twitter.com/AwedaIdris">Twitter</a>, or <a target="_blank" href="https://github.com/Zubs">GitHub</a>. Let’s continue this journey together toward mastering database systems!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Relational Database Course – How to Learn SQL in VSCode Using Docker and freeCodeCamp ]]>
                </title>
                <description>
                    <![CDATA[ You can now learn Relational Database concepts and SQL right inside your VSCode editor. This tutorial will walk you through how to install it using Docker. During this full-length 300-hour course, you will learn to build more than a dozen projects. S... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-run-freecodecamps-relational-databases-curriculum-using-docker-vscode-and-coderoad/</link>
                <guid isPermaLink="false">66b0aa467cd8dca6718a22aa</guid>
                
                    <category>
                        <![CDATA[ freeCodeCamp.org ]]>
                    </category>
                
                    <category>
                        <![CDATA[ freeCodeCamp Curriculum ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Relational Database ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Tom Mondloch ]]>
                </dc:creator>
                <pubDate>Thu, 16 Sep 2021 16:17:32 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/09/Screen-Shot-2021-09-12-at-9.22.55-PM.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>You can now learn Relational Database concepts and SQL right inside your VSCode editor. This tutorial will walk you through how to install it using Docker.</p>
<p>During this full-length 300-hour course, you will learn to build more than a dozen projects. Some of them will involve step-by-step instructions, and others will be open ended, with elaborate test suites.</p>
<p>You will use real developer tools and software like VS Code, PostgreSQL, and the Linux / Unix command line to complete interactive tutorials and build projects.</p>
<h3 id="heading-what-you-will-learn">What you will learn</h3>
<ul>
<li><p>The Linux / Unix Command Line</p>
</li>
<li><p>Relational Databases</p>
</li>
<li><p>SQL and PostgreSQL</p>
</li>
<li><p>Bash and Bash Scripting</p>
</li>
<li><p>Git and GitHub</p>
</li>
<li><p>Nano</p>
</li>
<li><p>And a lot of other concepts and tools</p>
</li>
</ul>
<p>This course was made possible by a grant from <a target="_blank" href="https://www.classcentral.com/">Class Central</a>, a search engine and review site for online courses.</p>
<h2 id="heading-how-to-install-docker-and-run-the-relational-database-curriculum">How to install Docker and run the Relational Database Curriculum</h2>
<p>Docker will run a container on your computer that has the software and file structure required for these tutorials.</p>
<p>You will be working in that container using VSCode and the Dev Containers extension. Once it's running, the CodeRoad extension will run the tutorials we have created.</p>
<h3 id="heading-prerequisites">Prerequisites</h3>
<p>Before you get started, you need to have a few things installed:</p>
<ol>
<li><p>The <a target="_blank" href="https://docs.docker.com/engine/install/">Docker Engine</a></p>
</li>
<li><p><a target="_blank" href="https://code.visualstudio.com/download">VS Code</a></p>
</li>
<li><p>The <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers">Dev Containers</a> extension for VS Code</p>
</li>
<li><p><a target="_blank" href="https://git-scm.com/downloads">Git</a></p>
</li>
</ol>
<h3 id="heading-how-to-run-a-project-in-docker">How to Run a Project in Docker</h3>
<p>Follow these steps to run the docker container and start a tutorial:</p>
<ol>
<li><p>Clone the RDB Alpha repo to your computer with <code>git clone https://github.com/freeCodeCamp/rdb-alpha</code></p>
</li>
<li><p>Open a terminal, navigate to the <code>rdb-alpha</code> directory, and open VS Code with <code>code .</code></p>
</li>
<li><p>In VS Code, open the command palette with <code>Ctrl / Cmd + Shift + P</code>. Then, enter and run <code>Dev Containers: Rebuild and Reopen in Container</code></p>
</li>
<li><p>A new VS Code window will open and begin building the Docker image. It will take several minutes to build the first time</p>
</li>
<li><p>Once the image is finished building, open the command palette again with <code>Ctrl / Cmd + Shift + P</code>, enter and run <code>CodeRoad: Start</code>. The command won't be available until the extension has finished installing in your container</p>
</li>
<li><p>In the CodeRoad window, click "Start New Tutorial"</p>
</li>
<li><p>Click the <code>URL</code> tab and enter the URL of the <code>tutorial.json</code> file for the project you want to start (ex: https://raw.githubusercontent.com/freeCodeCamp/learn-bash-by-building-a-boilerplate/main/tutorial.json) Full list of available tutorials below.</p>
</li>
<li><p>Click the "Start" button to start the lessons</p>
</li>
</ol>
<h3 id="heading-how-to-restart-or-switch-projects">How to Restart or Switch Projects</h3>
<p>If you restart or switch projects, you will lose your progress on a tutorial you may have started along with any files or folders you may have created.</p>
<ol>
<li><p>Open the command palette with <code>Ctrl / Cmd + Shift + P</code>, enter and run <code>Dev-Containers: Rebuild Container</code></p>
</li>
<li><p>Wait for VS Code to reopen the reload the container</p>
</li>
<li><p>Open CodeRoad from the command palette like you did before, click "Start New Tutorial", and enter the URL of the <code>tutorial.json</code> file for the project you want to do</p>
</li>
</ol>
<h3 id="heading-available-courses">Available Courses</h3>
<p>Here is a list of tutorials currently available. Open one of them and use its URL, as described in the instructions above, to start it.</p>
<ul>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-bash-by-building-a-boilerplate/main/tutorial.json">Learn Bash by Building a Boilerplate</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-relational-databases-by-building-a-database-of-video-game-characters/main/tutorial.json">Learn Relational Databases by Building a Database of Video Game Characters</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-celestial-bodies-database/main/tutorial.json">Celestial Bodies Database</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-bash-scripting-by-building-five-programs/main/tutorial.json">Learn Bash Scripting by Building Five Programs</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-sql-by-building-a-student-database-part-1/main/tutorial.json">Learn SQL by Building a Student Database: Part 1</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-sql-by-building-a-student-database-part-2/main/tutorial.json">Learn SQL by Building a Student Database: Part 2</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-world-cup-database/main/tutorial.json">World Cup Database</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-advanced-bash-by-building-a-kitty-ipsum-translator/main/tutorial.json">Learn Advanced Bash by Building a Kitty Ipsum Translator</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-bash-and-sql-by-building-a-bike-rental-shop/main/tutorial.json">Learn Bash and SQL by Building a Bike Rental Shop</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-salon-appointment-scheduler/main/tutorial.json">Salon Appointment Scheduler</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-nano-by-building-a-castle/main/tutorial.json">Learn Nano by Building a Castle</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-git-by-building-an-sql-reference-object/main/tutorial.json">Learn Git by Building an SQL Reference Object</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-periodic-table-database/main/tutorial.json">Periodic Table Database</a></p>
</li>
<li><p><a target="_blank" href="https://raw.githubusercontent.com/freeCodeCamp/learn-number-guessing-game/main/tutorial.json">Number Guessing Game</a></p>
</li>
</ul>
<h4 id="heading-heres-a-video-of-me-doing-learn-bash-by-building-a-boilerplate-in-13-minutes-and-38-seconds">Here's a video of me doing "Learn Bash by Building a Boilerplate" in 13 minutes and 38 seconds:</h4>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/VQmCwzfSM-k" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<h2 id="heading-also-download-the-freecodecamp-dark-theme-for-vs-code">Also, Download the freeCodeCamp Dark Theme for VS Code</h2>
<p>If you like the color scheme that these tutorials use, you can download the <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=freeCodeCamp.freecodecamp-dark-vscode-theme">freeCodeCamp Dark Theme extension</a> from the Visual Studio Marketplace.</p>
<p>You can <a target="_blank" href="https://www.freecodecamp.org/news/vs-code-dark-mode-theme/">learn more about the Dark Theme here</a>.</p>
<h2 id="heading-help-us-improve-these-courses-by-asking-questions-and-giving-us-feedback">Help us improve these courses by asking questions and giving us feedback</h2>
<p>If you have any questions about these new Relational Database courses, get stuck at some point, or just have general feedback about them, you can create a thread on <a target="_blank" href="https://forum.freecodecamp.org/">the freeCodeCamp Forum</a>.</p>
<p>We also have our own Slack-like chat room system where you can ask questions and help contribute to our open source projects. <a target="_blank" href="https://chat.freecodecamp.org/home">Join our chat room system</a>.</p>
<p>Happy Coding.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
