Link to home
Start Free TrialLog in
Avatar of shanemay
shanemayFlag for United States of America

asked on

Fill a dataset with multiple linked tables.

I have a database with events, each event has multiple organizers and multiple classifications. I am wondering the best manner in which to fill a dataset with the data so I can map the dataset to my event class.  Any advice would be greatly appreciated.

A little framework - I have a eventID that is a foreign key in two tables one that contains organizerID and  the other that contains a classificationID.   I can easly query the database three times and get the data.  Is that the best way?  Or is it possible to get all the data in a single dataset?


   
Avatar of shanemay
shanemay
Flag of United States of America image

ASKER

Below is the query that I am using.  I used EVENT.* to shorten the code sample.  
SELECT     EVENT.*, EVENT_CLASSIFICATIONS.classificationID, EVENT_ORGANIZERS.organizerID
FROM         EVENT INNER JOIN
                      EVENT_CLASSIFICATIONS ON EVENT.eventID = EVENT_CLASSIFICATIONS.eventID INNER JOIN
                      EVENT_ORGANIZERS ON EVENT.eventID = EVENT_ORGANIZERS.eventID
ORDER BY EVENT.eventID, EVENT_CLASSIFICATIONS.classificationID, EVENT_ORGANIZERS.organizerID

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for the responses.  I think I might be on the correct path.  However,
Filling the dataset in one sql statement is what I am doing currently, then I have a DataMap method that maps the data from the dataset into the Event Class.  However, with all the data contained in a single dataset, the logic is rather complex to ensure that the correct contributorIDs and classificationIDs are mapped into ArrayLists.  Because all the data is in the same dataset multiple copies of the data must be sorted and discarded.  Is there a better way to map the data?  
Thank you for your comments, time, and consideration on my behalf.