Results 1 to 5 of 5
  1. #1
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    110

    Many-to-Many Self Join

    I was discussing this in another thread but it was way off topic so I'm reposting it here.



    Short version: I need to know how to setup a Self Join for a table with a many-to-many relationship to itself.

    Long Version: I have a table of Objects (i.e. Desktop Computers, Access Points, Offices, Personnel). Many of these Objects have other Objects as properties (Users belong to an Office, Desktop Computers belongs to a User, etc.). So, because of things like Users being able to belong to multiple Offices, but also, of course, multiple Users being able to belong to one Office, it needs to be a many-to-many relationships. There's also an ObjectType table and each Object Type can be assigned and ObjectType as a property as well. I'd like for my final forms to be datasheet forms. Each datasheet represents all the Objects in one ObjectType and each column is an ObjectType associated as a property to the datasheet's ObjectType. Here's my current structure:

    tblJunctionObjectTypes
    -JunctionID pk
    -ObjectTypeID fk (The ObjectType receiving another ObjectType as a property)
    -PropertyObjectClassID fk (The ObjectType being assigned as property.)

    tblObjectTypes
    -ObjectTypeID pk
    -ObjectCTypeName

    tblObjects
    -ObjectID pk
    -ObjectTypeID fk

    tblPropertyObjects
    -PropertyID pk
    -ObjectID fk (The Object receiving an Object as a property)
    -AttributeObjectID fk (The Object being assigned as a property)


    How do I setup the relationships and how do I build a query that gets all Objects of a particular ObjectType and all the Objects of ObjectTypes associated <i>to</i> it.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Um, you say you "have a table of objects" then you list 4 table definitions? I'm confused.

    You can link tables to each other using the Relationships window - drag column names from one table to another.

  3. #3
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    110
    I did say that "I have a table of objects" (tblObjects), but then a couple lines down I said I have a table of ObjectTypes as well (tblObjectTypes). I then explained that these tables need to have a many-to-many relationship with themselves, which requires there be a junction table for each (tblJunctionObjectTypes, tblPropertyObjects).

    I understand how to create relationships, what I need to learn is how to make self joins and specifically how to make a self join when it's a many-to-many relationship.

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Sorry, in way over my head here. I would just make them all separate tables.

  5. #5
    brharrii's Avatar
    brharrii is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2012
    Location
    Seattle, WA
    Posts
    63
    Did you ever find an answer to this question? I've been trying to figure out how to do this but I can't find any deffinitive answers.

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

Similar Threads

  1. Join 2 Querys
    By afslaughter in forum Queries
    Replies: 4
    Last Post: 12-07-2011, 02:59 PM
  2. Outer Join Nested in Inner Join
    By Stevens7 in forum Queries
    Replies: 2
    Last Post: 10-19-2011, 01:34 PM
  3. SQL - Inner Join
    By springboardjg in forum Queries
    Replies: 1
    Last Post: 05-12-2011, 05:10 AM
  4. Help with right join
    By usa_dreamer2002 in forum Queries
    Replies: 3
    Last Post: 02-25-2011, 04:47 PM
  5. inner join in query
    By Hrcko in forum Access
    Replies: 1
    Last Post: 02-01-2010, 05:54 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