Is SQL basically a domain specific instance of map + fold + filter?
It seems to me that the following SQL:
SELECT name
FROM fruits
WHERE calories < 100
is just syntactic sugar for the following map + filter + fold operation:
var fruits = [{id : 1, name: 'orange', calories : 100},
{id : 2, name : 'banana', calories : 150},
{id : 3, name: 'apple', calories : '50'}];
fruits.map(function(fruit) { return { name : fruit.name, calories : fruit.calories })
.filter(function(obj) { return obj.calories < 100 })
.reduce(function (accumulator, obj) { accumulator + "\n" + val.name; });
Is this coincidence, or is there a sound semantic equivalence that can be proven? How, roughly?
I know in practice SQL has a lot of bells and whistles but at its core is it simply a map-fold-filter operation?
The following article is relevant: http://blogs.msdn.com/b/doriancorompt/archive/2013/01/21/bringing-the-querying-power-of-sql-to-javascript.aspxLink