Re: Aggregating multiple databases

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

From: Bowen Dwelle
Subject: Re: Aggregating multiple databases
Date: 19:14 on 17 Oct 2004
Simon Cozens wrote:
> I don't know if this is possible, but I thought I'd ask to see if anyone has
> any ideas about how to do it.
> 
> I have an application, Songbee, which organises songs and song lyrics. It uses
> an SQLite database with CDBI, and the all-important song table (Songbee::Song
> class) holds information about title, lyrics, key, copyright information and
> so on.
> 
> One of the users has asked for the ability to use multiple databases of songs; 
> so, for instance, to have an english.db and a japanese.db and a spanish.db,
> and if they choose to use all three at once, have the contents of the song
> table from all three available from Songbee::Song->retrieve_all, as thought
> they were all in the one table. 
> 
> I'm guessing I may well have to write Songbee::Song to inherit from an
> aggregator class that collects data from multiple Song classes generated on
> the fly with Class::DBI::Loader, but that's as far as I can get. Can anyone
> think of how this might be achieved?

Couldn't you use Class::DBI::View and a SQL UNION?

   __PACKAGE__->setup_view(<<SQL);
     SELECT id, title, etc
     FROM songs_english
     UNION
     SELECT id, title, etc
     FROM songs_japanese
     etc...
   SQL

?

Aggregating multiple databases
Simon Cozens 07:22 on 16 Oct 2004

Re: Aggregating multiple databases
Y00R0B0T 14:58 on 17 Oct 2004

Re: Aggregating multiple databases
Simon Cozens 18:00 on 17 Oct 2004

Re: Aggregating multiple databases
Tim Bunce 08:37 on 18 Oct 2004

Re: Aggregating multiple databases
Bowen Dwelle 19:14 on 17 Oct 2004

Re: Aggregating multiple databases
Terrence Brannon 10:49 on 09 Nov 2004

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