mattsmith321 wrote:
Hi all!
I've got two tables: Members and Events. Multiple members can 'belong' to an event so I have a EventMembers table that is two columns: EventID and MemberID.
When I am adding an event, I need to add any associated members to the EventMembers table. In the help file, there is an example that demonstrates adding related entities but that example appears to deal with tables with a single primary key. So, can I do what I need to do with the combination EventID+MemberID primary key, or should I add a new primary key column and create a unique constraint to enforce the relationships?
Any help for outlining approaches on this would be great.
Matt
I need to restate my question because I think I left out some critical bits of information which caused the wrong question to be answered.
First, I'm using the Adapter pattern and it is for a web app.
Second, the specific scenario that I am trying to address is when saving an Event. The Event form has a list of available Members that can belong to the Event. When creating an Event, the user would check the Members that need to belong to the Event. So, when saving an Event for the first time, I will have at least one (requirement), possibly more, Member that belongs to the Event. So, when creating an Event, I don't have an EventID to populate the EventMembers entity with prior to the transaction. I could save the Event, get the EventID and then save the EventMembers separately but as I mentioned, it appears from the help doco that you can save an Event that has EventMembers associated to it and it will save all of it for you. So, my question is: will it be able to populate the correct EventID into the EventMembers?
Follow-up question: Saving a new Event is relatively straight forward since you know that you are saving a new Event and whatever new EventMembers were chosen. However, what is the best strategy for saving changes to an Event where the EventMembers have been checked (or unchecked) by the user? Do I query for all associated EventMembers, delete them and then add back the chosen EventMembers? Or do I query the list of EventMembers and then iterate through the list comparing it to the latest selected members (which may or may not have been changed, or new members selected, or a member dropped from the event) and add a collection of EventMembers to Event that has the various states selected for Delete this association, Add this association, etc.
I'm just looking to find out how much LLBL Gen Pro can handle because of built-in functionality versus what I need to do custom. And whether things would be easier with a different primary key on the EventMembers table versus a compound primary key with EventID and MemberID.
Thanks for any help you can provide and if you need additional clarification, please let me know.
Matt