COMP3311 26T1 Assignment 1
SQL Schema
Database Systems
Last updated: Fri 11th Mar 2026
Most recent changes are shown in red ... older changes are shown in brown.

[Assignment Spec] [SQL Schema] [Examples]

Football/soccer/whatever is touted as the World Game†, and there are a plethora of sites dedicated particularly to international competition. Consider the following database design that could sit behind one such site:

Note that we have omitted the primary keys in the above diagram. They are all implemented as numeric attributes in

An SQL schema based on this design:

-- Football/Soccer Schema

-- Time in minutes since game started
create domain game_time as integer check (value between 0 and 90);

-- Cards are warnings given to players for naughty acts
-- Yellow card = final warning;  Red card = send off
create domain card_colour as varchar(6) check (value in ('red','yellow'));

-- Tables

create table matches (
	id          integer,
	city        varchar(50) not null,
	played_on   date not null,
	primary key (id)
);

create table teams (
	id          integer,
	country     varchar(50) unique not null,
	primary key (id)
);

create table involves (
	match       integer     not null,
	team        integer     not null,
	is_home     boolean     not null,
	primary key (match, team),
	foreign key (match) references matches(id),
	foreign key (team)  references teams(id)
);

create table players (
	id          integer,
	name        varchar(50) not null,
	birthday    date,
	member_of   integer not null,
	position    varchar(20),
	primary key (id),
	foreign key (member_of) references teams(id)
);

create table goals (
	id          integer,
	scored_in   integer not null,
	scored_by   integer not null,
	time_scored game_time not null,
	rating      varchar(20),
	primary key (id),
	foreign key (scored_in) references matches(id),
	foreign key (scored_by) references players(id)
);

create table cards (
	id          integer,
	given_in    integer not null,
	given_to    integer not null,
	time_given  game_time not null,
	card_type   card_colour not null,
	primary key (id),
	foreign key (given_in) references matches(id),
	foreign key (given_to) references players(id)
);

Some assumptions made in developing the above schema:

You should familiarise yourself with this schema before proceeding to solve the queries. It would also be useful to examine the database contents to ensure that you understand what all of the data represents.

† even though Aussie Rules is clearly a much better game ...

End of Notes