4 ms·
Jacking a comment from tfa: > B. K. Oxley (binkley) (guest) 30 Apr 2017, 11:42 > Does SQL match your notion of Cartesian paradigm? It's declarative (not proce
by pharrington 10y ago
Jacking a comment from tfa:
> B. K. Oxley (binkley) (guest) 30 Apr 2017, 11:42
> Does SQL match your notion of Cartesian paradigm? It's declarative (not procedural or functional), and works over sets. The "larger scope" would be the whole set of data; the "smaller scopes" would be projections, selections, etc.
"
My immediate thought also was set-based programming, and in turn SQL and its kin.
- nickpsecurity 10y agoWait, do you mean it in a sense of mathematical sets or sets in SQL?
- pharrington 10y agoYou know what, I'm not sure. I only learned anything about set theory after learning SQL, and I haven't yet taken the time to think/read about SQL's formal relation to mathematical sets, so I may just be holding onto on misinformed assumption born from ignorance.
- nickpsecurity 9y agoI got the other problem: I've been away from SQL and databases too long to tell you. Set theory is one of those mathematical notations that can be used to model all kinds of things. They often prove out the simpler, easy-to-automate logics in more powerful ones like it. There's introductions to set theory online but here's what you might have not spotted: https://en.wikipedia.org/wiki/Set_theoretic_programming https://en.wikipedia.org/wiki/Set_theoretic_programming It was also used in formal specifications like Z. Also, used in one, verifying compiler that cheated the spec-to-code correspondence by straight-up turning the logical specs into executable Prolog. On database side, it would be Datalog for you to look into to explore logic programming + queries. Plenty of info out there on that with one DB (Datomic) built around it. https://en.wikipedia.org/wiki/Z_notation https://en.wikipedia.org/wiki/Z_notation http://www-users.cs.york.ac.uk/susan/bib/ss/hic/ http://www-users.cs.york.ac.uk/susan/bib/ss/hic/
- roywiggins 9y agoSQL is not quite a relational algebra but it's very related. https://en.m.wikipedia.org/wiki/Relational_algebra?wprov=sfla1 https://en.m.wikipedia.org/wiki/Relational_algebra?wprov=sfl...
- rumcajz 9y agoI think that comment goes in the right direction. It's kind of like relational programming but with focus on generation of data rather than querying it. While writing this kind of thing in SQL would be a headache, maybe a simpler language that would translate to SQL or maybe an extension to SQL would be a good idea.
- Twisell 9y agoSo I guess is should order a metric ton of painkiller for my potentiel headache. "Relational programming using SQL with a focus on generation of data rather than querying it" is basically my job since 4-5 years. And i can't believe I'm the only one SQL guy out there doing that. It very effective for data manipulation once you get the correct mindset.
- rumcajz 9y agoCan you share your experience? I've tried to rewrite the testsuite example to SQL, but it's quite ugly. Also, I am not sure how to model the inheritance relationship: CREATE TEMP VIEW boxes AS SELECT 'box1' AS hostname, 'linux' AS os, 'x86-64' AS arch, 8 AS ram UNION SELECT 'box2', 'freebsd', 'arm', 16 UNION SELECT 'box3', 'windows', 'x86-64', 4 UNION SELECT 'box4', 'illumos', 'sparc', 4; CREATE TEMP VIEW compilers AS SELECT 'gcc' AS binary, '4.8.4' AS version, '-o' AS output_option UNION SELECT 'clang', '3.4.1', '-o' UNION SELECT 'msvc', '15.00.30729.01', '/Fe'; CREATE TEMP VIEW tests AS SELECT 'frobnicate' AS name, 'frbonicate.c' AS sources UNION SELECT 'loadtest', 'loadtest.c helpers.c' UNION SELECT 'end2end', 'end2end.c helpers.c'; CREATE TEMP view testsuite AS SELECT *, compilers.binary || ' ' || tests.sources || ' ' || compilers.output_option || ' ' || tests.name AS cmdline FROM boxes, compilers, tests WHERE NOT(tests.name = 'loadtest' AND boxes.ram < 8); SELECT * FROM testsuite;
- Twisell 9y agoTo make it less ugly, and assuming you are using PostgreSQL you could make the code a little more appealing rewriting it like that. (If you are not using postgres WITH will probably not work but VALUES instead of UNION should still work). Please also notice that "binary" is quoted because it's a reserved postgresql word. WITH boxes(hostname, os, arch, ram) AS (VALUES ('box1', 'linux', 'x86-64', 8), ('box2', 'freebsd', 'arm', 16), ('box3', 'windows', 'x86-64', 4), ('box4', 'illumos', 'sparc', 4) ), compilers("binary",version,output_option) AS (VALUES ('gcc', '4.8.4', '-o'), ('clang', '3.4.1', '-o'), ('msvc', '15.00.30729.01', '/Fe') ), tests(name,sources) AS (VALUES ('frobnicate' , 'frbonicate.c' ), ('loadtest', 'loadtest.c helpers.c'), ('end2end', 'end2end.c helpers.c') ) SELECT *, compilers.binary || ' ' || tests.sources || ' ' || compilers.output_option || ' ' || tests.name cmdline FROM boxes, compilers, tests WHERE NOT(tests.name = 'loadtest' AND boxes.ram < 8) Here is a fiddle to play around... http://sqlfiddle.com/#!15/9eecb7db59d16c80417c72d1e1f4fbf1/16606/0 http://sqlfiddle.com/#!15/9eecb7db59d16c80417c72d1e1f4fbf1/1... But this is a stand alone query, SQL really become useful IMHO if data is stored inside the DB or gathered automatically by the db. For the inheritance I'm really clueless, it depend on what you try to achieve and i'm just a DB guy.