COMP3311 20T3 The University of New South Wales Database Systems
COMP3311 Database Systems
20T3
[Instructions] [Notes] [Database] [Course Website] [Cheat Sheets]
[Q1] [Q2] [Q3] [Q4] [Q5] [Q6] [Q7] [Q8] [Q9] [Q10] [Q11] [Q12]
Question 4 (9 marks)
Write a PLpgSQL function that takes the names of two teams ans returns the number of
matches that they have played against each other.
create or replace function Q4(_team1 text, _team2 text) returns integer … If the teams have never played against each other, the function should return 0. If either of the
function parameters is not the name of a team, return NULL.
Instructions:
Work on this question in the work/q4/ directory
Define the function q4(…) in the file q4.sql
Also, place any additional views used by q4 in this file Additional views must be placed before the q4 definition
Load it into your database using: psql footy -f q4.sql Sample output is in the file: tests/01.expected
Test it via: select * from q4(‘Australia’,’France’); Checkitusing: ./checkintheq4directory
Submit it using: give cs3311 sample_q4 q4.sql or Webcms3
End of Question