Solved

Access Relationship Problem

Posted on 2015-01-19
7
206 Views
Last Modified: 2015-01-19
I have an exercise in which I need to assign one-to-many relationships to some tables in a db.

I can get one such relationship but all the remaining tables form a one-to-one relationship and I don't understand why when they are very similar to the two tables in which I was able to form a one-to-many relationship.

The primary keys have the same data types. In my file a one-to-many relationship exist between the table "tblRentals" and tblRenters". I need to form the same relationship between all the remaining tables except that when I try I get a one-to-one relationship. Why???
0
Comment
Question by:James Coats
  • 3
  • 2
  • 2
7 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 40558281
Do you have the Primary Key in the One table as a Foreign Key in the Many table ... and for the Foreign Key ... do you have Index - Allow Duplicates ?

mx
0
 
LVL 57
ID: 40558283
For a one to many, you should have a copy of the "one's" primary key in the record of the "many" sides record as a separate field.  This is called a foreign key.

If your getting a one to one, then what your doing is joining the primary keys of each table to one another, which is not what you want.

Jim.
0
 
LVL 75
ID: 40558338
:-)
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Closing Comment

by:James Coats
ID: 40558354
I went to the "tblRentals" and selected the key or foreign key for each of the table and selected "Allow Duplicates" from the connecting tables primary keys which now allows a one-to-many connections. I also enforced referential integrity. Thanks for the help. You both answerd correctly but you got there first so I gave you the points.

So the way I see it now on the table connecting you select a primary key you choose no duplicates for the table and then you choose the table being connected to and place your foreign key there and select allow duplicates. You also would have indexed this field. Is this correct??
0
 
LVL 57
ID: 40558361
<<You also would have indexed this field. Is this correct?? >>

 If you enforce Referential Integrity, no as Access (actually JET) will create an index on the many side of the join.

 If you create an index with RI enforced, you'll be creating a duplicate index.   Note that you won't see the hidden index.

Jim.
0
 
LVL 75
ID: 40558422
Actually ... I really didn't mean to say (and Jim is correct about the dup index) "and for the Foreign Key ... do you have Index - Allow Duplicates ?" .... what I meant was ... be SURE that you do not have Indexed - No Duplicates - which will result in a One to One when you try to create a Relationship.


And of course, unless you enforce RI ... you don't really have a meaningful Relationship.

mx
0
 

Author Comment

by:James Coats
ID: 40558435
Thanks a lot guys. I am new and learning a lot.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now