this is an old post, but just in case you're still working on it:
as i understand it, one activity may have many elements, and one element may
be included in many activities - as you posted previously, that is a
many-to-many relationship. a template is the assignment of one or more
specific elements to a specific activity - the "union" or "join" table
between activities and elements, forming the -many side of a one-to-many
relationship with each of those two tables. and one user may create many
templates, but each template is created by only one user - a one-to-many
relationship.
if the above is correct, try the following tables/relationships structure,
as
tblUsers
UserID (primary key)
UserName
UserCode
UserRights
tblActivities
ActivityID (pk)
ActivityCode
ActivityName
ActivityDescription
tblElements
ElementID (pk)
ElementCode
ElementName
ElementDescription
tblActivityElements
UserID (foreign key)
ActivityID (fk)
ElementID (fk)
<you could assign a surrogate primary key here, or use the three foreign key
fields as a combination primary key.>
relationships would be
tblUsers.UserID 1:N tblActivityElements.UserID
tblActivities.ActivityID 1:N tblActivityElements.ActivityID
tblElements.ElementID 1:N tblActivityElements.ElementID
though if you are tracking additional data that describes a specific
*activity* of a specific *user*, you may want two tables here instead of
one, as
tblUserActivities
UserActivityID (pk)
UserID (fk)
ActivityID (fk)
<other fields that describe a specific activity as related to a specific
user - there should be no fields describing elements, in this table.>
tblUserActivityElements
UserActivityID (fk)
ElementID (fk)
<you could assign a surrogate primary key here, or use the two foreign key
fields as a combination primary key.>
relationships for the two tables above would be
tblUsers.UserID 1:N tblUserActivities.UserID
tblActivities.ActivityID 1:N tblUserActivities.ActivityID
tblUserActivities.UserActivityID 1:N
tblUserActivityElements.UserActivityID
tblElements.ElementID 1:N tblUserActivityElements.ElementID
hth
tina
What's the relationship? Which field is it linked to?
Well... then it will take even longer for me to explain the answer, since
I
don't really understand the question!
How are Users, Activites and Elements related?
What is a "template table"? That doesn't appear to be an Access term.
That's not a question, and I'm not at all sure what you're trying to say!
Let's keep at this... again, if you could describe (in general terms, you
needn't post your entire business rule set) what real life Entities each
table
represents, and how those entities are related to one another in the real
world, we should be able to help.
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see alsohttp://
www.utteraccess.com
I have user, activity, element and user template four tables.
user table has following fields
user id, user name, user code, user rights.....
actitivy table has following fields
activity id, activty code, activity name, actiivty description,
Element table has following fields
Element id, element code, element name, element description,
and I am design user template to let user fill the information from
user template table base on user creates the combination of activity
and element the relationship between activity and element is many to
many.
I need have a composite key for user template table which is user id,
activity id and element id to get right template base on user's
activity and element selection.
It seems that I need use the middle table of activity and element
table for their many to many relationship and user template table to
link with user table and activity element table.
Thanks again for helping,