It seems that writing Declarative SQL is very popular in Imperative Programming. However, it also seems that writing Declarative Prolog could save a lot of complexity but this is not very common.  Is there a historical precedent for this apparent preference of SQL over Prolog?If the reason is lack of native support by Imperative languages, then is it possible to answer why the language creators didn't find it useful to natively support Prolog in the first place?To provide some specific examples:Example 1Evaluating a loan application might be just a few lines of code in Prolog, like the SELECT/JOIN query that is just a few lines of code in SQL, but it seems the advantage is not as obvious as SQL.Example 2Here is another example problem and the solution in Prolog. The following constraint logic program represents a simplified dataset of john's history as a teacher:teaches(john, hardware, T) :- 1990  T, T < 1999.teaches(john, software, T) :- 1999  T, T < 2005.teaches(john, logic, T) :- 2005  T, T  2012.rank(john, instructor, T) :- 1990  T, T < 2010.rank(john, professor, T) :- 2010  T, T < 2014.The following goal clause queries the dataset to find out when john both taught logic and was a professor::- teaches(john, logic, T), rank(john, professor, T).Result:2010  T, T  2012.In the above example it will be easy with SQL to get the same result. But suppose that you have this data in an Array.  Then it is not as easy to get the same results using SQL.  And in the case of data stored in an array, I believe that the Prolog code will be easier to write and maintain.
Historical precedent for why Prolog is less popular than SQL in Imperative Programming?
programming languages;sql;history;prolog
I believe this is primarily historical thing.SQL was primarily used in businesses for making business applications. Some companies build their livelyhood on selling SQL solutions and they used their money to advertise and push SQL into minds of many. This was especially empowered by how important data is for business people. This is why SQL won over it's many competitors and is so widely known and used even today.Prolog on the other way was mostly known in academic sphere, usually in area of artificial intelligence. Academic people rarely push their tools and ideas on others in a way business does. It usually requires some company to advertise a technology that was born in academia for it to spread among common developers. Also, while data is extremely important, the business rules are not so. While they might seem important, they are much less important than data. Business rules can usually be fixed easily. Trying to fix broken data is usually much harder problem. So businesses focused much more on getting their data solutions than their business rules solutions.