Enforce Multiple Relationships Between Two Tables In Access
Asked Answered
T

1

5

I want to create (and enforce) multiple "one-to-many" relationships between the primary key of one table to attributes of another.

Hopefully this example will explain better. I have a table for a character in a game. The character can hold one item in each hand.:

Table: GamePlayer
gamePlayerID    Number  PK
name            Text    Unique
classID         Number  FK->PlayerClass.classID
leftHandItem    Number  FK->Items.itemID
rightHandItem   Number  FK->Items.itemID

How do I implement the leftHandItem -> Items.itemID and rightHandItem -> Items.itemID with enforcing referential integrity.

Tranquilizer answered 2/8, 2011 at 16:7 Comment(0)
G
7

In the Relationships window, add the Items table twice. The second occurence will automatically get an alias. Use the 2 occurences like if they were 2 distinct tables to create relationships.

Gusgusba answered 2/8, 2011 at 16:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.