Discussing the article: "Market Simulation: Getting started with SQL in MQL5 (I)"

 

Check out the new article: Market Simulation: Getting started with SQL in MQL5 (I).

In today's article we will begin studying the use of SQL in MQL5 code. We will also look at how to create a database. Or, more precisely, how to create a SQLite database file using the features built into MQL5. We will also see how to create a table, and then how to establish a relationship between tables by using primary and foreign keys. All of this, once again, will be done with MQL5. We will see how easy it is to create code that can later be migrated to other SQL implementations by using a class that helps hide the implementation being created. And, most importantly, we will see that at various points we may face the risk that something will go wrong when using SQL. This happens because, in MQL5 code, SQL code will always be placed inside a string.

In the previous article Market Simulation (Part 24): Getting started with SQL (VII) we completed what I consider the basic foundation needed so that, even without SQL experience, you can at least understand what we will do next. This is because we are moving to a new stage in the development of the replication/simulation system, and here knowledge of SQL will be of paramount importance so that you can follow this and the following articles.

Do not worry if you have only just started learning SQL and are relying only on the knowledge gained in the previous articles. If this material is used and understood correctly, it will already be enough to solve many of the tasks we really need. At this first stage, my true intention is for us to remain within SQLite, because it is already integrated into MetaTrader 5, which makes it much easier to use without resorting to DLLs or even sockets.

So, if you already use SQLite in your MQL5 programs, this article will not add anything new to what you already know. But if you are just beginning your journey in this world, where the use of databases must be treated very seriously, and you do not know how to implement this with MQL5, I think it is best to sit comfortably in your chair and study this article carefully. Here we will examine how to start working with an SQL database using the MQL5 language. However, we will not use just any database, but SQLite. And, as you have already seen in the previous articles, we can do a lot within this system. All of this with minimal effort in MQL5.


Author: Daniel Jose