Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

Major Keys, 6/100 Days of Code

  • June 24, 2018March 25, 2019
  • by Richard Clarke

In the little SQL experience I had prior to this course, I thought the primary key was just a way to keep track of rows in a table. They are far more important than I imagined.

Primary keys are at least one column in a table used to identify the meaning of its data. A single column primary key could be a student ID number in a table of students, and a multi-column primary key could be an athlete’s team and jersey number.

Simply put, you should be able to look at a primary key in a table and know what it represents.

The most important feature of a primary key is users cannot duplicate them when inserting information into a table. Let’s say an Android app prompts for a person’s favorite basketball player, team, and jersey number. Since each basketball player has a distinct team and jersey number, those columns would be set as the primary key of the database.

If a user enters LeBron James’ info (Cavaliers, #23, James), then accidentally enters Jeff Green with the same team and number (Cavaliers, #23, Green), the database will signal an error since the number 23 is a duplicate primary key. Fun fact, Jeff Green is #32 on the Cavaliers so this error is probably common in data entry. (see below)

Related

Good Apples, 5/100 Days of Code
Hello Again World, 7/100 Days of Code
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
100daysofcode keys primary keys Programming SQL

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress