← Back to Views & Indexes
Question 63
Unique Instructor Names
Unique Instructor Names
No two instructors may share the same full name. Create a unique index calledidx_instructors_nameon theinstructorstable covering two columns,first_namefirst andlast_namesecond, in that order. A secondGrace Okaformust then be rejected, while a newGrace Chen(a shared first name but a different last name) is still accepted.
Expected result:
Table instructors ✓ id INTEGER PRIMARY KEY ✓ first_name TEXT NOT NULL ✓ last_name TEXT NOT NULL ✓ email TEXT NOT NULL ✓ department_id INTEGER ✓ hire_date TEXT ✓ salary REAL ✓ office TEXT ✓ phone TEXT ✓ is_tenured INTEGER NOT NULL DEFAULT 0 ✓ title TEXT ✓ department_id REFERENCES departments(id) ✓ UNIQUE (first_name, last_name) ✓ UNIQUE (email) ✓ UNIQUE INDEX ON (first_name, last_name) ✓ Insert a second Grace Okafor: rejected (UNIQUE) ✓ Insert Grace Chen (same first name, different last name): accepted
Hints2 available
Sign in to use hintsTopics:
Views & Indexes
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.