the university of akron dept of business technology computer information systems
DESCRIPTION
The University of Akron Dept of Business Technology Computer Information Systems. The Relational Model: Query-By-Example (QBE). 2440: 180 Database Concepts Instructor: Enoch E. Damson. Query-by-Example (QBE). Query Questions represented in a way the DBMS can recognize and process QBE - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/1.jpg)
The University of AkronThe University of AkronDept of Business TechnologyDept of Business Technology
Computer Information SystemsComputer Information Systems
The Relational Model:The Relational Model:
Query-By-Example (QBE)Query-By-Example (QBE)
2440: 1802440: 180Database ConceptsDatabase Concepts
Instructor: Enoch E. DamsonInstructor: Enoch E. Damson
![Page 2: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/2.jpg)
2The Relational Model: QBE
Query-by-Example (QBE)Query-by-Example (QBE) Query Query
Questions represented in a way the DBMS Questions represented in a way the DBMS can recognize and processcan recognize and process
QBE QBE
Visual approach to writing queriesVisual approach to writing queries
Used in MS-AccessUsed in MS-Access
![Page 3: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/3.jpg)
3The Relational Model: QBE
Figure 2.3: An Example of Simple Queries
![Page 4: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/4.jpg)
4The Relational Model: QBE
Figure 2.4: Simple Queries…
![Page 5: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/5.jpg)
5The Relational Model: QBE
Simple CriteriaSimple Criteria Criteria – conditions that data must satisfyCriteria – conditions that data must satisfy
Criterion – a single conditionCriterion – a single condition
To display specific query results, enter the To display specific query results, enter the condition in the appropriate column in the condition in the appropriate column in the design griddesign grid
![Page 6: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/6.jpg)
6The Relational Model: QBE
Query with Simple Criteria
![Page 7: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/7.jpg)
7The Relational Model: QBE
Comparison (Relational) Comparison (Relational) OperatorsOperators
Finds something other than an exact matchFinds something other than an exact match
Comparison operators are:Comparison operators are:
= (equal to)= (equal to)
> (greater than)> (greater than)
< (less than)< (less than)
>= (greater than or equal to)>= (greater than or equal to)
<= (less than or equal to)<= (less than or equal to)
NOT (not equal to)NOT (not equal to)
![Page 8: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/8.jpg)
8The Relational Model: QBE
Compound CriteriaCompound Criteria
Combines comparison operatorsCombines comparison operators
Many languages use AND or OR between Many languages use AND or OR between the separate criteriathe separate criteria
In an AND criterion, both criteria must be In an AND criterion, both criteria must be truetrue
In an OR criterion, the overall criterion is In an OR criterion, the overall criterion is true if either of the individual criteria is true if either of the individual criteria is truetrue
![Page 9: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/9.jpg)
9The Relational Model: QBE
Query Using AND Criteria
![Page 10: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/10.jpg)
10The Relational Model: QBE
Query Using OR Criteria
![Page 11: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/11.jpg)
11The Relational Model: QBE
Computed FieldsComputed Fields You can include calculated fields that are You can include calculated fields that are
not in the database in queriesnot in the database in queries
Computed field (calculated field) – a field Computed field (calculated field) – a field that is the result of a calculation using one that is the result of a calculation using one or more existing fieldsor more existing fields
In a query that uses computed fields, if a In a query that uses computed fields, if a field name contains spaces you must field name contains spaces you must enclose it in square bracketsenclose it in square brackets
![Page 12: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/12.jpg)
12The Relational Model: QBE
Query Using Computed Field
![Page 13: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/13.jpg)
13The Relational Model: QBE
Calculating StatisticsCalculating Statistics
CountCount
SumSum
Avg (average)Avg (average)
Max (largest value)Max (largest value)
Min (smallest value)Min (smallest value)
StDev (standard StDev (standard deviation)deviation)
Var (variance)Var (variance)
FirstFirst
LastLast
Built-in statistics (called aggregate functions in Access) include:
![Page 14: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/14.jpg)
14The Relational Model: QBE
Query to Calculate an Average
![Page 15: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/15.jpg)
15The Relational Model: QBE
GroupingGrouping
Grouping – creating groups of records Grouping – creating groups of records that share some common characteristicthat share some common characteristic
Functions can be used in combination Functions can be used in combination with grouping where statistics are with grouping where statistics are calculated for groups of recordscalculated for groups of records
![Page 16: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/16.jpg)
16The Relational Model: QBE
SortingSorting Sorting – listing records in a query’s results in Sorting – listing records in a query’s results in
a particular waya particular way It is possible to sort using more than one fieldIt is possible to sort using more than one field Sort Key – the field on which records are Sort Key – the field on which records are
sortedsorted Major sort key (primary sort key) – the more Major sort key (primary sort key) – the more
important fieldimportant field Minor sort key (secondary sort key) – the less Minor sort key (secondary sort key) – the less
important fieldimportant field Major sort key is on the left of the grid and the Major sort key is on the left of the grid and the
minor sort key is on the rightminor sort key is on the right
![Page 17: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/17.jpg)
17The Relational Model: QBE
Query to Sort Records
![Page 18: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/18.jpg)
18The Relational Model: QBE
Query to Sort on Multiple Keys
![Page 19: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/19.jpg)
19The Relational Model: QBE
Query to Sort on Multiple Keys…
![Page 20: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/20.jpg)
20The Relational Model: QBE
Joining TablesJoining Tables Queries to select data from more than one tableQueries to select data from more than one table
Join the tables based on matching fields in Join the tables based on matching fields in corresponding columnscorresponding columns
In an Access query, a join line between In an Access query, a join line between matching fields in the two tables will be created matching fields in the two tables will be created indicating how the tables are relatedindicating how the tables are related
When joining multiple tablesWhen joining multiple tables
Add all the tables involved to the upper paneAdd all the tables involved to the upper pane
Add the query results grid in the desired orderAdd the query results grid in the desired order
![Page 21: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/21.jpg)
21The Relational Model: QBE
Query to Join Table
![Page 22: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/22.jpg)
22The Relational Model: QBE
Query to Join Tables…
![Page 23: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/23.jpg)
23The Relational Model: QBE
Update QueryUpdate Query
Update query – a query that changes dataUpdate query – a query that changes data
Makes a specified change to all records Makes a specified change to all records satisfying the criteria in the querysatisfying the criteria in the query
In Access, a new row is created that is In Access, a new row is created that is used to indicate how to update the data used to indicate how to update the data selected by the queryselected by the query
![Page 24: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/24.jpg)
24The Relational Model: QBE
Update Query
![Page 25: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/25.jpg)
25The Relational Model: QBE
Delete QueryDelete Query Queries can be used to delete one or more Queries can be used to delete one or more
records at a timerecords at a time
Delete query – deletes all the records Delete query – deletes all the records satisfying the criteria entered into the satisfying the criteria entered into the queryquery
When you change the Query type to Delete When you change the Query type to Delete Query, an extra row, called a Delete row, Query, an extra row, called a Delete row, is added to the design gridis added to the design grid
![Page 26: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/26.jpg)
26The Relational Model: QBE
Delete Query
![Page 27: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/27.jpg)
27The Relational Model: QBE
Make-Table QueryMake-Table Query
Queries can be used to create a new table Queries can be used to create a new table in either the current database or in a in either the current database or in a separate databaseseparate database
Make-table query – creates a new table Make-table query – creates a new table using the query resultsusing the query results
The data added to the new table is The data added to the new table is separate from the original table in which separate from the original table in which it appearsit appears
![Page 28: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/28.jpg)
28The Relational Model: QBE
Make-Table Query
![Page 29: The University of Akron Dept of Business Technology Computer Information Systems](https://reader036.vdocument.in/reader036/viewer/2022062518/56813ff8550346895dab26a8/html5/thumbnails/29.jpg)
29The Relational Model: QBE
Make-Table Query…