Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close

Welcome to SQL Constraints! This is the third course in the track Creating Database Structure. We assume that you know the basic syntax of how to create a table in SQL. You should also know the data types available in a SQL database.

If you’re not familiar with creating tables or with SQL data types, we recommend you do The Basics of Creating Tables in SQL and Data Types in SQL courses before starting this one.

In this course, we talk about database constraints. A constraint is a mechanism that relational databases use to check data correctness. They can verify if a value is unique or is a certain type of data. You can also use constraints to make sure important fields are not left empty.

SQL databases have several types of constraints: primary keys, foreign keys, UNIQUE, NOT NULL, CHECK, and DEFAULT. We will show you how to create tables with constraints and how to drop or modify a constraint.

This interactive tutorial is based on standard SQL; what you learn here will work in all popular relational database management systems, including SQL Server, MySQL, Oracle, and PostgreSQL.

This is a course for beginning IT professionals, computer science students, programmers, developers, and junior database administrators (DBAs). If you need to learn about controlling data entered into a relational database, this is the course for you.

The topics discussed in this course are:

  • Primary keys and foreign keys. We start with a review of primary and foreign keys, which we introduced in The Basics of Creating Tables in SQL.
  • The UNIQUE constraint, which ensures that values or combinations of values are found only once in a table. We show how to create a table with this constraint and how to add a UNIQUE constraint to an existing table.
  • NOT NULL. We review this constraint, which was introduced in the first course of the track. We also discuss how to alter a table and add a NOT NULL constraint.
  • The CHECK constraint, which verifies that values meet a specified criteria.
  • DEFAULT. We discuss how to set up a default value for a column and how to add a default value to an existing column.

This course is interactive. You solve the exercises directly in your web browser and learn how different constraints work. You’ll be writing real SQL commands, which our online platform runs and verifies. You don’t need to install anything on your computer.

What Do You Need to Take This Course?

  • A web browser and an internet connection.
  • Knowledge of SQL, including SELECT, INSERT, UPDATE, and DELETE.
  • Basic understanding of the CREATE TABLE syntax.

This Course Will Teach You How To:

  • Define, modify, and remove primary keys.
  • Define, modify, and remove foreign keys.
  • Define a UNIQUE constraint on a column or set of columns.
  • Add and remove NOT NULL constraints.
  • Add, modify, and remove CHECK constraints.
  • Add, modify, and remove DEFAULT constraints.
  • Alter existing tables to remove or modify constraints.

Who Should Take This Course?

  • Beginning developers and programmers
  • Beginning database administrators (DBAs)
  • Students taking classes in relational databases
  • Anyone who wants to learn how to apply constraints to columns and tables

    Table of contents

    Progress: 0% completed 0 of 76 exercises done

    1. Primary keys and foreign keys

    What are database constraints? A short recap of primary keys and foreign keys.

    More details Less

    2. UNIQUE constraint

    Learn how you can make sure that all values in a column are different.

    More details Less

    3. NOT NULL constraint

    Learn how to make sure that a column in a database has a value.

    More details Less

    4. CHECK constraint

    Price below zero? Customer over 200 years old? Learn how CHECK constraints can ensure that information in a database is correct.

    More details Less

    5. DEFAULT constraint

    How to provide a default value for a column.

    More details Less

    6. Final Quiz

    Time to test your knowledge!

    More details Less

    Reviews

    Average rating

    0/50.0 (0)

    Details

    5 Stars 0%
    4 Stars 0%
    3 Stars 0%
    2 Stars 0%
    1 Stars 0%
      Load more reviews

      Comments

      0