Results 1 to 4 of 4
  1. #1
    AlexSo is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    Torquay
    Posts
    2

    1 table with 2 relationships to another table

    I'm putting together a database for a charity that runs a transport service. The group has members some of whom are drivers who take patients (other members) to medical appointments. I have a table for all members details and one called tblPatientJourneys to store information so that we can track payments that members pay for the journey and driver reimbursements.

    However because a driver is a member he/she can also be a patient being taken to an appointment by another driver.

    tblMembers

    Id Name Driver
    001 Mr A No
    002 Mrs B Yes
    003 Ms C Yes
    004 Mrs D No

    tblPatientJourneys



    PatientID DriverID Journey
    001 002 Hospital
    003 002 Dentist
    002 003 Surgery

    Access allows the setting of relationships from one field in the members table to 2 fields in the journeys table, however things seem to become a bit unstuck from then on.
    I could have a separate Drivers table, but I want to treat the drivers as ordinary members in all other ways. And some member could become a driver for a short time then revert back to being a non driver which would mean swapping the data between the two tables.

    Is there any help out there? – thanking you in advance.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Since a person can play many roles, you have to associate the role the person is playing to the driving event.

    tblPeople
    -pkPeopleID primary key, autonumber
    -txtFName
    -txtLName

    By the way the word "name" is a reserved word in Access so it should not be used as field or table name

    tblRoles (records such as patient, driver, etc.)
    -pkRoleID
    -txtRole

    tblPeopleRoles (associate the person and roles that they may play)
    -pkPeopleRoleID primary key, autonumber
    -fkPeopleID foreign key to tblPeople
    -fkRoleID foreign key to tblRoles

    Also, since you have many people associated with a journey, that would be a one-to-many relationship

    tblPatientJourneys
    -pkPatientJourneyID primary key, autonumber
    -dteJourney (date of journey)
    -JourneyReason

    tblPatientJourneyPeopleRoles (for each journey you will have many people who are participating according to their role)
    -pkPatientJourPeoRoleID primary key, autonumber
    -fkPatientJourneyID foreign key to tblPatientJourneys
    -fkPeopleRoleID foreign key to tblPeopleRoles

  3. #3
    AlexSo is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    Torquay
    Posts
    2
    Thank you. Guess I need to read a good (and not too difficult) book.

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You might check out Crystal's site; it has several tutorials.

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

Similar Threads

  1. Table Relationships
    By ledbyrain in forum Access
    Replies: 1
    Last Post: 09-07-2010, 05:05 PM
  2. Plz help Table Relationships
    By heominhon127 in forum Database Design
    Replies: 6
    Last Post: 09-06-2010, 01:36 PM
  3. Table Relationships
    By seanp in forum Access
    Replies: 2
    Last Post: 04-15-2010, 07:12 AM
  4. Table Relationships?
    By Meld51 in forum Access
    Replies: 3
    Last Post: 03-01-2010, 08:34 AM
  5. Table Relationships
    By jp2access in forum Database Design
    Replies: 3
    Last Post: 06-19-2009, 10:20 AM

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