CJCoding With Joseph
15free / daySign inCreate account

Workshop Credits Between 1 and 4

Create a table called workshops with three columns: id (an INTEGER PRIMARY KEY), title (TEXT, required) and credits (INTEGER, required). Credits must fall in the range 1 to 4 inclusive: a workshop worth 0 or 5 credits must be rejected, while 1 and 4 are fine. Write the range rule as a CHECK on the credits column.

Expected result:

Table workshops
✓ id INTEGER PRIMARY KEY
✓ title TEXT NOT NULL
✓ credits INTEGER NOT NULL
✓ Insert a workshop worth 5 credits: rejected (CHECK)
✓ Insert a workshop worth 0 credits: rejected (CHECK)
✓ Insert a workshop worth 4 credits: accepted
✓ Insert a workshop with no credits at all: rejected (NOT NULL)
Hints3 available
Topics:
Constraints
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)

Results

Run your SQL to see every statement's output here, then how it compares with the expected answer.

Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns — or open the database browser on the left.