Even more often than with the ambiguity of key selection, developers are faced with the lack of a key among the data that needs to be stored. A similar fact can be established in the process of analyzing a subject area. For example, if you want to keep a simple list of people names, surnames, patronymics and dates of birth, then there is no key at all in this set of attributes it is conceivable that two different people have the same data. In this case, it is necessary to artificially introduce an additional field, for example, a unique person number. With the 먹튀검증 this is important now.
The Key for You
Such a key is sometimes called a surrogate in the literature. Often, a surrogate key is also introduced for reasons of efficiency. If, for example, the table has a long composite key, then developers often enter an additional short numeric surrogate key and make it primary. Often they do this even if there is a simple key that has an “inconvenient” (inefficient for search) data type, for example, a string. Such operations are no longer relevant to theory, but are often found in practice.
An attentive reader may pay attention to the fact that the key can almost always be expanded (unless all the fields of the table are included in it) by including redundant fields. Formally, such a key will remain the key, but from a practical point of view it is only a game of concepts. Such keys are not considered as possible, since it is always necessary to strive to minimize the length (complexity) of the key.
Normal forms, normalization
Not every table that we can draw on paper or in Word can be a relational database table. And not every table that can be used in a relational database is correct in terms of the requirements of the relational model.
Firstly, it is required that all data within the same column have the same type (for types, see “Data Description”. From this point of view, the following example does not even make sense to discuss:
Secondly, it is required that a primary key be assigned in the table
These requirements are necessary, but insufficient. In the theory of relational databases, the concepts of the so-called “normal forms” are introduced – the requirements for organizing data in tables. Normal forms are numbered sequentially as requirements are tightened. In a correctly designed database, the tables are at least in the third normal form. Accordingly, we consider the first three normal forms. Recall that we are dealing with tables that satisfy the two basic requirements formulated above.
The first normal form
The first normal form prescribes that all the data contained in the table should be atomic (indivisible). The list of corresponding atomic data types is determined by the DBMS. The requirement of 1NF is completely natural. It means that in each field of each record there should be only one value, but not an array or any other data structure. Here is a meaningful example of a table that is not in 1NF. Let us have a list of student grades in a certain subject.