Question 5
AQA Computer Science November 2021 Paper 2 (7517/2)A level13 marks
On the specification
- 5.1
- 4.10 Fundamentals of databases
- 5.2
- 4.10 Fundamentals of databases
- 5.3
- 4.10 Fundamentals of databases
Question text
5 box A sports centre uses a relational database to store information about its facilities (such as the swimming pool) and the bookings that have been made to use them. Figure 3 shows the structure of the relations in the database. Figure 3 Facility(FacilityID, Description, MaxPeople, PricePerHour) FacilityForSport(Sport, FacilityID) Booking(FacilityID, BookingDate, StartTime, EndTime, CustomerID) Customer(CustomerID, Forename, Surname, EmailAddress) • The Facility relation stores the different facilities available at the sports centre. Each one is identified by a unique number and has a brief description. For example, the facility with FacilityID 1 has the description ‘Outdoor Pitch A’. PricePerHour is the price of hiring a facility for 1 hour. For example, the facility with FacilityID 1 has a price per hour of £17.50. • The FacilityForSport relation identifies which facilities are suitable for which sports. For example, the facility with FacilityID 1 is suitable for football, rugby and hockey and would therefore require three separate records in this relation. • The Booking relation stores the bookings that have been made. Bookings must start and end either on the hour, at quarter past, half past or quarter to the hour. A customer can make bookings for more than one facility for the same time. For example, a badminton club secretary might book both of the indoor sports halls for the same time. However, each facility can only be booked by one customer at any one time. • The Customer relation stores the details of customers who have made bookings. 5.1 The entity identifier (primary key) for the Booking relation is a composite entity identifier, consisting of these three attributes: FacilityID, BookingDate, StartTime An alternative entity identifier could have been chosen, composed of different attributes. Shade one lozenge to indicate which of the following groups of attributes would form a valid alternative entity identifier for the Booking relation. [1 mark] A BookingDate, StartTime, EndTime B FacilityID, BookingDate, EndTime C FacilityID, StartTime, CustomerID D FacilityID, BookingDate, EndTime, Sport 5.2 box A different design was originally proposed for the database. This design did not have the Customer relation and had the following design for the Booking relation: Booking(FacilityID, BookingDate, StartTime, EndTime, Forename, Surname, EmailAddress) Explain why this alternative design would have been rejected in favour of the design in Figure 3. [2 marks] 5.3 Complete the following SQL statement to create the Facility relation specified in Figure 3, including the primary key. [3 marks] CREATE TABLE Facility ( ) Figure 3 is repeated below to help you answer Question 05.4 without having to turn box back in the question paper. Figure 3 (repeated) Facility(FacilityID, Description, MaxPeople, PricePerHour) FacilityForSport(Sport, FacilityID) Booking(FacilityID, BookingDate, StartTime, EndTime, CustomerID) Customer(CustomerID, Forename, Surname, EmailAddress) 5.4 A customer wants to book a facility that is suitable for playing basketball on the 15/06/2021 between 14:15 and 16:15 As part of the booking process, a query is needed to list all the existing bookings that would overlap with the new booking. Write a query that will list all the bookings for facilities that are suitable for playing basketball and which would overlap with the booking that the customer wants to make. For each booking which would overlap with the new booking only the FacilityID, StartTime and EndTime fields should be listed. [7 marks] This table is included so that you can answer Question 06.1 on page 17. box Table 1 – Standard AQA assembly language instruction set LDR Rd, <memory ref> Load the value stored in the memory location specified by <memory ref> into register d. STR Rd, <memory ref> Store the value that is in register d into the memory location specified by <memory ref>. ADD Rd, Rn, <operand2> Add the value specified in <operand2> to the value in register n and store the result in register d. SUB Rd, Rn, <operand2> Subtract the value specified by <operand2> from the value in register n and store the result in register d. MOV Rd, <operand2> Copy the value specified by <operand2> into register d. CMP Rn, <operand2> Compare the value stored in register n with the value specified by <operand2>. B <label> Always branch to the instruction at position <label> in the program. B <condition> <label> Branch to the instruction at position <label> if the last comparison met the criterion specified by <condition>. Possible values for <condition> and their meanings are: EQ: equal to NE: not equal to GT: greater than LT: less than AND Rd, Rn, <operand2> Perform a bitwise logical AND operation between the value in register n and the value specified by <operand2> and store the result in register d. ORR Rd, Rn, <operand2> Perform a bitwise logical OR operation between the value in register n and the value specified by <operand2> and store the result in register d. EOR Rd, Rn, <operand2> Perform a bitwise logical XOR (exclusive or) operation between the value in register n and the value specified by <operand2> and store the result in register d. MVN Rd, <operand2> Perform a bitwise logical NOT operation on the value specified by <operand2> and store the result in register d. LSL Rd, Rn, <operand2> Logically shift left the value stored in register n by the number of bits specified by <operand2> and store the result in register d. LSR Rd, Rn, <operand2> Logically shift right the value stored in register n by the number of bits specified by <operand2> and store the result in register d. HALT Stops the execution of the program. Labels: A label is placed in the code by writing an identifier followed by a colon (:). To refer to a label, the identifier of the label is placed after the branch instruction. Interpretation of <operand2> <operand2> can be interpreted in two different ways, depending on whether the first character is a # or an R: • # – use the decimal value specified after the #, eg #25 means use the decimal value 25 • Rm – use the value stored in register m, eg R6 means use the value stored in register 6 The available general-purpose registers that the programmer can use are numbered 0–12