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
Concurrency control wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Functional Database Model wikipedia , lookup
Ingres (database) wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Clusterpoint wikipedia , lookup
ContactPoint wikipedia , lookup
Information Systems Design and Development Databases A database is a collection of data or information which is held together in an organised or logical way. Today databases exist almost entirely on computer systems. A database is made up of a file, records and fields. Link 1 – What is an information System? Version 2 1 File Data is stored in files. A file is a collection of data on one topic in a simple database. Files are made up of sets of records. Record A record is all the information about one person or thing in the file, for example one book in a book database. Records can be updated, deleted or new records can be inserted. Field Each bit of information in a record is stored in a field. Each field has a field name eg title in a book database. Fields can be deleted or added. Link 2 – What is a Database? Version 2 2 Field Types Number – stores numbers, e.g. exam marks Text – stores words or numbers not being used for calculations, e.g. surname, phone no. Graphic - stores images, e.g. photographs Date - stores dates, e.g. date of birth Time – stores a time of day, e.g. the start time of an exam Calculated – stores a formula and uses 1 or more of the other fields to carry out a calculation. The answer is displayed. e.g. averages or totals Object (OLE) field. In Microsoft Access, for example, an object field can hold a word document, an Excel spreadsheet or a Paint graphic. Version 2 3 More Field Types Boolean – stores just two values, eg. ‘Yes’ or ‘’No’. Eg. Married? Link - stores a hyperlink within the database or a hyperlink to a document outside the database. e.g. To another record or to an Internet site. Version 2 4 Validation Validation is the process of checking that data entered into a system makes sense and is allowable. Types of validation check: Presence check Restricted choice Field length check Field range check Version 2 5 Presence Check Checks that data has been entered and that the data field has not been left blank. Restricted Choice Forces the user to enter data from a list of acceptable values e.g. from a dropdown menu with the days of the week. Field Length Check Checks that the data entered is of a certain length e.g. year with 4 digits. Field Range Check Checks that the data entered is within a certain range of numbers e.g. month entered should be from 1 to 12. Version 2 6 Searching Using one or more fields to search for records from the database. Sorting Putting the records into some kind of order. Records can be sorted into ascending or descending order. More than one sort can be carried out. e.g. First Name Abby Carol Alison John Robert Sally Surname Brown Brown Campbell Green McDonald McDonald A primary sort has been done on the ‘Surname’ field then a second sort on the ‘First Name’ field. Version 2 7 Flat File Database A simple database structure has one table containing all the fields and the data they contain. Relational Database A database which contains more than one table. The tables are linked together via a relationship between the primary key of one table and the foreign key of another table. Relational databases reduce data duplication and data inconsistency. Key Field – a field in a record that is used to uniquely identify a record in the database eg. reference number, account number. Link 3 – More About Databases Version 2 8 A primary key field and a foreign key field are used to make relationships between tables. A primary key uniquely identifies each record in a database. For example, a primary key could be an ID number or an account number. A Table can only have 1 primary key. A foreign key enables you to set up relationships, or links, between tables in a database. Link 4 – Even More about Databases Version 2 9 Look at the following flat file database. The data stored shows flights leaving Glasgow airport and the pilot who will captain the flight. Look for data duplication and data inconsistency Version 2 10 Example 1 Flights Database Flight ID Date Destination Pilot ID Surname Forename Salary (£) EZ2580 12/03/14 London PID0001 Casey Nicola 50,000 EZ3210 14/13/14 Paris PID0002 Smith James 46,500 EZ2550 14/03/14 Dublin PID0001 Casey Nicolas 50,000 BA1231 12/03/14 Rome PID1001 Miller JohnData inconsistency 50,000 BA1229 14/03/14 Madrid PID1001 Miller John 50,000 AA0981 14/03/14 New York PID2001 Murray Anne 65,000 AA0985 17/03/14 LA PID2001 Murray Anne 65,000 Data duplication Version 2 11 Example 1 Flights Database In order to split a table into two tables you need to decide: 1. How the data in the table will be split. • It could be library members and the books they borrow. • It could be teachers and the pupils they teach. 2. What are the primary and foreign keys? • Decide on the primary key for each table. (the primary key must be unique for each record). • Decide which field will link the tables. This will be the primary key in one table and becomes the foreign key in the other table. Version 2 12 Flight Table Pilot Table Duplications can be removed Link Flight ID Date Destination Pilot ID Surname Forename Salary (£) EZ2580 12/03/14 London PID0001 Casey Nicola 50,000 EZ3210 14/13/14 Paris PID0002 Smith James 46,500 EZ2550 14/03/14 Dublin PID0001 Casey Nicolas 50,000 BA1231 12/03/14 Rome PID1001 Miller John 50,000 BA1229 14/03/14 Madrid PID1001 Miller John 50,000 AA0981 14/03/14 New York PID2001 Murray Anne 65,000 AA0985 17/03/14 LA PID2001 Murray Anne 65,000 Version 2 13 Example 1 Flights Database We can now split this flat file into two tables, one table to store the flight details and the other to store the pilot details. Foreign Key Primary Key Primary Key Flight ID Date Destina tion Pilot ID Pilot ID Surname Forename Salary (£) EZ2580 12/03/14 London PID0001 PID0001 Casey Nicola 50,000 PID0002 Smith James 46,500 PID1001 Miller John 50,000 PID2001 Murray Anne 65,000 EZ3210 14/13/14 Paris PID0002 EZ2550 14/03/14 Dublin PID0001 BA1231 12/03/14 Rome PID1001 BA1229 14/03/14 Madrid PID1001 AA0981 14/03/14 New York PID2001 AA0985 17/03/14 LA PID2001 Flight Table Pilot Table We then link the two tables on the PilotID field . PilotID is known as the foreign key in the Flight table. Version 2 14 Example 2 Library Database Member ID Member Name KP102 Mary Smith Data duplication KP982 James Main Telephone Book Reference Book title Date Borrowed 987 2650 BK345 The Green Mile 17/01/14 967 3641 BK287 The Dark Tower 15/01/14 KP102 Mary Smith 987 2650 BK290 Pride and Prejudice 17/01/14 KP982 Jimmy Main 967 3641 BK205 Emma 15/01/14 KP982 James Main 967 3641 BK106 A Fine Balance 20/01/14 945 2351 BK239 Sunset Song 21/01/14 KP345 Jo Jones Data inconsistency Version 2 15 Link Book Table Member Table Member ID Member Name Telephone Book Reference Book title Date Borrowed KP102 Mary Smith 987 2650 BK345 The Green Mile 17/01/14 KP982 James Main 967 3641 BK287 The Dark Tower 15/01/14 KP102 Mary Smith 987 2650 BK290 Pride and Prejudice 17/01/14 KP982 Jimmy Main 967 3641 BK205 Emma 15/01/14 KP982 James Main 967 3641 BK106 A Fine Balance 20/01/14 KP345 Jo Jones BK239 Sunset Song 21/01/14 945 2351 Version 2 16 Example 2 Library Database We can now split this flat file into two tables. Foreign Key Primary Key Member Table Book Table Primary Key Member Telephone Name Member ID Mary Smith 987 2650 KP102 James Main 967 3641 KP345 Jo Jones 945 2351 KP982 We then link the two tables on the MemberID field. MemberID is known as the foreign key in the Book table. Member ID Book Reference Book title Date Borrowed KP102 BK345 The Green Mile 17/01/14 KP982 BK287 The Dark Tower 15/01/14 KP102 BK290 Pride and 17/01/14 Prejudice KP982 BK205 Emma 15/01/14 KP982 BK106 A Fine Balance 20/01/14 KP345 BK239 Sunset Song 21/01/14 Version 2 17 Example 3 Police Database Surname Forename Nickname Sex Heigh t (M) CrimeType Date Arrested Police Ref ID Mathers Michael Eminem Male 1.68 Burglary 12/03/13 GCR001 Smith Kevin Smithy Male 1.54 Kidnap 03/06/12 GCR320 Mitchell Gary Gazza Male 1.80 Forgery 08/11/12 GCR458 Smith Kevin Smithy Male 1.54 Assault 13/07/13 GCR239 Mathers Michael Eminem Male 1.68 Bank Robbery 13/06/13 GCR289 Mitchell Gary Gazza Male 1.54 Hacking 09/06/13 GCR310 Jones Anne JoJo Female 1.32 Dangerous driving 13/06/13 GCR201 Link? Version 2 18 Example 3 Police Database • In this example we want to split the database into two tables, one containing the data about a criminal and the other containing the data about the crime. • However in the criminal table there is no obvious primary key. When this happens another field should be added that will become the primary key. This can simply be an autonumber field. Version 2 19 Criminal Table Crime Table ID Surname Forename Nickname Sex Height (M) Crime Type Date Arrested Police Ref ID 1 Mathers Michael Eminem Male 1.68 Burglary 12/03/13 GCR001 2 Smith Kevin Smithy Male 1.54 Kidnap 03/06/12 GCR320 3 Mitchell Gary Gazza Male 1.80 Forgery 08/11/12 GCR458 2 Smith Kevin Smithy Male 1.54 Assault 13/07/13 GCR239 1 Mathers Michael Eminem Male 1.68 Bank Robbery 13/06/13 GCR289 3 Mitchell Gary Gazza Male 1.54 Hacking 09/06/13 GCR310 4 Jones Anne JoJo Female 1.32 Dangerous driving 13/06/13 GCR201 Link Version 2 20 Example 3 Police Database We have split this flat file into two tables. Primary Key Criminal Table Criminal Surname Forename Nickname ID Sex Height (M) 1 Mathers Michael Eminem Male 1.68 2 Smith Kevin Smithy Male 1.54 3 Mitchell Gary Gazza Male 1.80 4 Jones Anne JoJo Female 1.32 Version 2 21 Example 3 Police Database. Primary Key Crime Table Foreign Key Crime Type Date Arrested Police Ref ID Criminal ID Burglary 12/03/13 GCR001 1 Kidnap 03/06/12 GCR320 2 Forgery 08/11/12 GCR458 3 Assault 13/07/13 GCR239 2 Bank Robbery 13/06/13 GCR289 1 Hacking 09/06/13 GCR310 3 Dangerous driving 13/06/13 GCR201 4 The two tables are linked by the Criminal ID field. Version 2 22 Example 4 Music Instructors The next example is a database containing a list of music instructors and the students they teach. The table contains data duplication and needs to broken into 2 tables that are linked by one field. Consider • what the two tables should be • what the primary key for each table should be • what the foreign key should be Version 2 23 Example 4 Music Instructors Instructor Instrument Cost per lesson Student Forename Student surname Age Email Mrs Keys Piano £20.00 John Smith 17 [email protected] Mrs Keys Piano £20.00 David Beckham 21 [email protected] Mr Bell Clarinet £18.00 Mary Hamilton 15 [email protected] Mr Bell Clarinet £18.00 Kevin Bridges 20 [email protected] Ms Watt Violin £18.00 Miley Cyrus 15 [email protected] Ms Watt Violin £18.00 Alex Salmond 20 [email protected] Ms Watt Violin £18.00 Ada Lovelace 19 [email protected] Version 2 24 Example 4 Music Instructors Instructor Table Primary Key Instructor ID 1 Teacher Instrument Mrs Keys Piano Cost per lesson £20.00 2 Mr Bell Clarinet £18.00 3 Ms Watt Violin £18.00 Autonumber field added Version 2 25 Example 4 Music Instructors Primary Key Student Table Foreign Key Student Forename Student Surname Age Email Instructor ID John Smith 17 [email protected] 1 David Beckham 21 [email protected] 1 Mary Hamilton 15 [email protected] 2 Kevin Bridges 20 [email protected] 2 Miley Cyrus 15 [email protected] 3 Alex Salmond 20 [email protected] 3 Ada Lovelace 19 We then link the two tables on the [email protected] 3 Instructor ID field. The two tables are linked by the Instructor ID field. Version 2 26 Music Instructors in Access Let’s now look at the implementation of this data in MS Access. Link to Access file Version 2 27