Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
UNIQUE
NOT NULL
CHECK
DEFAULT
Summary
35. Revision #3

Instruction

That was a piece of cake for you! Are you ready for the final challenge?

Exercise

Write the proper CREATE TABLE instruction based on the description below:

RPG game lovers need a table called character where they will put some information about the fantastic characters they play. Each character has a unique name of up to 30 characters (which is essential and is the primary key) and some points given for the following abilities (separate integer columns): strength, dexterity and intelligence. Each ability can be given 0-10 points and the sum of all the points in the three abilities must be lower than 20.

Stuck? Here's a hint!

Type

CREATE TABLE character (
  name varchar(30) PRIMARY KEY,
  strength int CHECK (strength BETWEEN 0 AND 10),
  dexterity int CHECK (dexterity BETWEEN 0 AND 10),
  intelligence int CHECK (intelligence BETWEEN 0 AND 10),
  CHECK (strength + dexterity + intelligence < 20)
);