Results 1 to 6 of 6
  1. #1
    Autoclave is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    7

    Combining N:N with 1:N relationships

    Hello dear friends!
    I have the following issue designing the relationships in my db.

    N:N relationship
    I have a list of companies and a list of tags.
    Each COMPANY can have multiple TAGS, the same TAG can be assigned to multiple COMPANIES.

    1:N relationship
    One TAG can have multiple SUBTAGS.

    Now, COMPANIES and SUBTAGS relationships:


    One COMPANY can have 0-to-many SUBTAGS within one TAG.

    How do I design this relationship? Companies, Tags, and Subtags are one table each.

    Thank you very much in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What you describe (the first one) is a many-to-many relationship. That is typically handled with a junction table (you'd still have the other 2). Let's call it "CompanyTags". It would have fields for the company ID field and the Tags ID field, and typically it's own ID field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Autoclave is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    7
    I have some experience with Many-to-many relantionships and junction tables. So this is not really the problem for me. The problem is how to connect the SUBTAGS to all this, which are N:1 with Tags.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Unless I'm missing something, that would simply be a one-to-many relationship with Tags. No direct relationship with the other tables.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    To view all the subtags for one company's tags, write a query like this:
    SELECT C.COMPANYNAME, T.TAGNAME, S.SUBTAGNAME FROM C AS COMPANIES INNER JOIN ((COMPANYTAGS AS CT ON C.COMPANYID = CT.COMPANYID) INNER JOIN TAGS AS T ON T.TAGID = CT.TAGID) INNER JOIN SUBTAGS AS S ON S.SUBTAGID = S.TAGID.

  6. #6
    Autoclave is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    7
    Thank you, goodguy, I will try it ASAP, and report if it works exactly as I want.

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

Similar Threads

  1. Combining first and last name
    By JRINC in forum Forms
    Replies: 3
    Last Post: 09-27-2011, 01:18 PM
  2. combining two queries
    By camell in forum Queries
    Replies: 4
    Last Post: 03-04-2011, 02:41 PM
  3. Combining queries
    By wildlifeaccess in forum Queries
    Replies: 10
    Last Post: 09-20-2010, 07:35 AM
  4. Combining events
    By daddylongtoe in forum Access
    Replies: 4
    Last Post: 06-25-2010, 02:55 AM
  5. Combining fields
    By cotri in forum Forms
    Replies: 2
    Last Post: 01-18-2010, 12:06 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