On Sun, 2013-10-06 at 00:05 +0200, Caveat wrote:
> > If you wanted to delete one row with values 347 200, then which row would 
> > it be?
> 
> It *doesn't matter*!  The rows are the same, so pick a row, ANY row!

That is exactly what I have been doing for the last 10 years.
In VB code I just looked for the criteria in the table and deleted the
first record that met the criteria, next update table and ready.

In Gambas I tried the same, now with the table being in MySql, and it
didn't work.

It never, ever failed me in those 10 years, even without a primary key.
Although most other tables do have primary keys and relations set up,
there never was a need for this table to have a primary key.
And I still do not see the need for a primary key.

> 
> > Without the primary key, you're asking MySQL to guess, and it wont.
> 
> Yes it will, if you use LIMIT (see my previous two mails).  Otherwise, it'll 
> happily delete all the rows that meet the criteria, whether they're 
> duplicates or not.
> 

And even in MySql there is NO need for the table to have a primary key
as the 'SELECT ... limit 1' will do what I expect, delete only 1 record
that meets the criteria.

> > >"duplicate rows are and always were a mistake in SQL", C.J.Date

Duplicate rows are a reality in real life data gathering.
I have been working with databases since dbase somewhere in the '80's
and I have had to deal with real life situations concerning data
storage, not with theory for ideal models. Not saying I haven't read my
share on relational database design and take it into account when
designing a database.

> 
> The guy has obviously never read William Kent's "Data and Reality". It's 
> a book I'd still recommend to anyone working with data and particularly 
> databases, even though it was written 35 years ago!
> 
> <RANT>
> Why *must* every record be uniquely identifiable?  Explain why... don't 
> just throw random snippets of relational database theory at me!  If I 
> ask you to model the contents of your pockets on a database, are you 
> going to attach some artificial key to each individual penny?  Why?  
> They each buy the same number of penny chews (showing my age!), and if 
> you take 3 pennies away, you've still got 3 pennies less than you had 
> before, no matter how carefully you select those 3 pennies!
> </RANT>
> 
> <HINT>
> A tuple is, by definition, unique.  If I have 8 rows on my database 
> representing 8 real-world penny objects and I can delete 3 of them... 
> are the remaining 5 rows tuples?  How closely does the database model 
> reality in this case?
> </HINT>

I like your penny story ;)


-- 
Kind regards,

Willy (aka gbWilly)

http://gambasshowcase.org/
http://howtogambas.org
http://gambos.org





------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to