Re: Stolen Ideas

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

From: Perrin Harkins
Subject: Re: Stolen Ideas
Date: 00:22 on 11 Aug 2004
On Tue, 2004-08-10 at 19:48, Scott McWhirter wrote:
> > my $cd = $artist->cds(year => 1980)->first;
> Can you be exactly sure that you'll always get exactly the same object
> back using that method?

That depends on your schema.  If you define the combination of year and
artist_id as unique in the artist_cd mapping table, then the answer is
yes.

>  and what if the cd i'm concerned with isn't the
> first in that year but the second

Same as above: define your schema to enforce uniqueness if you want it
to match only one.

> ... or has suddenly been deleted from
> the database?

You get back undef.

> The reason for using a hash is that you know for a _fact_ that there
> will always be a unique object for that key and then you can use it just
> as you would any other hash.

That's just syntactic sugar.  The result is the same as what Tony is
showing above IF you have a database schema that is set up to enforce
these constraints.  Tangram just auto-generates a schema to do that.

> Say for example, you have a database schema where objects are constantly
> being created and deleted... can you be absolutely certain that your
> object can be retrieved in the same manner?

Not sure what you're getting at here.  This is the normal case for
databases.  Your query either matches something or it doesn't.

> In tangram, every object in the database, no matter the class; is
> assigned a unique object ID (OID) so that mapping of relationships
> (keyed, indexed, etc.) only ever does very simple lookups. You could see
> it as a complex behavioural change, but it's actually a pretty
> significant performance enhancement on top of the functionality.

It's standard practice for every table to have a primary key, and I
don't see how this is different except that it might avoid multi-column
primary keys.  The SQL required for the mapping table query above would
not be changed.  Something like this:

SELECT cd.cd_id
FROM   cd, artist_cd
WHERE  artist_cd.cd_id = cd.cd_id
AND    artist_cd.artist_id = ?
AND    artist_cd.year      = ?

That is not what Class::DBI does right now with a mapping table (it uses
two queries), but when many-to-many is improved, it should.

> > I'm sure it can be knocked up as a plugin. If it can't I'm willing to
> > look at ways to making it possible to do so. But I don't expect that
> > I'll add anything like this to the core any time soon.
> Yup, I believe Aaron Trevena is currently working on something along
> these lines... though I think he's finding it a bigger chunk to bite
> than he expected. I'm sure we'll hear something from him though.

I think you can handle simple cases (like serializing a set of strings
by joining them with commas) like this:

Music::CD->has_a(tracks => 'Set::Array',
                       inflate => sub { Set::Array->new(split(',',
shift)) },
                       deflate => sub { shift->join(','),
               );

- Perrin

(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