Querying and Sorting IT Key Ideas, Dynamic Database Systems, 2002 Chapter 3.

Slides:



Advertisements
Similar presentations
Reports IT Key Ideas, Dynamic Database Systems, 2002 Chapter 5.
Advertisements

Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 2 Querying a Database Using the Select Query Window.
Access Tutorial 3 Maintaining and Querying a Database
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 3 1 Microsoft Office Access 2003 Tutorial 3 – Querying a Database.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Querying a Database Using the Select Query Window
Querying a Database Microsoft Office Access 2003.
QUERYING A DATABASE By: Dr.Ennis-Cole. OBJECTIVES: Learn how to use the Query window in Design view Create, run and Save queries Define a relationship.
Concepts of Database Management Sixth Edition
Microsoft Access 2010 Chapter 7 Using SQL.
Access Tutorial 3 Maintaining and Querying a Database
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 3 – Finding, Filtering,
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory Pasewark & Pasewark.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory.
CIS*1000*DE – Databases Microsoft Access (Part 2).
Maintaining and Querying a Database Microsoft Access 2010.
DAY 16: ACCESS CHAPTER 2 Tazin Afrin October 10,
1 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Introduction to Access By Mary Ann Chaney and Alicia Harkleroad.
You can use a query to view a subset of your data or to answer questions about your data. For example, if you want to view a list of student names and.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access Committed to Shaping the Next Generation.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
Microsoft Access Intro Class 5 Working with Queries.
G-Databases Competency 7.00 Objective 7.01 Demonstrate basic database concepts and functions.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 4 BACKNEXTEND 4-1 LINKS TO OBJECTIVES Query Design Query Criteria Modify a Query Using OR.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
Analyzing Data For Effective Decision Making Chapter 3.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 6 – Designing.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
Slide 1 Standard Grade Computing Databases. Slide 2 Standard Grade Computing Definitions DatabaseA database is a structured collection of similar information.
MS-ACCESS BY SANGEETHA PARTHASARATHY Topics to be covered §Comparing Values in Selection Criteria §Calculating Values in a Query §Changing the appearance.
Concepts of Database Management Seventh Edition
Statistical Outcomes IT Key Ideas, Dynamic Database Systems, 2002 Chapter 6.
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
Concepts of Database Management Seventh Edition
Chapter 17 Creating a Database.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
Microsoft Access 2007 Tutorial (Part II) CIS*1000*DE.
SESSION 3.1 This section covers using the query window in design view to create a query and sorting & filtering data while in a datasheet view. Microsoft.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making Chapter.
® Microsoft Access 2010 Tutorial 3 Maintaining and Querying a Database.
COMPREHENSIVE Access Tutorial 3 Maintaining and Querying a Database.
Database Applications – Microsoft Access Lesson 4 Working with Queries 36 Slides in Presentation.
Microsoft Office 2003: Advanced 1 ADVANCED MICROSOFT ACCESS Lesson 10 – Analyzing Data.
O FFICE M ANAGEMENT T OOL - II B BA -V I TH. Abdus Salam2 Week-7 Introduction to Query Introduction to Query Querying from Multiple Tables Querying from.
You can sort Access data so you can view records in the order you want to view them, and you can filter data so you only see the records you want to see.
Databases.  A database is simply a collection of information stored in an orderly manner.  A database can be as simple as a birthday book, address book.
CHAPTER 1 – INTRODUCTION TO ACCESS Aliya Farheen March 5, 2014.
Pasewark & Pasewark Microsoft Office 2003: Introductory 1 INTRODUCTORY MICROSOFT ACCESS Lesson 4 – Finding and Ordering Data.
In Excel, a data base is referred to as a list. A list consists of a set of column headers and rows of data beneath the column headers. Excel 2003 includes.
Databases Competency Explain advanced database concepts and functions.
DAY 18: MICROSOFT ACCESS – CHAPTER 3 CONTD. Akhila Kondai October 21, 2013.
Key Applications Module Lesson 22 — Managing and Reporting Database Information Computer Literacy BASICS.
Access Query Design. IT Fundamentals2 Access Query Design The Query design screen provides a mechanism for selecting specific data from datafile(s) by:
ACCESS PROJECT TWO. PROJECT ONE In project one you: -Created Tables -Created Forms -Created Reports In this project you will learn about queries. Databases.
Practical Office 2007 Chapter 10
Find and Replace Used to quickly find and/or replace data quickly
Microsoft Office Access 2003
Microsoft Office Access 2003
G-Databases Competency 7.00
Spreadsheets, Modelling & Databases
Introduction to Access
Assignment 3 Querying and Maintaining a Database
Presentation transcript:

Querying and Sorting IT Key Ideas, Dynamic Database Systems, 2002 Chapter 3

Interrogating the Database IT Key Ideas, Dynamic Database Systems, 2002 The real power of database software is the ability to query the database in order to find answers to specific questions, page 15 or in other words to turn data into information.

IT Key Ideas, Dynamic Database Systems, 2002 The result of a query is a set of records that match the conditions of the query. This set of records is a table in appearance, although it is not a real table of the database system in use. Often it is referred to as a temporary or resultant table.

Queries provide the following advantages specific fields can be chosen to display particular columns of data specific records can be searched for that match a criteria records can be viewed in a specific order calculations can be performed on the data in a table data from multiple tables may be matched specific data can be obtained for use in forms, reports or graphs.

The interrogating of the database to find records that match a criteria is an essential component of any database system. The result of the interrogation is referred to as an outcome of the system. An outcome should present a sub-set of the data, rather than show all of the records of the database. IT Key Ideas, Dynamic Database Systems, 2002

When one asks for help in a library, the librarian will ask a question like IT Key Ideas, Dynamic Database Systems, 2002 what topic are you researching (eg. database systems), or what author are you looking for (eg. Potter)?

When a person walks into a car yard to purchase a car the salesperson will ask a question like what brand of car are you interested in (eg. Commodore), or what size car (eg. 6 cylinder) or what type of vehicle (eg. wagon)?

Queries Practical 3.1page 16 IT Key Ideas, Dynamic Database Systems, 2002

2.Display a list of all surnames and given names, in that order. 3.Display a list of given names followed by surnames, where the list is alphabetically sorted by surname. 4.Display a list of the surnames of females and then males, where each group is alphabetically sorted. 5.Display a list of the people who have red hair, in alphabetical order? 6.How many males are there? Hint: look at the data in the table before executing the query. 7.Display a list of people who do not have blonde hair. 8.How many people are 15 years of age? IT Key Ideas, Dynamic Database Systems, 2002 Practical 3.1

Database file for querying IT Key Ideas, Dynamic Database Systems, 2002 Data FileClass Details

Querying a Database Table IT Key Ideas, Dynamic Database Systems, 2002

Show/Add a table to the query IT Key Ideas, Dynamic Database Systems, 2002

click and drag fields to the Field line or click the pop-down list arrow and choose QBE Grid page 17

To display all fields page 17 drag the asterisk to the field line

Toolbars IT Key Ideas, Dynamic Database Systems, 2002

If the line Table line is showing within QBE grid turn it off, View Table Names command; as the current database only has one table. IT Key Ideas, Dynamic Database Systems, 2002 Advice

Displaying particular fields drag Given Names and Surname to the field line click the Datasheet View or Run button in order to view the recordset

Changing the order of the Fields IT Key Ideas, Dynamic Database Systems, 2002 highlight a column(s) drag the column(s) across by using the Field Selector (it’s a very thin grey line) Field Selector

Ordering Records IT Key Ideas, Dynamic Database Systems, 2002 click in the required column on the sort line and choose ascending or descending

Sorting on more than one field and controlling the display IT Key Ideas, Dynamic Database Systems, 2002 how is the table organised?

Hint:in order to achieve the required output, it is possible to insert the same field more than once. IT Key Ideas, Dynamic Database Systems, 2002

Given NamesSurnameSex Ascending Surname Ascending

Conditional Retrieval IT Key Ideas, Dynamic Database Systems, 2002 Setting a condition, by using criteria in the QBE, can retrieve particular records of a database table. Remember that a record is a row of data. The database software processes the data in the database by finding records that match the criteria and produces a subset of data, from the whole system.

Alphanumeric Criteria IT Key Ideas, Dynamic Database Systems, 2002 To find people with red hair, enter the value red as the criterion under the Hair Colour field. Hair Colour red

SQL equivalent IT Key Ideas, Dynamic Database Systems, 2002 SELECT [Given Names], Surname FROM Details WHERE [Hair Colour] =”red” ORDER BY Surname;

SQL IT Key Ideas, Dynamic Database Systems, 2002 SELECT specifies the fields in the query FROM specifies the table the data is stored in WHERE specifies the criteria that records have to match, and ORDER BY specifies the order in which the records will be sorted.

IT Key Ideas, Dynamic Database Systems, 2002 How many males? Sex m

IT Key Ideas, Dynamic Database Systems, 2002 Not blondes not is referred to as a logical operator Hair Colour not blonde

Calculation Fields IT Key Ideas, Dynamic Database Systems, 2002 In order to query the database for ages, eg. 15 year olds, it is necessary to calculate people’s ages, as each person has their Date of Birth stored. Date of Birth is stored so that when queries are executed at later times correct outputs apply irregardless of when the list is produced.

IT Key Ideas, Dynamic Database Systems, 2002 The fact that different outputs will be produced depending on when the query is executed is referred to as dynamic. It is this concept of dynamic outputs that distinguishes IT apart from other fields of study.

IT Key Ideas, Dynamic Database Systems, 2002 In order to calculate people’s ages it is necessary to develop an algorithm to complete the calculation. An algorithm is a series of steps to solve a problem.

IT Key Ideas, Dynamic Database Systems, 2002 Consider your age. What does your age depend on? Calculating Age

IT Key Ideas, Dynamic Database Systems, 2002 Your date of birth and today’s date Calculating Age

IT Key Ideas, Dynamic Database Systems, 2002 Today’s date can be displayed by using the function Date(). Type this on the Field line. NB: The Now() function could be used alternatively. Today’s date

IT Key Ideas, Dynamic Database Systems, 2002 The Expr1: can be replaced by your own field name, eg. Current – followed by a colon : Today’s date

IT Key Ideas, Dynamic Database Systems, 2002 A person’s age is calculated by Today’s Date minus their Date of Birth Age

IT Key Ideas, Dynamic Database Systems, 2002 Functions and fields can be selected using a point and click method by using the Expression Builder. Age

IT Key Ideas, Dynamic Database Systems, 2002 Empty the field line and click on the Build button. Select Functions Built-in Functions Date/Time and double-click Date

IT Key Ideas, Dynamic Database Systems, 2002 Type or click on a minus sign then select Tables Details and double click Date of Birth Select OK

IT Key Ideas, Dynamic Database Systems, 2002 Also place the Date of Birth field in this query as a separate column. Run the query.

IT Key Ideas, Dynamic Database Systems, 2002 This calculation produces a person’s age in days, as computers store dates in days - from a starting point, such as 1/1/1900.

IT Key Ideas, Dynamic Database Systems, 2002 To determine a person’s age in years, divide the result of the subtraction by NB:The decimal component is necessary to allow for leap years every 400 and every 4 years, but not every 100 years.

IT Key Ideas, Dynamic Database Systems, 2002 Re-enter the Expression Builder and enter the division. Hint: don’t forget the extra brackets. Change the name of the calculated field to Age. Age Run the query.

IT Key Ideas, Dynamic Database Systems, 2002 Ages now appear, except they include a decimal component. To remove the decimal component, as one is 15 at 15 years and 1 day through to 364 days, another function, namely Int, is utilised. Age, as a whole number

IT Key Ideas, Dynamic Database Systems, 2002 Int is a function in both database and spreadsheet software. ExampleInt(Cost) Int(number)

IT Key Ideas, Dynamic Database Systems, 2002 Place the previous expression inside the brackets of Int function. Age, as a whole number Save this query for re-use many times.

IT Key Ideas, Dynamic Database Systems, year olds Age: 15 Age:Int((Date()-[Date of Birth])/ )

IT Key Ideas, Dynamic Database Systems, 2002 At least 15 years of age Age:Int((Date()-[D >=15

IT Key Ideas, Dynamic Database Systems, 2002 Full Names People’s full names consist of their given name(s) and their surname. To join strings of text together use the & operator. This can be constructed by pointing and clicking on the field names in the Expression Builder.

IT Key Ideas, Dynamic Database Systems, 2002

Full names of females Save this query! Both with the Sex field and without – in order to re-use the Full Name calculation in future questions! Full Name:[Given Names]&” “&[Surname]Sex F

IT Key Ideas, Dynamic Database Systems, 2002 Between 14 and 17 years of ages Age:Int((Date()-[Date of Birth] between 14 and 17

IT Key Ideas, Dynamic Database Systems, 2002 Born in the second of 1986 Age:Int((Date()-[Date of Birth] Ascending between 1/7/86 and 31/12/86

IT Key Ideas, Dynamic Database Systems, , 14 or 17 years of age Age:Int((Date()-[Da in (12, 14, 17)

IT Key Ideas, Dynamic Database Systems, 2002 Brownish hair Hair Colour *brown

IT Key Ideas, Dynamic Database Systems, 2002 Complex Criteria A query with a criterion (one single criteria) is referred to as a simple query. A query with two or more criteria is referred to as a complex query.

IT Key Ideas, Dynamic Database Systems, 2002 Complex Criteria As a complex query involves two or more criteria the conditions are joined through the use of the and or or logical operators. eg.blue eyes and blonde hair 16 years of age or male

IT Key Ideas, Dynamic Database Systems, 2002 Blue eyes and blonde hair SELECT Surname, Eye Colour, Hair Colour FROM Details WHERE [Eye Colour] = blue AND [Hair Colour] = blonde; SQL Hair ColourEye Colour blueblonde

IT Key Ideas, Dynamic Database Systems, 2002 Blue or hazel eyes Eye Colour blue hazel

IT Key Ideas, Dynamic Database Systems, 2002 Blue eyes or red hair Hair ColourEye Colour blue red

IT Key Ideas, Dynamic Database Systems, 2002 Blue eyes and blonde hair and 15 Hair ColourEye Colour bluenot blonde Age:Int((Dat 15

IT Key Ideas, Dynamic Database Systems, 2002 Blue eyes and not blonde hair Hair ColourEye Colour bluenot blonde

IT Key Ideas, Dynamic Database Systems, 2002 blue eyes and blonde hair brown eyes and brownish hair Matching hair and eyes Hair ColourEye Colour blueblonde brown*brown

IT Key Ideas, Dynamic Database Systems, who have either brown or blonde hair Hair Colour brown or blonde15 Age:

IT Key Ideas, Dynamic Database Systems, 2002 Brown hair or blonde haired 15 year olds Hair Colour brown blonde 15 Age:

IT Key Ideas, Dynamic Database Systems, 2002 Same hair colour and eye colour SELECT Surname, Hair Colour FROM Details WHERE [Hair Colour] = [Eye Colour]; SQL Hair Colour [Eye Colour]

Exercise Extension page 33 IT Key Ideas, Dynamic Database Systems, 2002 Data File People

Homework/Study Exercise 3.3page IT Key Ideas, Dynamic Database Systems, 2002 table of data page 34

Chapter 3 ********************************