Databases allow not only conveniently placing large amounts of data, but also quickly enough to obtain the desired information. To do this, use a special command called a query.
SQL query
This is a special string reference to the database, which reflects the fields (data particles) and the conditions under which this information must be provided.
The logic of compiling a data request from the database in most programming languages ββis as simple as possible. To obtain information, it is necessary to specify the control system configured for a particular repository, the main six parameters:
- the names of the tables from which data must be taken;
- Fields to return
- relationships between tables;
- sampling conditions (if necessary);
- auxiliary (sorting, presentation methods, restrictions and others).
Thanks to this structure, it is enough for users to understand only the structure of the desired request, after which it will be very easy to implement it βon paperβ. The reverse scheme also works - to understand what information is obtained by one or another team, you need to know the basics in order to deal with the request. This has made the SQL query language very popular both among IT professionals and among those wishing to master the complex science of programming.
Query Features
The SQL programming language is flexible, so you can modify the query for various purposes. This may be due to the specific architecture of the database, which will affect the query execution time, the prevention of possible problems at a certain stage of work, as well as the readability of the result.
Compared to most other programming languages, SQL queries always return a clearly structured result in the form of a table. Therefore, when developing tools that require active work with large amounts of data, a specialized module is built into the program code that provides quick and clear exchange of information with the database, which can increase the speed of work up to several times, especially when working with users.
In addition to the advantages, there is one significant negative feature of the SQL query. This is working with fields that have the same name. In this case, it is necessary to closely monitor the built-in connection, specify independently from which table the data should be taken.
Example
Consider the simplest database query using the SQL language example. Let there be two tables storing the unit of measure of the currency - "Currency", and the exchange rate for the past 7 days - "Rate". To execute a request for quotes for a certain currency, it will be enough to run the following command:
SELECT a.Date, a.Course FROM Course a, Currency b WHERE a._id = b.id AND (b.Money = 'rub')
The query result is a table of two columns that will contain data on the date and exchange rate for each of the days on the exchange of the ruble. Due to the ease of modifying the query, just change the fields you want to receive. In particular, to verify the correctness of the unloading, you can add a currency to the list of displayed columns.