Re: Relationship::HasVariant

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

From: Ricardo SIGNES
Subject: Re: Relationship::HasVariant
Date: 23:46 on 12 Oct 2004
--9lPOKfY2vCV97ybw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

* Tony Bowden <tony-cdbitalk@xxxxx.xxx> [2004-10-12T19:25:51]
> On Tue, Oct 12, 2004 at 03:04:29PM -0400, Ricardo SIGNES wrote:
> > I've just published to the CPAN Class::DBI::Relationship::HasVariant.
> > We have a lot of tables here that provide extra data about rows, so
> > there's a (rowid, x, y, x) relation and then a (rowid, attrid, value)
> > relation with all the really unusual stuff that we only measure now and
> > then.

> How does this differ from might_have()?

Please correct me if I misunderstand might_have -- I'm sure you will. :)

might_have brings in the columns from a named table.  In the canonical
example: if there is an entry for { artistid => $x } in band, for a
given artist, then the columns from band are available on $x's Artist
object.

HasVariant is for attributes that are stored, if you will, vertically.
The table that is joined does not have the same primary key, and it may
have multiple entries.

So, if we were to (stupidly) rewrite the Artist/Band/Person stuff with
HasVariant, we might have:

 CREATE TABLE artist_attributes (
   artistid,
   attribute,
   attr_value,
   PRIMARY KEY (artistid, attribute)
 )

Then, Elvis might be represented by three rows:

 in artist: (100, 'Elvis Presley', 10000)
 in artist_attributes:
   (100, 'gender',    'M')
   (100, 'haircolor', 'Brown')

I'm using this for a system in which there are a few hundred attributes,
and I'm constantly getting demands for more.  Any given object has five
or six.

Obviously, it's easy to just do has_many to get the list of attributes,
but I want a number of them to be inflatables, and I can't (as far as I
can tell) selectively has_a the columns without has_variant.

--
rjbs

--9lPOKfY2vCV97ybw
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQFBbGzq5IEwYcR13KMRAgneAJ4lAykOw22ZdlVl7ZXEdGMP5anCrACgmGnd
65NcbWlaeqHd2bZgdlQn0h4=
=88OC
-----END PGP SIGNATURE-----

--9lPOKfY2vCV97ybw--

Relationship::HasVariant
Ricardo SIGNES 19:04 on 12 Oct 2004

Re: Relationship::HasVariant
Tony Bowden 23:25 on 12 Oct 2004

Re: Relationship::HasVariant
Ricardo SIGNES 23:46 on 12 Oct 2004

Re: Relationship::HasVariant
Ricardo SIGNES 23:52 on 12 Oct 2004

Re: Relationship::HasVariant
Aaron Trevena 08:39 on 13 Oct 2004

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