{"id":20692,"date":"2020-08-01T14:36:02","date_gmt":"2020-08-01T21:36:02","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=20692"},"modified":"2023-12-01T03:57:16","modified_gmt":"2023-12-01T11:57:16","slug":"sql-constraints","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/sql-constraints\/","title":{"rendered":"SQL Constraints: A Beginner\u2019s Guide"},"content":{"rendered":"\n<p>One of the great features of databases is that they can restrict the types of values stored in a particular column. This means that you don\u2019t need to validate every value before you try to insert it into a database.<br><\/p>\n\n\n\n<p>That\u2019s where SQL constraints come in. You can build in some initial validation using constraints which will check the integrity of a record before it is added to a database. In this tutorial, we\u2019re going to discuss what constraints are and what constraints you can use in <a href=\"https:\/\/careerkarma.com\/blog\/how-long-is-to-learn-sql\/\">SQL<\/a>.<br><\/p>\n\n\n\n<p>Without further ado, let\u2019s begin!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is an SQL Constraint?&nbsp;<\/h2>\n\n\n\n<p>A constraint limits the values that can be stored in a particular column in a table.<br><\/p>\n\n\n\n<p>Constraints are useful because they help you preserve the accuracy of a database table. Using constraints allows you to make sure that each value you add into a column is formatted correctly before it is added. This can prevent complications due to improperly formatted data.<br><\/p>\n\n\n\n<p>There are six main constraints in SQL:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>PRIMARY KEY<\/li><li>FOREIGN KEY<\/li><li>UNIQUE<\/li><li>NOT NULL<\/li><li>DEFAULT<\/li><li>CHECK<\/li><\/ul>\n\n\n\n<p>These constraints are imposed when you create a table. This means that once a constraint is set, it will validate all the values you add into a table. You do not need to set a constraint for each record you add into a table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SQL PRIMARY KEY Constraint<\/h2>\n\n\n\n<p>The PRIMARY KEY constraint uniquely identifies a row in a table. A table cannot hold more than one record with the same <a href=\"https:\/\/careerkarma.com\/blog\/primary-keys-foreign-keys\/\">primary key<\/a>. Primary key fields also cannot be null.<br><\/p>\n\n\n\n<p>Let\u2019s create a table called \u201cemployees\u201d with an ID column. This ID column uses a primary key:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>CREATE TABLE employees (\n\tid INT NOT NULL PRIMARY KEY,\n\tname VARCHAR(50),\n\tbranch VARCHAR(50),\n\temail VARCHAR(50)\n);<\/pre><\/div>\n\n\n\n<p>This table will have four columns: id, name, email, and branch. Every record must have a unique ID value. Otherwise, an error will be returned when you try to add in a record with a duplicate ID.<br><\/p>\n\n\n\n<p>In this example, there are a few logical primary keys. Having a unique column called ID works because each employee has their own ID number. We could identify employees by their email address because no two employees will share an email address.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SQL FOREIGN KEY Constraint<\/h2>\n\n\n\n<p>A FOREIGN KEY is a combination of columns that creates a relationship between two tables.<br><\/p>\n\n\n\n<p>Consider the following database. This database has two tables: employees and branches.<br><\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td><strong>employees<\/strong><\/td><td><strong>branches<\/strong><\/td><\/tr><tr><td>id INT<\/td><td>branch_id INT<\/td><\/tr><tr><td>name VARCHAR(50)<\/td><td>branch_name VARCHAR(50)<\/td><\/tr><tr><td>email VARCHAR(50)<\/td><td><br><\/td><\/tr><tr><td>branch_id INT<\/td><td><br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>There is a value in the employees table called \u201cbranch_id\u201d. This is a foreign key. This value links the employees and branches tables together. The value of <code>branch_id<\/code> in the employees table corresponds to the respective <code>branch_id<\/code> in the branches table.<br><\/p>\n\n\n\n<p>You can create a FOREIGN KEY when you create a new table:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>CREATE TABLE employees (\n\tid INT NOT NULL PRIMARY KEY,\n\tname VARCHAR(50),\n\temail VARCHAR(50),\n\tbranch_id INT,\n\tFOREIGN KEY (banch_id) REFERENCES branches(branch_id)\n);<\/pre><\/div>\n\n\n\n<p>This command creates a link between the employees and branches table. The column name of the foreign key that you want to create must exist in the other table. For instance, \u201cbranch_id\u201d needs to exist in the \u201cbranches\u201d table for our CREATE TABLE command to work.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SQL UNIQUE<\/h2>\n\n\n\n<p>The UNIQUE constraint ensures each value in a column has a unique value. This helps preserve the integrity of the data in a table.<br><\/p>\n\n\n\n<p>The UNIQUE constraint is used when you want a column to contain unique values without imposing a primary key. Only one primary key can be assigned per table whereas you can use as many UNIQUE constraints as you want in a table.<br><\/p>\n\n\n\n<p>Let\u2019s create a table that uses the unique constraint:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>CREATE TABLE employees (\n\tid INT NOT NULL PRIMARY KEY,\n\tname VARCHAR(50),\n\tbranch VARCHAR(50),\n\temail VARCHAR(50) UNIQUE\n);<\/pre><\/div>\n\n\n\n<p>The UNIQUE constraint is added after the type of data that a column should use. We\u2019ve used UNIQUE to limit the value of \u201cemail\u201d to contain only unique values. If we try to insert a duplicate email into the database, an error will occur.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SQL NOT NULL<\/h2>\n\n\n\n<p>The NOT NULL constraint states that a column cannot accept NULL values.<br><\/p>\n\n\n\n<p>When a NOT NULL constraint is specified, you must add in a value for the column on which that constraint is imposed when you create a record. If you try to change the value of that column, you must specify a value that is not NULL.<br><\/p>\n\n\n\n<p>Let\u2019s create a table that uses the NOT NULL constraint:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>CREATE TABLE employees (\n\tid INT NOT NULL PRIMARY KEY,\n\tname VARCHAR(50) NOT NULL,\n\tbranch VARCHAR(50) NOT NULL,\n\temail VARCHAR(50) \n);<\/pre><\/div>\n\n\n\n<p>The NOT NULL keyword comes after the type of data a column uses. In this table, we\u2019ve used three NOT NULL statements.<br><\/p>\n\n\n\n<p>In order to add a record into our database, we must specify an id, the employee\u2019s name, and the branch at which an employee works. These columns do not accept null values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SQL DEFAULT<\/h2>\n\n\n\n<p>Have you ever wanted to set a default value for a column? The DEFAULT constraint has you covered. This table-level constraint sets a default value for a column in a database.<br><\/p>\n\n\n\n<p>Default values are added into a record if you do not specify a value for a column in an <a href=\"https:\/\/careerkarma.com\/blog\/sql-insert\/\">INSERT statement<\/a>. Consider this SQL <a href=\"https:\/\/careerkarma.com\/blog\/sql-create-table\/\">CREATE TABLE statement<\/a>:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>CREATE TABLE employees (\n\tid INT NOT NULL PRIMARY KEY,\n\tname VARCHAR(50),\n\tbranch VARCHAR(50) DEFAULT &quot;San Francisco&quot;,\n\temail VARCHAR(50) UNIQUE\n);<\/pre><\/div>\n\n\n\n<p>By default, every record added into the <code>employees<\/code> table will have the branch name <code>San Francisco<\/code>. This will only be overridden if you explicitly specify a value for the <code>branch<\/code> column when you create a column.<br><\/p>\n\n\n\n<p>The DEFAULT statement is commonly used with the NOT NULL constraint. This is because the DEFAULT statement allows you to create a record without a value. But, once that record has been created, you will not be able to set the value of the column to NULL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SQL CHECK<\/h2>\n\n\n\n<p>The CHECK constraint checks whether a value inserted into a column meets a condition or set of conditions.<br><\/p>\n\n\n\n<p>Our business only has two branches: San Francisco and Cambridge. We want to limit the values in the \u201cbranch\u201d column so that only those two branch names can be used. We can do this using a CHECK statement:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>CREATE TABLE employees (\n\tid INT NOT NULL PRIMARY KEY,\n\tname VARCHAR(50),\n\tbranch VARCHAR(50) CHECK (branch = &quot;San Francisco&quot; OR branch = &quot;Cambridge&quot;)\n\temail VARCHAR(50) UNIQUE\n);<\/pre><\/div>\n\n\n\n<p>Every time a record is inserted into the employees table, the database will check to make sure the value of \u201cbranch\u201d is either San Francisco or Cambridge. If another value is specified, an error will be returned.<br><\/p>\n\n\n\n<p>CHECK statements are particularly useful because they reduce the prospects of a typo inside a column that can only have a certain range of values.<br><\/p>\n\n\n\n<p>For instance, if the value of \u201cbranch\u201d was set to be \u201cSan Ffrancisco\u201d, an error would be returned. \u201cSan Ffrancisco\u201d is not in our CHECK statement. Thus, the CHECK statement would have prevented the typo from being added to the database.<br><\/p>\n\n\n\n<p>CHECK is not supported in MySQL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>SQL constraints limit the type of values that can be stored in a column. There are six main constraints in SQL: PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, DEFAULT, and CHECK.<br><\/p>\n\n\n\n<p>Constraints are imposed in a CREATE TABLE statement. This means that you don\u2019t need to specify a constraint every time you create or update a record. The constraint is stored in the structure of the table itself.<br><\/p>\n\n\n\n<p>Now you\u2019re ready to start using SQL constraints like an expert!<br><\/p>\n","protected":false},"excerpt":{"rendered":"One of the great features of databases is that they can restrict the types of values stored in a particular column. This means that you don\u2019t need to validate every value before you try to insert it into a database. That\u2019s where SQL constraints come in. You can build in some initial validation using constraints&hellip;","protected":false},"author":240,"featured_media":20693,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17284],"tags":[],"class_list":{"0":"post-20692","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-sql"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"SQL","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>SQL Constraints: A Beginner\u2019s Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"SQL constraints limit the values that can be stored in a database column. On Career Karma, learn how to impose SQL constraints.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/sql-constraints\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Constraints: A Beginner\u2019s Guide\" \/>\n<meta property=\"og:description\" content=\"SQL constraints limit the values that can be stored in a database column. On Career Karma, learn how to impose SQL constraints.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/sql-constraints\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-01T21:36:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:57:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"685\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"SQL Constraints: A Beginner\u2019s Guide\",\"datePublished\":\"2020-08-01T21:36:02+00:00\",\"dateModified\":\"2023-12-01T11:57:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/\"},\"wordCount\":1148,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg\",\"articleSection\":[\"SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/sql-constraints\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/\",\"name\":\"SQL Constraints: A Beginner\u2019s Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg\",\"datePublished\":\"2020-08-01T21:36:02+00:00\",\"dateModified\":\"2023-12-01T11:57:16+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"SQL constraints limit the values that can be stored in a database column. On Career Karma, learn how to impose SQL constraints.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/sql-constraints\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg\",\"width\":1000,\"height\":685},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/sql-constraints\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL\",\"item\":\"https:\/\/careerkarma.com\/blog\/sql\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQL Constraints: A Beginner\u2019s Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"SQL Constraints: A Beginner\u2019s Guide | Career Karma","description":"SQL constraints limit the values that can be stored in a database column. On Career Karma, learn how to impose SQL constraints.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/sql-constraints\/","og_locale":"en_US","og_type":"article","og_title":"SQL Constraints: A Beginner\u2019s Guide","og_description":"SQL constraints limit the values that can be stored in a database column. On Career Karma, learn how to impose SQL constraints.","og_url":"https:\/\/careerkarma.com\/blog\/sql-constraints\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-08-01T21:36:02+00:00","article_modified_time":"2023-12-01T11:57:16+00:00","og_image":[{"width":1000,"height":685,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"SQL Constraints: A Beginner\u2019s Guide","datePublished":"2020-08-01T21:36:02+00:00","dateModified":"2023-12-01T11:57:16+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/"},"wordCount":1148,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg","articleSection":["SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/sql-constraints\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/","url":"https:\/\/careerkarma.com\/blog\/sql-constraints\/","name":"SQL Constraints: A Beginner\u2019s Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg","datePublished":"2020-08-01T21:36:02+00:00","dateModified":"2023-12-01T11:57:16+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"SQL constraints limit the values that can be stored in a database column. On Career Karma, learn how to impose SQL constraints.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/sql-constraints\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ben-kolde-t9DooibgMEk-unsplash.jpg","width":1000,"height":685},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/sql-constraints\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"SQL","item":"https:\/\/careerkarma.com\/blog\/sql\/"},{"@type":"ListItem","position":3,"name":"SQL Constraints: A Beginner\u2019s Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/20692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=20692"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/20692\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/20693"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=20692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=20692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=20692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}