4 ms·
I disagree, it's quite elegant if you think in terms of relational algebra operators: * Projection (Π): awk and cut for simple cases * Selection (σ): grep for
by nextos 7y ago
I disagree, it's quite elegant if you think in terms of relational algebra operators:
* Projection (Π): awk and cut for simple cases
* Selection (σ): grep for simple cases, otherwise sed & awk
* Rename (ρ): sed
* Set operators: join, comm...
- agumonkey 7y agontfsql dreams
- chongli 7y agoBravo! This is one of the most insightful comments I've read in a long time! I have been using some of these tools for years but I never thought of describing them this way. Now I can think of writing a complex query in relational algebra and translating it into these commands in a very natural way.
- _TwoFinger 7y agoHere's an interesting article that links shell scripting and relational algebra - http://matt.might.net/articles/sql-in-the-shell/ http://matt.might.net/articles/sql-in-the-shell/
- graphpapa 7y agoI’m pretty mathsy but I don’t get this
- rz2k 7y agoIt is from relational algebra used in database theory. There is an excerpt from one of the first MOOCS offered here on Lagunitas now.[1] It is pretty intuitive once you get the hang of it. [1] https://lagunita.stanford.edu/courses/DB/RA/SelfPaced/course/ https://lagunita.stanford.edu/courses/DB/RA/SelfPaced/course...
- graphpapa 7y agoThank you for this context
- bloopernova 7y agoThank you, and thank you (really, not sarcasm) for the new stuff I have to learn about relational algebra. I'm a huge fan of wide/shallow knowledge that allows me to dive into a subject quickly.
- thomas2718 7y agoIndeed, and with a bit of tuning (e.g., using mawk for most things), one can get quite good performance. [1] The project also provides a translator from Datalog to bash scripts [2]. Disclaimer: I was one of the authors [1] https://www.thomasrebele.org/publications/2018_report_bashlog.pdf https://www.thomasrebele.org/publications/2018_report_bashlo... [2] https://www.thomasrebele.org/projects/bashlog/datalog https://www.thomasrebele.org/projects/bashlog/datalog