Indexing for faster queries

I understand that creating an index table can reduce the time taken for SQLite to search for rows that meet a specified condition. When creating an index table, the first column is taken from the original database and set as the primary key in the index table - in the mission on indexing, the population column is used to create an index table. However, if the primary key in the index table can only contain unique values, what happens if two countries have exactly the same population, unlikely though this may be?

Link to mission on indexing: https://app.dataquest.io/m/116/introduction-to-indexing/9/all-together-now

Here’s an explanation on indexing with duplicate: https://stackoverflow.com/questions/28256072/database-index-on-a-column-with-duplicate-values

Here’s a story ending with beautiful visualization: https://www.toptal.com/database/sql-indexes-explained-pt-1

3 Likes