Database Management/Query by Example

This lesson introduces Query by Example (QBE). QBE is a database query language for relational databases, using visual tables where the user enters commands, example elements and conditions.

Objectives and Skills
Objectives and skills for this lesson include:
 * Understand QBE concepts
 * Create single-table QBE queries using a database application
 * Create multi-table QBE queries using a database application

Readings

 * 1)  Query by Example
 * 2)  LibreOffice Base
 * 3)  Microsoft Access
 * 4)  Microsoft Office/Create queries for a database

QBE

 * 1) YouTube: Running Queries: Query by Example (QBE)
 * 2) YouTube: Query By Example

LibreOffice Base

 * 1) YouTube: Getting Started with LibreOffice Base
 * 2) YouTube: LibreOffice Base Introduction to Queries

Microsoft Access

 * 1) YouTube: Access - Getting Started
 * 2) YouTubeː Microsoft Access - Tutorial for Beginners
 * 3) YouTube: How to Create a Calculation Query in Microsoft Access
 * 4) Microsoft: Using date criteria in queries

Activities

 * 1) Select a database application to use for this lesson. LibreOffice Base and Microsoft Access are recommended.
 * 2) Review Database Applications and Database Software for background information and tutorials.

LibreOffice Base

 * 1) For Linux, MacOS, and Windows. Download and install the free and open LibreOffice suite.
 * 2) Complete one or more of the following tutorials using LibreOffice Base:
 * 3) * ELearn: LibreOffice Queries
 * 4) * Tech Republic: How to Query a LibreOffice Database Using the Query Design View
 * 5) * LibreOffice.org: Getting Started with Base - Creating Queries
 * 6) To view the database E-R diagram, select   and.
 * 7) To view SQL for a query, open the query and then select   and.

Microsoft Access

 * 1) For Windows only. If you don't already have Microsoft Access installed, you can sign up for the free Microsoft: Azure for Students. Within the Microsoft: Azure Education Software portal, there is an option to download Access 2016.
 * 2) Complete the following tutorials using Microsoft Access:
 * 3) * GCF Global: Access - Introduction to Databases
 * 4) * GCF Global: Access - Introduction to Objects
 * 5) * GCF Global: Access - Designing a Simple Query
 * 6) * GCF Global: Access - Designing a Multi-Table Query
 * 7) * GCF Global: Access - More Query Design Options
 * 8) To view the database E-R diagram, select   and.
 * 9) To view SQL for a query, open the query and then select   and.

Northwind

 * 1) Download a copy of the Database Examples/Northwind database for your selected database application.
 * 2) Review the E-R diagram in your database application to verify that it matches the Database Examples/Northwind example. Note the primary keys, foreign keys, and relationships. Then create QBE queries to determine results for each of the following. View the SQL generated for each query.
 * 3) Select all fields and all records in the Categories table.
 * 4) Select the CustomerName for all customers.
 * 5) Select the CustomerName for all customers in the country 'Italy'.
 * 6) Select the ProductName for all products in Category 1 with a price less than $5.00.
 * 7) Select the SupplierName for all suppliers from English-speaking countries (Australia, Canada, UK, USA)
 * 8) Select the first and last names of all employees having a birthday in September.
 * 9) Select the CustomerName and OrderID for all orders placed on 9 September 1996.
 * 10) Select the ProductName for all seafood products with a supplier from 'Boston'.
 * 11) Select the CustomerName and OrderID for all customers who ordered 'Aniseed Syrup', sorted in alphabetical order.
 * 12) Select the ProductName, Quantity, Price, and ExtendedPrice (Quantity * Price) for orders 10344 and 10345.
 * 13) Select the first and last names and current age of all employees having a birthday in September.
 * 14) Select the OrderID, count of products ordered, and total order cost for orders 10344 and 10345.
 * 15) Select the total number of orders and total cost of orders shipped by 'Speedy Express' in February 1997.

Pubs

 * 1) Download a copy of the Database Examples/Pubs database for your selected database application.
 * 2) Review the E-R diagram in your database application to verify that it matches the Database Examples/Pubs example. Note the primary keys, foreign keys, and relationships. Then create QBE queries to determine results for each of the following. View the SQL generated for each query.
 * 3) Select all fields and all records in the Authors table.
 * 4) Select the emp_id and lname for all employees.
 * 5) Select the au_firstname and au_lastname for all authors in the state 'UT'.
 * 6) Select the orderid for all orders in storeid 7131 with a quantity greater than 20.
 * 7) Select the publishername for all publishers in the European-speaking countries (Germany, France).
 * 8) Select the first and last names of all employees having a hire date in June.
 * 9) Select the orderid, ord_detail, and title for all orders placed on September 13, 2024.
 * 10) Select the first and last employee name for all job descriptions with a publisher name from 'NY'.
 * 11) Select the storename and orderid for all stores that ordered 'The Busy Executive's Database Guide', sorted in alphabetical order.
 * 12) Select the title, quantity, price, and extendedprice (quantity * price) for sales orders P2121 and P723
 * 13) Select the first and last names and current number of years for all employees having a hire date in November.
 * 14) Select the order number, sum of quantity sales ordered, and total extended cost for orders P2121 and P723.
 * 15) Select the total number of orders and total cost of orders shipped by 'Bookbeat' between January - May 2023.

Lesson Summary

 * Query by Example (QBE) is a database query language for relational databases.
 * QBE is a graphical query language, using visual tables where the user enters commands, example elements and conditions.
 * QBE supports retrieving data, inserts, deletes, and updates, as well as creation of temporary tables.
 * Behind the scenes, QBE converts the user's actions into statements expressed in a database manipulation language, such as SQL. It is this statement that is actually executed.
 * It is easier and more productive for end-users (and even programmers) to select tables and columns by selecting them rather than typing in their names.
 * LibreOffice Base is a free and open-source relational database management system that is part of the LibreOffice office suite.
 * LibreOffice Base is designed to allow users to easily create, access, modify, and view databases and their data.
 * LibreOffice Base provides users with a graphical user interface that allows users to work with four main tools: tables, queries, forms, and reports.
 * Microsoft Access is a database management system (DBMS) from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software-development tools.
 * Microsoft Access users can create tables, queries, forms and reports, and connect them together with macros. Advanced users can use Visual Basic for Applications (VBA) to write rich solutions with advanced data manipulation and user control.

Key Terms

 * form
 * Provides an attractive layout used for entering or looking up data on screen.


 * join
 * Combines columns from one or more tables into a new logical table or view.


 * query
 * Provides the ability to access or modify data by asking questions.


 * report
 * Provides an attractive layout used for printing out data with sophisticated presentation.


 * table
 * Stores information about one specific kind of item.