Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Oracle Database wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Functional Database Model wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Relational algebra wikipedia , lookup
Ingres (database) wikipedia , lookup
Concurrency control wikipedia , lookup
Versant Object Database wikipedia , lookup
Clusterpoint wikipedia , lookup
ContactPoint wikipedia , lookup
AQA A level Computer Science Teaching and Learning Resources Chapter 43 – Relational databases TASK QUESTIONS (WITH ANSWERS) 1 What is a relational database? A relational database is a way of storing data in any number of related tables. Separate tables are created for each aspect of the database and then links are created between the tables. 2 Explain the following terms: a) entity a table of data stored in a relational database b) attribute a field in a relational database c) relationship a link between one table and another in a relational database 3 Describe how primary keys and foreign keys are used to create relationships between tables. A primary key is an attribute that uniquely identifies every record in an entity. To create a relationship between entities, the primary key from the first entity is included in the second entity as the foreign key. Therefore the relationship is created by joining the primary key in the first entity to the foreign key in the second. 4 A company employs engineers to fix faults on photocopiers. The company has 20 engineers and over 200 clients. The engineers will travel to client sites in order to fix their machines and can fix between one and five machines a day. The company employs a ‘work controller’ who takes the call from the client and then allocates an engineer to the job. She uses a relational database to keep track of all the details relating to the clients, engineers and jobs. Part of the database is shown below in standard notation: CLIENT (Name, Address) ENGINEER (Name, Address) JOB (Date, Nature of Problem) a) Suggest a suitable identifier for each table. CLIENT, ENGINEER and JOB AQA A level Computer Science © Hodder & Stoughton Limited 2015 AQA A level Computer Science Teaching and Learning Resources b) c) d) e) f) 5 Draw an entity-relationship diagram to show the relationship between the three entities. CLIENT JOB ENGINEER One client has many jobs One engineer has many jobs Suggest foreign keys that could be used to create the relationships. Client ID and Engineer ID Identify four other attributes that the company may store. Client’s details such as company name, address, contact details, make of copier. Engineer details such as name and address. Job details, such as the nature of the fault, date recorded, date fixed. Now complete the standard notation. CLIENT (Client ID, Company Name, Contact Name, Address, Type of copier) ENGINEER (Engineer ID, Name, Address) JOB (Job ID, Client ID, Engineer ID, Date recorded, Date fixed, repair carried out) How could attributes be combined to form a composite key for the ENGINEER table? A candidate key must uniquely identify each engineer. If an Engineer ID is not used then name alone would not be sufficient as you could have two engineers with the same name. Two attributes could be combined, for example, Engineer Name and the first line of the address to ensure it is unique. A garage uses a database to store details about its customers, their cars and the repairs that are carried out. The system is currently stored as a single table, an extract of which is shown below. a) b) Identify three problems with the way the database is currently stored. Data is repeated, the data is not normalised, the database is going to get large and disorganised A relational database is to be designed using three tables: Customer, Car and Repairs. Normalise the database to 3NF showing your answer in standard notation: ENTITYNAME (Primary key, attribute 1, attribute 2 …) This will involve identifying suitable primary and foreign keys. AQA A level Computer Science © Hodder & Stoughton Limited 2015 AQA A level Computer Science Teaching and Learning Resources CUSTOMER (Customer ID, Name, Address, Job Number) VEHICLE (Registration Number, Make, Model, Year) JOB (Job Number, Customer ID, Registration Number, Nature of repair, Date, Price) Customer Address Reg No Make of car Date repaired Repair carried out John Brown Mary Jones John Brown Jane Fox 1 High Street 10 Low Road 1 High Street 2 New Lane M222 HGG K222 HKK P333 AAA J123 AAA Ford Escort VW Golf Citroen Saxo VW Polo 11/03/15 11/03/15 11/03/15 11/03/15 Replace exhaust Electrical fault New tyres Starter motor AQA A level Computer Science © Hodder & Stoughton Limited 2015