SunQuest
 
      MS Access
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Iron Speed
Go Back   Tutorialized ForumsDatabasesMS Access

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 24th, 2007, 08:57 AM
salim salim is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 7 salim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 17 sec
Reputation Power: 0
1:M relationship

Hi,
I am trying to estblish the relationship between tbles and I get the following errors:


no unique index found for the referenced field of primary table


my desing of tables contains of course primary keys but because i have also foreing keys I am making them PK in the tables where they should be ( 1:M) as well in the Database Design Mode. is it why I am having this problem? I tried to put only one PK in each table and once I do the relationship it works fine ( well it looks 1:m ) but all i am worried about is the outcome, i am not sure if i will get the desired result, please can you correct me if i am wrong in this?
thanks

Reply With Quote
  #2  
Old August 24th, 2007, 10:44 AM
Slyce Slyce is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 4 Slyce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 11 sec
Reputation Power: 0
Re:1:M relationship

Quote:
Originally Posted by salim
Hi,
I am trying to estblish the relationship between tbles and I get the following errors:


no unique index found for the referenced field of primary table


my desing of tables contains of course primary keys but because i have also foreing keys I am making them PK in the tables where they should be ( 1:M) as well in the Database Design Mode. is it why I am having this problem? I tried to put only one PK in each table and once I do the relationship it works fine ( well it looks 1:m ) but all i am worried about is the outcome, i am not sure if i will get the desired result, please can you correct me if i am wrong in this?
thanks

Hi Salim,
it seems you have more than one primary key per table, if that's the case then it could be the source of your problems. That is unless the primary keys are compound PK which are basically a combination of at least two fields. See if you can stick with one PK per table and lets hear how it goes.

Reply With Quote
  #3  
Old August 24th, 2007, 11:06 AM
salim salim is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 7 salim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 17 sec
Reputation Power: 0
Quote:
Originally Posted by Slyce
Hi Salim,
it seems you have more than one primary key per table, if that's the case then it could be the source of your problems. That is unless the primary keys are compound PK which are basically a combination of at least two fields. See if you can stick with one PK per table and lets hear how it goes.



Hi Slyce,
thanks for your reply, do you mean that if I keep the FK ( Forgein Key )not as PK ( Primary Key) would be fine? I tried it and it seems okay, but as I said I am not quite sure about the desired outcome for my queries. So far it's okay, tried it with couple fields and see how it goes all along, again my concerns are that if a FK is assigned in another table then it's not necessary that it must be a PK

Reply With Quote
  #4  
Old August 24th, 2007, 11:53 AM
Slyce Slyce is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 4 Slyce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 11 sec
Reputation Power: 0
Re:1:M relationship

Quote:
Originally Posted by salim
Hi Slyce,
thanks for your reply, do you mean that if I keep the FK ( Forgein Key )not as PK ( Primary Key) would be fine? I tried it and it seems okay, but as I said I am not quite sure about the desired outcome for my queries. So far it's okay, tried it with couple fields and see how it goes all along, again my concerns are that if a FK is assigned in another table then it's not necessary that it must be a PK


Hey Salim,
if i understand you correctly; you need to have your foreign keys(in child fields) relating to primary keys in (parent fields) that's the basis of the one to many relationships. It may be a good sign that "so far it's okay". My understanding is that a foreign key should be a PK in the table with parent fields.

Reply With Quote
  #5  
Old August 28th, 2007, 05:00 AM
salim salim is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 7 salim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 17 sec
Reputation Power: 0
Quote:
Originally Posted by Slyce
Hey Salim,


Hi again
if i understand you correctly; you need to have your foreign keys(in child fields) relating to primary keys in (parent fields) that's the basis of the one to many relationships. It may be a good sign that "so far it's okay". My understanding is that a foreign key should be a PK in the table with parent fields.



So why is it then giving me the error message ? if a FK must be PK in the parent field, then it should be okay.
I think you understand my point and all i am getting is the error, so what do you think is going wrong?
here is my table for example:


Booking_tbl
Booking_ID (PK)
Customer_ID (PK) ( but is a foreign key because of the result of 1:M)

Vehicle_tble
Vehicle_ID (PK)
booking_ID (FK) ( but PK key in the table this is my understanding of how to design it in access)


now I am wrong because I get the error message?
If I don't set booking_ID as PK then nothing happens.
much appreciated

Reply With Quote
  #6  
Old August 28th, 2007, 05:35 AM
Slyce Slyce is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 4 Slyce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 11 sec
Reputation Power: 0
Re:1:M relationship

Hey Salim,
the table structure you sent shows you have two primary keys for the Booking_tbl, now the only way you can get away with that is if you have a composite primary key (a combination primary key composed of the two fields). If that's not what you have then it's most likey the source of your problem. You can have only one PK per table.What seems right would be to leave Boking_ID as PK in Booking_tbl, remove the PK on Customer_ID in Booking_tbl.

Quote:
Originally Posted by salim
So why is it then giving me the error message ? if a FK must be PK in the parent field, then it should be okay.
I think you understand my point and all i am getting is the error, so what do you think is going wrong?
here is my table for example:


Booking_tbl
Booking_ID (PK)
Customer_ID (PK) ( but is a foreign key because of the result of 1:M)

Vehicle_tble
Vehicle_ID (PK)
booking_ID (FK) ( but PK key in the table this is my understanding of how to design it in access)


now I am wrong because I get the error message?
If I don't set booking_ID as PK then nothing happens.
much appreciated

Reply With Quote
  #7  
Old August 29th, 2007, 09:12 AM
salim salim is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 7 salim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 17 sec
Reputation Power: 0
Quote:
Originally Posted by Slyce
Hey Salim,
the table structure you sent shows you have two primary keys for the Booking_tbl, now the only way you can get away with that is if you have a composite primary key (a combination primary key composed of the two fields). If that's not what you have then it's most likey the source of your problem. You can have only one PK per table.What seems right would be to leave Boking_ID as PK in Booking_tbl, remove the PK on Customer_ID in Booking_tbl.

Hi Slyce
I think you're right about it, I tried it many times and didn't work, now it seems working, I just wanted to double check to avoid any undesired result. Thanks for your tips and help.

Reply With Quote
  #8  
Old August 29th, 2007, 09:45 AM
Slyce Slyce is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 4 Slyce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 11 sec
Reputation Power: 0
Re:1:M relationship

You are most wellcome, glad my tips helped.
Quote:
Originally Posted by salim
Hi Slyce
I think you're right about it, I tried it many times and didn't work, now it seems working, I just wanted to double check to avoid any undesired result. Thanks for your tips and help.

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesMS Access > 1:M relationship


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway