If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Tables design help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-10-05, 07:07
kevinq kevinq is offline
Registered User
 
Join Date: Feb 2005
Posts: 1
Tables design help

Hello,

I am creating a web application to provide the form of football (soccer) matches. The problem I have is with the relationship between the tables TEAM and MATCH.

I have a table TEAM...

teamid (PK)
teamname

and a table MATCH...

matchid (PK)
hometeamid (FK relating to team.teamid)
awayteamid (FK relating to team.teamid)
hometeamgoals
awayteamgoals
matchdate

The relationship works fine but when it comes to caculating the amount of points for each team or the current league tables etc, the sql becomes quite complicated and a little cumbersome.

I would be grateful if anyone could suggest a more suitable, more efficient structure.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 02-10-05, 07:10
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
the sql is not complicated at all, you just need to join to the team table using an OR join condition

and that is the best table design

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On