EF Codd eh? Circa 1981, I had to do a CS project, and having read an article (in Byte I think) on Codd's paper, I wrote up the proposal for my project as: "A simple exploration of the Relational Model". To be written in BASIC Plus 2. And yes, BASIC.
I had one term to write it.
It took 6 weeks for the college library to obtain a photocopy of the paper--it had to come from the British Library in London, the only people in the UK who had a copy. It was photocopy, of a photocopy, of a bound paper with all the distortions and fuzzy greyness that entails. It took me two whole weeks to read it--I understood very little of it. So there I was with half my time gone and nothing to show for it.
Back to the point.
And that is, all DBI needs to know is the first two fields of the DSN. The first must match 'dbi' (+-case); the second must match a module "DBD::<2ndfield>" that is installed locally. What comes after that is none of its concern. It just gets passed through to the loaded DBD driver.
And the forms of that opaque token are myriad. A quick survey turns up:
$dbh = DBI->connect("dbi:Informix:$database", $user, $pass, %attr);
$dbh = DBI->connect("DBI:Unify:dbname[;options]" [, user [, auth [, a
+ttr]]]);
$dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid", $user, $passwd)
+;
$dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","");
$dbh = DBI->connect("DBI:drizzle:database=test;host=localhost", "joe"
+, "joe's password", {'RaiseError' => 1});
$dbh = DBI->connect('dbi:ODBC:DSN', 'user', 'password');
$dbh = DBI->connect("dbi:Pg:dbname=$dbname", '', '', {AutoCommit => 0
+});
$dbh = DBI->connect('DBI:RAM:','usr','pwd',{RaiseError=>1});
$dbh = DBI->connect("DBI:Wire10:host=$host", $user, $password, {Raise
+Error' => 1, 'AutoCommit' => 1}
$dbh = DBI->connect("DBI:CSV:f_dir=/home/joe/csvdb")
$dbh = DBI->connect("dbi:JDBC:hostname=$hostname;port=$port;url=$url"
+, $user, $password);
$dbh = DBI->connect("dbi:Sqlflex:$database", $user, $pass, %attr);
$dbh = DBI->connect("dbi:DB2:db_name", $username, $password);
$dbh = DBI->connect("DBI:mysql:database=test");
$dbh = DBI->connect('DBI:DBMaker:' . $database, $user, $pass);
$dbh = DBI->connect('dbi:PgPP:dbname=$dbname', '', '');
$dbh = DBI->connect('dbi:PgLite:dbname=file');
$dbh = DBI->connect("dbi:ADO:Provider=Microsoft.Jet.OLEDB.4.0;Data So
+urce=C:\data\test.mdb", $usr, $pwd, $att )
$dbh = DBI->connect("DBI:Ingres:dbname[;options]", user [, password],
+ \%attr);
$dbh = DBI->connect('DBI:Solid:TCP/IP somewhere.com 1313', $user, $pa
+ss, 'Solid');
$dbh = DBI->connect("dbi:Google:", $KEY);
Look at the variations once you get beyond the first two fields. Yes you could keep these all separate in a hash, but to what end? You (as a DBI user) cannot do anything useful with them because there is insufficient consistency to make even validation judgements, much less anything else.
Even where several DBDs require, for example, a "dbname", for some this will be have SQL identifier limitations--though even they aren't consistent across all SQL-like DBs.
For some it will be a filename (with local filesystem semantics--case dependance (or not); reserved characters (or not); length limitations (or not).
For some, it's a hostname and port.
For some--see the ADO example--it's a whole bunch of stuff entirely unique to that DBD.
For some the subfields have to be prefixed with their tagname, others are position dependant.
Why stick all these disparate bit into a hash and then have DBI concatenate the bits--risking getting it wrong because (for example) it adds tagnames where none are required, or the hash ordering screws up the position dependance; or ...?
To achieve all that, you'd need more than just a hash. You'd need one flag per field to decide whether the key name should be prepended to the fields value. You'd need another value to ensure ordering. You'd need yet another flag to ensure that (for example) backslashes in pathnames got escaped for interpolation.
And all of that complexity buys you what? The user can far more easily know what the requirements are for the DBD (or two; or three) he is going to use, than any programmer can try and unify into one generic interface structure that will stand the test of time.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|