Results 1 to 15 of 15
  1. #1
    Hairy is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    7

    Exclamation Problem linking two tables(relational)


    I am having a problem with linking two tables in order to make a relational database. My problem is that whenever I change an information in one table, it does not seem to change in the other.

    Any solutions?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Why would something need to change in 'other' table? Want to provide db for analysis? Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Hairy is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    7
    Quote Originally Posted by June7 View Post
    Why would something need to change in 'other' table? Want to provide db for analysis? Follow instructions at bottom of my post.
    For example if i link two tables having one common field, telephone number, so if i change the telephone number in one table it does not automatically change in the other.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Why is the telephone number in both tables? This is duplication of data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Hairy is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    7
    Quote Originally Posted by June7 View Post
    Why is the telephone number in both tables? This is duplication of data.
    If you can see in the attachment( I hope that it got uploaded) it will be much easier to tell me what my problem is.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    You want phone number to be primary key? What if more than one patient (family members) have the same phone number?

    Use form/subform arrangement to synchronize saving primary key as foreign key in child record. http://office.microsoft.com/en-us/ac...010098674.aspx
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Hairy is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    7
    I have read the guidance and found something new. My tables do not have the infinity sign. Can you please tell me how to make the infinity sign appear?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Select 'Enforce referential integrity' in the Relationshp builder JoinType settings.

    Do you really want the RegistrationNumber to be a text and not Autonumber?

    Advise no spaces in names. Better would be CPRNUM or CPR_Num or CPR_Number.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Hairy is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    7
    Quote Originally Posted by June7 View Post
    Select 'Enforce referential integrity' in the Relationshp builder JoinType settings.

    Do you really want the RegistrationNumber to be a text and not Autonumber?

    Advise no spaces in names. Better would be CPRNUM or CPR_Num or CPR_Number.

    I have done what you told, and thanks for that. But i need to know how to automate the changes as so when i want to change the phone number of a person in the first table it will automatically change in the other.(eg if a person changed his/her number)

  10. #10
    smithse is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    37
    Hi hairy,

    As June7 correctly makes note, there is duplication of not only the phone number, but also the patient name. IMO the patients name and phone number should be in one table, and only in that table.
    You should have a unique number which identifies that person/patient which is what I think your 'CPR' number is. If that's all your registration table is storing, then your CPR number should also be in the patient table.
    If the "sessions" table stores information about the visits for that patient, then there should be one record for each visit. This would have a One-to-Many relationship with the patient table on the CPR number. In that case, when you update the CPR number (though it seems one of those numbers that shouldn't ever need to be changed) as long as you have referential integrity enforced on the relationship, the change will occur in the "sessions" table.

  11. #11
    Hairy is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    7
    So what your saying is that in the other table, There shouldnt be patients name and phone number?
    And which two fields do you think I should best relate?

  12. #12
    Hairy is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    7
    I just have one more problem if you may help me. How can I set a foreign key on the CPR field?

  13. #13
    smithse is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    37
    Quote Originally Posted by Hairy View Post
    So what your saying is that in the other table, There shouldnt be patients name and phone number?
    And which two fields do you think I should best relate?


    Hi hairy,

    So, above is the relationships that your application currently has.

    Modify your patients table to include the name, phone number, gender, CPR number (PK), past history. IMO, your current complaint and treatment fields should be stored in a session table record, as these are likely to change with each visit? Just a thought.
    Querying the patient's current complain is as simple as selecting the latest complaint from the session table for that patient.

    Your "Session" table should contain a SessionID (PK), CPRNumber (which is linked using a One-to-Many relationship on the CPRNumber in the patients table), DateOfVisit and any other information that you wish to store. Once again, querying the number of sessions or visits by a patient is straighforward; simply select the count of session records for that particular patient.

    I hope that helps.

    Below is the relationship you should adopt. This prevents or should I say alleviates the neccessity to store the same data in more than one table:


  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    I agree with smithse. However, smithse, I can't see the images you tried to attach.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    smithse is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    37
    Quote Originally Posted by June7 View Post
    I agree with smithse. However, smithse, I can't see the images you tried to attach.
    Damn, don't you hate that LOL.
    Sorry about that, and here is the image (hopefully) of the relationship that you should probably use. I will skip adding the relationship that you had beforehand though.

    Click image for larger version. 

Name:	relationships_proposed.png 
Views:	7 
Size:	8.3 KB 
ID:	9250

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Creating relational links between tables
    By NancyLoc in forum Import/Export Data
    Replies: 2
    Last Post: 04-10-2012, 01:38 AM
  2. Replies: 0
    Last Post: 03-04-2011, 10:28 AM
  3. Relational tables - again
    By BarbT in forum Access
    Replies: 6
    Last Post: 10-31-2010, 10:28 AM
  4. Relational tables help
    By BarbT in forum Access
    Replies: 5
    Last Post: 10-21-2010, 09:03 AM
  5. Relating 2 Tables - Relational Problem
    By jeng in forum Database Design
    Replies: 5
    Last Post: 04-01-2010, 09:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums