From the course: Programming Foundations: Databases
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Primary and foreign keys
From the course: Programming Foundations: Databases
Primary and foreign keys
- The next important task we'll need to do in designing our database is to look for keys, or to provide keys if there aren't natural keys already in our data. How do we uniquely identify our records? Let's start by looking at the Customers table. When working with personal information, we don't want to make the assumption that anything about the individual will be unique. That might sound a little harsh, but it's often the case that people share the same name. And depending on their situation, they might also share a phone number, an email address, mailing address, and even the same birthday. So none of the information in our Customers table is reliably unique. That means we need to add our own unique information, a surrogate or a synthetic key that will be different for each person. We'll add a Customer ID column to the Customers table. It'll be a numeric field, so we'll use the integer type. Later, we'll tell the…