Re: preventing duplicate records: how to?
Re: preventing duplicate records: how to?
- Subject: Re: preventing duplicate records: how to?
- From: Michael Warner <email@hidden>
- Date: Tue, 27 May 2003 09:42:54 -0700
It seems to me that there are two kinds of attributes, those that by
definition cannot be duplicates in the real world (say, soc. sec.
number), and those that can (e.g., firstname, mi, lastname). Unless at
least one of the attributes you are checking for follows the former
logic, there is the risk of preventing two different people with the
same name from being allowed, when in fact the business logic says they
should be allowed.
In the case where a company is adding new clients itself, and perhaps
doesn't have a soc. sec. number or similar type of attribute, you can
present the administrative user with as much info. as possible about
other people in the database who already have the same name(s), and let
the administrative user decide if the new person already exists.
In the case where users are self-enrolling into the database, you can
require that no two people have the same email address (not always
acceptable to the client your programming for), or you can require a
unique name and/or password, but you will never know if the same person
has registered with you two or more times, some of the time with pseudo
information.
Or so I think. If I am wrong or if I am missing something here, I
would like to be corrected or 'schooled'.
Hope this is relevant to your issue.
Mike W.
On Tuesday, May 27, 2003, at 09:01 AM, Tom Woteki wrote:
I am seeking an alternative to an approach I have for preventing the
insertion or update of records that duplicate selected fields of
already existing records. My approach is based on comparing
EOGlobalIDs. I keep thinking I have missed something obvious or that
there may be preferred way of doing this.
Here is an example of my situation: Say I have an entity, Person,
whose primary key does not involve any of N other attributes, 2 of
which are firstName and surname. I want to prevent the insertion of
new Persons or updating of existing Persons that would result in
duplicates of these 2 attributes. (Note: These are not the only 2
attributes for which I want to avoid duplicates, so simply making
their combination the primary key would not solve my problem.)
Here is the approach I use: Say p is a new Person entity I am about to
insert (i.e. saveChanges() after insertObject() has been called on
some editingContext). I fetch any entities whose 2 attributes from
above match those of p. If I find any whose EOGlobalID in the editing
context is different than p's I conclude I am about to create a
duplicate and prevent the save. I use a similar technique for updates.
Is there another way, a preferred way, of doing this?
Thanks
Tom
_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.