ComputerApplication
ComputerApplication
Introduc on to Databases
Databases are used for storing, manipula ng, and managing data in various fields of life,
such as booking ckets, library management, banking transac ons, and more.
Data can be in mul ple formats, including text, images, audio, and video. These are
processed to generate useful informa on.
Informa on: Processed data that is meaningful and organized, such as a report card or an
invoice.
Database: A collec on of logically related data, stored systema cally to allow easy retrieval
and management.
DBMS (Database Management System): So ware that helps in crea ng, upda ng, and
retrieving data in a database.
Advantages of DBMS:
Data Analysis: Allows analysis based on criteria (e.g., finding averages, max/min values).
Data Consistency: Ensures uniformity across tables (e.g., upda ng a name in all tables where
it appears).
Accuracy and Validity: Ensures accurate retrieval by minimizing errors and se ng valida on
rules.
Security: Unauthorized access can be restricted using passwords and encryp on.
4. Data Models
o Network Model: Uses a more flexible structure where mul ple records can be linked
to the same master file (like an inverted tree).
o Rela onal Model: Data is stored in tables with rows and columns, and rela onships
are formed between these tables.
Proposed by E. F. Codd (1970), this model organizes data into tables (rela ons) made of rows
(records) and columns (fields).
Primary Key: Uniquely iden fies a row in a table (e.g., Roll Number for a Student table).
Foreign Key: A field in one table that refers to the primary key in another table, establishing a
rela onship.
Candidate Key: Any field that can uniquely iden fy a row in a table.
Alternate Key: Candidate keys that are not chosen as primary keys.
Table: The core object in a DBMS where data is stored in rows and columns.
Forms: User-friendly interfaces for data entry, allowing users to input data easily into tables.
Queries: Used to retrieve specific informa on from the database based on criteria (e.g.,
retrieving students who scored above 50).
Summary
Data refers to raw facts, and Informa on is processed data that provides meaningful
insights.
A Database stores related data efficiently and can be managed using a DBMS.
Rela onal Databases store data in tables and use keys to form rela onships between tables.
Primary Key uniquely iden fies records, and Foreign Keys link records across tables.
DBMS provides various objects like tables, forms, queries, and reports to manage and
retrieve data effec vely.
Introduc on to LibreOffice Base
LibreOffice Base is a free, open-source Database Management System (DBMS), available for
both Windows and Linux opera ng systems.
It is used for crea ng, managing, and manipula ng databases, helping users store and
organize different types of data such as text, numbers, and dates.
Data types specify the kind of data that can be stored in a field. Understanding the right data
type for each field ensures proper data handling and storage.
Text (CHAR): Fixed length, used for things like passport numbers.
o Used to store numbers (integers and real numbers) on which arithme c opera ons
can be performed.
TinyInt: 0 to 255
o Stores digi zed images or sounds, o en in the form of binary data (1s and 0s).
o Open LibreOffice Base via Start Menu (Windows) or the applica on menu (Linux).
o Step 3: Click Finish and save the file with a .odb extension.
Database Pane: Displays database objects like Tables, Forms, Queries, Reports, etc.
o Assign field types, set proper es, and specify a Primary Key.
2. Design View
o Allows crea ng a table from scratch with custom fields.
o Set Field Names, Field Types, and Field Proper es like Length, Default Value, and
Format.
o A er defining fields, set a Primary Key by right-clicking and selec ng Primary Key.
1. Entering Data
o Open the table and begin typing in the fields in datasheet view.
2. Naviga on
o The Naviga on Box at the bo om helps move between records. It shows the current
record number.
o Use the Record Selector Box and Naviga on Bu ons to scroll through records.
3. Edi ng Data
4. Dele ng Records
o Select a record and press Del or right-click and choose Delete Record.
5. Sor ng Data
o To sort data, select the field and click the Sort Ascending or Sort Descending bu on
in the toolbar.
Fields:
1. Event_Id (Varchar)
3. Date (Date)
1. Edi ng Tables:
o To edit a table, right-click on the table name in the database pane and select "Edit."
2. Dele ng Tables:
3. Renaming Tables:
o Right-click the table name, select "Rename," and type the new name.
1. Purpose:
o They ensure accurate and consistent data entry across related tables.
2. Prerequisite:
3. Example:
o One-to-One: One record in the master table corresponds to one record in the
transac on table.
o One-to-Many: One record in the master table corresponds to mul ple records in the
transac on table.
o Many-to-Many: Mul ple records in the master table correspond to mul ple records
in the transac on table.
Example: A teacher may have mul ple roles, each related to mul ple
students.
Advantages of Rela ng Tables
Referen al Integrity: Ensures data in the foreign key field matches the primary key in the
master table.
Data Valida on: Ensures no invalid data is entered in the related fields.
Automa c Updates: Changes in the master table reflect in the transac on tables.
Referen al Integrity
o For instance, if a record with Admission No 1001 is deleted in the master table, it
should not appear in the transac on table.
o Update Cascade: Updates or deletes the referenced field and related records.
o Set NULL: Assigns a NULL value to related fields when the master record is
deleted/updated.
o Set Default: Assigns a default value to related fields when the master record is
deleted/updated.
1. Example Setup:
o Add a CategoryID field to the Events table and a new EventCategory table with
CategoryID as the primary key.
o Create a rela onship between CategoryID in Events (foreign key) and EventCategory
(primary key).
2. Steps:
o Add both Events and EventCategory tables to the Rela onship Design window.
2. One-to-Many: One record in the master table corresponds to mul ple records in the
transac on table (e.g., Customer and Product).
3. Many-to-Many: Mul ple records in the master table correspond to mul ple records in the
transac on table (e.g., Teacher and Student).
Effec ve Notes on Queries in LibreOffice Base
Introduc on to Queries
Purpose: Queries help retrieve and display data from one or more tables in a database.
What is a Query?: A query is a ques on or request made to the database to fetch specific
data, based on certain criteria.
Why Use Queries?: They simplify data retrieval, making it easier to search through large
datasets.
Queries are essen al for data manipula on and retrieval in a database. In LibreOffice Base, you can
create queries in three ways:
1. Using a Wizard
2. In Design View
3. In SQL View
Types of Queries
o Step-by-Step Process: The wizard guides you through selec ng fields, applying
sor ng and filtering criteria, and customizing the query.
o Example: For a sports database, a query can display the Event Name and Winner for
events with CategoryID = C001.
o Allows you to design complex queries involving mul ple tables and various filtering
op ons.
o Example: Display Event Name, Winner, and Category Name from Events and
EventCategory tables.
o Alias: You can change the display names of fields (e.g., "Winner" to "Winner Name").
o Sor ng: Allows sor ng the results by specific fields (e.g., sor ng by Event Name in
ascending order).
o Allows wri ng raw SQL queries for even more control and customiza on.
Step 6: Assign Alias Names for readability (e.g., "Winner" to "Winner Name").
Edi ng a Query
Step 1: Right-click the query name in the Objects pane and select Edit.
Step 2: Modify the query by changing fields, adding condi ons, or applying different sor ng.
Func ons: You can apply func ons to numerical data like Count, Sum, Min, Max, and
Average.
Example: Create a query that calculates the average points for each category of events.
o Apply the Average func on to the Points field and the Group func on to the
Category Name field.
Filtering: Add condi ons to display specific groups (e.g., Category = Athle cs).
Summary of Key Points
You can filter data using criteria, apply sor ng, and even perform mathema cal func ons like
average, sum, and count.
Queries help organize and simplify the process of retrieving and displaying specific data from
large datasets.
o Aggregate the total Monthly Rent collected for each Category (e.g., AC, Non-AC).
Introduc on to Forms and Reports
Forms provide a user-friendly interface for data entry and modifica on, making them
essen al for users who are not well-versed with computers. They are visually organized and
allow for easier data entry compared to the data-sheet view.
Forms and reports are objects in the LibreOffice Base interface, located in the Database
Pane.
Forms serve as the front end for interac ng with the data stored in tables.
Field Controls are used to display and enter data, with each field having a label (text
describing the data) and a field value text box (for entering data).
Forms can contain addi onal elements like text, images, and other controls (e.g., list boxes,
radio bu ons).
1. Step 1: Open the database and select the Form icon from the Database Pane. Choose Use
Wizard to Create Form.
2. Step 2: Select the table (e.g., Events table) from which the form will be created.
3. Step 3: Shi the fields from the "Available Fields" list to the "Fields in the Form" list.
4. Step 4: Skip subform setup if not needed and proceed to the next step.
5. Step 5: Choose the layout of the form. Op ons include columnar display (with labels on the
le or top).
6. Step 6: Define the form's purpose: for data entry, viewing, or both.
7. Step 7: Select the form's appearance, such as border style and background color.
8. Step 8: Name the form and specify whether you wish to modify it a er crea on.
Modifying a Form
o Right-click on the form and select Page Style. Choose the Area tab to pick a color.
2. Edi ng Labels:
o Right-click the label (e.g., EventID) and select Control Proper es to change the label
text and forma ng.
3. Moving Controls:
o Click and drag controls to new posi ons. To move only the label or text box, hold Ctrl
while selec ng.
4. Resizing Controls:
o Tool ps help users by displaying a helpful message when the cursor hovers over a
control. Right-click the control, go to Control Proper es, and add text in the Help
Text field.
o Select the date field, enable the DropDown property, and the date field will show a
calendar.
o Use the Label tool to add tles, headings, or subheadings to the form.
o Toggle between Design View and Form View to interact with the form.
Dele ng a Record:
Form View is used to interact with the data, add, or modify records.
A report in a database management system (DBMS) is used to display retrieved data in an a rac ve
and customized format. Unlike simple tables, reports allow for be er presenta on and organiza on
of data, which can be especially useful when displaying results from mul ple tables. Here's a step-by-
step guide to crea ng a report in LibreOffice Base using the "Events" table from the "Sports Day"
database.
o In the LibreOffice Base User Interface, click on the Reports icon in the Database
Pane.
o The Report Wizard opens with the Report Builder window and the Add Field dialog
box. For now, focus on the wizard.
o In the wizard, select the Events table from the "Tables or Queries" list. The table’s
fields will be listed in the Available Fields box.
o Move all the fields from the Available Fields list to the Fields in report list by clicking
the >> bu on.
o Click Next. The wizard allows you to change field names (for example, to use more
descrip ve names instead of abbreviated field names). Modify these as needed.
7. Grouping Data:
o If you don’t want to group data, click Next. (For example, don’t group by any field at
this stage.)
o In the Sort op ons, you can specify the field by which the data should be sorted. For
example, selec ng EventID and sor ng in Descending order.
9. Choose Layout:
o Select a layout for how the report data will be displayed. Choose Tabular layout
(default) and leave the Landscape orienta on.
o Click Next.
o Name the report (e.g., "EventsReport") and select whether you want the report to
update automa cally (Dynamic) or not (Sta c).
o Choose to create the report with the current se ngs and click Finish.
While the report generated using the wizard is func onal, it can be further enhanced by adding
controls like tles, date, me, and other forma ng features. Here’s how:
o Right-click on the report name (e.g., EventsReport) and select Edit to open the
Report Builder.
2. Add a Title:
o Drag the label textbox to the report, double-click to open the Proper es dialog box.
o Enter the tle text (e.g., "Annual Sports Day Report") and adjust font style and size.
1. Insert Date:
o Go to Insert > Date and Time to open the Date and Time dialog box.
o The date will be inserted into the Page Header. You can reposi on it by dragging it
within the header.
Grouping Data:
To create a report that groups data by a specific field, such as event categories:
o In step 3 of the wizard, select a field (e.g., CategoryID) to group the data.
o A er comple ng the wizard, the data will be displayed with records grouped by
category, crea ng a more organized and meaningful report.
Final Report Example:
Once you've followed all the steps, the report will look well-structured with: