473,781 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating relationships

Ok let me just say first that I am a newbie in Access and I don't know
much of SQL or VB programming.

But I am trying to create this contact database using Access 97. I
have created 2 tables, one Personal (it has all the personal
information) and the other one Organization (this one has details of
diff organizations). One person can belong to more than any (upto 5 in
this case) organizations. So I included orgid1, orgid2, orgid3, orgid4
and orgid5 in Personal table. In Organization table, I have OrgId and
Org name and other info.

How do I create the relationship, so when I am retrieving the
information (creating a report), I can list the name of the person and
all the organizations that person belong to.

Did I create the right tables, right structures? or is it all screwed
up??

Please help, thank you in advance.
Nov 13 '05 #1
4 2028
Ronnie wrote:
Ok let me just say first that I am a newbie in Access and I don't know
much of SQL or VB programming.

But I am trying to create this contact database using Access 97. I
have created 2 tables, one Personal (it has all the personal
information) and the other one Organization (this one has details of
diff organizations). One person can belong to more than any (upto 5 in
this case) organizations. So I included orgid1, orgid2, orgid3, orgid4
and orgid5 in Personal table. In Organization table, I have OrgId and
Org name and other info.

How do I create the relationship, so when I am retrieving the
information (creating a report), I can list the name of the person and
all the organizations that person belong to.

Did I create the right tables, right structures? or is it all screwed
up??

Please help, thank you in advance.


I highly recommend you have an autonumber primary key for each table.
Your link between the two tables are the autonumbers; PersonalID is
primary key in Personal and OrgID in Organization.

You could have another table with PersonalID and OrgID...and any other
relevent info you need...like date joined, date terminated, date added
to the system, etc. When you add/edit a person, a subform could exist
where you add the organizations the person belongs to.

This way you can swing it so that you can view an organization and see
all assigned persons to it or visa versa, persons and all orgainzations
they belong to.
Nov 13 '05 #2
You have what is called a "many-to-many" relationship.
A person can belong to many Orgs, and a single Org can be linked to many
different persons.
You need another table to join the two, and should get rid of the 5 OrgID
fields in the Personal Table.
This allows you to have an unlimited number of relationships, or none at
all, and not have blank ID fields sitting in your tblPerson wasting space.
So your Person table might have:
PersonID <<< primary key for this table
FirstName
LastName
(etc.)

The new table might be called "tblPersonO rg" and have:
PersonOrgID <<< primary key for this table
PersonID <<< ID from tblPerson
OrgID <<< ID from tblOrg
Unless there is something more like Employee Start Date or some other field
about a person linking to an org, you shouldn't need any other fields in
this table.

Your Org table might have
OrgID <<< primary key for this table
OrgName
OrgInfo
(etc.)

HTH.
~ Duane.

"Ronnie" <ro*****@yahoo. com> wrote in message
news:a9******** *************** ***@posting.goo gle.com...
Ok let me just say first that I am a newbie in Access and I don't know
much of SQL or VB programming.

But I am trying to create this contact database using Access 97. I
have created 2 tables, one Personal (it has all the personal
information) and the other one Organization (this one has details of
diff organizations). One person can belong to more than any (upto 5 in
this case) organizations. So I included orgid1, orgid2, orgid3, orgid4
and orgid5 in Personal table. In Organization table, I have OrgId and
Org name and other info.

How do I create the relationship, so when I am retrieving the
information (creating a report), I can list the name of the person and
all the organizations that person belong to.

Did I create the right tables, right structures? or is it all screwed
up??

Please help, thank you in advance.

Nov 13 '05 #3
Ronnie wrote:
Ok let me just say first that I am a newbie in Access and I don't know
much of SQL or VB programming.

But I am trying to create this contact database using Access 97. I
have created 2 tables, one Personal (it has all the personal
information) and the other one Organization (this one has details of
diff organizations). One person can belong to more than any (upto 5 in
this case) organizations. So I included orgid1, orgid2, orgid3, orgid4
and orgid5 in Personal table. In Organization table, I have OrgId and
Org name and other info.

How do I create the relationship, so when I am retrieving the
information (creating a report), I can list the name of the person and
all the organizations that person belong to.

Did I create the right tables, right structures? or is it all screwed
up??


Not too harsh! But you missed one point. If a person can belong to more
organisations, and an organisation can 'contain' more than one person,
there is a n:m relationship (that is, many to many) that is mapped
through a third table. You don't have that one.

With your five fields, you would run into trouble if a sixth relation
had to be added.

The new table, let's call it Membership, should have the same fields as
the primary keys from Personal and Organization; all those fields are
the primary key in the Membership table.

Create two relations with referential integrity (and I usually set
cascaded updates on, not cascaded deletes), both from Personal and
Organization (drag from those) to Membership (drop here).

Now, for every old orgid1 you create a record in Membership; same for
orgid2 (excluding Nulls of course), etc.
After you've done that, the fields orgidX can be deleted.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #4
Creating different fields for each organization is the temptation when
first starting out. What you need is one field which will display which
orginization the person is connected. In the relationships window, link
the two tables with a "one-to-many". You said one person can belong to
many orginizations. By using an autonumber, as one person suggested, for
your primary key, you may have several lines for any individual, one line
for each orginization the person belongs to. Consider using a drop down
box for the orginization selection. If you think the list of orginizations
will change, use a seperate table to base the list on or base the list on
your orginization table.

Now, as you may not want to type all the personal information over and
over for each orginization the person belongs to, you will need a third
table. You have one table with all the personal information on each
person. If you make the PersonsName the key field, you will ensure you do
not get two people the same - like John Smith - or have double entries
for the same person. You have one table containing all the information on
each orginization. The third table yo need is just for the links,
PersonName and Orginization. The middle table creates a "many-to-many"
relationship, becuase you have one-to-many Person to Link and one-to-many
Organization to Link. Make the OrganizationNam e the key field in the
Organization table, so the Link table will have PersonsName listed beside
OrganizationNam e. You will have one line for each combo. In the Link
table. You link the one-to-many relationship from the key field to a non
key field, so PersonsName and OrginizationNam e cannot be key. Also, key
must be unique, so can not for that reason. You create an autonumber key
field in the Link table, because you are not worried about any duplicate
information there.
Hope this gives you a more clear picture.

Nov 13 '05 #5

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

Similar topics

6
2706
by: Jade | last post by:
Hi, I am trying to create a dataset with 6 tables and 5 relationships created between them. I am creating it in the Form_Load event. However i keep getting the following error... An unhandled exception of type 'System.ArgumentNullException' occurred in system.data.dll Additional information: 'column' argument cannot be null. The code stops on this line... Dim rel_Booking_CaraBook As New DataRelation("dsFullBooking",...
2
2227
by: Andrea | last post by:
I'm having some difficulty creating a report in Access and I need some suggestions. My company issues "Return Authorizations" when customers need to return products. A customer calls in and we provide the number. The customer then returns items for a refund or for an exchange. Here is the basic set up of the tables in question. -ReturnAuthorizationTable- ReturnNumber_PK CustomerID ReturnType
8
4329
by: Brian S. Smith | last post by:
Hi gang, Please help. I've been through the Access help, searched the Web, and I can't seem to get a straight answer. As the Subject line suggests, I want to run a fairly simple VB/Access Sub Function/Module that creates relationships for my tables. The problem is that I need to provide for some tables that may have > 32 relationships (which is apparently the limit on Indexes that Access can support). How can I prevent Access from...
3
11734
by: GGerard | last post by:
Hello Does anyone know if it is possible with Access 2000 to create relationships between tables using code? Thanks G.Gerard
5
4704
by: Mike Turco | last post by:
What is the difference between creating relationships in the front-end vs. the back-end database? I was trying to create a relationship in a database front-end and noticed that I could not check the referential integrity box. What gives? Continuing on with that line of thinking, I understand what do the relationships do for you in a database, but what do they do physically to the tables? Thanks,
2
6125
by: Gandalf | last post by:
I'm creating relationships between tables using VBA and ADOX. I can create one-to-one relationships with an inner join, but I can't figure out how to create these relationships with an outer join (specifically a left outer join). I'm including the code that creates the relationships with the inner join. Any help or suggestions would be greatly appreciated. Thanks! <----- CODE FOLLOWS ----->
1
1567
by: Kosmos | last post by:
Hi...I'm new but decided to take on learning access programming for my job and I'm having trouble building relations. Any help would be very appreciated! So here's the jist of the program...I have a bunch of fields that I have the program read through and check to see if one number is missing and then reads through the serial numbers which have asset numbers within them but has to remove the characters of A-Z so it can be compared to the...
5
1864
by: Kosmos | last post by:
Hey :) hopefully someone can help me with this...I decided to take on the task of programming an access database for my legal co-op/internship...I'm studying law and music production on the side...most of the background I have in programming has to do with music production... The program I'm creating pulls data from an excel sheet (with defined fields) and brings them into an access database. The data being pulled is the following: ...
10
4456
by: Richard | last post by:
Hi folks, thanks for taking the time to read this (and hopefully point our where I'm going wrong). The scenario: I have a local Access2007 database which links in several read only mySql tables via ODBC. The problem:
0
9639
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
10143
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10076
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
9939
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
8964
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
7486
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
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
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
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.