Re: prefixing table names?

[prev] [thread] [next] [Date index for 2004/10/15]

From: Bradley K. Embree
Subject: Re: prefixing table names?
Date: 22:16 on 15 Oct 2004
Bowen Dwelle wrote:
> Tony Bowden wrote:
> 
>> I don't understand the problem.
>>
>> Class::DBI doesn't impose any limits on your table names. You can
>> merrily have lots of tables called siesta_*, wibble_*,
>> whiteporcelainsink_*, etc.
>>
>> What am I missing?
> 
> 
> I'm talking about a way to _apply_ a prefix to application code written 
> without having to hard-code a prefix on every reference to a table. I.e. 
>  refer to the tables/objects by their unprefixedd names (e.g. "person", 
> "company") X times but set TABLE_PREFIX = 'appname_' in one place. This 
> allow the prefix to be changed, so that multiple applications (and even 
> multiple instances of the same app) can co-exist in the same namespace.
> 
> Perrin Harkins wrote:
> 
>> It's better, and more common in my experience, to use different
>> schemas or tablespaces or whatever your database happens to call
>> them. You can usually set one as part of your connection routine.
>> That's how I do it in Postgres.
> 
> 
> I know exactly what you're referring to, and I agree in theory, but many 
> (e.g. hosted) environments don't support multiple databases, schemas or 
> tablespaces, and so multiple apps _must_ be able to coexist in a single 
> namespace.
> 
> Does this help clear things up?
> 
> -- Bowen
> 

Could you not set up a TABLE_PREFIX in a parent CDBI class and have your 
other classes inherit from that? The problem with this is needing to be 
extra careful when rolling your own SQL to use the prefix where 
necessary. Of course the __TABLE__ notation provided by Ima::DBI makes 
that easier.


package My::CDBI;

sub TABLE_PREFIX {
     return 'foo_';
}

package My::CDBI::Bar;

use base 'My::CDBI';

__PACKAGE__->table( __PACKAGE__->TABLE_PREFIX() . 'bar' );


Hope that makes some sort of sense,

Brad

(message missing)

prefixing table names?
bowen 15:20 on 15 Oct 2004

Re: prefixing table names?
jason 15:36 on 15 Oct 2004

Re: prefixing table names?
Tony Bowden 18:45 on 15 Oct 2004

SQL Generation ( was Re: prefixing table names?)
jason scott gessner 00:08 on 19 Oct 2004

Re: SQL Generation ( was Re: prefixing table names?)
merlyn (Randal L. Schwartz) 09:46 on 19 Oct 2004

Re: SQL Generation ( was Re: prefixing table names?)
merlyn (Randal L. Schwartz) 10:00 on 19 Oct 2004

Re: prefixing table names?
Tony Bowden 15:36 on 15 Oct 2004

Re: prefixing table names?
Bowen Dwelle 22:05 on 15 Oct 2004

Re: prefixing table names?
Bradley K. Embree 22:16 on 15 Oct 2004

Re: prefixing table names?
Bowen Dwelle 22:48 on 15 Oct 2004

Re: prefixing table names?
Bowen Dwelle 23:20 on 15 Oct 2004

Re: prefixing table names?
Perrin Harkins 16:44 on 15 Oct 2004

FromCGI and Untaint question
Peter Speltz 17:23 on 19 Oct 2004

Re: prefixing table names?
Bowen Dwelle 01:31 on 02 Nov 2004

Re: prefixing table names?
Bowen Dwelle 16:36 on 02 Nov 2004

Generated at 11:35 on 01 Dec 2004 by mariachi v0.52