Results 1 to 7 of 7
  1. #1
    TurmoilMishka is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    3

    Access Query/Design Question

    Hello,

    In my database i have Clients and Consultants. The Clients are Assigned to Consultants by State , how would i set that up as a relationship? I also want to run the query to print the assigned client and consultant

    table1 - ID, First Name , Last Name , Address
    table2 - ID, First Name , Last Name , Address


    lets say they are assigned by state , NY to NY, MA to MA

  2. #2
    TurmoilMishka is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    3
    table1 - ID, First Name , Last Name , Address
    table2 - ID, First Name , Last Name , Address
    lets say they are assigned by state , NY to NY, MA to MA

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    You need to have a Foreign Key in the Consultant Table which equals the ID key in the Client table so that a relationship can be created. Make sure that your address fields(s) contain the State in a Separate field. I usually make it a number and have a separate table for states. This then avoids the issue of misspellings.

    Then you can run your query based upon one or more states.

  4. #4
    TurmoilMishka is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    3
    I might be not saying it correct.

    How does the database know that they are related by states during the query so Sally NJ and John NJ , Jake NY and Bill NY.

  5. #5
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    When you build your query you join on the state fields.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by TurmoilMishka View Post
    In my database i have Clients and Consultants. The Clients are Assigned to Consultants by State
    Which statement is correct?

    Statement 1: "One Client has one Consultant and one Consultant has many Clients"
    This is a one to many relationship. You need two tables.

    Consider tables:

    tblConsultants
    -------------
    ConsultantID_PK (Autonumber)
    FirstName (Text)
    LastName (Text)
    Address
    1 (Text)
    CityName (Text)
    StateName (Text)
    ZipCode (Text)


    tblClients
    -------------
    ClientID_PK (Autonumber)
    ConsultantID_FK (Number - Long) Link to tblConsultant
    FirstName (Text)
    LastName (Text)
    Address
    1 (Text)
    CityName (Text)
    StateName (Text)
    ZipCode (Text)




    Statement 2: "One Client has many Consultants and one Consultant has many Clients"
    This is a many to many relationship. You need three tables.

    Consider:

    tblConsultants
    -------------
    ConsultantID_PK (Autonumber)
    FirstName (Text)
    LastName (Text)
    Address
    1 (Text)
    CityName (Text)
    StateName (Text)
    ZipCode (Text)


    tblClients
    -------------
    ClientID_PK (Autonumber)
    FirstName (Text)
    LastName (Text)
    Address
    1 (Text)
    CityName (Text)
    StateName (Text)
    ZipCode (Text)


    jnctClientsConsultants
    --------------------

    ClientConsultID_PK (Autonumber)
    ClientID_FK (Number - Long) Link to tblClients
    ConsultantID_FK (Number - Long) Link to tblConsultants
    (Other fields if/as necessary)


  7. #7
    Join Date
    Apr 2017
    Posts
    1,792
    Statement 3: "One Client has one Consultant at any time moment, but may have different Consultants at different time moments"
    You again need 3 tables.


    tblConsultants
    -------------
    ConsultantID_PK (Autonumber)
    FirstName (Text)
    LastName (Text)
    Address
    1 (Text)
    CityName (Text)
    StateName (Text)
    ZipCode (Text)


    tblClients
    -------------
    ClientID_PK (Autonumber)
    FirstName (Text)
    LastName (Text)
    Address
    1 (Text)
    CityName (Text)
    StateName (Text)
    ZipCode (Text)

    tblClientsConsultants
    --------------------
    ClientConsultID_PK (Autonumber)
    ClientID_FK (Number - Long) Link to tblClients
    ConsultantID_FK (Number - Long) Link to tblConsultants
    ValidFrom (date)

    tblClients
    -------------
    ClientID_PK (Autonumber)
    ConsultantID_FK (Number - Long) Link to tblConsultant
    ...
    This looks like marriage in very chatolic country

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

Similar Threads

  1. Noob question on query design
    By Joshcorp in forum Queries
    Replies: 3
    Last Post: 08-28-2017, 07:58 PM
  2. Replies: 1
    Last Post: 01-05-2017, 10:10 PM
  3. Linked Tables and Query Design Question
    By burrina in forum Database Design
    Replies: 4
    Last Post: 01-06-2013, 01:04 AM
  4. Basic query design question
    By megabrown in forum Queries
    Replies: 1
    Last Post: 12-15-2010, 09:10 AM
  5. Query Design Question
    By copegjc15 in forum Queries
    Replies: 7
    Last Post: 11-13-2010, 10:28 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