Received: from spider.pilosoft.com (alex.pilosoft.com [207.99.38.199]) by hub.org (8.9.3/8.9.3) with ESMTP id AAA61348 for ; Wed, 19 Apr 2000 00:08:31 -0400 (EDT) (envelope-from alex@pilosoft.com) Received: from localhost (alexmail@localhost) by spider.pilosoft.com (8.9.3/8.9.3) with ESMTP id AAA28519; Wed, 19 Apr 2000 00:08:04 -0400 (EDT) Date: Wed, 19 Apr 2000 00:08:04 -0400 (EDT) From: Alex Pilosov To: Manuel Lemos cc: Thomas Good , pgsql-general@postgresql.org Subject: Re: Connecting website with SQL-database..... In-Reply-To: <3758.143T2716T9396025mlemos@acm.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200004/416 On 18 Apr 2000, Manuel Lemos wrote: > I may be mistaken, but the last time that I looked at Perl DBI, it didn't > seem to a complete database abstraction layer than it is needed. For > instance, you want retrieve data from date fields the results come > formatted in a database dependent way. This means that your DBI > applications can't really be that much database independent as you still > have to handle datatype differences in the application code. I have used another database abstraction layer, that wants to be all-singing, all-dancing. It is called ODBC. It sucked. There are add-ons to DBI which allow you to further abstract from your database, if you choose so. For most of them, you need to still write database-specific code yourself, it just gives you a cleaner interface on how to do it. I believe that in general, this is the superior approach instead of trying to abstract it all in the system/driver code. The developer always knows what database-dependent features he is using, and should appropriately abstract them into different file). > With this Metabase package in PHP date fields are always returned formatted > in the industry standard ISO 3166 (YYYY-MM-DD HH:MI:SS). Then you do > whatever processing you want with dates formatted this way, but it's always > DBMS independent. Reformatting things every time kills performance. Then again, since you are using PHP, you are probably not worried about performance that much. > Another thing that seems to be lacking in DBI and other database abstraction > layers is support for DBMS independent schema installation. I mean if you > want to install a given database schema (tables, fields, indexes, > sequences) you still have to hand code database dependent SQL commands to > create them. Because of the great variety in types, refint restrictions and other restrictions supported by databases (and don't get me started on SQL standards), its hard for _driver_ to know what exactly you want to create. DBI drivers now provide information on types the database supports and more-or-less standardized 'description' of them, but its up to you to make a use of it. > As I explained before, with this Metabase PHP package you only need to > describe the database schema in a custom XML format that looks like this: > > > > > test > 1 > > > users > > user_id integer 0 1 > user_name text > password text > reminder text > name text > email text > > users_id_index > 1 > user_id > > >
> > > user_id > 1 > users
user_id
>
>
What if database doesn't support named sequences? (i.e. it only has 'sequence' as column type, but you can't create a sequence with a name). > Metabase will install this schema description on any SQL based database. > Furthermore, if you change the schema later you may tell Metabase to apply > the changes without affected any data that was added to the database > afterwards. Sounds like a pipedream. (Or like ER/win tool, which is probably what you _really_ want to use if you have tens of tables which periodically need revision). > There are other neat features like support for requesting just a range of > rows of a SELECT query. In some DBMS it would be as simple as specifying > the LIMIT clause, but it is not that simple in many others. Metabase > abstracts all that for you because those are desirable features that all > database abstraction layers should provide. If database doesn't support something, it is not necessarily a feature to transparently provide emulation for it. Sometimes failing with an error and forcing programmer to provide emulation code or forcing programmer to ASK for emulation is the right thing. -alex