Question 10
AQA Computer Science June 2017 Paper 2A level18 marks
On the specification
- 10.1
- 4.10 Fundamentals of databases
- 10.2
- 4.10 Fundamentals of databases
- 10.3
- 4.10 Fundamentals of databases
- 10.4
- 4.10 Fundamentals of databases
- 10.5
- 4.10 Fundamentals of databases
Question text
10 A garage services and repairs cars. It uses a relational database to keep track of the jobs that customers have booked for it to carry out. The database includes jobs that have been completed and jobs that are waiting to be done. The details of the jobs that the garage does, together with the parts that it stocks and uses are stored in the database using the four relations shown in Figure 7. Figure 7 Job (JobID, CarRegNo, JobDate, InGarage, JobDuration) Car (CarRegNo, Make, Model, OwnerName, OwnerEmail, OwnerTelNo) Part (PartID, Description, Price, QuantityInStock) PartUsedForJob (JobID, PartID, QuantityUsed) • Each car has a unique CarRegNo. • A type of car can be uniquely identified by the combination of its Make and Model. Different Makes may use the same Model name and a particular manufacturer (Make) will produce several different car Models. • A booking made for a car on a particular date counts as one job, regardless of how many different tasks are completed upon it. • A job might require the use of any number of parts, including zero. • Some of the details are stored in the database as soon as a booking is made and others are only added when a job has been completed. The attribute JobID is the Entity Identifier (Primary Key) of the Job relation. 10.1 If the JobID attribute were not included in the Job relation, which other attribute or attributes that are currently in the relation could probably be used as an Entity Identifier (Primary Key) instead? [1 mark] It has been suggested that the owner details (OwnerName, OwnerEmail, OwnerTelNo) should not be stored in the Car relation and that a new relation should be created to store owner details separately from car details. 10.2 Explain why storing the owner details separately would improve the design of the database. [2 marks] 10.3 On the incomplete Entity-Relationship diagram below show the degree of any three relationships that exist between the entities. [2 marks] Job Car Part PartUsedForJob When an appointment is made for a job, this is represented in the Job relation. At the time of booking, the InGarage attribute is set to False and the JobDuration attribute is set to 0:00. When the car arrives at the garage the value of the InGarage attribute is changed to True. When the job is finished the value of the JobDuration attribute is updated to indicate how long the job took and details of the parts used are recorded in the database. The Job with JobID 206 has been completed. The job took 1 hour 30 minutes (1:30) and used two of the parts with PartID 12. 10.4 Write the SQL commands that are required to record the amount of time that the job took in the database. [3 marks] 10.5 Write the SQL commands that are required to record in the database the fact that two of the parts with PartID 12 were used. [2 marks] Figure 7 is repeated below. Figure 7 (repeated) Job (JobID, CarRegNo, JobDate, InGarage, JobDuration) Car (CarRegNo, Make, Model, OwnerName, OwnerEmail, OwnerTelNo) Part (PartID, Description, Price, QuantityInStock) PartUsedForJob (JobID, PartID, QuantityUsed) A mechanic needs to produce a list of all of the parts used on the job with JobID 93 for a customer. This list must include the PartID, Description, Price (each) and QuantityUsed of each part, and no other details. The parts in the list should be ordered by PartID with the parts with the lowest PartIDs nearest to the top of the list. 10.6 Write an SQL query to produce the list. [5 marks] There are restrictions on which parts can be fitted to which cars. For example: • The driver’s door mirror with PartID 104 can only be fitted to one particular make and model of car. • The ignition switch with PartID 27 can be fitted to any model of car for one particular make as the maker uses the same ignition switch in all models. • The tyre with PartID 97 can be fitted to a wide range of cars of different makes and models as it is a standard size. If the information about which parts could be fitted to which makes and models of cars were represented in the database, it could be used to help a mechanic identify the correct parts to use for a job. 10.7 Explain how the database design could be modified to represent which makes and models of car a part can be fitted to. [3 marks]