I have a table that stores "Matches" these matches have the following columns: MatchId, TeamA, TeamB, Wager,Winner
I want to be able to make TeamA and TeamB return a list of players for each team. The number could be arbitrary for each one, is this possible or even practical? I cant think of any other way of designing this. Is there a better schema over all for this? The players are going to be UserId's and a user is not bound to a team, the team is only relative to the match.
EDIT: For instance, Player A, B, C, D, E, F
Match 1: 3v3 ABC vs DEF
Match2: 3v3 DAB vs FEC
The player should not be bound to any specific TeamId because it is only dependant on the match. A player can team up with anyone he or she desires in a match.
A possible database schema could look like this:
You can then select out of it like so:
SELECT M.*, P.*
FROM Matches M
JOIN MatchPlayers MP ON MP.MatchID = M.MatchID
JOIN Players P ON P.PlayerID = MP.PlayerID
WHERE M.TeamA_ID = MP.TeamID OR M.TeamB_ID = MP.TeamID
Excuse me if my SQL is rough around the edges or the schema is rubbish - it should likely, probably, hopefully, marginally work.
That particular SQL doesn't tell you the team the player was in, but the information is there to be had with some small changes.
For what you want, data that relates to other data, serialization is not the answer - or it's not what you think... I sense a terminology mismatch there. Read up on using databases from .NET - there are lots of great tutorials on the web. Also read up on relational database design, again web sources are great for this.