Introduction to Database Management Systems
Introduction to Database Management Systems
INTRODUCTION
A database is an organized collection of data. It is considered as a
container of information.
In the manual system, you would maintain several files with different bits of
information while in the computerized system you would use database
programs such as Microsoft Access, LibreOffice Base, [Link]
Base, and MySQL, to organize the data as per your business need.
The software that is used to create, update and retrieve data is known as
database management system (DBMS). It facilitates planning and
maintenance of the database for the user. Some of the common examples
of DBMS are MS Access, Open Office or LibreOffice base, Oracle, MySQL.
Advantages of Database
1) Organised Storage : The data in the database is stored in an organised
manner, so that retrieval of the required data is fast and accurate.
4) Sharing of Data : In a database, the users of the database can share the
data among themselves.
5) Data Integrity : Data integrity means that the data is accurate and
consistent in the database.
7) Privacy : The privacy rule in a database states that only the authorized
users can access a database according to its privacy constraints.
In this model the data is organized into a tree like structure. The data is
stored in the form of records. All these records are linked to each other at
various levels, thereby forming a hierarchy. For example
Introduction to
DBMS – Hierarchical Data Model
Introduction to
DBMS – Network Data Model
Record or Row or Tuple – The data values for all the fields related to a
person or object is called a record. It is
presented as rows within a table.
Foreign key : The foreign key identifies a column or set of columns in one
(referencing) table that refers to a column or set of columns in another
(referenced) table.
Data Values : Data values are the raw data represented in numeric,
character or alphanumeric form. Examples of data values are ‘Abhinav
Bindra’, ‘26’ ‘shooting’, “Chandigarh”, “10-12-2018”, etc.
Objects of an RDBMS
An object in a database is a structure or a feature that is used to store,
represent or retrieve data. In fact a database is a collection of these objects
given below
Table : – A table is the basic unit of any DBMS. The data is first stored in
tables in row and column format.
Introduction
LibreOffice Base is a free and open source DBMS. It can be downloaded
from [Link]. Data which we stored in DBMS can be a text,
number, date or in any other form. So, we need to understand different
types of data that can be stored in a table.
Data Types
A data type refers to the type of data that will be stored in that particular
field. The memory size of a field varies according to its data type. Some
commonly used data types are :
Float FLOAT
Double DOUBLE
The currency data type is used to store the numeric values with symbol of
currencies of various countries. For example $100, £ 500 or Rs. 25.50.
4. Date Data Type –
This data type is used to store dates and time. For example 12/25/2019,
08:45 AM. Following table shows various forms of date data type.
Name Description
Time Stores the time of the day as hour, minute and second.
In boolean data type there can be only two values- True or False, Yes or No
The Binary data type used to store digitized images and sounds that comes
as long string of zeros and ones.
Field Properties :
To set the field properties: Select the table > Right click > Select the option
Edit > the table will open in Design View.
In design view there are different properties of fields according to the data
type set for each field.
1) AutoValue – if set to yes then field will get the auto numeric values.
2) AutoValue – if set to yes then field will get the auto numeric values.
3) Length – By default length of the field is 10 but the size of the field can
be set to maximum length.
4) Default Value – A default value can be set for a field if user don’t provide
any value while entering the values in the table.
5) Format – This property helps to set the format of the data entered in the
field such as 91-222-333.
1) Entry Required – if set to yes then it will be must to insert the value in the
field.
2) Length – By default length of the field is 10 but the size of the field can
be set to maximum length.
3) Default Value – A default value can be set for a field if user don’t provide
any value while entering the values in the table.
4) Format – This property helps to set the format of the data entered in the
field such as 91-222-333.
Database
Wizard
NOTE: If any database that has already been created is to be opened, then
select Open an Existing Database
4. The Next step gives the option to register our database with
[Link]. Click and select the radio button with option, ‘No, do not
register the database’.
Register
Database
NOTE: If we register the database, then our database is made public and
hence can be accessed by other people.
5. This step also asks whether you want to open the database for editing or
want to create a table using the wizard.
6. Click Finish button. The Save As dialog box appears.
7. Select the location and type the name in the File name text box and click
on Save button.
NOTE: The database in Base is saved with an extension .odb. The default
name of database is New [Link].
Title Bar – The title bar displays the name of a database and an application
in which it is made.
Menu Bar – The menu bar appears below the title bar. It consists of seven
menu items – File, Edit, View, Insert, Tools, Window and Help.
Database Pane – The database pane is located on the left side of the
window. It shows data objects like Tables,
Forms, Queries, Reports
Ch 9 Starting with Libre Office Base NOTES
2. The Table Wizard of Base consists of ready-made tables. Select any one
table, say Customer.
3. After selecting the Customer table, The required fields from Available
fields box can be shifted one by one to Selected fields box using > button
or in one stroke by clicking on >> button.
6. Click on Next button, that will take you to the complete the process of
creating table using wizard and finally click on Finish button.
Setting the Primary Key
To make a particular field as the primary key, place the mouse pointer
before the field name, and right click. A pop up menu appears and Select
the Primary Key option. A key icon appears before the field name indicating
that it is a primary key.
Saving a Table
1. To save the table click on the save button or click File > Save As or press
Ctrl + S from the keyboard.
2. A Save As dialog box is displayed. Enter the name of table and click on
OK button.
Record Navigation
The various components of Navigation Box are as follows:
Record Selector Box – This is the text box where the currently active
record number is displayed. We may enter the record number that we want
to see in this text box.
Navigation Buttons – These are used to scroll vertically in the table.
Editing Data
To edit or modify the entered data, place the cursor on the field value that
has to be edited to edit and enter the new value. The Edit icon appears
before the record that is being edited. This icon is displayed till the table is
saved after making the required changes.
NOTE: Press Esc key to cancel the corrections made and restore the
original contents.
NOTE: Attempting to delete the record will display the Confirmation box.
Clicking on Yes button will finally delete the record, while clicking on the
No button will not delete the record.
Sorting Data in the Table
Data in a table can be arranged in ascending or descending order. This
process of arranging the records in particular order on any filed is called as
sorting. Steps to sort the table are:
1. Open the Event table in datasheet view and select the field on which you
want to sort.
2. From the tool bar click Sort Ascending or Sort Descending icon to sort in
ascending or descending order respectively.
NOTE: To sort the table based on more than one fields. In such case, click
Sort icon on the toolbar.
INTRODUCTION
After creating the table in database, we may require to edit or delete the
table. Sometimes we have to setup the relations between tables to control
data redundancy and inconsistency.
Each record in Table 10.2 has a value of Admission No. that corresponds to
a record in Table 10.1 with same
value of Admission No.
NOTE: It is important to note that the data types of the common field in
both the tables must be same. If they are not same then LibreOffice Base
will display an error message and will not allow to set the relationship
between the two tables.
After setting the relationship between two tables, once a student’s record
has been entered in the Student_Details table, only then that particular
Admission No can be entered in the Student_Result table. Therefore
Student_Details is called the master table and Student_Result is called the
transaction table.
Types of Relationships
Three types of relationships can be set up between two tables in a
relational database. These are:
(i) One-to-One
(ii) One-to-many
(iii) Many-to-Many
One-to-One
Relationship
The relationships applied on the tables can be removed also with the help
of Delete option. Right Click on the relationship thread and select Delete
option.
Referential Integrity
Referential integrity is used to maintain accuracy and consistency of data
in a relationship. In Base, data can be linked between two or more tables
with the help of primary key and foreign key.
Update cascade – This option allows the user to delete or update the
referenced field but along with it all the related records in any of the
transaction tables will also be deleted or updated.
Set NULL – This option assigns NULL value to all the related fields if the
master record is deleted or updated.
Set default – This option assigns any fixed default value to all the related
fields if the master record is deleted or updated.
3) Deleting records from a primary key table if there are any matching
related records available in associated table(s).
Introduction
A database is used to store data in an organized manner. Queries are used
to retrieve the desired data easily and accurately from database. In other
words we can say that a query is a sort of question asked from a database.
A query is one of the most important feature of any DBMS. Using a query,
we can retrieve and display data from one or more tables in a database.
LibreOffice Base allows us to create a query and even save it as an object
in a database. This helps us to run the query multiple times as and when
required.
Using a query, we can specify the fields that we want to display and also
the criterion based on which the records to be filtered. For example In a
Student database, if we want to display the names and marks of the
students in a particular class from the Result table, who have scored less
than 320 aggregate marks.
Queries
A query is to collect specific information from the pool of data. A query
helps us to join information from different tables and filter that information
OR
Queries are commands that are used to define the data structure and also
to manipulate the data in the database.
Creating a Query
A query can be created in three ways. In this chapter we will learn the first
two methods to create a query.
1 Anil X 2500
2 Anuj XI 3000
Let us create a query that will display Roll number, Name, Class from table
“Table1” whose Roll number is 3.
4. Select the required table and then select the required fields(Name, Class
and Rno) from the “Available fields” window to “Field in the Query” window
and click on Next Button.
Query Wizard Field Selection
NOTE: Clicking on >> button moves all fields to “Fields in the Query” area.
7. The next step is to set the search conditions or the criteria on the basis
of which records will be filtered from the table.
Query wizard criteria
NOTE: Since we want to display the detail of student having roll number 3
so we set roll number as 3 in above step
9. Steps 4, 5 and 6 given in the Steps Pane are not required if there is no
numeric field involved in the query. So skip these steps.
10. The next step to give alias name i.e. the column header name will be
displayed when we run the query. Click on Next after writing alias name.
Query Wizard Alias
11. The last step of the Query wizard displays the entire overview of the
query.
Libre Office Base Query Wizard Overview
NOTE:
NOTE: Last Step of Query Wizard includes the following (Query Wizard
Overview).
Complete detail of the query – This section contains a summary about the
query that has been created.
1 Anil X 2500
2 Anuj XI 3000
Let us create a query that will display Roll number, Name, Class from table
“Table1” whose Roll number is 3
Query
Design View
3. Click on the “Table1” table to be used in the query and then click on Add
Button. Alternatively double click on the “Table1” table.
4. Click Close button in the Add Table or Query dialog box to close it.
5. Next step is to select the fields. For our query we want to display Roll
number, Name and Class. So in the list box of “Table1” table, double click
on the required field.
NOTE: Observe that the Visible Check Box is by default selected. This
means that all these three fields will be visible when you run the query. In
the grid, there is a row titled Alias. It can be used to display meaningful
names in the output. For example, instead of Rno, we would just like to
display Roll Number.
NOTE: Once the query is designed, click Run Query ( ) button on the
toolbar or press F5 key. The query result will be displayed in the Tables
Pane area.
NOTE: By default, the name of the Query is Query1. To run the query again,
double click on the query name. To close the Query window, click on on
close button on the top right corner of the window.
Editing a Query
1. Right click on the Query Name Which you want to edit in the Objects
Area of the Database window.
2. Select Edit option from the drop down menu. The Query Design window
will be displayed.
3. Make the required changes like change the Alias, apply criteria or edit
the existing criteria etc.
1 Anil X 2500
2 Anuj XI 3000
Let us create a query that will display maximum fees from the table
“Table1”.
1. In the Database Window, click Create Query in Design View… button to
open the Query Design Window.
2. Select the required field. For our query we want to display Fees. So in the
list box of “Table1” table, double click on the required field.
3. Select the function “Maximum” from the drop down list of functions
under “Fees” Column as shown below.
Introduction
Data-sheet view is used to enter data into the tables which is not a user
friendly interface. So it is required to develop a user friendly data entry
screen for data entry operator or a user, who is not very well versed with
computers.
Therefore LibreOffice Base provides the Form feature for data entry
purposes.
Also, when the user wants to retrieve and view the data from one or more
tables in a database using queries then Report feature of LibreOffice Base
helps us to present the retrieved data in a user friendly, understandable
and formatted manner.
Both reports and forms are considered as objects of the database and are
present in the Database Pane of the LibreOffice Base User Interface.
Forms:
A form is an object of the database that has a user friendly interface where
data can be entered. For any database, it is the front end for data entry and
data modification.
● Using a wizard
● Using the Design View
1. Click the Form icon on the Database Pane. Click the option Use Wizard to
Create Form… on the Tasks Pane.
Forms Wizard
2. Select the table for which the form has to be created.
3. After selecting the “Table1” table, all the fields of the “Table1” table will
be listed in the Available Fields list box as shown below.
Form Wizard
4. Shift all the fields of Event table from Available Fields list box to Fields in
the Form list box using >> button. (shown above)
6. This step arrange controls i.e. to set up the design of the form. In this
step we arrange the label and field value text boxes as we want them to be
visible on the screen.
NOTE: By default, all controls will be left aligned. A field control consists of
two parts – label and the field value text box.
8. The step 6 of the wizard asks whether the form will be used for
displaying data, entering data or both. After Selecting appropriate option,
we click on Next button.
9. The next step is to apply styles to the form. Select the desired
background colour and border type.
NOTE: By default the border of the field text value is displayed in 3D look.
We can select the options No Border or Flat if required.
Form Wizard
10. Click Next button.
12. Click Finish button. The form with the first record will be displayed on
the screen in a separate window.
NOTE:
1. By default the name of the form is same as the name of the
table.
2. By default, the radio button with the option Work with the form
is selected. If you wish to modify the form after the wizard
finishes, click Modify the form option.
Forms Layout
Four layouts of Forms are given in the Wizard.
Form Layout
3. Display as datasheet.
Form Design
Window
This toolbar contains various controls that can be added to the form.
2. Records Toolbar
The Records toolbar contains the navigation control buttons. With the help
of these we can move from one record to another record.
Modifying a Form
We can modify the form in any manner once it is created. The modification
includes change the background color, font size and color of the text or
even positioning of various controls in the form.
1. Open OpenOffice Base and click on Forms icon in the Database Pane.
2. Right click on the form name and select Edit… option. A separate Form
Design View will open.
3. To change the background color of the form, right click on the form and
select Page Style… option from the pop up menu.
4. The Page Style dialog box will appear, where you select Area tab and
choose the desired color from the palette.
Form background colour
Edit the labels means to change the text or to change the formatting
effects. Steps to edit the labels are given below.
1. Place the mouse pointer over the label which you want to edit.
4. The Properties: Label Field dialog box will appear. (It contains various
properties of the selected label like width, height, alignment, font style and
font size)
5. After making the desired changes close the Properties dialog box.
Moving a Control
Click on the control (either Label or Text box) that has to be moved. Both
the label and the text box will be selected. Now, click and drag the control
to move to the desired location.
NOTE: If only Label or Text box to be moved then press Ctrl key while
clicking on that control.
Changing the size of the textbox control
1. Select the textbox and handles will appear around it.
2. Place the mouse pointer on any of these handles and drag them
to the desired size.
A tool-tip is a small piece of text that is displayed when the mouse pointer
is placed on a particular control. In other words we can say text that
appears when the mouse pointer is placed on a particular control is called
the tool-tip text or help text. Steps to add tool tip are given below:
1. Press Ctrl button and click on a text box where you want to add
a tool tip.
2. Right click and select Control Properties… option. The
Properties: Text Box dialog box will be displayed.
3. Type the required text in Help text property.
4. Close the dialog box.
Steps to add the calendar to the date field in the form are:
1. Click the Label tool on the Form Controls tool box.
2. Click and drag the mouse to create a label field box on the form.
3. Double click on box to open the Properties: Label Field dialog
box.
4. Type the title in the Label property.
5. Set the Font by clicking the Font button in front of the Font
property. (The Character dialog box will be displayed and
choose the desired font style and size and click on OK button)
6. Close the Properties: Label Field dialog box.
After designing the form, we can insert records using the form. For this, we
have to shift from “Design View” to “Form View” by clicking on Design
Mode button on the Forms Controls toolbar. The Form View window
appears with the first record displayed in the respective text boxes.
Steps to add a new record into the table using the form are:
NOTE: To toggle between Design view and Form view press Design Mode
button on the Forms Controls toolbar.
Reports
A report is another useful feature of a database management system. Using
a report we can present the data in an attractive and customized manner.
We can create a report based on a table or a query or both. If a report has
to be generated from multiple tables, a query should be created first and
then that query can be used to generate the report.
Layout is the manner in which the labels, field values and titles will be
displayed in the report. We may also choose the orientation option
Landscape or Portrait in this step.
When the field values in the base table or query changes, the dynamic
report will also change automatically while static report will remain same,
whenever, there is a change in the values of the table.
The report generated is very simple and boring. We can make report more
presentable by inserting some more controls like titles, author name, date
of generation of report etc.
Right click on the Report name on the LibreOffice User Interface and then
select the Edit… option. The Report Builder window will open as shown
below. In this window, various controls can be inserted using the Report
Controls toolbar.
Report Builder Window
1. Click on the Label tool available on the Report Controls toolbar.
2. Bring the mouse pointer on the report. Click and drag to insert
the label textbox.
3. Double click on it to open the Properties dialog box.
4. Type the title text that you want to display in the Label property
textbox and also set the font style and size using the Font
property.
5. Close the Properties dialog box.
Steps to insert the date on which the report is generated are given below:
3. The Date and Time dialog box will be displayed. Select the desired format
for date and time format and click on OK button.
Date and Time Window
4. The date will be inserted on the top left corner of the Page Header area.
We can drag it to reposition it in any place in the Page Header area.