Queries in Base
Complete exam-oriented revision notes for CBSE Class 10 Information Technology (402), prepared from the uploaded NCERT Domestic Data Entry Operator — Class X (2023–24) textbook.
✍️ Read • Revise • RecallSource check: Chapter 11 “Queries in Base” starts on printed page 186 of the uploaded textbook. The notes below follow the chapter content, examples, summary and Check Your Progress.
What is a Query?
A query is a sort of question asked from a database. It is used to search for desired records and retrieve the required data from one or more tables according to specified conditions.
Why are Queries Required?
As the number of records in a database increases, finding specific information by manually going through each record becomes difficult. A query allows us to retrieve the required information without individually checking every record.
📌 Key Definition
Query: A query is a feature of a DBMS used to retrieve and display data from one or more tables by providing specific search criteria.
What can be specified in a Query?
- The fields that we want to display.
- The criteria based on which records are to be filtered.
- The table or tables from which the information is required.
A query is mainly used to retrieve and display desired information from a database using specific search criteria.
How is Query Result Displayed?
The result of a query is displayed in tabular form. The field names are displayed in columns and the records are displayed in rows.
| Part | Meaning |
|---|---|
| Columns | Contain field names / column headings. |
| Rows | Contain the records retrieved by the query. |
Example — Student Database
Suppose a Student database contains a Result table. We want to display the names and marks of students who have scored less than 320 aggregate marks.
| Requirement | Specification |
|---|---|
| Name of Table | Result |
| Fields | Name, Marks |
| Criterion | Aggregate marks should be less than 320 |
Query = Fields to display + Criteria to filter records
Three Ways
A query in LibreOffice Base can be created in three ways:
| Method | Important Point |
|---|---|
| Query Wizard | Provides a step-by-step method to create a query. |
| Design View | A more flexible method for creating queries. |
| SQL View | Query can also be created using SQL view. |
Q. How many ways can a query be created in LibreOffice Base?
Answer: Three
Q. Name the three ways.
Using Wizard, Design View and SQL View.
Example Used in the Textbook
The textbook uses the Sports Day database containing two tables:
- Events
- EventCategory
The example query displays Event Name and Winner for events whose CategoryID is C001.
🎯 Query Requirement
Table: Events
Fields: Event Name, Winner, CategoryID
Criterion: CategoryID = C001
Step 1 — Open the Database
Open the Sports Day database. In the Database Design window, click the Queries button present in the Database Pane on the left.
Step 2 — Start Query Wizard
In the Tasks Area, click Use Wizard to Create Query…. The Query Wizard will start.
Step 3 — Select the Table
The first step of the wizard is to select fields from the respective table. Select the Events table from the Tables list box. The corresponding fields are displayed in the Available Fields list box.
Step 4 — Select Fields
Select the required fields and click the right arrow ( > ) button to move them into Fields in the Query. For the textbook example, select:
- Event Name
- Winner
- CategoryID
- > → Moves selected field to Fields in the Query.
- < → Moves field back to Available Fields.
- » → Moves all fields to Fields in the Query.
- « → Moves all fields back to Available Fields.
- ∧ / ∨ → Changes the order of fields.
Step 5 — Set Sorting Order
The next step is to select the sorting order. The result of a query can be displayed in ascending or descending order of a particular field. If no particular sorting order is required, click Next.
Step 6 — Set Search Criteria
The next step is to set the search condition or criterion on the basis of which records will be filtered. For the textbook example:
Field: Events.CategoryID
Condition: is equal to
Value: C001
Match All / Match Any
By default, Match all of the following is selected. If any one of the given conditions should be matched, select Match any of the following.
⚠️ Important Exam Fact
A maximum of three search conditions can be given in the Query Wizard.
Step 7 — Numerical/Summarizing Steps
The wizard contains steps for tasks such as summarizing and performing numerical calculations. If there is no numeric field involved in the query, these steps are not required and can be skipped.
Step 8 — Give Alias
An Alias is an alternative, more readable name used as the column heading in the query output. For example, instead of displaying the field name Winner, we can give the alias Winner Name.
Alias = Alternative / meaningful name of a field displayed as the column heading in query output.
Step 9 — Query Overview
The last step of the Query Wizard displays the entire overview of the query. It shows the work performed during the previous steps in summarised form.
Information Shown in Overview
- Name of the Query
- Action after Wizard finishes
- Complete detail/summary of the query
By default, the query name may be displayed as Query_Events. The default action is Display Query. The Modify Query option can be selected if the query has to be edited in Design View.
Step 10 — Finish
Click the Finish button. The records satisfying CategoryID = C001 will be displayed.
Table → Fields → Sorting → Criteria → Numerical/Summary → Alias → Overview → Finish
Why Design View?
Design View is a more flexible method for creating a query. It can be used to create a query using a single table or multiple tables.
Example from the Textbook
The textbook creates a query to display records of the Athletics category using:
- Events table
- EventCategory table
Step 1 — Open Queries
Click the Queries icon in the Objects Pane of the Database Window.
Step 2 — Create Query in Design View
Click Create Query in Design View… in the Tasks Pane. The Query Design Window appears. The Add Table or Query dialog box is displayed.
Step 3 — Add Events Table
Select the Events table and click Add. Alternatively, double-click the Events table. The table is added to the Tables Pane.
Step 4 — Add EventCategory Table
Similarly, add the EventCategory table to the Tables Pane.
Step 5 — Close Dialog Box
Click the Close button in the Add Table or Query dialog box. Both tables are now visible in the Table Pane.
Step 6 — Select Fields
For the textbook example, select:
- EventName from Events
- Winner from Events
- CategoryName from EventCategory
The selected fields appear in the Design Grid in the lower part of the Query Design Window.
Visible Check Box
The Visible check box is selected by default. This means that the field will be displayed when the query is run. If a field should not be displayed in the output, deselect its Visible check box.
Q. Is the Visible check box selected by default?
Answer: Yes.
Step 7 — Alias Row
The Design Grid contains an
Alias
row.
It is used to display a meaningful column heading instead of
the original field name.
Example:
Winner → Winner Name
Step 8 — Sort Row
By default, query data is not sorted. The Sort row is used to arrange records in ascending or descending order. For example, to display Event Name alphabetically, select Ascending under the Event Name column.
Step 9 — Run the Query
After designing the query, click the Run Query button on the toolbar. The shortcut key to run a query is:
⌨️ Shortcut Key
F5 = Run Query
Step 10 — Save the Query
Click the Save button. The Save As dialog box appears. By default, the query name may be Query1. Enter a different name if required and click OK.
Running a Saved Query Again
The saved query appears in the Objects Area of the Database Window. To run the query again, simply double-click the query name. The result will be displayed in a separate window.
Queries → Create Query in Design View → Add Table or Query → Add Tables → Select Fields → Alias/Sort/Criteria → Run with F5 → Save
Two Main Sections
The Query Design Window is divided into two sections.
| Section | Purpose |
|---|---|
| Upper Section / Table Pane | Displays the tables or queries added for designing the query. |
| Lower Section / Design Grid | Used to select fields and specify properties such as Alias, Sort, Visible and Criterion. |
Query Design Window → Two sections.
This is directly asked in the textbook's Check Your Progress.
Why Edit a Query?
After creating a query, its design can be modified. For example, a criterion can be added or changed to display different records.
Steps to Edit a Query
- Click the Queries icon in the Database Window.
- The list of created queries will appear in the Objects Area.
- Right-click the required query.
- Select Edit from the drop-down menu.
- The Query Design Window will appear.
Example — Athletics Category
To display only records belonging to the Athletics category, type:
Criterion row under Category Name:
Athletics
Applying Numerical Criteria
Suppose we want to display records where the Points scored are more than 10. Add the Points field to the Design Grid and enter:
>10
Relational Operators
The Criterion row can use relational operators such as:
| Operator | Meaning |
|---|---|
| < | Less than |
| > | Greater than |
| <= | Less than or equal to |
| >= | Greater than or equal to |
| != | Not equal to |
| = | Equal to |
The Criterion row is used to apply conditions for filtering records.
What is a Criterion?
A criterion is a condition specified in a query to filter the records according to the required value.
Examples
| Requirement | Criterion |
|---|---|
| Points more than 10 | >10 |
| Points less than 10 | <10 |
| Points equal to 10 | =10 |
| Points not equal to 10 | !=10 |
Multiple Conditions
The Criterion row can also be used to apply multiple conditions. The required conditions are entered in the appropriate fields of the query design.
📌 Remember
Criterion = condition used to filter records.
Numerical Functions in Queries
A query can do more than simply display records. When numerical data is involved, mathematical functions can be used to calculate values.
The textbook mentions functions to find:
- Count
- Sum
- Minimum
- Maximum
- Average
| Function | Purpose |
|---|---|
| Count | Finds the count of data values/records. |
| Sum | Calculates the total of numerical values. |
| Minimum | Finds the smallest value. |
| Maximum | Finds the largest value. |
| Average | Calculates the average value. |
Example — Average Points for Each Category
The textbook designs a query to display the average points for each category of events. The required tables are:
- Events
- EventCategory
Step 1 — Add Fields
Add:
CategoryName from EventCategory
Points from Events
Step 2 — Group CategoryName
Under CategoryName, click the down arrow in the Function row. Select Group. The Group option forms groups for each different data value in the CategoryName column.
Step 3 — Apply Average to Points
Under the Points column, select the Average function.
Step 4 — Run Query
Press F5 to run the query. The query result will show the average points for the categories.
CategoryName → Group
Points → Average
Run → F5
Applying a Condition on Groups
A criterion can also be applied to groups. For example, to display the average of only the Athletics category, type Athletics in the Criterion row under Category Name.
Q. Name any four mathematical functions that can be applied
to numerical data in a query.
Answer: Count, Sum, Minimum and Maximum.
Average can also be used.
| Term | Exam-Oriented Meaning |
|---|---|
| Query | A sort of question asked from a database to retrieve desired information. |
| Criterion | A condition used to filter records. |
| Alias | An alternative/meaningful name used as a column heading. |
| Design View | A flexible method of creating a query from one or multiple tables. |
| Query Wizard | A step-by-step method for creating a query. |
| Visible | Determines whether a selected field will be displayed in the query result. |
| Sort | Used to arrange query results in ascending or descending order. |
| Criterion Row | Row used to specify conditions for filtering records. |
| Function Row | Used to apply functions such as Group and Average while working with numerical data. |
| Query Wizard | Design View |
|---|---|
| Provides a step-by-step procedure for creating a query. | Provides a more flexible method for creating a query. |
| Fields are selected through the wizard's list boxes. | Fields are selected directly in the Query Design Window. |
| Search conditions are specified through wizard steps. | Criteria can be entered directly in the Criterion row. |
| Alias can be assigned through the wizard. | Alias can be entered in the Alias row. |
| Suitable for guided query creation. | Useful when more flexibility is required. |
Q. Which is a flexible way to create a query?
Answer: Design View.
- Define a query. What is the need of creating a query in a database?
- Name the three ways of creating a query in LibreOffice Base.
- Explain the steps to create a query using Query Wizard.
- What is the use of the Available Fields list box?
- What is the use of the Fields in the Query list box?
- What is the purpose of setting the sorting order?
- What is a criterion in a query?
- How many search conditions can be given at the most in the Query Wizard?
- What is an Alias? Why is it used?
- What information is displayed in the last step of the Query Wizard?
- Why are numerical/summarizing steps skipped when no numeric field is involved?
- Why is Design View considered a flexible method of creating queries?
- What is the use of the Visible check box?
- What is the use of the Alias row in the Design Grid?
- What is the use of the Criterion row?
- Name the relational operators that can be used in the Criterion row.
- What is the shortcut key to run a query?
- Name any four mathematical functions that can be applied to numerical data in a query.
- Explain how the Group function and Average function are used in a numerical query.
- How can a saved query be run again?
MCQ Topics Directly Asked
- Meaning of Query
- Ways of designing a Query
- Flexibility of Design View
- Number of sections in Query Design Window
- What is NOT true about queries
- Shortcut key F5
- Numerical functions
- Moving fields using the > button
- Relational operators
- Add Table or Query dialog box
- Numerical/summarizing step
True / False Concepts
- A query can be run more than once.
- A query can be created from multiple tables.
- F5 is used to run a query.
- A query can contain numerical data.
- By default, query results are not sorted.
- A query can display the average value of a numerical field.
- Criterion can be applied to fields.
- Alias is an alternative name for a field.
- Visible check box is selected by default.
- A query created using a wizard can be edited in Design View.
Fill in the Blanks — Key Answers
| Question Concept | Answer |
|---|---|
| A sort of question asked from a database | Query |
| Query result displayed in ______ form | Tabular |
| Number of ways to create a query | Three |
| Query Design Window sections | Two |
| Shortcut key to run query | F5 |
| Conditions are set in the ______ row | Criterion |
| Fields displayed after selecting a table in Wizard | Available Fields |
| Sorting order | Ascending / Descending |
| Maximum search conditions in Wizard | Three |
| Last Wizard step displays entire ______ | Overview |
| More flexible method | Design View |
| Column heading instead of field name | Alias row |
Remember These Actions
- Queries icon → opens query-related options.
- Use Wizard to Create Query → starts Query Wizard.
- Create Query in Design View → opens Query Design Window.
- Add Table or Query → appears when Design View is opened for the first time.
- > → moves selected field into Fields in the Query.
- ∧ / ∨ → changes field order.
- Visible → controls whether the field appears in output.
- Alias → changes displayed column heading.
- Sort → arranges records.
- Criterion → filters records.
- F5 → runs the query.
- Save → saves the query for future use.
- Double-click saved query → runs the saved query again.
🎯 Practical Recall
Fields decide what to display.
Criterion decides which records to display.
Alias decides what column heading to show.
Sort decides the order of records.
⚡ CHAPTER 11 — LAST MINUTE RAPID REVISION
- Query: A sort of question asked from a database.
- Purpose: Retrieve and display desired data from one or more tables.
- Query Result: Displayed in tabular form — field names in columns and records in rows.
- Three methods: Wizard, Design View and SQL View.
- Design View: More flexible method of creating a query.
- Wizard: Step-by-step method of creating a query.
- Maximum Wizard search conditions: Three.
- Match all: All specified conditions should be matched.
- Match any: Any one of the specified conditions can be matched.
- Alias: Alternative/meaningful name displayed as the column heading.
- Criterion: Condition used to filter records.
- Criterion row: Used to enter filtering conditions.
- Sort row: Used to arrange records in ascending or descending order.
- Visible check box: Selected by default; controls whether a field is displayed.
- Query Design Window: Divided into two sections.
- Add Table or Query: Dialog box shown when Query Design Window is opened initially.
- F5: Run Query.
- Relational operators: <, >, <=, >=, != and =.
- Numerical functions: Count, Sum, Minimum, Maximum and Average.
- Group: Forms groups for each data value in a field.
- Average: Calculates average numerical value.
- Saved query: Can be run again by double-clicking its name.
- Editing: Right-click the query and select Edit.
QUERY = SELECT → FILTER → SORT → DISPLAY
FIELD → What to display
CRITERION → Which records
ALIAS → Column heading
SORT → Order
F5 → Run