473,738 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Preventing duplicate records in query/database design?

Hi,

I'm trying to design contact (names and addresses) tables in an Access
database. Some of the contacts represent vendors, some are board members of
the organization, some are donors, some are neighbors of the organization,
some are politicians, etc. Rather than create separate tables for each type
of contact, I thought it would be better to have:

one table with names/addresses
one table with kinds of lists (vendors, board members, donors, neighbors,
politicians, volunteers, etc) and
one table with list details (which combine IDs of names/addresses with IDs
of kinds of lists).

This way a person/company could be on more than one list at a time, by
having multiple records in the list details table.

My problem occurs when I want to prevent the same name/address records from
appearing multiple times when I run queries. For instance, a board member
may also be a member of the community, and thus have 2 records in the list
details table. I want to create mailing labels from a query that includes
people who are either board members or live in the community, but I don't
want 2 labels for the same person. DISTINCT and DISTINCTROW are not working
for me. Can you help?

Thanks,
Allen
May 17 '06 #1
2 3381
Your data structure sounds perfect:
- a table of people;
- a table of roles;
- a junction table with just the PersonID and RoleID foreign keys, to define
the roles each person has.

The query should work with DISTINCT, as long as you output fields from the
Person table only.

Obviously if you output the roles as well, then the person can turn up in
multiple records, since the query perceives the role as different when it
sorts out the DISTINCT part.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Allen Anderson" <al***********@ mindspring.com> wrote in message
news:b8******** ********@newsre ad3.news.pas.ea rthlink.net...

I'm trying to design contact (names and addresses) tables in an Access
database. Some of the contacts represent vendors, some are board members
of the organization, some are donors, some are neighbors of the
organization, some are politicians, etc. Rather than create separate
tables for each type of contact, I thought it would be better to have:

one table with names/addresses
one table with kinds of lists (vendors, board members, donors, neighbors,
politicians, volunteers, etc) and
one table with list details (which combine IDs of names/addresses with IDs
of kinds of lists).

This way a person/company could be on more than one list at a time, by
having multiple records in the list details table.

My problem occurs when I want to prevent the same name/address records
from appearing multiple times when I run queries. For instance, a board
member may also be a member of the community, and thus have 2 records in
the list details table. I want to create mailing labels from a query that
includes people who are either board members or live in the community, but
I don't want 2 labels for the same person. DISTINCT and DISTINCTROW are
not working for me. Can you help?

Thanks,
Allen

May 17 '06 #2
Thank you Allen.

Yes. After posting my question I noticed that one of the secondary tables
had a "shown" field, putting it into the SELECT clause as well as the WHERE
clause. Removing that field fixed my problem.
Thanks for your feedback on the data structure.

"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:44******** *************** @per-qv1-newsreader-01.iinet.net.au ...
Your data structure sounds perfect:
- a table of people;
- a table of roles;
- a junction table with just the PersonID and RoleID foreign keys, to
define the roles each person has.

The query should work with DISTINCT, as long as you output fields from the
Person table only.

Obviously if you output the roles as well, then the person can turn up in
multiple records, since the query perceives the role as different when it
sorts out the DISTINCT part.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Allen Anderson" <al***********@ mindspring.com> wrote in message
news:b8******** ********@newsre ad3.news.pas.ea rthlink.net...

I'm trying to design contact (names and addresses) tables in an Access
database. Some of the contacts represent vendors, some are board members
of the organization, some are donors, some are neighbors of the
organization, some are politicians, etc. Rather than create separate
tables for each type of contact, I thought it would be better to have:

one table with names/addresses
one table with kinds of lists (vendors, board members, donors, neighbors,
politicians, volunteers, etc) and
one table with list details (which combine IDs of names/addresses with
IDs of kinds of lists).

This way a person/company could be on more than one list at a time, by
having multiple records in the list details table.

My problem occurs when I want to prevent the same name/address records
from appearing multiple times when I run queries. For instance, a board
member may also be a member of the community, and thus have 2 records in
the list details table. I want to create mailing labels from a query
that includes people who are either board members or live in the
community, but I don't want 2 labels for the same person. DISTINCT and
DISTINCTROW are not working for me. Can you help?

Thanks,
Allen


May 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3627
by: Drew | last post by:
I have a permission tracking app that I am working on, and I have made the insert page for it. I am having issues on how to prevent duplicates from getting entered. Currently the interface for the app has a mixture of select boxes, list boxes and checkboxes. The form submits the page to processAIMR.asp and then does the inserting. I am using a loop to insert a new record for each checkbox checked or listbox entry selected. My...
9
14584
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or FirstName/LastName/email? Or is it possible to allow this but to throw up an alert message? Warning that this person is probably already in the database? TIA
2
2778
by: Jason | last post by:
I have a table of 650,000 records associated to contracts. Some of the contracts have multiple records but each contract only has one Active Record (there might be several inactive records). There are dates associated with each of the records (whether active or inactive). I need to compare the dates between the active and inactive contract records. So far, I've created a "find duplicates query" for contract to identify contracts that...
3
2177
by: ColinWard | last post by:
I am using the following code to validate that the person that is being entered into the database does not already exist. However wnem I test it by entering myself as a contact(I first checked that I was indeed NOT in the database), the message still comes up saying that I am in the database. what am I doing wrong? Private Sub txtEmailName_AfterUpdate() On Error GoTo Err_txtEmailName_AfterUpdate >> If DLookup("EmailName", "Contacts",...
2
4084
by: Ross | last post by:
i have less hair now than i used to...i have a database with many duplicate records in it with only one exception, there is one field with the date it was put in the database and that is different. i can eliminate duplicate records with ease but how do you specify in an sql statement to delete the one with the earlier date? please help me before i go bald... thanks
5
3990
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone | ------------------------------------------------------- | mr x | 8th lane | 124364 | | mr x | 6th lane | 435783 | | mrs x | 6th lane | 435783 |
4
3309
by: HLCruz via AccessMonster.com | last post by:
I am working with a database that has client information separated in to 4 related tables - tFolder, tAddress, tEmail, tPhone number. In addition there are related tables tGifts and tCalls. The database has roughly 22,000 records but should only have around 6,000. The remaining records are duplicates, but in many cases the correct data for one person is spread out between the duplicate records and related tables. I need to be able to...
6
11900
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and clicks again, which created duplicate forcm submission and hence duplicate records. So I am trying to disable the button as soon as it is clicked, and as soon as it's done,
1
7271
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
0
8968
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8787
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9259
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4824
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.