Forum Discussion

JasmineSexton's avatar
JasmineSexton
Qrew Member
3 years ago

Need help building a relationship between counties in multiple districts !!!!

I have two tables, a district and a county table. I currently have a relationship where there is more than one county per district. I want the total number of counties to report under their corresponding district. The tricky part is for counties that are in more than one district, how can I get this county to display in both districts? Right now I'm using a multi-select text field for district selection. 

Example: County A is in District 1 and 2, my current setup allows me to pick either district 1 or 2, or create a new district called "1&2". However, I want County A to report in BOTH district 1 and 2 separately. 
THANKS!!

-----------------------------
------------------------------

2 Replies

  • KimG's avatar
    KimG
    Qrew Cadet
    Hi

    I'm not sure if you actually need a many-to-many relationship, or if you just need to switch the relationship from more than one county per district to more than one district per county.

    If your Counties and Districts would look like this, then you have a many-to-many relationship:

    As in:
    • County A is in District 1, 2, 5
    • County B is in District 3, 4
    • County C is in District 3, 5 6

    If a District is only in one county then, it would look like this:
    As in: 
    • County A is in District 1, 2
    • County B is in District 3, 4
    • County C is in District 5, 6
    So, if what you have is like the first example and Counties can have multiple Districts, AND Districts can have multiple counties, then you need to set up a many-to-many relationship through a third table.

    If it looks like the second, then you just need to change the relationship from more than one County to District to more than one District per County.

    ------------------------------
    Kim G
    ------------------------------
    • JasmineSexton's avatar
      JasmineSexton
      Qrew Member
      Thank you! I was able to make the table work by using a many-to-many relationship!

      ------------------------------
      Jasmine Sexton
      ------------------------------