Discussing the article: "Market Simulation (Part 24): Getting Started with SQL (VII)"

 

Check out the new article: Market Simulation (Part 24): Getting Started with SQL (VII).

In the previous article, we completed the necessary introduction to SQL. And, in my opinion, we properly clarified what we wanted to show and explain about SQL. This was done so that anyone who comes to look at the replication/simulation system being built can at least get an idea of what may be happening there. The point is that there is no sense in programming things that SQL handles perfectly.


What we are about to see should be used only if we are sure of what we are doing. Do not try to use it without first becoming familiar with the material from the previous sections. Otherwise, you will end up in a terrible situation with SQL. So now let us understand what this is about. Suppose there is a very complex database in terms of table structure. And this database uses a very specific relationship between these tables.

As we saw in the previous topic, if we try to delete a record based on its primary key, and this key is used in another table through a foreign key, we will not be able to delete the record until all existing references to that primary key have first been removed. The way to perform this task was described in the previous topic. When we have few tables, doing something like this is quite simple and clear, but if we have many tables, the situation becomes more complicated, since a DELETE command must be created for each table.


Author: Daniel Jose