The emergence of computer technology in ourModernity marked an information revolution in all spheres of human activity. But in order for all information not to become unnecessary garbage on the global Internet, a database system was invented in which materials are sorted and systematized, making them easy to find and submit to subsequent processing. There are three main types - allocate relational, hierarchical, network databases.
Returning to the emergence of databases, it is worthto say that this process was quite complicated, it takes its origin along with the development of programmable information processing equipment. Therefore, it is not surprising that the number of their models currently reaches more than 50, but the main of them are considered hierarchical, relational and network, which are still widely used in practice. What do they represent?
The hierarchical database has a treestructure and is composed of data of different levels, between which there are connections. The network database model is a more complex pattern. Its structure is reminiscent of a hierarchical, and the scheme is expanded and improved. The difference between them is that the hereditary data of the hierarchical model can be associated with only one ancestor, and the network can have several. The structure of a relational database is much more complicated. Therefore, it should be disassembled in more detail.
This model was developed in the 1970s.Doctor of Science Edgar Codd. It is a logically structured table with fields that describes the data, their relationships with each other, the operations performed on them, and most importantly - the rules that guarantee their integrity. Why is the model called relational? It is based on the relationship (from Lat. Relatio) between the data. There are many definitions of this type of database. Relational tables with information are much easier to organize and inject into processing than in a network or hierarchical model. How to do it? It is enough to know the features, the structure of the model and the properties of relational tables.
In order to create your own DBMS, you shoulduse one of the modeling tools, think through what information you need to work with, design tables and relational single and multiple relationships between data, fill in entity cells and establish primary, foreign keys.
Table modeling and relational designdatabases are made using free tools such as Workbench, PhpMyAdmin, Case Studio, dbForge Studio. After a detailed design, you should save the graphically ready relational model and translate it into a ready-made SQL code. At this stage, you can begin working with data sorting, processing and systematization.
Each source describes its elements in its own way, so for less confusion, I would like to give a little hint:
To navigate to the properties of a relational database, you should know which of the basic components it consists of and what they are intended for.
Now, knowing the constituent elements of the table, you can go to the properties of the relational database model:
Based on the properties of a relational DBMS, it is clear that the values of attributes must be of the same type, length. Consider the features of attribute values.
Field names must be unique withinone entity. The types of attributes or fields of relational databases describe which category of data is stored in entity fields. Relational database field must have a fixed size, calculated in characters. The parameters and format of the attribute values determine the manner in which the data is corrected. There is also such a thing as "mask", or "input template". It is intended to define the input data configuration for an attribute value. Certainly when writing the wrong data type in the field should be given an error notification. Also on the field elements are some restrictions - the conditions for checking the accuracy and accuracy of data entry. There is some mandatory attribute value that must be uniquely filled with data. Some attribute strings may be filled with NULL values. It is allowed to enter empty data in the field attributes. Like the error notification, there are values that are automatically filled in by the system - this is the default data. To speed up the search for any data, an indexed field is intended.
Attribute Name 1 | Attribute Name 2 | Attribute Name 3 | Attribute name 4 | Attribute Name 5 |
Element_1_1 | Element_1_2 | Element_1_3 | Element_1_4 | Element_1_5 |
Element_2_1 | Element_2_2 | Element_2_3 | Element_2_4 | Element_2_5 |
Element_3_1 | Element_3_2 | Element_3_3 | Element_3_4 | Element_3_5 |
For a detailed understanding of the control systemmodels using SQL is best to consider the scheme by example. We already know what a relational database is. The entry in each table is one data item. To prevent data redundancy, it is necessary to perform normalization operations.
1. The value of the field name for a relational table must be unique, one of a kind (the first normal form is 1NF).
2. For a table that has already been converted to 1NF, the name of any non-identifying column must be dependent on the unique identifier of the table (2NF).
3. For the entire table, which is already in 2NF, each non-identifying field cannot depend on the element of another unrecognized value (3NF entity).
There are 2 main types of relations of relational tablets:
Primary and secondary keys definepotential database relationships. Relational relationships of the data model can have only one potential key, this will be the primary key. What is he like? A primary key is an entity column or attribute set that allows you to access data from a specific row. It must be unique, unique, and its fields cannot contain empty values. If the primary key consists of only one attribute, then it is called simple, otherwise it will be a component.
Кроме первичного ключа, существует и внешний (foreign key). Many do not understand what the difference between them. Let us analyze them in more detail using an example. So, there are 2 tables: “Dean's office” and “Students”. The entity “Dean's Office” contains the fields: “Student ID”, “Full Name” and “Group”. The “Students” table has such attribute values as “Full Name”, “Group” and “Average Ball”. Since the student ID cannot be the same for several students, this field will be the primary key. “Full Name” and “Group” from the “Students” table may be the same for several people, they refer to the student ID number from the “Dean's Entity” entity, therefore, they can be used as a foreign key.
For clarity, we present a simple example of a relational database model consisting of two entities. There is a table with the name "Dean".
Essence "Dean" | ||
Student ID | Full name | Group |
111 | Ivanov Oleg Petrovich | IN-41 |
222 | Lazarev Ilya Aleksandrovich | IN-72 |
333 | Konoplev Peter Vasilyevich | IN-41 |
444 | Kushnereva Nataliya Igorevna | IN-72 |
Необходимо провести связи, чтобы получилась full relational database. The entry "IN-41", as well as "IN-72", may be present more than once in the plate "Dean's Office", as well as the last name, first name and patronymic of students in rare cases may coincide, therefore these fields can not be made a primary key. We show the essence of "Students".
"Students" table | |||
Full name | Group | Average Score | Phone |
Ivanov Oleg Petrovich | IN-41 | 3,0 | 2-27-36 |
Lazarev Ilya Aleksandrovich | IN-72 | 3,8 | 2-36-82 |
Konoplev Peter Vasilyevich | IN-41 | 3,9 | 2-54-78 |
Kushnereva Nataliya Igorevna | IN-72 | 4,7 | 2-65-25 |
Как мы видим, типы полей реляционных баз данных completely different. Both digital and symbolic entries are present. Therefore, in the attribute settings you should specify the values integer, char, vachar, date and others. In the "Dean" table, only the student ID is a unique value. This field can be taken as the primary key. The full name, group, and phone number of the "Students" entity can be taken as a foreign key that refers to the student ID. Connection established. This is an example of a one-to-one model. Hypothetically, one of the tables is superfluous, they can be easily combined into one entity. To prevent student IDs from becoming universally known, the existence of two tables is quite realistic.