The account number associated with each CUSTOMER_ID allows for the secure handling of customer queries and quick search times (as with any indexed table.)įor example, a customer may be asked to provide his surname when conducting a bank query. Then, the database automatically generates a unique number each time a customer is added, guaranteeing unique identification.Īs this key is created, the column is designated as the primary key within the SQL script that creates the table, and all null values are automatically rejected. The best option is to create a separate primary key in a new column named CUSTOMER_ID. The next logical option is to use a combination of columns, such as adding the surname to the date of birth to the email address, resulting in a long and cumbersome primary key. However, some account holders may not have Social Security numbers, so this column’s candidacy is eliminated. Thus, certain columns are immediately eliminated, e.g., surname and date of birth.Ī good primary key candidate is the column that is designated to hold Social Security numbers. To uniquely identify customers, a column or combination of columns is selected to guarantee that two customers never have the same unique value. Two of the database tables include the CUSTOMER_MASTER, which stores basic and static customer data (name, date of birth, address, Social Security number, etc.) and the ACCOUNTS_MASTER, which stores various bank account data (account creation date, account type, withdrawal limits or corresponding account information, etc.). Street addresses or driver license numbers are examples of primary keys used to uniquely identify (respectively) locations or cars.Īs another example, a database must hold all of the data stored by a commercial bank. citizens have government-assigned and uniquely identifiable Social Security numbers. In fact, since a table can easily contain thousands of records (including duplicates), a primary key is necessary to ensure that a table record can always be uniquely identified.Īll keys that come from real-world observables and attributes are called natural primary keys, as opposed to surrogate primary keys that are, instead, arbitrarily assigned to each record.Īlmost all individuals deal with natural primary keys frequently but unknowingly in everyday life.įor example, students are routinely assigned unique identification (ID) numbers, and all U.S. Without the primary key and closely related foreign key concepts, relational databases would not work. The primary key concept is critical to an efficient relational database. Every row must have a primary key value.Ī primary key might use one or more fields already present in the underlying data model, or a specific extra field can be created to be the primary key.It must contain a unique value for each row of data. ![]() ![]() A table cannot have more than one primary key. A primary key is used as a unique identifier to quickly parse data within the table.
0 Comments
Leave a Reply. |