Step 7: Store links in a database
A Map disappears when the server restarts. Design two tables: links (id, target, creation time) and clicks (one row per visit, with the link id and a referrer). One row per click, instead of a counter column, is what lets you answer new questions later: clicks per day, where visitors came from. The index on link_id keeps those queries fast.
Examplesql
Now the analytics questions the statistics page needs:
Examplesql
Quick check
Why store one row per click instead of one counter?
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.