Term 2 Grade 12 Computer Studies UNIT : DATABASE © Copyright 2020 Port Moresby Grammar School Limited – All Rights Reserved PREPARED BY TKAUMAS – IT DEPARTMENT 1
Term 2Grade 12 Computer Studies
UNIT : DATABASE
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT 1
Unit Overview
This presentation will further develop your understanding and skills of databases. It is a continuation from what you have learnt in Term 1 (module 2) under the Unit Database. Most importantly under this topic, you will explore the searching techniques (criteria, operators & wildcards) used in locating a record/records in a database.
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
2
Topic: 2
• Methods of processing and analysing data.
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
3
Sub Topic:
Searching records in databases.
Week 1 - 2
Topic Outcomes:
Weeks 1 - 2
• Understand how to search records in given databases.
• Define query.
• Explain how Query is constructed.
• Explain how operators and wildcards are used in queries.
• Create queries in database
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
4
• This PowerPoint presentation is for (2) weeks as seen on the third slide. It contains the lesson notes and an activity for you to complete .
• Please refer to your Database handout which was given to you in Term 1 (Module 2) with the Lesson notes in this Power Point Presentation to answer the questions.
• Your answers should be written on the Answer Sheet attached.
• You may also ask your parents or guardians to check your work once you are done.
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
5
Timeframe and Instructions
Database management systems allow users to process data by editing and
analyse data by sorting and searching
Editing is the process of changing data. It involves inserting data, deleting data,
moving data and modifying the data structure.
Sorting is the process of arranging data in a particular order. It is a way of
organising data. Sorts can be performed in either ascending or descending
order.
• Ascending order arranges data from smallest to largest (0-9) or from first to
last (A-Z)
• Descending order is the reverse: from largest to smallest (9-0) or from last to
first (Z-A)
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
6
Using ‘ Find’ or ‘Search’ commands Using queries
Searching is the process of locating data and information. For small databases
the ‘Find’ or ‘ Search’ commands are adequate. However, for large databases the
most efficient way of searching is to construct a query.
A query is a search of a database for records that meet a certain condition. It is
a question you ask of the database to get a specific information/ record..
The results of a query are usually displayed in a table but can be used as the
basis for a form, report or even a graph.
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
7
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
8
Step 1 To create a query, open the database table.
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
9
Step 2 Click ‘CREATE’ and select ‘QUERY DESIGN’
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
10
Step 3 Select the database, e.g. Table 1 and click ‘Add’. Close the dialog box.
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
11
Step 4 Add all the fields in the query design view below.
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
12
Step 5Now for example, if you are looking for a person with a Last Name Fisher, you would type =‘Fisher’ in the ‘Last Name’ field in the Criteria section and leave the remaining fields blank. The Database Management System (DBMS) would then search and select the records that have ‘ Fisher’ as a ‘ Last name’
© Copyright 2020 Port Moresby Grammar School Limited – All © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
13
Step 6Click DESIGN TAB and Select Run..
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
14
Step 7Now for example, if you are looking for a person with a Last Name Fisher, you would type =‘Fisher’ in the ‘Last Name’ field in the Criteria section and leave the remaining fields blank. The Database Management System (DBMS) would then search and select the records that have ‘ Fisher’ as a ‘ Last name’
Construct a query of all employees who live at Blacktown.
5. There you have it! The query showing names of employees with the Last name ‘Fisher’
6. Now save your Query. Right click and ‘Save’.
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
15
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
16
• Queries are constructed using an operator. Operators represent the action to be performed by the query. Operators are classified as either relational or logical.
• Relational operators (=,<>,<,>,<=,>=) are symbols or words indicating the relationship between two expressions. Some DBMS have additional relational operators such as ‘begins with’, ‘contains’ and ‘does not contain’
• Logical operators (and, or, not) are used to combine two or more single queries. It is important to understand the difference between these operators. The ‘and’ operator requires both the first and the second query to
be true. It only retrieves the records that appear in both queries.
For example, if you require an employee with a Last name Fisher who lives in Blacktown, the query would be: ‘Last name=Fisher’ and Suburb = Blacktown’.
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
17
Operators
Results of using two logical operators on the personal database
Using ‘an’ operator
Using ‘or’ operator
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
18
• The ‘or’ operator requires either the first or the second query to be true. It retrieves all the records from both queries.
For example, if you require all the employees with a last name of Fisher as well as the employees who live in Blacktown, the query would be: ‘Last name=Fisher’ orSuburb = Blacktown’.
• The data in a query can contain wildcard characters. Wildcard characters represent one or more unknown characters.
• Some common wildcard characters are the asterisk (*) that substitutes for any number of characters and the question mark (?) that substitutes for one character.
• A query such as ‘Last name = Be* would find last names such as Bee, Bell, Beat or Beatle. However, a query ‘Last name=Be?’ would only find last names such as Bee and Bed.
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
19
Wildcard Characters
Mathematical Calculations
• There are variety of mathematical calculations that can be performed in a database. For example, you can calculate the average of the values in one field or multiply the values in two fields.
• When instructing the DBMS to perform a calculation, it is important to follow the correct syntax such as ‘ =Avg([Salary])’. For example, if one parenthesis (bracket) is omitted an error message will result.
• Database calculations are performed using either:
a predefined calculation – uses functions such as sum, average, count, minimum and maximum
a custom calculation – the user writes a formula to perform a calculation such as ‘=[Salary] *1.2’ and a separate field is usually created to store the calculated results.
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
20
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
21
Activity
© Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
22
Activity 1Instruction: Write your answers on the answer sheet attached to the PowerPoint presentation.
1. State whether the statement is True or false.a) The structure of the database involves changing the data dictionary.
_____________b) Descending order arranges data from largest to smallest (9-0).______________c) The ‘or’ operator only retrieves the records that appear in both queries.
____________d) Wildcard characters represent only one unknown character. _____________
2. Explain the difference between:a) sorting and searchingb) relational operators and logical operators
3. Explain how data is deleted from the field.4. What is an adequate method of searching small databases?5. Describe a wildcard.6. Explain why MS Access is the better tool to create Database with than MS Excel.
7. Refer to the database below to answer the questions.
a) How many tables were created? _____________b) How many queries were created? ____________c) In ascending order, which employee by the Last Name should be the 3rd?
_______________
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
23
8. Refer to the queries below and briefly explain each. You may include the type of operator if necessary.
Example
a.
b.
The query shows the employees who has the Last name ‘ Fisher’ .
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT
24
Answer
You can attempt this activity if you have a computer with MS Access program.
© © Copyright 2020 Port MoresbyGrammar School Limited – All RightsReserved PREPARED BY TKAUMAS – IT DEPARTMENT 25
Practical Activity (Optional)
9. Following the sample below of employee table, create a database table in MS Access, and construct the following queries.
a. Construct a query of all the employees with a last name of ‘Tway’.b. Construct a query of all the employees whose last name contain letter ‘p’.c. All the employees whose salary is greater than $51, 000.