variation of "weak link" lookup table

[prev] [thread] [next] [Date index for 2004/06/24]

From: step2
Subject: variation of "weak link" lookup table
Date: 01:47 on 24 Jun 2004

hello list--

first of all, thanks to all who helped me 'get' CDBI.  it's made my life a
better place.  i have another question about how to setup a different kind of
lookup table.

supposing i have these two tables:

artist ( artistid, name )
artistaliast ( artistid1, artistid2 )

and supposing i have ArtistAlias:

__PACKAGE__->table('artistalias');
__PACKAGE__->columns(Primary => qw/artistid1 artistid2/);
__PACKAGE__->has_a(artistid1 => 'Artist');
__PACKAGE__->has_a(artistid2 => 'Artist');

and supposing i have Artist:

__PACKAGE__->table('artist');
__PACKAGE__->columns(Primary => 'artistid');
__PACKAGE__->columns(All => qw/artistid name/);
__PACKAGE__->has_many(tracks => ['TrackArtist' => 'trackid']);
__PACKAGE__->has_many(aliases => ['ArtistAlias' => 'artistid1']);

then supposing the following code:

i have a track, which has_many to TrackArtists...

my @artists = $track->artists;
foreach(@artists) {
    my @artist_aliases = @_->aliases;
    foreach(@artist_aliases) {
        print $_->name;
    }
}

and i have artist alias setup like so:

artistid1 | artistid2
     1    |     4
     4    |     1

so if my $_->artistid is 1 in the above code, about half the time i will get
what i want (the other nomme(s) de guerre for this artist), and half the time i
don't.  i get that CDBI is randomly loading everything up, which is ok.  i'm
just wondering, what would be the correct way to lock it down so that the
behavior in this situation is consistent?

apologies in advance if this list is not quite the right place for this
question, and thanks in advance for any help...

steve

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

variation of "weak link" lookup table
step2 01:47 on 24 Jun 2004

Re: variation of "weak link" lookup table
Tony Bowden 07:20 on 24 Jun 2004

Re: variation of "weak link" lookup table
steve shapero 08:09 on 24 Jun 2004

Re: variation of "weak link" lookup table
merlyn (Randal L. Schwartz) 15:10 on 24 Jun 2004

Re: variation of "weak link" lookup table
steve shapero 18:43 on 24 Jun 2004

Re: variation of "weak link" lookup table
Tony Bowden 07:23 on 24 Jun 2004

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