Databases
-
Upload
brandon-sargent -
Category
Documents
-
view
21 -
download
0
description
Transcript of Databases
Lesson 1 - IntroductionLI: Explain the difference between Data and Information .
Describe what a database is.
Data & Information• Data is raw, unprocessed facts
and figures. • Data is collected, stored and
processed by computers.
• Information is processed data with structure or meaning.
• Information is useful to humans.
Data368
HR101FE
010468
Baker
25168
Information
Age: 36 years 8 months
Post Code: HR10 1FE
Date of Birth: 01/04/68
Occupation: Baker
Total Spent: £251.68
Data & Information Task: Add meaning or structure to the following data to change it to information.
Data2
041208
159
24
46523
15595
Compare your resulting information with the person next to you. Did you get the same answers?
Information
Number of owners: 2
Date first registered: 04.12.08
Model: 159
Engine: 2.4 L
Mileage: 46523
Price: £15,595
What is a Database?A database is a structured collection of similar information that can be searched and sorted to find out answers to particular questions.
Databases can either be electronic or manual but both share the definition above. Some examples of manual databases include: Phone books, encyclopaedias, filing cabinets.
What is a Database?Task: Find out about 3 different examples of an electronic database and the information stored in them. Discuss your findings.
Manual Vs ElectronicManual Electronic
Speed Slow to search and sort. Fast to search and sort
Sharing of Info Difficult. Information and data can be held on a central computer system and accessed and updated by many remote users at the same time.
Volume storage of paper records is very bulky. Information or data can be stored on discs without taking up as much space as storing the information on paper or in filing cabinets.
Accuracy easy to mis-file information, or information may be lost or damaged.
Computers cannot lose information or put in the wrong place.
Lesson 1 – Success Criteria•I can explain the difference between data and
information.
•I can describe what a database is and give examples of manual and electronic databases.
Lesson 2 – Database StructureLI: Describe the elements that make up the structure of a database.
I can identify different types of data that is stored in a database.
Database StructureFile: A collection of structured data on a particular topic. A file is made up of records.
Record: Information held about one person or thing. A record is made up of fields.
Field: A single item of information.
10
Name: Miss WattAddress1: 4 West WoodAddress2: KirklandPost Code: KI2 9QU
Name: Mrs BrownAddress1: 4 West WoodAddress2: KirklandPost Code: KI2 9QU
Name: Mr LoveAddress1: 4 West WoodAddress2: KirklandPost Code: KI2 9QU
Name: Mr SmithAddress1: 4 West WoodAddress2: KirklandPost Code: KI2 9QU
A FILE contains RECORDS, RECORDS contain FIELDS, FIELDS contain CHARACTERS
Database Structure – Field (data) Types
Fields in a database contain different types of data formats. They are important so that memory is used efficiently and validation checks can be carried out when the data is entered.
The most common types include:
TEXT: This can be letters only or numbers only [ but no arithmetic can be performed on them ] or a mixture of letters and numbers i. e. ALPHANUMERIC. Examples include JANE , Glasgow, J462 LBH (car reg), 0141- 123-4567, AB11 22 33 A
NUMBERS:• INTEGER - A positive or negative whole number and zero e.g. 1, 45, 0, -
21, -234. These use less computer memory than…
• REAL i.e. fractional decimal numbers e.g. 2.34, 77.898
DATE/TIME: Allows a variety of formats for dates and times to be displayed
e.g.12/12/2003; 12th December 2003; 6.24pm or 18:24
CURRENCY: Displays the £ sign e.g. £9.99
BOOLEAN: Allows one of two values e.g. True/ false; Yes / No
GRAPHIC: Holds a picture. Some database types allow for storing multimedia types like a movie.
Database Structure – Field (data) Types
Calculated Field: It is possible to use the database to perform calculations which involve other fields. These are know as computed or calculated fields. To make a field a calculated field you type the expression in a blank field in a query. e.g.
Database Structure – Field (data) Types
Key Field: is a field which is unique to the topic or individual and so can be used for identification purposes. e.g. A car reg, a serial number, an employee number…
Database Structure – Field (data) Types
FILE : PATIENTS
NAME John SmithADDRESS 32 Oak RdDate of Birth 01.04.1940AGE 72GENDER MALLERGY PenicillinNational Ins No 23456 H
Database Structure – Task
From the database record opposite identify the following:
1. The fields in the record.2. The data types used for each field3. The key field
Lesson 2 – Success Criteria•I can accurately describe the elements that make
up the structure of a database: File, Record, Field.
•I can identify different types of data and field types that are stored in a database, including key fields and calculated fields.
Lesson 3 – Calculating the size of DB File.
LI: I will be able to calculate the size of a database file using information about the database.
When designing a database it is important to know how large the database file will be in advance. This will help us decide what sort of backing store to use.
What factors affect the size of a database file?
1. Field length2. Size of 1 record3. Number of records in the file.
Calculating Database Size – Key Factors
Step 1 - Field Length: This is the total number of characters, including spaces, needed to hold the information in a field.
It is good practice to design the length of some fields to ensure that they can accommodate future data entries that are larger than existing entries.
Calculating Database Size – Step 1
Forename Surname Date of Birth
Gender
Jonathan O’Reilly 08/02/1990 M
Cheryl Thomson 12/09/1989 F
Kevin Delray 23/05/1990 M
Pamela Hamilton 19/12/1989 F
Sarah – Louise Cunningham
31/07/1989 F
Robert Davey 05/08/1990 M
Which fields would be designed to accommodate larger data entries?
What would you suggest are suitable field sizes for each field?
20 20 10 1
Step 2 - Size of 1 record: This is calculated by adding up all of the field sizes.
Calculating Database Size – Step 2
Forename Surname Date of Birth
Gender
Jonathan O’Reilly 08/02/1990 M
Cheryl Thomson 12/09/1989 F
Kevin Delray 23/05/1990 M
Pamela Hamilton 19/12/1989 F
Sarah – Louise Cunningham
31/07/1989 F
Robert Davey 05/08/1990 M
5120 20 10 1+ + + =
One character requires 1 byte of storage.
Therefore:
One record requires 51bytes of storage.
Calculating Database Size – Units of Data Storage (revision)
Bit = 0 or 1
Byte = 8 bits
Kilobyte = 1024 bytes
Megabyte = 1024 Kb
Gigabyte = 1024 Mb
Terabyte = 1024 Gb
Step 3 - Size of DB file: This is calculated by multiplying the size of 1 record by the number of records in the database.
Calculating Database Size – Step 3
Forename Surname Date of Birth
Gender
Jonathan O’Reilly 08/02/1990 M
Cheryl Thomson 12/09/1989 F
Kevin Delray 23/05/1990 M
Pamela Hamilton 19/12/1989 F
Sarah – Louise Cunningham
31/07/1989 F
Robert Davey 05/08/1990 M
51bytes20 20 10 1+ + + =
51x 6 = 306 bytes
If necessary you should show your final answer in appropriate units.
Using the database below suggest a suitable field size for each field and calculate how many bytes are required for one record and how many kilobytes are required to store the details of 100 employees.
Calculating Database Size - Task
20 + 20 + 4 + 15 + 2 + 2 + 3 = 66 bytes
x 100 (records)
= 6600 bytes / 1024
= 6.45 Kb
Lesson 3 – Success Criteria•I can determine the size of each field in a database
and using this information and the number of records, I can calculate the size of a database file.
•I can express the answer to my calculations in appropriate units.
Lesson 4 – Searching & SortingLI: I can describe and exemplify the process of searching and sorting a database.
Searching & SortingApart from storing data and information, databases are excellent at searching for answers to questions about the information and once found perhaps sorting the data alphabetically or numerically.
These searches and sorts are performed much faster than a human possibly could.
SEARCHING on the computer may require the user to build a query using the database software or a “language” called SQL (Structured Query Language) e.g….
Searching
SELECT Make, Model, Colour, [Cost (£)], CommentsFROM Table1WHERE (((Colour)="red") AND (( [Cost (£)])<10000));
=
SearchingIn written tasks the type of search SIMPLE or COMPLEX must be specified and the field and the rule must be written out in full.
EXAMPLES
1. To look for pupils in a school database who are in 3H1 would require the following written solution.
Perform a simple search on the field class for data ”3H1”
2. How would you find pupils in a third year database who failed their Word Processing exam ?
Perform a simple search on the field WordProcessing Score for data “ < 50 “
Complex SearchingA COMPLEX SEARCH is a search on more than one field. It involves the
Boolean operators AND and OR.
3. How would you find all red Ford cars in a car database
Perform a complex search on the fields make for data “Ford” AND field colour for data “red “.
Searching – Wildcards (*)The use of the wildcard (*) feature is useful if you are just searching for one word (or part of a word) in a phrase.
4. For example in the aircraft database, find the pilot from Aberdeen who had between 10 and 15 years service and can fly long haul flights.
Perform a complex search on the field airport for data “ABZ” AND on the field service for data “>10 “ and “<15” AND on the field Flight Type for data *Long*
SortingSORTING involves arranging lists into alphabetic or numerical order. This can be set when designing a query or using the or commands.
Data can be sorted in ascending (0…9, A…Z) or descending (9…0, Z…A) order.
1. How would you put the computing class results into alphabetical order?
Perform a simple sort on the field surname in ascending order [A to Z].
A COMPLEX SORT is a sort on more than one field.
2. How would you arrange pupils in 3G into alphabetical order and class order ?
Perform a complex sort on the field surname in ascending [ A to Z ] order AND on the field class in ascending order [ 1 to 10 ].
Lesson 4 – Success Criteria•I can build a complex database query to search a
database.
•I can use Boolean operators, including the wildcard.
•I can explain the process of searching and sorting databases and structure my answers appropriately.
Lesson 5 – User InterfaceLI: I understand the importance of user interface design and can recognise and create user friendly interfaces.
User Interface - Forms•Forms are used to display the
records in a table in a more user-friendly way. By using a form you can enter and edit records more easily.
•Forms can be changed to meet the needs of the user by adding buttons and editing the appearance to include images.
User Interface - Reports•Reports are used to print
information from your database. They provide professional looking output from a table or query.
•Reports can be changed to meet the needs of the user by changing the format of data and editing the appearance to include images.
•They can also be altered to include summary data from the database.
User Interface – Report Design•The look and feel of the reports you design will vary
depending on the type of information you want to present.
•If you’re creating a simple report that lists book sales in a particular region of the United Kingdom, you can use the Report Wizard to create a basic two-column report that lists only regions and sales.
•Plan to spend some time thinking through what data your report needs to display and how the data should be presented. This will save you editing and revision time later on.
User Interface – Report DesignAs you think about what you want to accomplish with the report you’re creating, consider these questions:
•Who will be using this report? What information will users expect to see, and how do they want the information to be laid out?
•What report format is best suited to your needs? For example, will you use multiple columns to present your data? How many columns do you need?
•Should the report include all the data in the record source?
•Should you use headings and graphic elements (such as lines and boxes) to help readers understand the report?
Lesson 5 – Success Criteria•I can create user a user form in a database
•I can create a custom report in a database
•I understand what makes an interface user-friendly
Lesson 6 – Linked TablesLI: I can…
Describe the terms ‘flat file’ and ‘relational’ in the context of databases and give advantages and disadvantages of each
Describe the three types of data relationships
Describe the terms primary key and foreign key
Create a relational database
Flat File Database•A flat-file database contains only 1 table which
stores all of the information.
Advantages Disadvantages
Simple to setup •Data is very likely to be duplicated
•The duplication of data leads to the possibility of data inconsistency. •It is not possible to store information about a member without entering details of a DVD (see next slide). This is called an insertion anomaly.
DVD Code Title Cost Date Out Date Due
Member Number Name
Telephone Number
002 Finding Nemo £2.50 03/09/04 04/09/04 1034 John Silver 142536
003 American Pie £2.50 27/08/04 28/08/04 1056 Fred Flintstone 817263
003 American Pie £2.50 01/09/04 02/09/04 1012 Isobel Ringer 293847
008 The Pianist £2.50 04/09/04 06/09/04 1097 Annette Kirkton 384756
011 Notting Hill £2.50 27/08/04 28/08/04 1012 Isobel Ringer 293847
011 Notting Hill £2.50 04/09/04 06/09/04 1056 Fred Flintstone 817263
014 Prime Suspect £2.00 27/08/04 28/08/04 1097 Annette Kirkton 384756
015 Shrek £1.50 10/09/04 11/09/04 1034 Joan Silver 142536
Data Inconsistency
If Fred’s phone number changes it would need change everywhere it appears.
If Notting Hill and American Pie DVDs are deleted then all of Fred’s details are deleted too.
Flat File Database
Insertion AnomalyIn order to enter a new member’s details you would need to add DVD information too.
Linked Table Database• A relational database stores data in more than one
table.• The idea is to ensure that data is only entered and
stored once, so removing the possibility of data duplication and inconsistency.
Advantages Disadvantages
Data is more consistent Can be complex to setup
More efficient searching Problems with incompatible data types
DVD Code Title Cost Date Out Date DueMember Number
002 Finding Nemo £2.50 03/09/04 04/09/04 1034
003 American Pie 3 £2.50 01/09/04 02/09/04 1012
008 The Pianist £2.50 04/09/04 06/09/04 1097
011 Notting Hill £2.50 04/09/04 06/09/04 1056
014 Prime Suspect £2.00 27/08/04 28/08/04 1097
015 Shrek £1.50 10/09/04 11/09/04 1034
Member Number Member Name
Telephone Number
1012 Isobel Ringer 293847
1034 John Silver 142536
1056 Fred Flintstone 817263
1097 Annette Kirton 384756
Linked Table DatabaseConsistent DataIf Fred’s phone number changes it only needs to change in the member table.
If Notting Hill DVD is deleted then Fred’s details are still stored in the member table.
Data InsertionA new member’s details can be added without having to enter DVD details.
Linked Table - TaskThe DVD table still has the problem of data anomalies.
Create another table containing the fields and how they are linked to prevent the data anomalies.
Linked Table DatabaseTask: Using the DVD example, create another table which solve the data anomalies in the DVD table.
DVD
DVD Code Title Cost
Rentals
DVD Code Date Out
Date Due
Member Number
Members
Member Number Member Name
Telephone Number
Data Relationships• One-to-one
• One-to-many
• Many-to-many
VEHICLE
REGISTRATIONNUMBER
MEMBER
DVD RENTAL
PUPIL
TEACHER
Key Fields• As you already know, a primary key is used to
uniquely identify a record in a table
• In a relational database the field that the primary key links to (in the other table) is called the foreign key
DVD
DVD Code Title Cost
Rentals
DVD Code Date Out
Date Due
Member Number
Members
Member Number Member Name
Telephone Number
PK
FK
PK
FK
Lesson 6 – Success CriteriaI have…
Created a relational database and linked primary keys and foreign keys
Set-up relationship types
Understood the advantages of relational databases
Lesson 7 – Verification & Validation
LI: I can…
Explain the difference between verification and validation with examples of each.
I can apply verification and validation checks to fields in a database.
VerificationThis is a pre-input check of any information coming into computer system.
This means that data is checked BEFORE it enters the computer system.
It mainly deals with transcription errors i.e typing numbers or letters in the wrong order. For example 3773 is entered as 7337.
VerificationThe most common form of verification is Double-Typing.
Q. Can you give an example ofdata that is commonly verified using the double typing method?
A. Passwords
ValidationValidation is used to make sure that data is allowed.
There are many forms of validation. 4 common forms of validation checking include…
Validation
1. Range Check - checks that data is within a certain range e.g. 0 to 100 for a percentage mark.
2. Field Check - checks that data is of the correct type i.e. Alphanumeric Floating point, or Integer.
Validation
3. Presence Check - ensures that data has been entered into the field and not missed out by mistake.
4. Check Digit - A mathematical function is carried out on numbers and the result is added to the original number.
Lesson 7 – Success CriteriaI have…
Set-up fields in a database with verification and validation checks
Explain why verification and validation checks are useful in database systems
Lesson 8 – Data Protection ActLI: I can…
Describe the responsibilities of organisations that hold data about individuals
Describe the rights of individuals that have data about them stored.
Data Protection Act 1998• Describes the duties and responsibilities of those
holding data on individuals (Data Users)• Describes the rights of these individuals (Data
Subjects)
• Data Users must:• register with the Data Protection Registrar• keep the information secure• make sure it is accurate• and to divulge it only to those persons who are
authorised to view it.• Data Subjects have the right:
• to view that information and to have it changed if it is inaccurate
Data Protection Act 1998• There are a number of organisations which may be
given exemption from this act - namely the Police, Customs, National Security and Health Authorities.