First DB issue (1 Viewer)

MrBLT

Registered User.
Local time
Tomorrow, 04:35
Joined
Oct 2, 2003
Messages
20
I'm trying to make a basketball database and i was going to enter each team in seperately. However whenever i enter a new team in say my score table, there is an error saying that it would create duplicate errors in the index, primary key or relationship. Why is this happening, or how can i get around this problem
Thanks
 

MrBLT

Registered User.
Local time
Tomorrow, 04:35
Joined
Oct 2, 2003
Messages
20
sorry about that
my table structure are as follows

gameid
date
home
away
venueid
homeATS
awayATS

gameid
1stqtr
2ndqtr
3rdqtr
4thqtr

gameid
teamid
fgm
fga
3ptm
3pta
ftm
fta
reb
foul
assist
block
steal
turnover

teamid
team

venueid
venue

this is my first database. it may be that my tables aren't right, i'm not sure.
Thanks. hope this is helpful
 

MrBLT

Registered User.
Local time
Tomorrow, 04:35
Joined
Oct 2, 2003
Messages
20
so basically i have the game info in the 1st table

gameid
date
home
away
venueid
homeATS
awayATS

i home team scores in the 2nd table

gameid
1stqtr
2ndqtr
3rdqtr
4thqtr

when i try to enter the away team scores in the same table using the same gameid, it tell me that there is an error saying that it would create duplicate errors in the index, primary key or relationship.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:35
Joined
Feb 19, 2002
Messages
43,266
The scores table needs a two-field primary key.

gameid (pk, field1)
teamid (pk, field2)
1stqtr
2ndqtr
3rdqtr
4thqtr

I would change this table further to normalize it which will make it more flexible.

gameid (pk, field1)
teamid (pk, field2)
periodid (pk, field3)
Score

With this structure, the table can hold scores for any number of periods. For example, 4 periods plus 1 or more others for overtime for basketball or football. Three periods plus a fourth for overtime for hockey. Nine innings, plus any additional innings for baseball. I would also normalize your play table in a similar way. You could even keep the play stats by period if you want that level of detail.
 

Users who are viewing this thread

Top Bottom