给定一个设计:
Player
===========
PlayerID
TeamID
FirstName
LastName
DateOfBirth
Team
===========
TeamID
TeamName
Grade
Match
===========
MatchID
HomeTeamID
AwayTeamID
Date
Result
我正在使用这个:
CREATE TABLE Match(
MatchID VARCHAR2(5) NOT NULL,
Dateofmatch date,
Result VARCHAR2(1) ,
HomeTeam VARCHAR2(5),
AwayTeam VARCHAR2(5),
CONSTRAINT MatchPK PRIMARY KEY(MatchID),
CONSTRAINT HomeFK FOREIGN KEY(HomeTeamIDFK) REFERENCES TEAM(TeamID),
CONSTRAINT AwayFK FOREIGN KEY(AwayTeamIDFK) REFERENCES TEAM(TeamID),
CONSTRAINT Result
Check (Result in (‘W’,’L’,’D’)
);
假设 Match ID、Player ID 和 teamID 列是 data type 来创建 Match 表VARCHAR2(5)
。比赛结果以主队为准,只能是 W、L 或 D。
这个对吗?
我已经出来了,请纠正我
CREATE TABLE Match (
MatchID VARCHAR2(5) NOT NULL,
Dateofmatch date,
Result VARCHAR2(1) ,
HomeTeam VARCHAR2(5),
AwayTeam VARCHAR2(5),
CONSTRAINT MatchPK PRIMARY KEY(MatchID),
CONSTRAINT HomeFK FOREIGN KEY(HomeTeamIDFK) REFERENCES TEAM(TeamID),
CONSTRAINT AwayFK FOREIGN KEY(AwayTeamIDFK) REFERENCES TEAM(TeamID),
CONSTRAINT Result Check (Result in (‘W’,’L’,’D’)
);