RDBMS Class VIII
RDBMS Class VIII
Introduction
Imagine you have a huge collection of different kinds of information, like names, addresses,
and phone numbers. Keeping track of all this information can get messy. A database is like a
super-organized filing cabinet that helps you neatly sort and manage all of this information so
you can find what you need quickly.
In this session, we’ll explore how databases work and focus on using LibreOffice Base, a free
tool that helps you create and manage databases. With OpenOffice Base, you can easily set
up and organise your information without any cost.
We’ll start with the basics, like what a database is and how relational databases work. These
are excellent for connecting different pieces of information. You’ll also learn about key
concepts like primary keys (which are like unique IDs for each piece of data) and foreign
keys (which help link related information together).
OpenOffice Base lets you create forms to enter data, generate reports, and search for
information—all in a simple and user-friendly way. It’s like having a smart assistant to keep
everything organised and easy to find.
Let’s get started and see how databases can make managing information much simpler!
Think of it like this: while it’s easy to remember the names of your friends, memorizing their
phone numbers is more challenging. If you store details like names and phone numbers in a
diary or mobile phone in an organized way, retrieving a specific phone number becomes
much easier. In this sense, the phone book acts as a simple database, and managing this
database electronically would require a DBMS.
Data Integrity: A DBMS ensures that data remains accurate and consistent, even if the
database structure changes. The applications using the data don’t need to be modified when
the database is updated.
Data Consistency: Data remains the same no matter who is accessing it, ensuring everyone
works with identical information.
Data Backups: It is easy to back up data from a central location, making it safer and more
reliable.
Data Security: Data is stored securely in a central location, and access can be controlled by
assigning different privileges to different users.
Data Accessibility: A major advantage of a DBMS is that it allows multiple users to access
the same data from different locations and at any time. This means that users can access
information remotely, round the clock.
Reduced Data Redundancy: A DBMS minimises data duplication, ensuring that information
is stored concisely and only once. This is achieved through a process called Normalisation,
which helps reduce storage costs and improves data integrity.
Simplified Data Management: DBMS software provides easy-to-use tools for entering,
modifying, and exporting data, making data management simpler. It also reduces the need for
users to rely on computer specialists or programmers to meet their specific data needs.
Independence from Programming Languages: One of the benefits of DBMS is that it is not
tied to any specific programming language. Users don’t need to learn a particular language to
access the database; writing SQL or NoSQL queries is sufficient, regardless of the
programming language used in the application.
Data Durability: DBMS ensures that data is durable, meaning that it remains intact even in
the event of a power outage or other disaster. The data in the database persists, ensuring its
safety and reliability.
A Relational Database Management System (RDBMS) is software that helps create, update,
and manage a relational database. In these databases, data is stored in tables, where columns
represent fields and rows represent records. To interact with the data, we use a language
called SQL (Structured Query Language), which allows us to store, modify, and retrieve
information from databases like MySQL, SQL Server, Oracle, and others.
In a relational database, tables are independent, each belonging to a different part of the
organization. However, they need to be connected to make meaningful relationships. This
connection is made using special fields called key fields. These key fields link tables
together, helping us understand the relationships between different sets of data. Before diving
deeper into RDBMS, it's important to grasp how these key fields work.
Here are some important terms related to a Relational Database Management System
(RDBMS):
Entity
An entity is a real-world object about which information is stored in a database. For example,
in a school database, a Student can be an entity. To store information about this entity, we
would include details like admission number, roll number, name, father’s name, date of birth,
etc. These details are called attributes, and they describe the entity. In this case, the attributes
like roll number, name, and admission number are specific pieces of information about the
Student entity. These attributes are shown as columns in a table.
Tables
Tables are the fundamental structures in a database where data is stored. A table is a
collection of related records, organized into rows and columns. Each row represents a single
record, while each column represents a specific attribute or field of that record.
Data Values
Data values are the actual pieces of information stored in the database, which can be in the
form of numbers, text, or a mix of both (alphanumeric).
Fields/Columns
Fields or columns are the individual pieces of data within a table. Each field has a specific
data type, like text, number, or date. A field is the smallest unit in the database. Multiple
fields make up a record, multiple records make up a table, and multiple tables make up a
database.
Records/Rows
Records or rows are individual entries in a table. Each record consists of data values for all
the fields related to one person or object. Every row represents one instance of data, with
each column containing a specific attribute or value for that instance.
Keys
A key is a field or a combination of fields that uniquely identifies a record (row) in a table.
Keys are crucial for maintaining data accuracy and creating relationships between different
tables in an RDBMS.
Relationships
Relationships describe how tables in a database are connected to each other. Common types
of relationships include one-to-one, one-to-many, and many-to-many. Relationships are
established using foreign keys, which are fields in one table that link to the primary key in
another table.
Constraints
Constraints are rules that ensure data accuracy within a database. They specify the conditions
that data must meet to be added, updated, or removed from a table. Common constraints
include primary key constraints, foreign key constraints, unique constraints, and check
constraints.
Queries
Queries are commands or statements used to retrieve, modify, or analyze data within a
database. Queries allow users to perform actions like selecting specific records, calculating
totals, updating data, and linking multiple tables.
Degree
The degree of a table refers to the number of attributes or columns it contains. For example, if
a table has five columns, its degree is 5.
Cardinality
Cardinality refers to the number of rows or records in a table. For example, if a table contains
100 rows, its cardinality is 100. Domain
Columns or Fields or
Attributes 10000,
10000
00
EMP_NO EMP_NAME DESIGNANATION SALARY
Primary
Key E1001 SAMEER MANAGER 900000 Cardinalit
y
E1002 SUMEDHA CLERK 40000
Rows (No. of
Or E1003 VANSHIKA MANAGER 900000 Rows) = 4
Records
Or Tuples E10004 AMAN PEON 150000
In a relational database, some fields have special roles because they have unique features.
Here are three important types of key fields:
Primary Key: A primary key is a special column in a table that uniquely identifies each
record or row. There can only be one primary key in a table. The key features of a primary
key are:
Example: In a School Database, imagine a table with fields like admission number, name,
date of birth, and address. Out of these, the admission number is the best choice for the
primary key because it is unique to each student. Other fields like name, date of birth, or
address might not be unique, because if we look at the other fields, two students can have the
same name, twins will have the same address, and the date of birth can also be the same for
some students.
STUDENT Table
Foreign Key
We use a foreign key to link two tables. A Foreign key identifies a column or a set of
columns in one table, which refers to the Primary key or a column or a set of columns in
another table. A table can have multiple foreign keys.
Here’s an example:
A composite key is created when more than one field works together as a primary key,
uniquely identifying each record in a table. None of the fields within a composite key can be
null. Although individual fields in a composite key may contain duplicate values, their
combined values must be unique for each record.
Example: In the school database, we have a STUDENT table where the primary key is the
admission number (Admn. No.). Now, let's create another table named EXAM_RESULTS.
This table will include fields like Admn. No., Exam Roll No., Student Name, marks in five
subjects, Total Marks, Percentage, and Rank.
The Exam Roll No. is coded as class-section-roll number. For example, "10567" might be the
exam roll number for a student in class 11 C with the class roll number 67. In this case, Exam
Roll No. is made the primary key, and Admn. No. is the foreign key, linking to the
STUDENT table.
Next, let's create a TOPPER_LIST table that records the top three rank holders for each
year. This table includes fields like Exam Roll No., Year_of_Passing, Student Name,
Percentage, and Admn. No.
Since the same roll numbers are given to new students each year, Exam Roll No. alone
cannot be the primary key. Instead, we use a composite key that combines Exam Roll No.
and Year of Passing. For example, "10567, 2023" and "10567, 2024" will represent two
different records.
STUDENTS Table
Primary Key
EXAM_RESULTS Table
Primary Key
Exam
Admn. Student Subject Subject Subject Subject Subject Total
Roll Percentage Rank
No. Name 1 2 3 4 5 Marks
No.
Rohan
201 10567 78 82 85 80 79 404 80.8% 2
Mehta
TOPPER_LIST Table
Composite Foreign Key
Key
Year_of_Passin
Exam Roll No. Student Name Percentage Admn. No.
g
Introduction
In today's session, we'll be exploring how relational databases work by using a tool called
OpenOffice Base. OpenOffice Base is a Database Management System (DBMS) developed
by the Apache Software Foundation. It's part of the OpenOffice Suite, which also includes
other useful programs like Word, PowerPoint, and Excel. This will help us understand how
databases store and organise data, making it simple to manage and retrieve information.
Base software enables us to work with data organised in tables, also known as relations. With
Base, you can easily manage, create, insert, delete, and retrieve data. It also lets you display
the information in a way that suits your needs, using special features designed for these tasks.
Let's get started.
DATABASE OBJECTS
Tables
OpenOffice Base databases consist of the
(Sets of related data)
following four main components:
• Tables
• Queries Forms
(An easy-to-use interface for (Results generated from
• Forms entering and viewing data) questions asked of tables)
• Reports
Queries
Reports
(Formatted data summaries
that are ready for printing)
These parts work together to help us enter, store, analyse, and organise our data in any way
we like. Let's understand what each of these parts does:
Table: A table is where data is stored in rows and columns. Each row is called a record, and
each column represents the field values for different records. Tables are sometimes called
relations. We use them to centralize all related data about a topic or entity. You can add,
delete, search, and update data in a table.
Query: A query is a tool that allows you to find and retrieve specific data from one or more
tables. It allows you to search, filter, sort, and group the data stored in a database. When you
create a query, you set criteria to filter the data, which helps you focus on just the information
you need.
Form: A form is a tool that lets you insert, update, or search for data
in a database. You can save a form and use it whenever you
need to work with your data. Forms make it simple to enter Brain Battle
new data, make changes to existing data, or find specific
information in your tables. Amit was noting down the features
of a database. Which of the
Report: A report helps you display the information from following features is he most likely
to include in his list?
your database in a way that you choose. You can decide
how the report should look, including the format and the a. Inconsistency b. Durability
data it should include. You can view a report on your screen c. Data anomalies d. Redundant data
or print it out, displaying data from one or more tables.
Before printing, you can preview the report to make sure everything looks right.
Starting OpenOffice Base
Step 1: When OpenOffice Base opens, select the "Create a new database" option by
clicking the radio button next to it.
• If you want to skip the remaining steps and create a database quickly, you can click
the Finish button.
Step 2: In the next window, under the registration section, choose "No, do not register the
database" by clicking its radio button.
• Choose your next step after saving the database file in the section below. You can
check the box for "Open the database for editing" if you want to start working on it
right away. If you want to create a new table using the table wizard, you can check the
box for "Create tables using the table wizard."
Note that an OpenOffice database is saved with the extension .odb. When you create a new
database named New Database.odb, it includes the following objects: Tables, Queries,
Forms, and Reports. After creating the database, the OpenOffice Base interface will open, as
shown in the image below.
The database is opened in a window. In this window, you will be provided with various
options to create or use tables, queries, reports and forms.
Title Bar
Menu Bar
Standard
Tool
Tasks Pane
Database
Pane
Tables/
Queries/
Forms/
Reports
pane
Status Bar
The user interface of OpenOffice Base is designed to give users easy access to database
management tools and features. Here's an overview of its main components:
Title Bar: The title bar shows the name of the database you're working on and the OpenOffice
Base application. It also includes the window control buttons for minimising, maximising,
and closing the window.
Menu Bar: The menu bar contains various menus like File, Edit, View, Insert, Tools,
Window, and Help. These menus offer a wide range of commands and options for managing
databases, designing forms, creating queries, generating reports, and more.
Standard Toolbar: Located below the menu bar, the standard toolbar offers quick access to
commonly used tools and commands. It includes icons for tasks like opening and saving
databases, creating new objects (tables, queries, forms, reports), printing, sorting, and more.
Database Pane: The database pane provides a hierarchical view of the various elements
within your database project, such as Tables, Queries, Forms, and Reports. You can navigate
through these components to manage and interact with your database objects.
Task Pane: The task pane offers options for performing common actions based on the
selected object in the database pane.
Tables/Queries/Forms/Reports Pane: This pane allows you to manage and access various
elements of your database. By default, it is usually positioned below the task pane, providing
easy access to different objects within your database.
Status Bar: Located at the bottom of the interface window, the status bar displays information
about the current state of the database or the active object. It may show the number of records
in a table, the type of view being used, or other relevant details.
To open an already existing database in OpenOffice Base, follow the given steps:
Step 1: Start the OpenOffice Base application by clicking on its shortcut on the desktop or
selecting it from the Start menu.
Step 2: Once the application opens, you'll see a window with several options. Choose the
"Open an existing database file" option by clicking on the corresponding radio button.
Step 3: Click on the dropdown list in the Recently used section, showing recently used
database files in OpenOffice Base. You can select your desired file from this list in the
Recently used section. If the file you want to open does not appear in the list, click the Open
button.
The Open dialog box appears.
In OpenOffice Base, the table is the fundamental component of a database. A table consists
of fields and field values, which are organized as records. Each field in the table has a name
and a data type associated with it. The data type of a field determines the type of data that can
be entered into that field for each record. Additionally, each field has properties that define its
behaviour.
The field name is the identifier used to access or refer to a field within the table. It typically
reflects the type of data stored in that field. For instance, consider a table named Student. In
this table, a field might be named Marks, indicating that it stores the marks obtained by
students. The field name should be intuitive, meaning it should clearly represent the kind of
data it holds. Fields are displayed as columns in the table, and when all the columns (fields)
are combined, they form the entire table. Field names can include letters, certain special
characters like underscores, dots, square brackets, and numbers. For instance, if a field name
consists of multiple words, they can be connected using an underscore, such as first_name.
A database can store various types of data in different fields of each record. The fields in a
database can contain data such as numbers, text, dates, binary objects, or Boolean values.
Therefore, it is necessary to assign a data type to each field, which specifies what kind of data
that field can hold and what operations can be performed on it.
For example, consider a table named Library. If a field is called Published_Year, it should
be assigned a numeric data type since it will store numerical values representing years. On
the other hand, a field named Cover_Image might store the book's cover photo in binary
form as a large object. This field would need a data type capable of storing binary data, such
as Binary.
Assigning a data type to a field restricts it from holding any values outside of its designated
type. For instance, if you set a field's data type to Date, you won't be able to enter text or
numbers that aren't in date format.
Numeric Types
Numeric data types are used to store numerical values, including both whole numbers
(integers) and real numbers with decimal points. These data types support arithmetic
operations, allowing calculations to be performed on the stored numbers.
These data types are ideal for fields such as Roll Number, Phone Number, Marks, Year of
Joining, Salary, Cost, Amount, or any other field that requires numerical data.
BOOLEAN boolean 1 no 0 or 1
This data type is designed to store combinations of numbers, letters, and other characters.
Since it handles text-based information, arithmetic operations cannot be performed on data
stored in this format.
Alphanumeric/Text data types are commonly used for fields such as Name, Address, City,
Customer Name, Product Name, Product Description, and similar textual information.
Data
Name Max length Description
type
Binary Types
Binary data types store information in a binary format. They are used for storing data such as
images, audio, video, or other file formats, including voice messages, sound clips, employee
photos, and similar content.
Data Max
Name Description
type length
The currency data type is used to store monetary values and can represent amounts in
different currencies. For example, $100, £500, or ₹25.50.
Date Time
This data type is used to store information in the form of a date, time, or both. Dates and
times can be stored in various formats, making it suitable for fields such as date of joining,
date of birth, login time, logout time, retirement date, date of admission, and more.
The Boolean data type is used to represent logical values, typically True or False. In e Base,
however, there isn't a dedicated Boolean data type like in some other database systems.
Instead, Boolean values are usually represented by integers, where 0 signifies false, and any
non-zero value indicates true.
Creating a Table
A table, or relation, is a component used to organize and store data in a structured format. To
create a table in OpenOffice Base, start by clicking on the Table icon located in the Database
Window Pane on the left side of the screen. You will then have three options for creating a
new table:
1. Design View
2. Create View
3. Wizard
You can create a table using Design View, which defines both the table's structure and name.
This includes specifying the field names, data types, and properties for each field. To create a
table in Design View, follow these steps:
Step 1: Select Tables option in the Database pane.
Step 3: In the Field Name column, enter the names of the fields for your table. Each field
name must be unique. You can add as many fields as needed.
Step 4: For each field, choose a data type from the dropdown list in the Field Type column.
Select a data type that matches the kind of data you want to store.
Step 5: In the third column, you can provide a description or notes for each field. This step is
optional.
The green arrow key before the cell shows the currently active field.
Field Properties
Field properties enhance the functionality of fields within a table. You can set these
properties in two ways:
1. While designing the table structure in Design View, you can modify the field
properties alongside.
o Step 2: Right-click on the table and choose the "Edit" option from the context
menu.
This will open the table in the Table Design window, where you can adjust the structure and
edit the field properties.
Here are the field properties available for Numeric data types:
AutoValue: Automatically increments a numeric value that is unique for each record when
added to the table. Typically, this field serves as the primary key, and the user cannot
manually input data into it. The drop-down for this property includes the option Yes.
Length: Specifies the maximum length a field can have for storing a value. This property
cannot be modified when the AutoValue property is set to Yes. For instance, if the field
Emp_No should only contain five characters, the length can be set to 5.
Default Value: Assigns a default value to the field, which the user can change during data
entry. For example, the field Salary can have a default value of 30000. This option is
unavailable when AutoValue is set to Yes.
Decimal Places: Defines the number of decimal places allowed in a numeric field. For
example, if you set decimal places to 2 for Salary, you can enter values like 3456.78.
Format Example: Allows the user to change how data in a field is displayed in the Table
Data View.
Set Primary Key (Optional):
Primary Key
If you want to change or remove the Primary Key, repeat step 6 for the field that is already a
Primary key.
Step 7: Click on the Save button in the Standard toolbar, or choose Save from the File menu.
You can also use the shortcut Ctrl + S.
A Save As box will appear. Enter a name for your table and click OK.
Step 8: To close the Design View window, click the Close button in the title bar at the top
right corner.
The Tables pane now displays your table with the defined structure.
Create Table using Wizard
You can also create a table using the Wizard. Wizards are predefined templates available in
OpenOffice Base that allow you to create a new table by using fields, constraints, and other
elements from existing tables. To create a table using the Wizard, follow these steps:
Step 1: Click on Use Wizard to Create Table in the Task pane. A "Table Wizard" dialog
box will appear.
Step 2: In the Category section, select the category that best matches the type of table you
want to create (e.g., Business or Personal). The Sample tables dropdown will change
according to the selected category.
Step 3: Choose a table from the Sample tables section. In the Available fields section, select
the fields you want to include in your table by clicking on them and then on the > button. If
you want to include all fields, click >>. If you accidentally add a field, select it in the
Selected fields section and press < to remove it.
Step 4: Click Next to proceed. Here, you can modify the data types, properties, and
constraints for the selected fields. This step is optional.
Step 5: In the next step, you can create a Primary Key, Composite Primary Key, or enable
Auto Value. Select the checkbox next to Create a Primary Key if needed. Click Next to
continue.
Step 8: Choose the Insert data immediately option by selecting the corresponding radio
button under What do you want to do next?
Step 9: Click the Finish button to complete the table creation process using the Wizard.
Since we selected Insert data immediately, the table will open in data view, where you can
start entering records directly.
You can also create a table using Create View. This method allows you to build a table by
combining fields from one or more existing tables. Here's how to do it:
Step 3: If you want to create more tables, just repeat Step 2 for each table. When you're done,
click the Close button.
Step 4: The selected tables will appear in the box at the upper section of the window. Double-
click on the fields in each table to add them to the new table. Repeat this process until all
desired fields are added.
Step 5: Click on the Save button located on the toolbar, or use the keyboard shortcut CTRL
+ S to save the table.
Step 6: A Save As dialog box will appear. Type the name of the table in the associated field
and press the OK button.
Step 7: In the File menu of the window, click on Close to close the window.
The Tables section of the main window will create and display your new table with the
desired fields.
Introduction
In the previous session, we learnt how to create tables in a database. But after creating these
tables, we also need to fill them with data, and sometimes, we might need to edit or delete a
table. Additionally, we set up relationships between tables to prevent data duplication and
inconsistencies. This ensures that our database stays organised, with no duplicate records or
conflicting information across different tables. When we link tables together, any changes
made in one table automatically update the related tables. In this session, we will focus on
how to do all of this: editing tables, setting up relationships, and maintaining the database.
Once you have created a table, you may need to modify its structure or design to better suit
your requirements. OpenOffice Base allows you to make these adjustments easily. You can
add new fields, remove or modify existing ones, and change the format, data types,
properties, and constraints of the table’s fields.
Adding Fields
To add new fields to an existing table, follow these steps:
Step 1: Select the table in the Tables tab you wish to modify.
Step 2: Select the Edit → Edit… option from the Menu bar. This will
open the table in Table Design View.
Step 3: In the Field Name column, type the name of the new field. In the
Field Type column, select the appropriate data type for the field. If
desired, you can also add a description. You can further set the properties
of the field as needed.
Deleting Fields
To remove fields from an existing table in OpenOffice Base, follow these steps:
Step 1: Select the table in the Table tab from which you want to delete fields.
Step 2: Select the Edit → Edit... option from the Menu bar. The table will open in Table
Design View.
Step 4: Select the Delete option from the Context menu. The
chosen field will be removed from the table.
Step 6: Click the Save button on the toolbar to save your table with the updated structure.
Step 7: Finally, go to the File menu and choose Close to exit the window.
Modifying Fields
Step 1: Select the table in the Table tab from which you
want to delete fields.
Step 2: Select the Edit → Edit... option from the Menu bar.
The table will open in Table Design View.
Step 5: If you wish to modify additional fields, repeat steps 3 and 4 as per the requirements.
Step 6: Click the Save button on the toolbar to save your table with all the modifications.
Step 7: Click the cross button to exit the Table Design View.
After creating the table, the next step is to enter data into it. You can later use this data for
querying or processing as needed. Follow the given steps to enter data into the table:
Step 1: Double-click on the table name where you want to enter data. Alternatively, you can
select the Open Database Object option from the standard toolbar.
This view displays the table with the field names in the top row, arranged in the same order
as they were added during table creation. If there are more fields than can fit in a single row,
you can use the horizontal scroll bar to view all of them. The cursor will be blinking in the
second row, ready for data entry.
Step 2: Click on the cell in the first empty row, where the cursor will start blinking. Type the
desired value in this field.
Step 3: To move to the next cell, press the Tab key or click on the adjacent cell. Enter the
value in this field as well.
Step 4: Continue this process for all the fields of a particular record in the table. Once you've
entered all the values for one record, you can add additional records as needed. To do this,
press the Enter key after completing the data entry for one record. The cursor will
automatically move to the first cell of the next row, allowing you to start entering values for a
new record.
Step
5:
Once you have entered all the necessary data, click the Save button on the toolbar to save
your table with the newly inserted records.
Step 6: Click the Cross (×) button on the Title bar to exit the window.
Step 1: In the Tables pane, double-click on the table name containing the data you want to
update. Alternatively, you can click on the Open Database Object option on the standard
toolbar.
Step 2: The table will open in Data View. Click on the specific field of the record you want
to modify, delete the existing value, and type in the new value.
Step
3:
Continue this process for any other fields or records that need updating.
Step 4: Click the Save button on the toolbar to save the table with the updated records and
field values.
Step 5: Click the Cross (×) button on the Title bar to exit the window.
Record Selector Text Box: This text box displays the number of the currently active record.
You can enter a specific record number in this box to select and activate that record in
Datasheet View.
Navigation Buttons: These buttons allow you to move through the records in the table. They
function as follows:
• The first button takes you to the first record in the table.
• The previous button moves to the record immediately before the currently selected
record.
• The next button moves to the record immediately after the currently selected record.
• The last button takes you to the last record in the table.
Sorting data involves organising it in either ascending or descending order based on the
values in a particular field of a table. In OpenOffice Base, you can sort data by one field or by
a set of fields. The sorting feature allows you to arrange data using the Sort Ascending or
Sort Descending options. To sort data in a specific table, follow these steps:
Step 1: In the Tables pane, double-click on the table whose data you want to sort.
Alternatively, you can click on the Open Database Object option on the standard toolbar.
Step 2: Click on the header of the column by which you want to sort the data. For example, if
you want to sort the data by the Emp_Name column, click on its header. The entire column
will be highlighted in blue, indicating that it is selected.
Step 3: On the standard toolbar, click the Sort Ascending ( )button to arrange the records
in ascending order based on the selected field.
Step4: To sort the data in descending order, click the Sort Descending button.
Step 1: In the Tables pane, double-click on the table name from which you want to delete
records. Alternatively, you can click on the Open Database Object option on the standard
toolbar.
Step 2: Right-click on the left side of the first field of the record you want to delete. A context
menu will appear.
Step 3: Select the Delete Rows option from the context menu. Alternatively, you can press
the Delete key on your keyboard after selecting the record.
A confirmation box will appear, asking if you want to delete the selected record.
Step 4: Click the Yes button to confirm. The selected record will be deleted.
Step 5: Repeat the deletion process for any additional records you wish to remove.
Sorting by Applying Multiple Sort Criteria
Consider a scenario where you want to sort the records in a table based on a specific field. If
two or more records have the same value in that field, you'll need to use additional criteria to
sort the records further. This is known as multiple sorting. In multiple sorting, when there is a
tie between the values of two or more records in the primary sorting field, additional criteria
are used to break the tie by sorting based on another field.
Step 1: Click the Sort ( ) button present on the Standard toolbar. A Sort Order dialog box
will appear.
Step 2: In the Sort Order dialog box, select the field you want to sort by first from the first
dropdown menu labelled Field name. In the corresponding Order dropdown list, choose
either Ascending or Descending to set the sort order.
Step 3: In the next dropdown menu below, labelled and then, select another field by which
you want to further sort the records in case of a tie. Again, choose the order as Ascending or
Descending from the corresponding Order dropdown list. You can repeat this step to add
one more sorting criterion if needed.
Brain Battle
Introduction
Databases are powerful tools used to store and manage information in an organised way,
making it easy to retrieve and use. One of the key features of a database management system
(DBMS) is the ability to use queries. A query is essentially a question asked to the database
to get specific information from it.
Queries help you search for and retrieve data based on certain criteria. For example, you
might want to see only the records of students who scored above 90% in their exams or find
all the products in a store that are currently out of stock. By specifying what you need, you
can filter, sort, and display data from one or more tables in the database without having to
look through each record manually.
As the amount of data grows, finding the right information can become challenging. Queries
simplify this process by allowing you to extract and present only the data you need; in the
format you want. In this session, we'll explore how to create, save, and run queries in
OpenOffice Base to efficiently manage and retrieve your data.
Queries
For instance, imagine you are managing a library database and you want to find all the books
that are currently checked out. To do this, you would create a query with the following
details:
The result of this query would be a list of books that are currently checked out, showing their
titles, authors, and due dates, displayed in a neat table format. This allows you to quickly
identify which books are not available and when they are expected to be returned.
A query is incredibly useful for extracting information from multiple tables by filtering data
based on specified criteria. Filtering is the process of using a query to narrow down data
based on specific criteria. This means that only the records that meet the defined conditions
will be shown to the user, while any data that does not match the criteria will be excluded.
OpenOffice Base enables you to create queries using Structured Query Language (SQL) and
save them as objects within the database. This feature allows you to run the query as needed,
multiple times, for consistent and efficient data retrieval.
Creating a Query
To create a query in OpenOffice Base, follow these steps. There are three methods you can
use:
Design View allows you to build a query by specifying the tables and criteria. For instance,
let's create a query that shows the number and name of employees, along with their salaries,
who earn more than 35,000 dollars.
The upper section shows the tables used in the query design. The lower section is the design
query grid, where you specify:
Fields: Select the fields to be included in the query output.
Alias: Assign an alternate name to a field in the output window.
Table: Specify the table from which a field is selected.
Sort: Decide if the field should be sorted in ascending or descending order.
Visible: Indicate if the field should be displayed in the output.
Criterion: Define the condition for displaying rows.
Step 5: Click the drop-down arrow next to the Field option. A drop-down list appears.
Step 6: Select the desired field from the respective tables in the drop-down list. In this case,
we have selected the Emp_No as shown below:
Step 7: Repeat steps 6 and 7 to add more fields. In this case, we have added the following
fields:
Step 8: Clicking on the column next to the Table will automatically populate the column with
data based on the selected fields.
Step 9: Type >=35000 in the Criterion cell under Salary in the query definition table.
Step 10: Save the query by selecting File → Save As from the menu bar, or click the Save
button in the toolbar. The Save As dialog box will appear with the default name Query1.
Step 11: Enter a name for the query in the Query name text box and click the OK button.
Step 12: Click on the File → Close option from the Menu bar to close the Query Design
window.
The query named Employee_Sal will now appear under the Queries pane in OpenOffice
Base.
Step 13: To run the query, double-click the query, or right-click on it and select Open from
the context menu. The results will be displayed in the output window.