I need to create a procedure that will store data into 3 tables, while using data from each table to reference the rest.
E.g.: I am creating a team challenge database. This will allow a person to challenge another, setup who will be in each others teams, then store in into a database.
I have a primary table which stores the matchId, initiatorName, teamOneListId
and teamTwoListId
.
- TeamOneList:
ID, memberID, TeamName
- TeamTwoList:
ID, memberID, TeamName
As you can see, I need to add data into all of them at once (While having the team size and limits vary for 1v1, 3v3 etc).
I am using C# Asp.Net, and am well-versed in Transactions. I am just not too clued up in databasing.
EDIT: Wrote this at the end of a long hard day.
The question is, what would be the simplest way or method of going about this?
I've tried to mess around with the stored procedure, I can forward identities to the different tables, but it seems I still have to create a new stored procedure for both teams, and for every type of event.
The only way I could get the aforementioned working was to start a match, get the last row's information, and forward that to a second page binding the rest of the 2 teams information into the database.
So to reiterate, I need to know how to do all this at once, or have a way of not simply getting the last row (that might be wrong?).