CJCoding With Joseph
15free / daySign inCreate account

One Permit Per Licence Plate

Create a table called parking_permits with three columns: id (an INTEGER PRIMARY KEY), plate (TEXT) and student_id (INTEGER). A licence plate can hold only one permit, so two rows with the same plate must be rejected; everything else, including one student holding two plates, is allowed.

Expected result:

Table parking_permits
✓ id INTEGER PRIMARY KEY
✓ plate TEXT
✓ student_id INTEGER
✓ UNIQUE (plate)
✓ Insert the same plate twice: rejected (UNIQUE)
✓ Insert two different plates for one student: accepted
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.