Practice Defining Constraints (4.2.2) - Structured Query Language (SQL) - Part 1
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Defining Constraints

Practice - Defining Constraints

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

What is the purpose of a PRIMARY KEY constraint?

💡 Hint: Remember what uniquely identifies a record.

Question 2 Easy

What does the NOT NULL constraint do?

💡 Hint: Think about whether there can be an empty space in that column.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What does the PRIMARY KEY constraint ensure?

Allows duplicates in a column
Uniquely identifies each row
Enforces NULL values

💡 Hint: Think about the identity of each record.

Question 2

A FOREIGN KEY constraint is used to:

True
False

💡 Hint: Consider how tables interact with each other.

1 more question available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

You are tasked to design a Students table. It should include a student ID that is unique, an email that must also be unique, and a condition that checks that age must be greater than 16.

💡 Hint: Remember to apply both UNIQUE and CHECK constraints in your SQL statement.

Challenge 2 Hard

Write an SQL statement to modify an existing table to include a NOT NULL constraint on the LastName column and a CHECK constraint that limits the Age to between 18 and 100.

💡 Hint: Use ALTER TABLE syntax to modify your existing structure.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.