CREATE TABLE Matches
(
mID INTEGER PRIMARY KEY,
date DATE NOT NULL,
location CHAR(25) NOT NULL,
teamA CHAR(15) NOT NULL,
goalsForA INTEGER,
pointsA INTEGER,
teamB, CHAR(15) NOT NULL,
goalsForB INTEGER,
pointsB INTEGER,
/*
M1: The match number must be under 65
*/
CONSTRAINT M1 CHECK (mID < 65),
/*
M2: location must refer to stadiumName in the Locations.
*/
CONSTRAINT M2 FOREIGN KEY (location) REFERENCES Stadiums (stadiumName)
ON DELETE CASCADE,
/*
M3:
*/
CONSTRAINT M3 ()
)
好吧所以我需要这样做,所以pointsA和pointsB由goalForA和goalsForB计算。如果goalsForA = goalsForB,则pointsA和pointsB各获得1。如果goalForA&gt; goalForB,然后pointsA得到3加,反之亦然B.我的教授从未教过我们如何做到这一点,我无法在任何地方找到它。
答案 0 :(得分:0)
作为一般规则,不要存储您可以计算的内容。创建一个没有pointsA和pointsB的表,然后用计算列来查看表。