Appendix
Complete
Logical Model
A) Relvar Definitions
POINTSYSTEM
Heading:
{POINTSYSTEMNAME(STRING)}
Key:
{POINTSYSTEMNAME}
Predicate:
Point system named §pointsystemname§ can be used for ranking.
TOURNAMENT
Heading:
{TOURNAMENTID(INT) TOURNAMENTNAME(NAME) TOURNAMENTSTARTDATE(DATE)
TOURNAMENTENDDATE(DATE) POINTSSYTEMNAME(STRING)}
Key:
{TOURNAMENTID} {TOURNAMENTNAME}
Predicate:
Tournament idendified by §tournamentid§ is titled $tournamentname$,
starts/started on §tournamentstartdate§ and ends/ended on
§tournamentenddate§ and uses point system §pointsystemname§.
TOURNAMENTROUND
Heading:
{TOURNAMENTID(INT) ROUNDID(INT) ROUNDEXPECTEDSTARTDATE(DATE)
ROUNDEXPECTEDENDDATE(DATE)}
Key:
{TOURNAMENTID, ROUNDID}
Predicate:
Round number §roundid§ of tournament §tournamentid§ has expected
start date of §roundexpectedstartdate§ and expected end date of
§roundexpectedenddate§.
PLAYER
Heading:
{PLAYERID(INT) PLAYERNAME(NAME)}
Key:
{PLAYERID} {PLAYERNAME}
Predicate:
Player idendified by §playerid§ is named §playername§.
MATCHDRAW
Heading:
{TOURNAMENTID(INT) ROUNDID(INT) MATCHID(INT) PLAYERID(INT)}
Key:
{TOURNAMENTID, ROUNDID, PLAYERID} {MATCHID, PLAYERID}
Predicate:
Player §playerid§ is drawn to play match §matchid§ of round
number §roundid§ of turnament §tournamentid§.
MATCHTABLE
Heading:
{MATCHID (INT) TABLESTRENGTH(INT)}
Key:
{MATCHID}
Predicate:
Match §matchid§ is played on table with difficulty §tablestrength§.
MATCHSCORE
Heading:
{MATCHID(INT) PLAYERID(INT) MATCHSCORE(INT)}
Key:
{MATCHID, PLAYERID}
Predicate:
Player §playerid§ scored §matchscore§ in match §matchid§.
B) Database Constraints Definitions
Count of players for each match (identified by Match ID) has to be
either 3 or 4 (finds tuples which violate the rule).
restrict(summarizeby(matchdraw,(matchid),(noofplayers(count))),
noofplayers < 3 or noofplayers > 4)
Match table has to
exists for each match of a round or for none of them (finds tuples
which violate the rule).
semiminus(
project(
join(
semijoin(
tournamentround
,join(
project(
matchdraw
,(matchid,roundid,tournamentid))
,matchtable))
,project(matchdraw,(matchid,roundid,tournamentid)))
,(matchid))
,matchtable)
The only allowed values
for Match Scores are even integers (finds tuples which violate the
rule).
not(mod(matchscore,2)
= 0)
Sum (Match Score) for
each match (identified by Match ID) has to be zero (finds tuples that
violate the rule).
restrict(summarizeby(matchscore,(matchid),total(sum(matchscore))),
total <> 0)
If a Match Score
exists, it has to contain scores for all players who played the
match. These players have to be the same as the players in the Match
Draw for the same match (finds tuples that violate the rule).
semiminus(
join(
matchdraw
,semijoin(
project(matchdraw,(matchid))
,project(matchscore,(matchid))))
These rules enforce what's usually referred to as foreign keys.
Tournament
round has to refer to an existing tournament.
Match
Draw has to refer to an existing tournament round.
Match
Draw has to refer to an existing player.
Match Score has to refer to an existing Match Draw.
Match Table has to refer to an existing Match Draw.
Match Score has to refer to an existing Match Draw.
Match Table has to refer to an existing Match Draw.
semiminus(tournamentround,project(tournament,(tournamentid)))
semiminus(matchdraw,project(tournamentround,(tournamentid,
roundid)))
semiminus(matchdraw,project(player,(playerid)))
semiminus(matchscore,project(matchdraw,(matchid,
playerid)))
semiminus(matchtable,project(matchdraw,(matchid)))
