LibreOffice Base GUI Query Design Notes

Fundamentals of Database Queries

  • A database query asks a question of a database. Instead of manually scrolling through every record in a table, a query pulls out exact rows and columns based on specific needs.

  • Core functions of a query include:

    • Retrieve: Fetch specific fields instead of an entire table.

    • Filter: Show only records that meet defined conditions (Criteria).

    • Sort: Arrange results in ascending or descending order.

    • Combine: Pull related data from more than one table simultaneously.

  • Conceptual Query Workflow: Table→Query→Result\text{Table} \rightarrow \text{Query} \rightarrow \text{Result}

    • Original Table Example (Students):

    • ID 1: Asha, Marks 88

    • ID 2: Ravi, Marks 45

    • ID 3: Meera, Marks 77

    • ID 4: Kabir, Marks 39

    • Applied Criteria: Marks≥50\text{Marks} \ge 50

    • Query Result Output:

    • Asha, Marks 88

    • Meera, Marks 77


Table to Query to Result Transformation Process

Objects in LibreOffice Base

  • LibreOffice Base serves as the graphical database front-end of the LibreOffice suite. It connects to a data source and provides a point-and-click interface without requiring SQL coding.

  • Base provides four main object types for database management:

    • Tables (T): Store raw data arranged in rows and columns.

    • Queries (Q): Ask questions of the data using criteria and filters.

    • Forms (F): User-friendly screens designed for data entry.

    • Reports (R): Formatted, printable summaries of stored data.

Interface Anatomy of Query Design View

  • Base's Query Design view is split into two main sections:

    • Table Pane (Top): Displays window boxes containing field lists for all tables selected for the query.

    • Design Grid (Bottom): Matrix where fields, sorting rules, output visibility, and filter criteria are configured.


Query Design Window showing Table Pane and Design Grid
  • Detailed breakdown of rows in the Design Grid:

    • Field: The selected field name from a table.

    • Table: The source table from which the field originates.

    • Sort: Controls record ordering (Ascending, Descending, or un-sorted -).

    • Visible: Checkbox (✓) determining whether the field appears in the final query result table.

    • Criteria: The row where filter conditions are typed to filter records.

Step-by-Step Procedure for Query Creation

  • Step 1: Open the Queries pane

    • In the Base main window, click Queries in the left-hand Database panel.

  • Step 2: Create Query in Design View

    • Double-click Create Query in Design View to open the query designer.

  • Step 3: Add table(s)

    • In the Add Table dialog, select one or more tables, click Add, and then click Close.

  • Step 4: Add fields to the grid

    • Double-click each required field in the table pane to drop it into the Design Grid columns.

  • Step 5: Set Sort & Criteria

    • Choose desired sort orders and type filter conditions into the Criteria row.

  • Step 6: Run and save

    • Click the Run Query icon to preview output results, then save the query under a unique name.

Single-Table Query Operations

  • A single-table query pulls data from only one table, filtering down to relevant fields and rows.

  • Worked Example Query Task: "Show me each student's Name and Class from the Students table."

    • Setup Steps:

    • Add only the Students table to the Design Grid.

    • Double-click Name and Class to place them into grid columns.

    • Leave StudentID, Marks, and Email out of the grid.

    • Do not enter any criteria (returns all table rows).

    • Source Data (Students Table):

    • StudentID 101 | Asha | Class 10 | Marks 88 | asha@mail

    • StudentID 102 | Ravi | Class 9 | Marks 45 | ravi@mail

    • StudentID 103 | Meera | Class 10 | Marks 77 | meera@mail

    • Query Output Result:

    • Asha | Class 10

    • Ravi | Class 9

    • Meera | Class 10

Sorting Query Results

  • Record ordering is controlled through the Sort row in the Design Grid by clicking the cell below a field name.

  • Ascending Sort (↑\uparrow):

    • Orders values from smallest/earliest to largest/latest (A→Z\text{A}\rightarrow\text{Z}, 0→90\rightarrow 9, oldest to newest date).

    • Example Result (Sorted Ascending by Marks):

    • Ravi | 45

    • Meera | 77

    • Asha | 88

  • Descending Sort (↓\downarrow):

    • Orders values from largest/latest to smallest/earliest (Z→A\text{Z}\rightarrow\text{A}, 9→09\rightarrow 0, newest to oldest date).

    • Example Result (Sorted Descending by Marks):

    • Asha | 88

    • Meera | 77

    • Ravi | 45

  • Multi-Field Sorting Rule: Sorting can be applied across multiple fields simultaneously; the leftmost sorted field in the Design Grid acts as the primary sort key.

Criteria Rules and Data Formatting

  • Criteria are conditions typed into the Design Grid to filter records, functioning identically to a WHERE clause in SQL.

  • Data Type Formatting Rules:

    • Text Values: Require enclosing double quotes (e.g., `=