Notes-Data-Base-Management-System
Notes-Data-Base-Management-System
Class 10
Data - The raw facts constitutes data.
The facts may be related to any person, place, activity or things. It may be stored in the form of text,
graphics, audio or video.
Database
A database is a collection of logically related data items stored in an organised manner.
DBMS
The information being stored in a database can be added, modified, deleted or displayed
according to the requirements of the user. 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.
Examples DBMS are MS-Access, Open Office or LibreOffice Base, Oracle, Ingress, MySQL,Sql
etc.
Advantages of DBMS:
Data Sharing – If the same data set is required for different applications then the database can be
shared with other applications. Hence using a database means making once and using it
repeatedly for multiple applications.
Reduce Data Redundancy – In the event of requiring the same data field in several tables the data
field might get repeated in number of tables. This is called as data redundancy. This can be
reduced by using DBMS tools.
Data Consistency – By reducing data redundancy, chances of inconsistent data being
stored is reduced. For example, it should not happen that the name of the student is changed in
one table and not in another. Such inconsistency is reduced by using a DBMS.
Security – it provides different level of security feature by providing passwordto the users and by
defining their role.
Organised Storage – The data in the database is stored in an organised manner, so that retrieval
of the required data is fast and accurate.
Data Analysis – A database helps in analysis of data based on certain criteria. It is easy to find
out maximum or minimum value, average or mean using a database.
Increases Efficiency – Since database tables are properly organised, saving, reading and
searching data can be carried out efficiently.
Increases Accuracy – Since data redundancy and inconsistency can be minimised in a database,
the data is retrieved accurately from the database.
Increases Validity – Properties of different data fields can be assigned when a database is
planned. So whether or not valid data is being entered can be checked at the data entry stage.
This increases the validity of the database.
Data Models
database can be designed in different ways depending on the data being stored. This structure of
database is known as data model
A data model consists of components for describing the data, relationships among them and the
constraints that hold data.
There are different data models such as hierarchical data model, network data model and
relational data model.
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.
Field or Columns or attributes – A field is the smallest entity in the database. A collection of
fields make a record, a collection of records make a table and a collection of tables make a
database.
Fields are individual record characteristics and are presented as columns within a table. Data
values are stored in a database as fields. A field holds the data values of one type of data for
several persons.
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.
Record or Row or Tuples – 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. A record holds the data values of all the
fields for a single person or object in a table. For example, in the Employee table with the field
names as Name, Designation, Department, the data values of all the fields for an employee may
be (‘Abhinav’, ‘Manager’, ‘Finance’) and this forms one record. It is also knows as tuples.
Primary Key – A primary key or simply a key is a field that uniquely identifies a row in a table.
The key identifier can be the value of a single column or of multiple columns. The primary key
is a unique identifier for the table. The column or combinations of columns that form the primary
key have unique values. At any time, no two rows in the table can neither have same values for
the primary key nor can data value for such field be
left blank. In a table we can have only 1 primary key.
For example, in a student table, each student has a unique admission no., which forms the
primary key.
If, in a table we use more than one fields to identify a record, it is known as a composite
key.
For example, we may form a composite key consisting of fields roll no. and name.
Foreign Key – If a field or a combination of fields of one table can be used to uniquely identify
records of another table, then that particular field is known as the foreign key. This foreign key
helps to build a relation between two tables.
Candidate Key – All the field values that are eligible to be the primary key are the candidate
keys for that table. Such fields can neither be left blank nor can have duplicate values.
Alternate Key – Out of the candidate keys, one or two are made as primary keys. The others are
the alternate keys.
Objects of an RDBMS
Table –A table is the basic unit of any DBMS. The data is first stored in tables
in row and column format. A column represents a field or an attribute while a row represents a
record.
Forms – A form is a feature of a database using which we can enter data in a table in an easy and
user friendly manner. A form consists of text boxes, labels, radio buttons, list boxes, check boxes
etc. that give a user friendly interface for entering data. The data entered through the forms is
stored in tables.
Queries – A query is used to retrieve the desired information from the database. In simple terms,
it is a question asked from the database.
For example, if we want to view the names of only those students who have scored more than 50
marks, then we post a query. The data set matching the given criterion is retrieved from the table
and displayed on the screen.
Reports – The output of a query may be displayed in the form of reports. The usual result of the
query is in the form of rows and columns. But if we want the report to be formal and in proper
layout, then we can use the Reports feature of RDBMS.
LibreOffice Base
LibreOffice Base is a free and open source DBMS.
Data Types
The nature of data to be entered for various fields are of different types.
For example, names are stored in the form of text, age in numbers, fees in decimal numbers, date
of birth in date format and so on.
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.
Currency Data Type – The currency data type indicates the monetary values and can be stored
using currencies of various countries.
Date Data Type – This data type is used to indicate dates. For example 12/25/2019. It stores
data in mm/dd/yy format.
Time Stores the time of the day as hour, minute and second.
Timestamp Stores date and time information at once.
Boolean – In boolean data type there can be only two values- True or False. This also can be
given in multiple formats like Yes/No, True/False, On/Off.
Binary – The Binary data type used to store digitized images and sounds that comes as long
string of zeros and ones. It is possible to store photos of the products or employees, or sound
snippets or voice messages in Base database.
Opening a Database
To open an already created database, click
File > Open
Or
shortcut key Ctrl+O
Creating a Table using a Wizard
To create a table at the time of creating a database in database wizard, select the radio button
with option “Create tables using the table wizard”, then click on the Finish button.
The Table Wizard dialog box will open. Follow the instructions in the wizard to create the table
with desired fields.
The Table Wizard of Base consists of ready-made tables. Click the Sample tables list box and
select select any one table, say Customer from the drop down list. After selecting the Customer
table, various fields appears under Available Fields. The required fields from Available fields
box can be shifted one by one to Selected fields box using > button. You can select all the
fields from Available fields to Selected fields in one stroke by clicking on >> button.
Click on Next button. It will move you to step 2. Set types and formats. Then click on Next
button. It will move you to step 3. Set primary key. Let us set the CustomerID field to primary
key. Click on Next button, that will take you to the complete the process of creating table using
wizard and display the screen. This screen will give you three choices. By default the “Insert data
immediately” option selected.
Click on the Finish button to complete the process of creating the table and using wizard. The
next screen will allow to enter the data as per the selected fields. The data sheet view interface
will open that allow to enter the data in the Customer table.
Editing Data
To edit or modify the previously entered data simply place the cursor on the field value that has
to be edited to edit and enter the new value.
Press Esc key to cancel the corrections made and restore the original contents.
Deleting Records from Table
To delete any record from the table, open the table and select the record to be deleted. The record
can be deleted by pressing the Del key from the keyboard or selecting the Delete Record option
from the Edit menu. Alternatively a record can also be deleted by right clicking on the record
and clicking on the Delete Rows option from the pop up menu.
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.
Sometimes we may need to sort the table based on more than one fields. In such case, click Sort
icon on the toolbar. The Sort Order dialog will be displayed.
Select the appropriate field name and field value according to which the records are to be sorted.
Choose the order of sorting ascending or descending as required from the Order drop down box.
Multiple fields may be selected in this dialog box. Click OK button once done.
One-to-One relationship
In this type of relationship, one specific record of a master table has one and only one
corresponding record in the transaction table.
Example one person can have only one ticket to get entry into a stadium to view the match.
One-to-Many relationship
This is one of the most common types of relationship between the tables in a database. As the
name says, in this type of relationship, one specific record of the master table has more than one
corresponding records in the related transaction table.
Example one person can sell multiple products.
Many-to-Many relationship
In this type of relationship, there will be multiple records in the master table that correspond to
multiple records in the transaction table as well.
Example relationship exists between a product and a customer.
Queries in Base
Using a query, we can retrieve and display data from one or more tables in a database. This is
done by giving specific search criteria to the DBMS so that we are able to view the exact
information that we want.
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.
Creating a Query
A query can be created in three ways. In this chapter you will learn the first two methods to
create a query.
(i) Using a Wizard
(ii) In Design View
(iii) In SQL view
Creating a Query Using a Wizard
To create a query using a wizard, follow the following steps.
Step 1. Open the database. In the Database Design window, click on Queries button present in
the Database Pane on the left.
Step 2. In the Tasks Area, click on Use Wizard to Create Query… option. The Query Wizard
will start. It contains the Steps Pane on the left and the Query Details Area on the right.
Step 3. The first step of the wizard is to select fields from the respective tables.
Step 4. Select field from the list box and click the right arrow (>) button. The field name will
appear in the Fields in the Query list box. Repeat the process for other fields.
Note that once the fields are added they can be moved up and down in order by clicking ∧ and ∨
buttons present on the extreme right of the wizard. Clicking on » button moves all fields to
Fields in the Query area and « button moves all the fields back to Available fields area.
Step 5. Clicking on the Next button will display the screen to select the sorting order. It will set
the sorting order. The result of the query can be displayed in ascending or descending order of
any particular field of the table. Click on Next button.
Step 6. The next step is to set the search conditions or the criteria on the basis of which records
will be filtered from the table.
Three search conditions can be given at the most in the wizard. Click and
select the radio button with option ‘Match any of the following’ if any one of the given
condition are to be matched for filtering the records.
Step 7. Steps 4, 5 and 6 given in the Steps Pane deal with tasks like summarizing and
performing numerical calculations. Such steps are not required if there is no numeric field
involved in the query. So you can skip these steps and move directly to “Step 7. Aliases” of the
wizard.
Step 8. The next step to give alias name i.e. the column header name will be displayed when we
run the query. By default the field names will be displayed as column headers. Many times field
names are not user friendly, so an alias name which is more readable, is chosen to be displayed
in the query output.
Step 9. The last step of the Query wizard displays the entire overview of the
query. All the steps performed till now are shown in a summarised manner.
Forms
A form is an object of the database that has a user friendly interface where data can be entered
and seen in an attractive and easy-to-read format. For any database, it is the front end for data
entry and data modification. It displays the data in a layout design by us and not just in a simple
row and column format.
Primarily, a form contains field controls arranged in a presentable and user friendly manner.
Each field control consists of a label and the field value text box. A label is a piece of text that
specifies the data that should
be entered in the field value text box. A field value text box is linked to the respective field in the
table. We may add all or selected fields from the table on the form. In addition to field controls,
it may contain some additional text like titles, headings and names, graphics like logos, list boxes
and radio buttons.
There are two ways to create a form:
• Using a wizard
• Using the Design View
Creating a Form Using a Wizard
This is the simplest way to create a form. Follow the following steps.
Step 1. Open the database created in LibreOffice, and click the Form icon on the Database
Pane. Click the option Use Wizard to Create Form… on the Tasks Pane. The Form wizard
will open along with a blank database form in design view in the background.
Step 2. Select the tables or queries for which the form has to be created.
Step 3. After selecting the table, all the fields of the table will be listed in the Available Fields
list box
Step 4. As we require all the fields to appear in the Form, shift all the fields of table from
Available Fields list box to Fields in the Form list box using >> button. Click on Next button
to move forward.
Step 5. The next step consists of setting up a subform, i.e. a form within a form. You need to
check the checkbox “Add Subform” to add the subform. click Next button to proceed further.
Step 6. The wizard skips the next two steps that relate to the subform and moves on to step 5.
This step arrange controls i.e. to set up the design of the form. Four layouts are given in this step
of the wizard to choose from:
Columnar display with Labels on the left of the field value
Columnar display with Labels on top of the field value
Display as datasheet
Block display with labels on top
Select Layout type as you required.
Step 7. Click Next button.
Step 8. The step 6 of the wizard asks whether the form will be used for displaying data, entering
data or both. As we go with the default settings, so
we click Next button.
Step 9. The next step is to apply styles to the form being created. We can select the desired
background colour and border type of the field value text
boxes.
Step 10. Click Next button.
Step 11. The next step is to set the name of the form. By default the name of the form is same as
thename of the table.
Step 12. Click Finish button. The form with the first record will be displayed on the screen in a
separate window.
Modifying a Form
It is possible to modify the form in any manner once it is created. The modification can be to
change the background color, font size and color of the text or even positioning of various
controls in the form.
Follow the following steps to change the form.
Step 1. Open OpenOffice Base User Interface for database and click on Forms icon in the
Database Pane. The name of the saved form will be displayed in the Objects Area.
Step 2. Right click on the form name and select Edit… option. A separate Form Design View
will open.
Step 3. Make changes as your required in the form.
Save the form.
Reports
Using a report we can present the retrieved data in an attractive and customized manner. We can
create a report based on a table or a query or both. Preferably, 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.
Follow the following steps to create a report.
Step 1. In the LibreOffice Base User Interface, click on the Reports icon in the Database
Pane.
Step 2. From the Tasks Pane, click Use Wizard to Create Report… option.
Step 3. The Report wizard along with two other windows will be displayed. One of the window
is Report Builder window and the other is Add Field dialog box.
Step 4. The first step of wizard is to select the table and the corresponding fields that we want to
display in our report. From the Tables or Queries list box, select the table.
Step 5. All the fields of the table will be listed in the Available Fields list box. Click >> button
to shift all the fields to Fields in report list box.
Step 6. Click on the Next button. The next step is to label the fields. By default, the column
headers will be displayed as labels or column headers for the field values. As fields names are
generally shortened, to change to more self-explanatory names, type the new names in the
respective text boxes.
Step 7. Click on the Next button. The next step is to group the data based on any of the fields in
the report. click on the Next button.
Step 8. The fourth step is to set the Sort options. If the data to be displayed in the report has to be
sorted in either ascending or descending order of a particular field, specify the field and sorting
order in this step.
Step 9. Click on the Next button to move on to the next step in which the layout of the report will
be selected.
Step 10. A layout is the manner in which the labels, field values and titles will be displayed in
the report. Out of various Layout options given, choose the desired layout, say Tabular and also
the layout of headers and footers (Default). You may also choose the orientation option
Landscape or Portrait in this step. Keep the default orientation option Landscape selected by
default.
Step 11. Click on the Next button to move to last step. Here we name the report and to specify
the manner in which we want to proceed after the wizard finishes. Type the name of the report.
By default the type of report is Dynamic. That means as the field values in the base table or
query change,
the report will also change automatically. If you don’t want automatic updation of the report,
choose the Static option. In this step, specify whether you would like to modify the report or
create the report once the wizard finishes.
Step 12. Click on Finish button to display the report.