Unique Instructor Names
mediumQuestion 63No two instructors may share the same full name. Create a unique index called idx_instructors_name on the instructors table covering two columns, first_name first and last_name second, in that order. A second Grace Okafor must then be rejected, while a new Grace 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 under the question.