#Creating unique keys in SQLite3
##Why create a unique key?
Say you want to ensure that certain values are never duplicated across rows in a given table-- e.g., voters can vote in many polls but they can only vote in one poll once. In the votes
table, a unique key would be applied to the combination of voter_id
and poll_id
.
Or, say you have a sections
table that represents sections of university courses. A section has a teacher, a teacher can teach many sections, but obviously a teacher cannot teach multiple sections that are held during the same day/time interval. So, you'll need a unique key on teacher_id
, days_held
and time_block
.
##Create your SQL table