Wayward
07-11-2005, 03:32 AM
I'm trying to create a table that automatically contains records for every permutation of the two foreign keys it imports. Let me explain with an example:
I have a Characters table:
CharacterID (Primary Key)
CharacterName
CharacterClass
[...]
And, I have a Skills table:
SkillID (Primary Key)
SkillName
SkillDescription
[...]
I want a third table named CharacterSkills to combine those two tables. It might look like this:
CharacterID (Primary Key)
SkillID (Primary Key)
CharacterSkillSlot
[...]
That looks a lot like a junction table for a many-to-many relationship. The difference is I want this table automatically filled with every combination of Characters and Skills. For example, if I have three characters and five skills this table would contain fifteen records. If I add a fourth character I'd expect this table to grow by another five records (as one record per skill is automatically added).
Here are those same tables with some example data.
Characters table:
CHR01, King Loo, [...]
CHR02, Humble Pie, [...]
CHR03, Jayne Bo, [...]
Skills table:
SK01, Amity, [...]
SK02, Diversion, [...]
SK03, Banish, [...]
SK04, Guilt, [...]
SK05, Shame, [...]
CharacterSkills table:
CHR01, SK01, [...]
CHR01, SK02, [...]
CHR01, SK03, [...]
CHR01, SK04, [...]
CHR01, SK05, [...]
CHR02, SK01, [...]
CHR02, SK02, [...]
CHR02, SK03, [...]
CHR02, SK04, [...]
CHR02, SK05, [...]
CHR03, SK01, [...]
CHR03, SK02, [...]
CHR03, SK03, [...]
CHR03, SK04, [...]
CHR03, SK05, [...]
Any pointers on how to create this magical third table, or whether it' possible at all, will be greatly appreciated.
I have a Characters table:
CharacterID (Primary Key)
CharacterName
CharacterClass
[...]
And, I have a Skills table:
SkillID (Primary Key)
SkillName
SkillDescription
[...]
I want a third table named CharacterSkills to combine those two tables. It might look like this:
CharacterID (Primary Key)
SkillID (Primary Key)
CharacterSkillSlot
[...]
That looks a lot like a junction table for a many-to-many relationship. The difference is I want this table automatically filled with every combination of Characters and Skills. For example, if I have three characters and five skills this table would contain fifteen records. If I add a fourth character I'd expect this table to grow by another five records (as one record per skill is automatically added).
Here are those same tables with some example data.
Characters table:
CHR01, King Loo, [...]
CHR02, Humble Pie, [...]
CHR03, Jayne Bo, [...]
Skills table:
SK01, Amity, [...]
SK02, Diversion, [...]
SK03, Banish, [...]
SK04, Guilt, [...]
SK05, Shame, [...]
CharacterSkills table:
CHR01, SK01, [...]
CHR01, SK02, [...]
CHR01, SK03, [...]
CHR01, SK04, [...]
CHR01, SK05, [...]
CHR02, SK01, [...]
CHR02, SK02, [...]
CHR02, SK03, [...]
CHR02, SK04, [...]
CHR02, SK05, [...]
CHR03, SK01, [...]
CHR03, SK02, [...]
CHR03, SK03, [...]
CHR03, SK04, [...]
CHR03, SK05, [...]
Any pointers on how to create this magical third table, or whether it' possible at all, will be greatly appreciated.