🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #4435

Re: Duplicate records

#4435
From: Unwanted Edict
Date: Fri, 28 Dec 2001 12:43
58 lines
3283 bytes
Why not use keys, etc.?

If you don't have duplicate keys, you technically don't have duplicate
records, but duplicate data. The RDBMS has no way to determine what is
duplicate data - it doesn't care about that, only keys and metadata
structures.

To remove duplicate data you have to "roll your own" - every db is
different. You need to write a table sweeper. Usually this is based on some
knowledge you have about the database - like if you have two records in a
master table with the same social security number, it's a good bet this is a
candidate for a duplicate. That wouldn't apply to a detail table, where
duplicate SSNs might be the norm.

Obviously the brute-force approach is a one-to-all comparison of each record
in a table to every other record. If all fields except the keys match, you
have a duplicate.

The trick is to know which duplicates to delete. Is the newest one the bogus
record, or the oldest one, or what? If the keys involve any kind of sequence
or timestamp, you'll need them to know.

If you are good with SQL you can write some tasty scripts to do this stuff,
but a programmatic approach is much more straightforward. You could just do
compares with FieldByName(), but that will give you the slowest performance.
The best way to deal with duplicate data is to keep it from happening in the
first place, but that isn't always possible. The second best way is to deal
with it on the server, as a timed or otherwise triggered script on the
RDBMS, or as a daemon or service application written in C++ Builder. This
way your client application need never deal with this stuff.


"Rick Golden" <GoldenRick@hotmail.com> wrote in message
news:3c224a5d_2@dnews...
> like Jim said you can do that with SQL
> but why not constraints to assure Database  integrity????
>
>
> Jim Young <jyoung@youngendeavors.com> wrote in message
> news:3c2221d1$2_1@dnews...
> > I'm not aware of any function that does this. You could do this
> > programatically using SQL.
> >
> > Jim
> >
> > "FretBuzzz" <none@none.com> wrote in message news:3c21f9a7_2@dnews...
> > > Hi,
> > > Does anyone know of a function that will delete duplicate entries in a
> > > database table.
> > > I want to be able to achieve this without the use of keys etc.
> > > Thanks in advance,
> > > FretBuzzz
> > >
> > >
> >
> >
>
>
Technical Details
Message-ID: <3c2c688f$1_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newshub2.rdc1.sfba.home.com!news.home.com!newsfeed.mesh.ad.jp!uunet!osa.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3c21f9a7_2@dnews> <3c2221d1$2_1@dnews> <3c224a5d_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,add4b0d12dd2238b
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2001-12-28 04:48:53 PST
From: "Unwanted Edict" <unwantededict@hotmail.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3c21f9a7_2@dnews> <3c2221d1$2_1@dnews> <3c224a5d_2@dnews>
Subject: Re: Duplicate records
Date: Fri, 28 Dec 2001 04:43:13 -0800
Lines: 60
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 64.160.39.91
Message-ID: <3c2c688f$1_1@dnews>
X-Trace: dnews 1009543311 64.160.39.91 (28 Dec 2001 04:41:51 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newshub2.rdc1.sfba.home.com!news.home.com!newsfeed.mesh.ad.jp!uunet!osa.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews