CJCoding With Joseph
15free / daySign inCreate account

No Two Rooms Share a Code

Create rooms with id INTEGER PRIMARY KEY, code TEXT NOT NULL UNIQUE and capacity INTEGER (NULL allowed). Inserting two rooms with the same code must fail, a room with no code must fail, and a room with a code but no capacity must be accepted.

Expected result:

Table rooms
✓ id INTEGER PRIMARY KEY
✓ code TEXT NOT NULL
✓ capacity INTEGER
✓ UNIQUE (code)
✓ Two rooms both coded T-100: rejected (UNIQUE)
✓ A room with no code: rejected (NOT NULL)
✓ A room whose capacity is unknown: accepted
Hints3 available
Topics:
CREATE TABLE
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.