I can give you some examples, but time is not my friend at present. Suffice to say, have a read of this, but only pp 29 onwards.Th real question is what do you gain by representing a database as a filesystem?
A long time ago, there was a research paper that explained how you can use the standard Unix commands sort, uniq, join and awk to implement a makeshift relational database. I can't find it online, and I'm not even sure I've ever seen that paper. Anyone know? It would probably be 30-40 years old by now.
PostgreSQL is nice once you get used to it. But at first, you have to memorize the weird replacements for MySQL commands, e.g.
becomesSQL:SHOW TABLES;
and so on.Code:\dt
case sqlmy: $q = "SHOW TABLES"; break;
case sqlpg: $q = "SELECT table_name FROM information_schema.tables
WHERE table_schema='public' AND table_type='BASE TABLE'
ORDER BY table_name"; break;
But there is a tension here: SQL can do everything that sort, uniq and (simple) awk can do. So you have the option to do everything within the SQL framework, with a coherent set of commands (SQL statements). Or you can split the work between SQL and the traditional Unix tools; now there are two different things to program and maintain. I would think in most cases having a single coherent implementation is preferable.Ahh... sort, uniq, and awk work best on the output of SQL commands.
Modern databases have highly complex encoding and compression of the data that's stored in tables. That's particularly true for "big" databases, the ones used in data mining, which are usually stored in columnar format. That allows interesting sorting, delta compression and bit encoding, making it incredibly efficient (I've seen examples where additional rows in a database need less than 1 byte per row, meaning the compression has reached the level of encoding into individual bits).As for UNIX design vs database design - there's a reason those are separate. Yes, it's not impossible to pretend that database tables are regular files, and to try and use text-processing tools on them - but the bigger the database, the worse the performance hit, and that was noticed back in 80s. ?
One of the reasons I like array languages such as APL & particularly K is for their use in “columnar databases”. It’s a slightly different way of processing data than SQL and more powerful (but less user friendly). I have wanted to write an “array shell” that makes data wrangling as easy as writing shell scripts….Modern databases have highly complex encoding and compression of the data that's stored in tables. That's particularly true for "big" databases, the ones used in data mining, which are usually stored in columnar format. That allows interesting sorting, delta compression and bit encoding, making it incredibly efficient (I've seen examples where additional rows in a database need less than 1 byte per row, meaning the compression has reached the level of encoding into individual bits).