You have a couple of ways you could do this, but regardless of how you do it I would ensure that every (jack, port, pair) has a unique idea that unique amongst all items. There is a reason for this because you bring them all back together into a big query where items from 3 tables get treated as "connectors".
1)Approach 1. Leave them in seperate tables but use a text field for each id. Also give the field a unique name not "id": port_ID, Jack_ID, and pair_ID. You may have to use some code to create the IDs.
A. So for the jack table I made my ids
J100,J101...J117
If I added a new one either manually or with code it would be J118
For the pairs they are
PA1, PA2,...PA101.
(If I had the time I would have made them PA1001 to PA1101 so that they could sort normally)
For the Ports I used
PO10...PO16
B. A modification to this approach would be to use a "natural key" instead of coming up with these artificial keys. If you had unique names for the pairs (or if you can come up with unique names for the pairs) a better solution would be to use the unique names as the keys for jacks, pairs, and ports. This would really make things easier to see and more intuitive. Then you would have these PKs for jacks:
21-1
21-2
21-3
21-4
21-5
21-6
21-7
...
and ports
01A0201
01A0202
02B0101
02B0105
...
Then in your tables you can see that 21-1 connects to 01A0201 without the need for a more complicated query.
Unfortunately Pairs do no not have unique names.
C. Now the trick is to bring everything together into a union query. So that all items appear in one table.
Code:
SELECT
"Pair" as item_type,
pair_id as item_id,
pair_name as item_name,
closet_id_1,
closet_id_2
FROM
pairs;
UNION
SELECT
"Port" as item_type,
port_id,
port_name,
closet_id as closet_id_1,
null as closet_id_2
FROM
ports
UNION SELECT
"Jack" as item_type,
Jacks.jack_id as item_id,
Jacks.jack_name as item_name,
closet_id as closet_id_1,
null as closet_id_2
FROM
Jacks;
Now this query can be joined to your connection table. Although, I am suggesting a different approach then you, this concept would be the answer to the approach you where trying. In your table xConnects table you would connect Start_id to this query, and End_Id to another instance of this query to pull in all of the details.
2) Approach 2 would be to put all items into one single table. This simplifies a lot of things. It is not perfect because there are a few different fields between ports, jacks, and pairs. But it may make things much easier. In this case I could use an autonumber for a primary key because I can ensure that everything would have a unique id. My single table looks like
tblConnectors
item_id (PK and could be a simple autonumber)
item_type ("Jack", "Port", or "Pair")
item_subType (for ports you could have "Analog" or "Digital")
closet_1_ID (this is just the closet id for jacks and ports and the closet 1 ID for pairs)
closet_2_ID (this is null for jacks and ports and the closet 2 ID for pairs)
The union query above, is basically creates the table above without but just starting with seperate tables.
3) My connection table is simply
xconnID (a key representing a connection)
item_id ( a foreign key to a port, jack, or pair)
start_id (a key that shows which item the item_id is connected to)
Here is an example:
xconn_id item_id start_id
1 J100
6 PA10 J100
7 J114
8 PA77 J114
9 PA50 PA77
This shows that J100-PA10
and J114-PA77-PA50
Do not need any other information. Site, closet information would come from the query related through the item_id.
4) If the single table concept would work, then you can even do away with the connection table. You would just add the field
start_ID to the tblConnectors.
This demo use the Union query approach. Even if the tree view does not work take a look at the union query and then a look at the connection data query.
Bottom line. There are several possible approaches, but whatever way you go somehow you need to bring all the connectors into a single "table" with unique IDs. Either a union query or start with everything in a union query. This is the same if you go with your approach of showing start and ends of connections, or as I do and just show each item and where it connects.
So it is your choice for the starting point.
1)Put jacks, ports, and pairs into a single table.
2)Keep jacks, ports, and pairs in own table with keys unique across the tables.