954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Foreign keys from one table to a parent field

I use the TableAdapter Configuration Wizard under VS2008 and use SQL Server Express.

This is my database diagram:

Database structure

And this is my SELECT statement:

SELECT        Parties.PartieID, Parties.RondeID, Parties.JoueurNoirID, Parties.JoueurBlancID, Parties.ScoreNoir, Parties.ScoreBlanc, Parties.VainqueurID, 
                         Parties.DetailVictoire, Rondes.Numero, Tournois.Nom, <strong>(SELECT  Pseudonyme FROM Joueurs WHERE JoueurID = Parties.JoueurNoirID) AS JoueurNoir, (SELECT  Pseudonyme FROM Joueurs WHERE JoueurID = Parties.JoueurBlancID) AS JoueurBlanc, (SELECT  Pseudonyme FROM Joueurs WHERE JoueurID = Parties.VainqueurID) AS Vainqueur</strong>

FROM            Parties INNER JOIN
                         Rondes ON Parties.RondeID = Rondes.RondeID INNER JOIN
                         Tournois ON Rondes.TournoiID = Tournois.TournoiID INNER JOIN
                         Joueurs ON Parties.JoueurBlancID = Joueurs.JoueurID AND Parties.JoueurNoirID = Joueurs.JoueurID AND Parties.VainqueurID = Joueurs.JoueurID

First, how to formulate to use JOINS instead of theSELECTs on Joueurs subqueries?

Second, is it the best to have three foreign keys related to the same parent indexed field? (i don't see how to do differently)

Any help would be very appreciated.

Greetings,

Nicolas

legal101205
Newbie Poster
1 post since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Can you post the table schema

dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You