Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice...
-
Upload
daryl-rouse -
Category
Documents
-
view
225 -
download
1
Transcript of Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice...
![Page 1: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/1.jpg)
Database
Ed Milne
![Page 2: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/2.jpg)
Theme
An introduction to databases Using the Base component of LibreOffice
![Page 3: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/3.jpg)
Database
A database is a structured set of data held in a computer
![Page 4: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/4.jpg)
SQL
Structured Query Language (SQL) is a programming language used to create, maintain and extract data from databases It is an ISO standard
e.g. SELECT isbn, title, price, price * 0.14 AS sales_tax FROM book WHERE price > 100 ORDER BY title
![Page 5: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/5.jpg)
Base
Base, a component of the LibreOffice suite is a front end to a databaseThe back end, the database engine, can be
A spreadsheet (Calc) HSQL – open source freeware embedded in base External sophisticated database engines such as PostgreSQL, MySQL and MariaDB
![Page 6: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/6.jpg)
Database Engines
The appropriate database engine depends on the performance of your computer and the amount of data in the database As a rough guide
Spreadsheets – up to 1,000 records HSQL – up to 50,000 records MYSQL etc. - over 50,000 records
![Page 7: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/7.jpg)
Database Engines
Using HSQL creates a database in a single fileUsing other engines creates two objects
The Base front end The DB engine containing the data
This can be useful when more than one person can be accessing the data at the same time In an organization, the engine can be on a server and a copy of the front end is on each employee's computer
![Page 8: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/8.jpg)
Database Engines
Sophisticated engines prevent two people from changing the same record at the same timeSeparate engines also make maintenance easier
Changes to the front end can be copied to each user e.g. New forms or reports
Changes to the engine only have to be made at a single location
![Page 9: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/9.jpg)
Database Engines
A separate front end and engine is also used on the web e.g. When you register at a web site, the form on the web page is the front end of a database
![Page 10: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/10.jpg)
Tables
The data in a database is organized in tables which look much like a spreadsheet LibreOffice has a wizard for creating tables
![Page 11: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/11.jpg)
Fields
A table consists of fields Each field is the equivalent of a column in a spreadsheet
![Page 12: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/12.jpg)
Field Data Type
Each field can only accept a specific type of data cf. a spreadsheet where you can enter any type of data in any cell
Integer Big integer – up to 19 digits Integer – up to 10 digits Small integer – up to 5 digits Tiny integer – up to 3 digits
![Page 13: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/13.jpg)
Field Data Type
Numbers Decimal – 10 digits
Fixed number of decimal places Float, Real, Double
17 digits e.g. 1.23E+017
Text Text – only uses the space required for the data Text (fix) Text (ignore case) Long text (memo) – up to 2,147,483,647 characters
![Page 14: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/14.jpg)
Field Data Type
Date and Time Date Time – HH:MM:SS Timestamp – date and time
Boolean Yes/No
![Page 15: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/15.jpg)
Field Data Type
Binary - up to 2,147,483,647 bytes Image Binary Binary (fix)
Other Up to 2,147,483,647 bytes
![Page 16: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/16.jpg)
Indexes
Each table must have a primary index to uniquely identify each record cf. The row number in a spreadsheet The integer data type has an autonumber feature which automatically creates a unique number for the record
![Page 17: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/17.jpg)
Relations
You can relate tables together by Adding a field for the primary index in another table to a table Linking these fields together
![Page 18: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/18.jpg)
One-to-Many Relationship
In the example shown, each media record can be linked to many books
![Page 19: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/19.jpg)
Many-to-Many Relationship
A many-to-many relationship can be made using an intermediate table In the example shown,a book can have more than one subject and a subject can relate to many books
![Page 20: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/20.jpg)
Views
You can create a View of a table which contains a subset of the fields in a table a set of fields from related tables
A view is a virtual table which can be used much like a table
![Page 21: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/21.jpg)
Forms
Forms let you add or edit the information in a database LibreOffice has a wizard for creating forms from a table or view
![Page 22: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/22.jpg)
Forms
The forms editor is the word processing component of LibreOffice After creation, you can modify the form
![Page 23: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/23.jpg)
Filters
You can filter the data on a form so only records with certain values appear e.g. You can filter the data in a book form so that only records with the medium “Magazine” appear as you browse through the records
![Page 24: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/24.jpg)
Datasheet Form
A datasheet form appears like a spreadsheet
![Page 25: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/25.jpg)
Subforms
Subforms are forms within a form Typically a datasheet form within a field form
![Page 26: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/26.jpg)
Form Controls
Check box Text box Numeric field Currency field Date field Time field Pattern field Spin button Push button
Option button Image button (icon) List box Combo box Label Image Scroll bar Frame Navigation bar
![Page 27: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/27.jpg)
Check Box
A check box accepts a Boolean (Yes/No) value
![Page 28: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/28.jpg)
Currency Control
Accepts a currency value The spin box control on the right increments or decrements the value by $1
![Page 29: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/29.jpg)
Date and Time Controls
There are various ways to format the date and time The large down arrow displays a calendar The spin buttons change the value selected by the position of the cursor
E.g year, month or day
![Page 30: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/30.jpg)
Dropdown Menus
Lets you select a value from a related table A list of constants embedded in the form
![Page 31: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/31.jpg)
Dropdown Menus
A list box saves the index of the record in the related table in the primary recordA combo box saves the displayed text in the primary recordEither control can save the selected value in the form rather than the record
![Page 32: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/32.jpg)
Buttons
Buttons can be used to execute a macro for the form set a value in the record
![Page 33: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/33.jpg)
Macros
Macros are subroutines in the programming language used by the application In this case OpenOffice Basic
You can create macros by1 Learning the programming language and writing the code2 Recording a macro3 Searching the web4 From books
![Page 34: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/34.jpg)
Macro Example
![Page 35: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/35.jpg)
Executing Macros
You can execute a macro by Using the Run Macro option in the menus Assigning a shortcut key to the macro Linking the macro to an event for a form or control
![Page 36: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/36.jpg)
Form Events
![Page 37: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/37.jpg)
Push Button Events
![Page 38: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/38.jpg)
Queries
Queries let you select, organize and manipulate data from the databaseQueries are used to select and organize the fields for
dropdown menus reports
![Page 39: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/39.jpg)
Queries
Base provides a Graphical User Interface (GUI) for select queries to Select fields Determine which fields should be visible Select records with specific values in a field Sort the extracted data Apply functions like Count or Average to the fields
![Page 40: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/40.jpg)
![Page 41: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/41.jpg)
Queries
The GUI generates SQL code like
![Page 42: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/42.jpg)
Queries
You can use other queries as well as tables as the data source i.e. You can created nested queries
In Base, you hand code other types of queries in SQL e.g. An Update query to make a mass change to the data
UPDATE "tblSubjectWork" SET "SubjectID" = '5' WHERE "SubjectID" = '7'
![Page 43: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/43.jpg)
Reports
Base has a report generator to create reports from queries or tablesReports can be
Grouped Group headers and footers
Sorted Output to text documents or spreadsheets
![Page 44: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/44.jpg)
Reports
![Page 45: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/45.jpg)
Database for Spreadsheets
Why use a spreadsheet as the back end of a database? You already have the data in a spreadsheet You want to use some features of a spreadsheet like charts and graphs A database allows strict data typing and limits
r.g. A value must be present and within a specific range Forms avoid horizontal scrolling Database reports
![Page 46: Database Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice LibreOffice.](https://reader038.fdocuments.us/reader038/viewer/2022102923/5519b66955034667578b47f6/html5/thumbnails/46.jpg)
References
LibreOffice Base Guide
Base Tutorial