Re: Stolen Ideas

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

From: Scott McWhirter
Subject: Re: Stolen Ideas
Date: 22:58 on 10 Aug 2004
Tony Bowden wrote:
> On Tue, Aug 10, 2004 at 09:42:37PM +0100, Scott McWhirter wrote:
> 
>>The essential difference is that you're not loading the objects on the 
>>many side as a set (even if there is just one element in the set), 
>>instead you just get the one that you want. Tangram has these features.
>>Hope that clears it up for the simpletons, etc.
> 
> 
> I think I'm being extra simple tonight as I still don't get this.
> 
> Class::DBI already lets you restrict a has_many:
> 
>   Music::Artist->has_many(cds => 'Music::CD');
>   my @cds = $artist->cds(year => 1980);
> 
> What does the other stuff give over this?

What it gives you, quite simply is a UNIQUE result for the access per
key or index - not a list as @cds, - just one - this is what a hash does
- one item for each key, and an Array has one item for each index.
Reassigning to the key or index REPLACES the value. This is seemingly
small difference has fairly profound programming implications - if you
think about it - this is precisely what makes hashes and arrays such
usefull data types. (my $cd = $artist->{'cds'}{'thisONEhere'};)

>>Distinct from this is Arrays and Hashes which are INTERNAL to the 
>>objects. That is, they don't represent a relationship between two 
>>classes, but store a serialised Array or Hash of flat values in a field 
>>in the table. Beer could therefore have a field called "awards" which 
>>could be saved as a comma delimited string in the field in the table - 
> 
> 
> Yuck, yuck, yuck, yuck, yuck.
> 
> Class::DBI isn't really about storing objects in a database. It's about
> going the other way.

Of course it is, but my suggestion focuses on making CDBI truly
orthogonal, not just a database abstraction tool, but a completely
natural OO mapping to the DB. This can be taken to an extreme in terms
of performance - storing lists of flat values if you know that they'll
only ever be flat reduces the number of joins you have to do. Awards in
our example may never be objects (informed business decision) - for a
hotel you may wish to store "5 star" and "3 roses", but know for your
purposes that you'll only ever be interested in the strings "5 star" and
"3 roses" for displaying on a web page and perhaps knowing how many
there are, or appending an award at a later date - creating objects is
expensive, as are joins when all you need is a list of very simple flat
values. It can be implemented really easily and can be viewed as a
performance enhancement.

(message missing)

Stolen Ideas
Tony Bowden 18:58 on 10 Aug 2004

Re: Stolen Ideas
ed-cdbi 19:03 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 19:06 on 10 Aug 2004

Re: Stolen Ideas
ed-cdbi 19:08 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 19:11 on 10 Aug 2004

Re: Stolen Ideas
ed-cdbi 19:19 on 10 Aug 2004

RE: Stolen Ideas
Thomas, Mark - BLS CTR 19:11 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 19:27 on 10 Aug 2004

Re: Stolen Ideas
Nelson C. T. Ferraz 15:14 on 12 Aug 2004

Re: Stolen Ideas
Scott McWhirter 19:18 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 19:28 on 10 Aug 2004

Re: Stolen Ideas
Scott McWhirter 20:42 on 10 Aug 2004

Re: Stolen Ideas
Perrin Harkins 21:08 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 21:33 on 10 Aug 2004

Re: Stolen Ideas
Scott McWhirter 22:58 on 10 Aug 2004

Re: Stolen Ideas
Perrin Harkins 23:23 on 10 Aug 2004

Re: Stolen Ideas
Gregory P. Smith 19:55 on 10 Aug 2004

Re: Stolen Ideas
Perrin Harkins 20:02 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 21:47 on 10 Aug 2004

Re: Stolen Ideas
Perrin Harkins 22:23 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 22:37 on 10 Aug 2004

Re: Stolen Ideas
Perrin Harkins 22:57 on 10 Aug 2004

Re: Stolen Ideas
Yuval Kogman 15:39 on 11 Aug 2004

Re: Stolen Ideas
Tony Bowden 22:02 on 10 Aug 2004

Re: Stolen Ideas
ed-cdbi 22:11 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 22:25 on 10 Aug 2004

Re: Stolen Ideas
Tim Bunce 08:53 on 24 Aug 2004

Re: Stolen Ideas
Perrin Harkins 22:16 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 22:42 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 22:16 on 10 Aug 2004

Re: Stolen Ideas
Tony Bowden 23:18 on 10 Aug 2004

Re: Stolen Ideas
Scott McWhirter 23:48 on 10 Aug 2004

Re: Stolen Ideas
Perrin Harkins 00:22 on 11 Aug 2004

Re: Stolen Ideas
Perrin Harkins 03:45 on 11 Aug 2004

Re: Stolen Ideas
Tony Bowden 08:36 on 11 Aug 2004

Re: Stolen Ideas
Aaron Trevena 19:05 on 13 Aug 2004

Re: Stolen Ideas
Aaron Trevena 17:13 on 15 Aug 2004

Re: Stolen Ideas
Dan Friedman 04:47 on 11 Aug 2004

Re: Stolen Ideas
Tony Bowden 08:39 on 11 Aug 2004

Re: Stolen Ideas
Branislav Zahradnik 15:21 on 11 Aug 2004

RE: Stolen Ideas
Thomas, Mark - BLS CTR 19:13 on 13 Aug 2004

Re: Stolen Ideas
Tony Bowden 23:16 on 10 Aug 2004

Re: Stolen Ideas
Perrin Harkins 23:42 on 10 Aug 2004

Re: Stolen Ideas
Tim Bunce 08:48 on 24 Aug 2004

Re: Stolen Ideas
Tony Bowden 21:57 on 11 Aug 2004

Re: Stolen Ideas
Simon Cozens 09:03 on 24 Aug 2004

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