Selections for the Best Database Table Models

The relational model requires that each row of the table be unique, i.e. so that any two lines differ in the value of at least one attribute. The traditional tabular form is convenient when you want to present the data itself. If, as in the above example, only the structure is interested the names of the fields, then from the point of view of clarity, ease of use in schemes and space saving it is more convenient to depict it as follows:

However, we will continue to operate primarily with a tabular representation.

The keys

A table key is a field or group of fields that contain values ​​unique to the table. The key uniquely identifies the corresponding row in the table. If the key consists of one field, it is often called simple, if from several composite. In the above example, the key is the TIN field (we consider it known that the TIN within the country is unique).

  • Consider an example of a table with a composite key. Weather forecast sites often provide information as follows, for each date, the predicted temperature is indicated at night, morning, afternoon and evening. To store this information, you can use a table of the following form:
  • In this table, neither the Date field, nor the Time of day, nor the Temperature is keys in each of these fields the values ​​can be repeated. But the combination of the fields Date and Time of day is unique and uniquely defines the row of the table. This is the composite key. Often there is a situation in which the choice of a key is not unique. For the 먹튀검증 this is important now.

Back to the first example

Suppose, in addition to the surname, first name, middle name, TIN, date of birth, it is required to store the series and number of the general passport and the series and number of the foreign passport. The table will have the following form.

In this table, you can select as many as three keys. One of them is simple (TIN), the other two are compound (Series + Passport number and Series + Passport number). In such a situation, the developer chooses the key that is most convenient from the point of view of organizing the database (in the general case, the key that takes the least time to find the value of). The selected key in this case is often called the primary, or primary, key, and other combinations of columns from which the key can be made are possible , or alternative, keys. Note that at least one possible key in the table is always present, since rows cannot be repeated and, therefore, the combination of all columns is guaranteed to be a possible key.

When displaying tables, the primary keys of the tables are usually allocated. For example, the corresponding fields are often underlined. And Microsoft Access highlights the key fields in bold.

 

Your Turn To Talk

Your email address will not be published.