ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions
7 marks · Entity-relationship diagrams
The following constraints apply to the database: • All events must be staffed, but not all staff will be allocated to an event. • When staff are allocated to an event they are given a specific role, but not all roles are required for every event. • An event is only added to the database if it has an associated venue, but venues may be added before they are used to host an event. The incomplete entity-relationship diagram has been provided below. Role is required for hosts requires Venue Event Allocation is allocated Staff Copy and complete the entity-relationship diagram. You should indicate: • strong and weak entities • relationship participation. State one reason why the Allocation entity would benefit from the use of a surrogate key. The data dictionary below shows details of the Event entity. Entity: Event Attribute name Key Type Size Required Validation eventID PK Int Yes Auto increment venueID FK Int Yes Existing venueID from Venue table eventName Varchar 25 Yes Complete the following SQL statement used to create the Event table. CREATE Event( eventID int NOT NULL AUTO_INCREMENT, venueID int NOT NULL, eventName varchar(25) NOT NULL, ______________________________ ______________________________ ); A company requires a database to hold details of their staff who are allocated to roles at events hosted in a number of venues. The structure of the proposed database is shown below. Staff staffID firstName lastName contactNumber address dateOfBirth Role roleID roleName description hourlyRate Event eventID venueID * eventName Venue venueID venueName address Allocation staffID * eventID * roleID * date startTime endTime
See sample solution below. Award 1 mark for mandatory-to- mandatory relationship participation between Event and Allocation entities. Award 1 mark for all 3 mandatory- to-optional relationship participation between Venue-Event, Role- Allocation and Staff-Allocation. Award 1 mark for all 3 mandatory- to-optional relationships found the right way/in the right order. Award 1 mark for Allocation and Event indicated as weak entities. • use of a surrogate key makes it easier to reference historical data • use of a surrogate key improves the performance of queries that involve a join with the Event, Role or Staff tables Award 1 mark for one correct reason. Do not accept quicker/easier without supporting statement. See sample solution below. Award 1 mark for primary key. Award 1 mark for foreign key. PRIMARY KEY(eventID) FOREIGN KEY(venueID) REFERENCES Venue(venueID)