I'm learning how to use sqlite3 with python. The example in the text book I am following is a database where each Country record has a Region, Country, and Population.
The book says:
The following snippet uses the CONSTRAINT keyword to specify that no two entries in the table being created will ever have the same values for region and country:
>>> cur.execute('''
CREATE TABLE PopByCountry(
Region TEXT NOT NULL,
Country TEXT NOT NULL,
Population INTEGER NOT NULL,
CONSTRAINT Country_Key PRIMARY KEY (Region, Country))
''')
Please could you explain what CONSTRAINT Country_Key
does here. If I remove it, the PRIMARY KEY statement alone seems to ensure that each country has a unique name for that region.