Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
313 views38 pages

RDBMS Class VIII

notes of software alternative to microsoft access

Uploaded by

aam aadmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
313 views38 pages

RDBMS Class VIII

notes of software alternative to microsoft access

Uploaded by

aam aadmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Unit 3

DATABASE MANAGEMENT SYSTEM


Session 1: Appreciate the concept of Database Management System

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!

Understanding Data and Information

Data refers to raw facts or figures, like individual numbers,


dates, or names. These bits of information by themselves may not Knowledge Casket
convey much meaning. However, when data is processed,
"The numbers have no
organised, or analysed, it becomes information—something that
way of speaking for
is meaningful and can be used to make decisions or understand
themselves. We speak
patterns.
for them. We imbue
Examples: them with meaning."
—Statistician Nate
• A list of dates is just data, but knowing these dates are Silver in the book The
public holidays gives them context, turning them into Signal and the Noise
information.

• Temperature readings taken over the last century are data,


but analysing them to conclude that global temperatures are rising turns that data into
information.
Understanding Structured Data

Structured data is a collection of related information organized


systematically in rows and columns. This organization allows the data
to be easily stored, searched, and processed. Structured data is Fact Locker
typically found in tables, databases, or similar formats, where the data
is arranged in a predefined way. Because of its organized nature, According to an
structured data is highly searchable using standard methods, making it annual survey by
a valuable resource for businesses and organizations. In contrast, S&P Global, 26% of
unstructured data lacks this organization and requires advanced enterprise leaders
analytics to extract meaningful insights. report that all
strategic decisions in
Classifications of Structured Data: their business are
data-driven, while
Flat File: A flat file stores data in a plain text format, with the
30% indicate that
information arranged in rows and columns. However, this format does
only ‘some’ or ‘few’
not support data constraints, leading to potential data redundancy.
decisions are based
Examples: Data created using tabs or commas in Word documents, on data. Furthermore,
CSV files, or spreadsheet files. a study by
Dimensional
Relational File: A relational file stores different types of data, such as Research revealed
text, numbers, and dates, in tables composed of rows and columns. that 82% of
These tables are interconnected through a common field, reducing the companies are
chances of data redundancy. making decisions
Examples: Databases where tables are linked by a shared key or field.

Databases and Database Management Systems (DBMS)

A database is an organized collection of logically related data stored systematically. The


information within a database can be added, modified, deleted, or displayed based on the
user’s needs. The software used to create, update, and retrieve data from a database is known
as a Database Management System (DBMS). DBMS tools help users plan and maintain
databases efficiently. Common examples of DBMS include MS Access, OpenOffice or
LibreOffice Base, Oracle, Ingress, and MySQL. In this book, we will focus on using
OpenOffice Base to explore various DBMS functionalities.

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.

Benefits of Database Management Systems (DBMS)


Database Management Systems (DBMS) have been an essential tool for businesses for many
years and continue to be popular today. Even though setting up a DBMS requires investment
in server infrastructure, maintenance, and security, more and more businesses are choosing to
use them to manage their documents and records because of the many benefits they offer.
Here are some of the key advantages of using 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.

Customisation of Applications: Applications can be customised to meet specific user needs


without having to alter the database itself.

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.

Relational Database Management System (RDBMS)

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.

This approach efficiently organises data, representing it in a two-dimensional format, which


is referred to as a Relation. A row within a relation is called a Tuple or Record, which is a
collection of related data fields. Each tuple is uniquely identified by a unique key known as
the Primary Key. Data can be easily extracted from different relations because they are
interlinked through this Primary Key. A column within a relation is called an Attribute or
Field, and it stores values of the same data type.

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.

Basic Terminologies of RDBMS

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

Degree (No. of Columns) = 4 Data


Value
Different Types of Keys Fields in a Relation

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:

• It must have a unique value for each row.

• It cannot have null (empty) values.

• Every row must have a primary key value.

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

Admn. No. Name Date of Birth Address

101 Arjun Sharma 15-05-2014 12, Lajpat Nagar, New Delhi

102 Priya Sharma 10-07-2015 12, Lajpat Nagar, New Delhi

103 Kavya Rao 10-07-2015 78, Banjara Hills, Hyderabad

104 Rohit Patel 2009-12-30 23, Vastrapur, Ahmedabad

105 Kavya Rao 2008-07-08 89, Park Street, Kolkata

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:

• In the STUDENT table, Admn. No. is the primary key.

• In the LIBRARY table, Accession No. is the primary key.


But the Admn. No. in the LIBRARY table links to the Admn. No. in the STUDENT table,
making it a foreign key in the LIBRARY table.

STUDENTS Table LIBRARY Record Table

Admn. No. Student’s Name Accession Book Title Issued to (Admn.No.)


No.
2014/9878 Alice Smith
A001 Mathematics 101 2014/9878
2019/0076 Karan Veer
A002 Science Basics 2021/8897
2021/8897 Manika Bansal
A003 History of Arts 2019/0076
Composite Key

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

Admn. No. Student Name Father’s Name Class Phone_No

201 Rohan Mehta Sumit Mehta XII C 9897698000

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

10567 2023 Rohan Mehta 80.8% 201

10689 2023 Aditi Nair 88.6% 202

Create and edit tables using wizard and SQL commands

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

OpenOffice Base is a database application that lets you create and


manage databases using tables. To start OpenOffice Base, follow
these steps:

Step 1: Type OpenOffice Base in the Search box.

Step 2: Select the OpenOffice Base App.

A window will appear asking if you want to create a new


database.

Creating a New Database

To create a new database in OpenOffice Base, follow these steps:

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."

Step 3: Click the Finish button. A Save


As dialog box will appear.

Step 4: In the File name field, type a


name for your database file and select
the location on your computer where
you want to save it.

Step 5: Click the Save button to create


your new database.

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

User Interface of OpenOffice Base

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.

Opening an Existing Database

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.

Step 4: In the dialog box, navigate to


the folder where your database file is
stored. Double-click the file to open it,
or alternatively, click once to select it
and then press the Open button.

Elements of a Table in OpenOffice Base

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.

Data Types of Fields

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.

Here are some common data types available in OpenOffice Base:

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.

The available numeric data types include:

Name Data No. of Signed Range


type Bytes

BOOLEAN boolean 1 no 0 or 1

TINYINT integer 1 no 0 to 255

SMALLINT integer 2 yes -215 to 215-1

INTEGER integer 4 yes -231 to 231-1

BIGINT integer 8 yes -263 to 263-1

NUMERIC number no limit yes (Max Scale, Max Precision )

Max Scale = unlimited

Max Precision = e(+/-)231

DECIMAL decimal no limit yes (Max Scale, Max Precision )


Max Scale = unlimited

Max Precision = e(+/-)231

REAL real 4 yes 2-1074 to (2-2-52)* 21023

FLOAT float 4 yes 2-1074 to (2-2-52)* 21023

DOUBLE double 4 yes 2-1074 to (2-2-52)* 21023

2-1074 to (2-2-52)* 21023 could also be stated as 5e-324 to 1.7976931348623157e+308

Alphanumeric/Text Data Type

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.

The available Alphanumeric/Text data types include:

Data
Name Max length Description
type

Stores up to the maximum


2GB for 32 bit number of characters specified
LONGVARCHAR text
OS by the user. It accepts any UTF-
8 character.

Stores exactly the number of


characters defined by the user.
2GB for 32 bit
CHAR text(fix) If the string is shorter, it is
OS
padded with trailing spaces. It
accepts any UTF-8 character.
Stores up to the specified
2GB for 32 bit number of characters without
VARCHAR text
OS padding. This functions
similarly to long varchar.

Stores up to the specified


number of characters, with
VARCHAR_IGNO 2GB for 32 bit
text case-insensitive comparisons.
RECASE OS
However, it retains the
capitalization as entered.

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.

The available binary data types include:

Data Max
Name Description
type length

Stores any array of bytes, including


2GB for
LONGVARBINARY image images, sounds, and other data
32 bit OS
formats, without requiring validation.

binary 2GB for Capable of storing any array of bytes


BINARY
(fix) 32 bit OS without the need for validation.

2GB for Accepts any array of bytes with no


VARBINARY binary
32 bit OS validation necessary.

Currency Data Type

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 available Date Time types include:

Name Description Format

Stores information about the month, day, and


Date 1/1/99 to 1/1/9999
year.

Stores information about the hour, minute, and Seconds since


Time
second. 1/1/1970

Timestamp Stores both date and time information.

Boolean Data Type

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

Create Table Using Design View

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 2: Click on Create Table in Design View… in the Task pane.

A window titled Table Design will appear.

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.

Repeat Step 5 to 7 to add more fields in the table.

The green arrow key before the cell shows the currently active field.

Set Field Properties (Optional):


Step 5: To add properties to a field, select the field and choose the properties from the Field
Properties section at the bottom of the window. For example, if you want to make it
mandatory for users to enter a value in a field, select Yes from the dropdown menu next to
Entry Required. This step is also optional.

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.

2. Alternatively, to change a field's properties later, follow these steps:

o Step 1: Select the table.

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):

Step 6: To make a field the Primary Key (which


uniquely identifies each record), right-click the left side
of the field name and select Primary Key from the
context menu. A golden key icon will appear next to the
field name, indicating that it is the Primary Key.

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.

Finalizing the Table Creation:


Step 7: Enter the table name in the "What do you want to name your table?" text box.

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.

Create a Table Using Create View

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 1: In the Tasks pane, click on the Create View label.


A window titled View Design will appear along with an Add Tables dialog box.

Step 2: In the dialog box, select the existing


tables from which you want to create a new
table by clicking on them and then clicking the
Add button.

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.

Session 3: Perform Operations on Table

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.

Modifying Table Design

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.

Step 4: If you need to add more fields, repeat


step 3 for each new field.

Step 5: Once all fields have been added, click


on Save button to update the table.

Step 5: Select the File menu and choose Close


to exit the Table Design View.

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 3: Right-click on the field you want to remove on the


left side. A context menu will appear.

Step 4: Select the Delete option from the Context menu. The
chosen field will be removed from the table.

Step 5: If you need to delete additional fields, repeat steps 3


and 4 for each field.

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

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 3: Click on the field you want to modify.

Step 4: You can modify the name, data type, or properties of


the selected field as needed.

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.

Insert Data into a Table

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.

The table will open in Table Data View.

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.

Updating Data into a Table

To update records in an existing table, follow the given steps:

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.

Navigating Records in a Table


In a table, a pointing arrow called the record pointer indicates the current position or
selection within the table. It shows which record is currently active or being operated on. To
navigate through the records in a table, you can use the navigation box located at the bottom
of the Table Data View window. The navigation box consists of two main components:

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 in a 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.

The table will open in Table Data View.

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.

Now, the records will appear in the desired sorted order.


Deleting Data from a Table

To delete records from a specific table, follow these steps:

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.

The table will open in Table Data View.

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

Raja was entering records


directly into the fields of a
table. In which view
Step 4: Click the OK button. The records in the table will now would Raja have opened
be sorted according to the multiple sort criteria you defined. the table to do this?
(a) Design
(b) Data
(c) SQL
(d) None of the above
Retrieve data using Query

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

A query is a fundamental feature of any Database Management System (DBMS). It allows


you to retrieve and display specific data from one or more tables based on certain criteria. By
creating and running queries, you can efficiently find and view the exact information you
need without manually sifting through every record.

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:

• Name of the Table: Books

• Fields to be Specified: Title, Author, Due Date

• Criterion: The book’s status must be "Checked Out"

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:

• Create Query in Design View


• Use Wizard to Create Query
• Create Query in SQL View

Creating a Query in Design View

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.

Follow the given steps to design a query using


Design View:

Step 1: Select the Queries icon in the Database


pane of the OpenOffice Base window.
Step 2: Choose Create Query in Design View…
under the Tasks pane.

This opens the Query Design window with


the Add Table or Query dialog box.

Step 3: Select the table you wish to include


in the query and then click on the Add
button. In this example, we have added the
Employee table.

Step 4: Click the Close button in the Add


Table or Query dialog box.
In the Query Design view, you will see two sections:

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.

Set the criterion for the query

Step 9: Type >=35000 in the Criterion cell under Salary in the query definition table.

A sorting criterion can also be added if required. This is an optional step.

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.

You might also like