The userID is a surrogate for a non-existing Social Security Number in this country. The Passport Number can change - but it's always unique, so you always get the right user. Whenever you want to get the identifier for a user, you can get it via the Passport Number. So, you have this table in the new country: userID They could create a new SSN, or they could just leverage the power of databases, and use a surrogate key.Ī surrogate key has no real world equivalent. Consider a country that doesn't have a Social Security Number yet, and they want to create a digital record of every citizen. If you're creating a database, make those your primary keys. In India, this is turning out to be the Adhaar Card. The next iteration means finding an identifier that doesn't change over time, and one that everyone has. How can you identify someone with a NULL key? Every row must have an identifier. You can't enter them into your system, since Primary Keys can't be NULL. The value must not change throughout the row's lifetime.Īnd then, you find there are some people who don't even have passports. Other systems keep using the old passport numbers, so they now point to ghost people. Whenever someone's passport expires, they get a new one. Then, a few years later, you find out an ugly truth: the entire country is facing an identity crisis. You know passport numbers are unique, so you feel good and implement this system. You figure that's all you need since the passport has the address and everything else. You choose the passport Number as the Primary Key - the identity for everyone. So, you create this database with everything about them: First Name Imagine you're the government, and you want to identify each one of your citizens digitally. And that's exactly why we need primary keys: they resolve the crisis. When creating a database, everything is in an identity crisis. You may think Luke is the only one with an identity crisis, but that's not true. We'll start with how to choose a Primary Key, fight an identity crisis, and then finish with code samples for creating a Primary Key in a database. Luke, the great Jedi Master, begins unsure - "Who am I?" - and how could I be anyone important? It takes Yoda, the one with the Force, to teach him how to harness his powers. Note that the RIGHT OUTER JOIN is the same as RIGHT JOIN.Every great story starts with an identity crisis.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |