THE AUSTRALIAN NATIONAL UNIVERSITY Mid-Semester Examination August 2006 RELATIONAL DATABASES (COMP2400) Reading Time: 10 minutes Writing Time: 1 hour Permitted Materials: One A4 sheet with notes on both sides Notes may be handwritten or printed/typed The A4 sheet may be a photocopy Total Marks: 30 If your examination paper is missing any pages, or if any pages are illegible, raise your hand and ask for another examination paper. In addition to the examination paper, you should have received a sheet of scribble paper. You may ask for more scribble paper. All answers are to be written on the examination paper. Write your student number on every page of your examination paper. Write your name on this cover sheet in UPPERCASE. At the end of the examination, hand in your A4 sheet of notes and your scribble paper as well as your examination paper. Your A4 sheet of notes and your scribble paper will be destroyed. Only the examination paper will be marked. If you are ill during the examination, or otherwise suffer adverse circumstances during the examination, advise an invigilator immediately. FAMILY NAME: GIVEN NAME: Page 1 of 10 RELATIONAL DATABASES (COMP2400)
GENERAL INSTRUCTIONS Write all your answers on the examination paper. Write your Student Number neatly, especially on the pages which contain a Part header (eg Page 3). Do not write in the boxes in the Part headers. All answers should be written legibly, preferably in blue or black ink or in very dark pencil (eg 2B). Do not write in red ink. Answer all questions in the context of the material covered in this course, including the assignments for this course. More marks will be awarded for answers that are simple, short and concrete than will be awarded for answers that are of a sketchy or rambling nature. Generally, you will receive more marks for answers that show an understanding of the material than for answers which are simply transcriptions from lecture outlines or solution notes. You may ask for clarification of anything written on this paper, especially if you suspect that there is a typographical error. However, you should not ask for help with answering any of the questions. There are no optional questions on this examination paper. Page 2 of 10 RELATIONAL DATABASES (COMP2400)
Part 1 (10 marks) 1 TRUE/FALSE Nominate whether each of the following statements is true or false by circling either True or False after each statement on this paper. You will receive You will lose 1 mark for each correct nomination; zero marks for each absent nomination. 1/2 mark for each incorrect or unclear nomination. (1) All databases are relational. (2) {h, o, b, b, i, t} is a set. (3) {x, y} is a proper subset of {x, y}. (4) A database is a collection of related data. (5) On an ER Diagram, foreign keys are written in italics. Page 3 of 10 RELATIONAL DATABASES (COMP2400)
(6) Foreign keys can never be null. (7) SELECT CourseCode, Year, COUNT(*) AS Enroled FROM Enrolment WHERE Year = 2005 GROUP BY CourseCode; will list the number of students enrolled in each course in each year. (8) SELECT StudentId FROM Enrolment WHERE Mark = MAX(Mark); will tell us which student has the highest mark. (9) When we copy a table using create table... as, the new table has the same constraints as the original table. (10) alter table allows us to add columns to a table. Page 4 of 10 RELATIONAL DATABASES (COMP2400)
Part 2 (10 marks) 2 ER DIAGRAMS You will receive up to 5 marks for your answer to the following. Using the COMP2400 Entity-Relationship modelling conventions, draw a Level Zero ER Diagram (ie do not show any attributes on your diagram) which matches the following schema. Relational Schema Album Artist Gig Musician (Album_Id, Title, Label, Year, Artist_Id) (Artist_Id, Name) (Album_Id, Musician_Id) (Musician_Id, Family_Name, Given_Name, Birth_Date, Birth_Country, Death_Date, Death_Country) Page 5 of 10 RELATIONAL DATABASES (COMP2400)
You will receive up to 5 marks for your answer to the following. Using the COMP2400 Entity-Relationship modelling conventions, draw an ER Diagram to model the information in the following scenario. ER Scenario Lord Peter Wimsey has decided to create another front for his sleuthing activities. The organisation's official business is the warehousing of whimsical gadgets of all kinds, and its name is Wimsey's Widget Warehouse (WWW). WWW sells widgets to customers. Each type of widget in the warehouse is uniquely identified by a number, and has a name, a category, a colour, and a price. WWW uniquely identifies each of its customers using an identifier created by WWW and stores the following information about each customer: name, address, phone number, email address. Page 6 of 10 RELATIONAL DATABASES (COMP2400)
Part 3 (10 marks) 3 SQL Write SQL queries to answer each of the questions on the following pages. Write one select statement for each query. Do not write any create or alter statements. The relational schemas for the tables against which the queries will be run: Actor ActsIn Customer Director Movie (ActorId, [pk] ActorName, BirthPlace, Nationality, YearBorn, YearDied, Sex) (MovieId [fk1], ActorId [fk2], [pk] StarsIn) (CustomerId, [pk] CustomerName, CustomerAddress, CustomerPhoneAH, CustomerPhoneBH) (DirectorId, [pk] DirectorName, YearBorn, YearDied) (MovieId, [pk] MovieTitle, MovieYear, Genre, CriticRating, Classification, Nominations, Awards, Length, InColor, DirectorId [fk1], StudioName [fk2], CertNoProducer [fk3]) MovieExec (CertNo, [pk] Name, Address, NetWorth) Studio Video (StudioName, [pk] Address, CertNoHead [fk]) (VideoId, [pk] StockDate, SupplierName, SoldTo [fk1], MovieId [fk2]) Simplified syntax for the SQL select command: select [distinct] <select_list> from <table_list> [where <boolean_condition>] [group by <column_list> [having <boolean_condition>]] [order by <column_list>] / Page 7 of 10 RELATIONAL DATABASES (COMP2400)
You will receive up to 5 marks for your answer to the following. (1) How many actors were born before 1984? Page 8 of 10 RELATIONAL DATABASES (COMP2400)
You will receive up to 5 marks for your answer to the following. (2) Which actors starred in the movie Gone With the Wind? Page 9 of 10 RELATIONAL DATABASES (COMP2400)
EXTRA PAPER FOR ANSWERS Clearly indicate which question(s) you are answering, from which Part(s). Page 10 of 10 RELATIONAL DATABASES (COMP2400)