CJCoding With Joseph
15free / daySign inCreate account

Rules the Database Enforces

Create clubs with id INTEGER PRIMARY KEY; name TEXT NOT NULL UNIQUE; founded_year INTEGER with a CHECK that it is at least 1900 (NULL is allowed, so a club with an unknown founding year passes); and member_cap INTEGER NOT NULL DEFAULT 30 with a CHECK that it is greater than 0. Write each CHECK on its own column: a club founded in 1800 and a club with a cap of 0 must both be refused, and two clubs named 'Chess' cannot coexist.

Expected result:

Table clubs
✓ id INTEGER PRIMARY KEY
✓ name TEXT NOT NULL
✓ founded_year INTEGER
✓ member_cap INTEGER NOT NULL DEFAULT 30
✓ UNIQUE (name)
✓ A club founded in 1800: rejected (CHECK)
✓ A club founded in 1999: accepted
✓ A club that may have 0 members: rejected (CHECK)
✓ Two clubs both called Chess: rejected (UNIQUE)
✓ A club whose founding year 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.