Step-By-Step Trai Ni NG Manual: Engl I SH Versi On
Step-By-Step Trai Ni NG Manual: Engl I SH Versi On
by-
step
Tr
aini
ngManual
Engl
ishVer
sion
I
nfor
mat
ion& Communi
cati
on
Technol
ogy(I
CT)
OpenOffice Base
CONTENT
LESSON PAGE
Lesson 1: Introduction 2
1.1 What is database? 2
1.2 What is table? 2
Lesson 7: Exercise 36
[AUTHOR NAME] 1
OpenOffice Base
Lesson 1: Introduction
By the end of this lesson, you should be able to:
Database is the collection of information that had been organized so that it can be easily
access, manage and update. Databases can be classified according to types of content
such as bibliographic, full text, images and even numeric.
Relational database are created by one or more tables that contain the information in an
organized form.
Data Type
o There are different data types used in creating database with selected software.
Following are some of the data type prepared by OpenOffice Base:
o Boolean
Range: 0 or 1 (True or False)
o Integer
Integer can come in different names in OOBase. TINYINT have range from 0
to 255. SMALLINT have range of -215 to 215-1. INTEGER have range of -231 to
231-1. BIGINT have range of -263 to 263-1.
o Float
4-bytes single precision float (Format: 1500.00)
o Double
8-bytes double precision float (Format: 750000.00)
o Text
There are different name in text, in which are LONGVARCHAR for a lot of
text. CHAR stores exactly the number of characters specified by user.
VARCHAR stores up to the specified number of characters, same as
LONGVARCHAR
[AUTHOR NAME] 2
OpenOffice Base
o Date
Stores month, day and year information (Format: 1/1/99 to 1/1/9999)
o Time
Stores hour, minute and second info (Format: Seconds since 1/1/1970)
o Timestamp
Stores date and time information
[AUTHOR NAME] 3
OpenOffice Base
Double click on the Open Office icon on the Windows desktop or you can click on the Start
button in the lower left corner of the screen, then click on Programs and click on Open Office
icon.
OR
When you open an Open Office application, you will be presented with all applications that
are links to Open Office, such as Writer, Draw, Sheet and so on.
[AUTHOR NAME] 4
OpenOffice Base
Click on to open the OpenOffice Base. A wizard will appear to assist in creating
a new database.
[AUTHOR NAME] 5
OpenOffice Base
Click Next and choose the setting that is suitable for the use of database:
Tick Open the database for editing if you wanted to display the database file and can edit
the structure of the database. Tick Create tables using the table wizard if you wanted to call
the Table Wizard after the Database Wizard is finished.
[AUTHOR NAME] 6
OpenOffice Base
[AUTHOR NAME] 7
OpenOffice Base
In OOBase, you can add and design your table by clicking the following button:
Let’s create our first table by using Create Table in Design View.
[AUTHOR NAME] 8
OpenOffice Base
Now that we have a Student Table, we wanted to create another table named Class. For
Class Table, we are going to create it with Use wizard to create table.
[AUTHOR NAME] 9
OpenOffice Base
For CategoryName to
ClassName and type change to
Text [VARCHAR]. Set Entry
required to Yes and put 50 as
length.
[AUTHOR NAME] 10
OpenOffice Base
To link tables, we must use the primary key for each table so that it can be used as foreign key
in other tables.
Primary key is a special database table column that is designated to uniquely identify all table
records. Main features of primary keys are:
Foreign key is a field where in one table it is uniquely identifies a row in another table. In simply,
foreign key is defined in the second table, but refers as primary key at its own table.
ClassID is a primary key in table Class but act as foreign key in table Student.
From Student table, search for ClassID and drag it to ClassID in Class table:
[AUTHOR NAME] 11
OpenOffice Base
By using this function, we are creating a form by specifying the record source, controls and
control properties.
Click on Create Form in Design View and following window will appear:
[AUTHOR NAME] 12
OpenOffice Base
You are free to create a form that is easy for users to key in the information needed. By using
the previous tables created, let’s create a simple form.
Click on Text Box and drag a box on the screen to create a text box for data entry.
Next, right click on the text box created and select Form.
[AUTHOR NAME] 13
OpenOffice Base
To make our form look decent, we can create something simple like the following:
Label
Combo Boxes give users the list of previous data set. To create a combo box, we must ensure
that the Wizard in form design is on. Highlighted icon means it is in mode on. After
labelling our combo box, we select the combo box icon and drag next to label created
earlier as follow:
Click Next.
[AUTHOR NAME] 14
OpenOffice Base
Click Next.
Click Finish.
[AUTHOR NAME] 15
OpenOffice Base
[AUTHOR NAME] 16
OpenOffice Base
Adding buttons can make the form looks professional. To add buttons into a form, we need to
Choose a button icon and drag a small button where you wanted your button is located.
By selected the created button, right-click and select Control.
Properties: Push Button window will appear and change the information as below:
New Button
Name : NewButton
Label : New
Action : New Record
Delete Button
Name : DelButton
Label : Delete
Action : Delete Record
Previous Button
Name : PrevButton
Label : <<
Action : Previous Record
Next Button
Name : NextButton
Label : >>
Action : Next Record
Button can be added as long as you are aware with what functions you wanted it to
possessed.
*Tips: Too many buttons in one form can cause confusion to your end-user. Make it simple and
organized.
[AUTHOR NAME] 17
OpenOffice Base
To insert data through form, we just need to select the Form tab and choose the created form:
Student Data. Double click and you can start editing.
When finished, you can check your Student Table and see all the data are inserted.
[AUTHOR NAME] 18
OpenOffice Base
There are 8 (including creating subform) steps in creating Form by wizard. Follow through the
step-by-step.
[AUTHOR NAME] 19
OpenOffice Base
Click Next.
Click Next.
Click Next.
[AUTHOR NAME] 20
OpenOffice Base
Click Finish.
[AUTHOR NAME] 21
OpenOffice Base
[AUTHOR NAME] 22
OpenOffice Base
View is created to specify what tables you wanted to show. This can be used to combine data
from different tables and show it in one single table.
To create a view in OOBase, go to Table tab and select . The following screen
will appear:
Add Tables window will appear alongside. If the window does not show, you can find it on top
of the menu with this icon, . Add both tables that we have so that we can linked the tables
together for easy access on the view.
[AUTHOR NAME] 23
OpenOffice Base
Now, we will choose the field where we wanted to show only some of the data, fill in the lower
part of the information as below:
[AUTHOR NAME] 24
OpenOffice Base
Click OK and you will see your table is added into the Database:
A database query is designed to retrieve specific results from a database. The query is
formulated by the user following predefined formats. After searching through the data,
information relevant to the query is filtered out of the data collection and reported to the user.
[AUTHOR NAME] 25
OpenOffice Base
Since all of the needed field had already been selected, it is easy
for us to just select StudentInfo.* as selecting all fields in the table.
[AUTHOR NAME] 26
OpenOffice Base
Double click to open the Query and you will see the following window:
To use wizard in creating, with the Query tab selected, click on Use Wizard to Create Query to
open a wizard window to create query.
[AUTHOR NAME] 27
OpenOffice Base
Step 1: Choose which table you would wanted to extract the information from. In this case,
we will choose Student Table as our source.
Step 2: Select the wanted fields to be shown in query later on. This case, we will choose
StudentName, Uniform, Academic, and Games.
Click Finish.
[AUTHOR NAME] 28
OpenOffice Base
To use this, you will need to know a simple instructions or commands used in database,
preferably SQL (Structured Query Language). Basic commands are SELECT, UPDATE and
DELETE. Let’s compute some command to create a simple query to our database.
With the Query tab selected, click on Create Query in SQL View:
[AUTHOR NAME] 29
OpenOffice Base
This will produce a query where we have information about student’s IDs, names, IC number
and their own associated class. Click to save the query as Student and Class Info.
Double click to open Student and Class Info, you will see the following results:
[AUTHOR NAME] 30
OpenOffice Base
Let’s add some data into our Student Table and see if it will affect our query as well. Go to
Form tab and double click on Student Data Form to insert two new data:
After adding above data into Student Data Form, go to Query tab and double click on
Student and Class Info, you should see something like this:
[AUTHOR NAME] 31
OpenOffice Base
In this lesson, we are going to create a report for Student Info where we wanted to know the
students’ name, which class he/she’s in, what are the uniform units, academic clubs and
games club he/she’s in.
[AUTHOR NAME] 32
OpenOffice Base
[AUTHOR NAME] 33
OpenOffice Base
[AUTHOR NAME] 34
OpenOffice Base
After it is saved, the software will automatically pop-out the finished report as below:
[AUTHOR NAME] 35
OpenOffice Base
Lesson 7: Exercise
In this exercise, we are going to create a simple hotel database. Let’s name our hotel as Hotel
Berjaya. In Hotel Berjaya, we will want to create an Employee table to store all information of
the hotel’s staff.
Employee Table
Field Name Field Type Entry required Length
Employee# (PK) Integer [INTEGER] Yes 10
FirstName Text [VARCHAR] Yes 50
LastName Text [VARCHAR] No 50
Title Text [VARCHAR] Yes 50
[AUTHOR NAME] 36
OpenOffice Base
Finished with the Employee table, we are going to create a table for us to keep our customers’
information. Let’s name our table as Customer table.
Customer Table
Field Name Field Type Entry required Length
Customer# (PK) Integer [INTEGER] Yes 5
FirstName Text [VARCHAR] Yes 50
LastName Text [VARCHAR] Yes 50
Phone# Decimal [DECIMAL] Yes 10
EmergencyName Text [VARCHAR] No 50
EmergencyPhone Decimal [DECIMAL] No 10
[AUTHOR NAME] 37
OpenOffice Base
Done with Customer table, we are now headed in creating Room table.
Room Table
Field Name Field Type Entry required Length
Room# Integer [INTEGER] Yes 5
RoomType Text [VARCHAR] Yes 20
BedType Text [VARCHAR] No 10
Rate Float [FLOAT] Yes 10
[AUTHOR NAME] 38
OpenOffice Base
Includes: Employee#, Customer#, Room#, Rate in the table too. Refer to previous tables.
Room Assignment
Field Name Field Type Entry required Length Format
Account# Integer [INTEGER] Yes 10
DateOccupied Date [DATE] 01/01/00
Notes Text [VARCHAR] No 20000
[AUTHOR NAME] 39
OpenOffice Base
Date
Account# Notes Employee# Customer# Room# Rate
Occupied
5272 01/11/16 Smoking Area 10001 30001 101 85.95
5510 05/11/16 Non-Smoke Area 10006 30002 302 500.00
6028 16/11/16 Honeymoon 10005 30601 202 124.95
4260 26/11/16 Smoking Area 10003 30102 302 725.00
[AUTHOR NAME] 40
OpenOffice Base
Create a query that shows the Customer#, customer’s first name, the room’s type and who is
the employee’s first name in charge of its room assignment.
[AUTHOR NAME] 41