1. Introduction to Database Management
System
Introduction
Databases and database systems are essential parts of our life. We
have been interacting with databases since a time. Recall the process
of looking for a word in a dictionary or finding the telephone number
of a friend from the telephone directory. With the advancement in
ever changing technology, computerized databases are being used to
store, manipulate, and manage the database. Today, we use
databases in almost all spheres of life. When we go to book railway
tickets, to search for a book in a library, to get the salary details, to
get the balance amount after withdrawal of money from the
ATM and so on, this list can run into several pages. Data being stored
in databases can be of varied types like text, images, audio and video.
This data is then stored and/or processed so as to get meaningful
information.
2. Data and Information
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. This data must be processed by any computing machine in
a
proper way to generate the useful and meaningful information. The examples of data are marks scored
by
the students, weights, prices, costs, numbers of items sold, employee names, product names,
addresses, tax
codes, registration, marks etc.
Information is the processed or organized form of data. If data is not correct or accurate, the
information
obtained by processing such data may not be correct. For example, marks obtained by students and
their roll
numbers is the data, while the report card/sheet is theinformation. Other forms of information are pay-slips,
schedules, worksheet, bar charts, invoices, account returns etc. Similarly the temperature recorded is data
which can be processed to find out the maximum or minimum temperature of day and night. Also this data
is generally organised in tabular form as shown in the Table 8.1
3. Databases and DBMS
A database is a collection of logically related data items stored in an organised manner. 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. Some of the common
examples
of DBMS are MS Access, Open Office or LibreOffice Base, Oracle, Ingress, MySQL. In this book, we will
use
LibreOffice Base version 6.4 to learn various aspectsof DBMS.
We all know that it is easy to remember names of our friends, but it is difficult to retain their phone
numbers
in our memory. If details like names and phone numbers are stored in a diary or mobile phone in an
orderly
manner, then it becomes easy to retrieve the phone number of a required person. Thus, the phone
book
can be considered a simple database and to manage this database electronically, we will require a
database
management system or a DBMS.
4. Advantages of DBMS:
• 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.
• 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 itrepeatedly for multiple applications.
• Minimal 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 minimising 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.
5. Increases Efficiency – Since database tables are properly organised, saving, reading and searching
data can be carried out efficiently.
• Increases Accuracy – Since data redundancy andinconsistency 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. For instance, we may set up a restriction while creating the table that
the amount of fees being entered should be more than 1000.
• Security – Unauthorized access can be controlled by assigning passwords to the users. The data
might be translated in such a manner that unauthorised users are not able to read it. This
is known as encryption. Both these measures increase the security of the database.
6. Data Models
A database can be designed in different ways depending on the data being stored. This structure of
database
is known as data model that describes the manner in which data will be stored and retrieved.
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.
Hierarchical Data Model
In this model the data is organized into a tree like structure. The data is stored in the form of records. A record is a collection
of fields and its data values. All these records are linked to each other at various levels, thereby forming a hierarchy. For
example, inFig. 8.1 the data of a company is stored using a hierarchical data model.
7. Network Data Model
In this model, multiple records are linked to same master file. It is also considered as an inverted tree where master is
present in the bottom of the tree and the branches contain information linked to the master.In Fig. 8.2, the data of the
company is represented using the network data model.
8. Relational Data Model
This data model is based on the principle of setting relationships between two or more tables of the same
database. It is the most commonly used database.
Relational Database Model
The Relational Database Model was proposed in 1970 by E. F. Codd. Relational database model is the most
common type of database model. The data elements are stored in different tables made up of rows and columns.
The data in different tables are related through the use of common fields. So relations are set between tables
based on common fields. That is why this model is termed as relational database model.
Relational Database Terminology
Let us get familiar with some of the common terms usedin RDBMS.
• Entity – It is a real world object about which information is to be stored in a database. For example, if we want to store
information about an entity Student in a school, then we need to have his admission number, roll number, name, father’s
name, date of birth, etc. These details associated with the entity are called attributes. Each entity is a collection of these
attributes associated with it. So roll number, name, admission number, etc., are attributes associated with the entity
student. These attributes are represented in the form of columns.
• Table – A table is a collection of logically related records. It is organised as a set of columns, and can have any number of
rows. For example, the Employee table can have columns, namely name, designation, department and have records or
rows having data of 100 employees.
• 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. For example, in the Employee table the field “Emp Name” will hold the names of
employees of an organisation.
9. Data Values – Data values are the raw alphanumeric form. Examples of data values are ‘Abhinav Bindra’, ‘26’
‘shooting’, “Chandigarh”, “10-12-2018”, etc.
• Record or Row – 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.
• 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.
For example, in a student table, eachstudent has a unique roll 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.
10. Relational Database – A relational database is a collection of related tables. For example, in Fig.
8.3, the database contains two related tables
11. 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. Considerthe example
given below.
In Student Registration Table, ‘Enrolment_Number’ is the primary key and in the Student Marks Table,
‘Roll_Number’ is the primary key, whereas ‘Enrollment_Number’ is the foreign key. This foreign key can be used to set 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. So in the table Student Marks, Enrollment Number and Roll Number both are
candidate keys.
• Alternate Key – Out of the candidate keys, one or two are made as primary keys. The others are
the alternate keys. Hence, if Roll Number is made as the primary key, Admission Number is the
Alternate key.
12. 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 that work on multiple sets of data related to each other.
Various
objects in a database are as discussed below:
• Table – As mentioned before, 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.