10 It Database Managementsystem Notes01-Combined
10 It Database Managementsystem Notes01-Combined
Relevant Knowledge
A database is an organized collection of data. You can visualize it as a container of information.
The data is typically organized to model relevant aspects of reality (for example, the availability of rooms in
hotels), in a way that supports processes requiring this information (for example, finding a hotel with facilities
such as Laundry, GYM etc…).
Suppose if you own a stationary shop, you need to keep detailed records of the materials available in your shop.
You also need to store information about pricing, stock levels for reordering, old stocks, etc. While in the
manual system, you would maintain several files with different bits of information; in the computerized system
you would use database programs such as Microsoft Access, OpenOffice.org Base, and MySQL, to organize the
data as per your business need. The database concept has evolved since the 1960s to ease increasing difficulties
in designing, building, and maintaining complex information systems (typically with many concurrent end-
users, and with a large amount of diverse data). In this lesson, you will learn database concepts and to work
with a Database Management System (DBMS).
To practice questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams.
Flat File: Data is stored in a single table. Usually suitable for less amount of data.
Relational: Data is stored in multiple tables and the tables are linked using a common field. Relational
is suitable for medium to large amount of data.
Database Servers
Database servers are dedicated computers that hold the actual databases and run only the DBMS and related
software. Typically databases available on the database servers are accessed through command line or graphic
user interface tools referred to as Frontends; database servers are referred to as Back-ends. Such type of data
access is referred to as a client-server model.
Advantages of Database
Sharing of Data
In a database, the users of the database can share the data among themselves. There are various levels
of authorisation to access the data, and consequently the data can only be shared based with the
authorized users.
Many remote users can also access the database simultaneously and share the data between
themselves.
Data Integrity
Data integrity means that the data is accurate and consistent in the database. Data Integrity is very
important as there are multiple databases in a DBMS. All of these databases contain data that is visible
to multiple users. So it is necessary to ensure that the data is correct and consistent in all the databases
and for all the users.
Data Security
Data Security is an important concept in a database. Only authorised users should be allowed to access
the database and their identity should be authenticated using a username and password. Unauthorised
users should not be allowed to access the database under any circumstances as it violates the integrity
constraints.
Privacy
The privacy rule in a database states that only the authorized users can access a database according to
its privacy constraints. To secure data levels are set in the database and a user can only view the data
which is allowed to be seen. For example - In social networking sites, access constraints are different
for different accounts a user may want to access.
Backup and Recovery
Database Management System automatically takes care of backup and recovery. The users don't need
to backup data periodically because this is taken care of by the DBMS. Moreover, it also restores the
database after a crash or system failure to its previous condition.
Data Consistency
Data consistency is ensured in a database because there is no data redundancy. Data Consistency
means there should be multiple mismatching copies of the same data. All data appears consistently
across the database and must be same for all the users viewing the database. Moreover, any changes
made to the database are immediately reflected to all the users and there is no data inconsistency.
Features of Database
Let’s look at the example of your address book. What do you store in an address book? You may have people’s
name, address, phone number and maybe even their birthdays. There is a common element here – people. In
this example, each person is considered an “ITEM”.
So, database will store information about that person. When you were recording information in your address
book, what did you ask the people? What is your address? What is your phone number? etc. Each question that
we ask about our ITEM is a “field”. Now, say you make new friends and want to add their information to your
address book. You will ask questions, get the answers and create a new “record”. So, a record is a set of
information (made up of fields) stored in your database about one of the items. A “value” is the actual text or
numerical amount or date that you put in while adding information to your database. When you put all the
information together in a grid (like you do in a spreadsheet), a collection of similar records creates a table.
There are some key features of a database:
1. A database can have one or many tables. An address book example is a very simple one, in real world there
are many more details involved. A big company would have in its database, one table for its products, one
table for its suppliers, one table for its customer details, one for orders received and maybe many others.
2. Each table in a database contains information about one type of item. So, a database is a container that
holds tables and other objects and manages how they can be used.
3. Another very important thing to remember is that when we put in information, we may have people with
the same name (there can be more than one Charu Arora) or the same address (members of a family). But
when creating a database an important feature is record uniqueness in every table. it is important to be
able to distinguish between different items having duplicate values.
Uniqueness helps to avoid accidental duplication of records caused by user or computer error. This can be
achieved by using some number or value that uniquely identifies a record. If such a unique value does not
exist in your fields, as the database designer, you can create a special additional field in a table where
unique numbers or values can be assigned for each new entry. Therefore, every table has a key field which
ensures that there are 100% unique values throughout the database.
4. Every database table should have one or more fields designated as key. You can assign a unique value to
this key for differentiating records that may have similar names or addresses.
Ram X A
Ravi X A
Ravi X A
Sanjay X B
In this table, it will be extremely difficult to differentiate between student records as they have names that are
similar. To differentiate, you can add additional field - roll number - that will be unique for each record
(example below).
19 Ram X A
20 Ravi X A
21 Ravi X A
22 Sanjay X B
EXAMPLE OF RDBMS
You had used the example of an address book in the previous section. An address book uses only one table. But
look at a different situation. If you are a dealer selling a single type of item and want to record details of your
sales in the past month and also want the details of the client who purchased the item (name, address, phone,
date purchased, number of items bought etc), what would you do?
To practice questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams.
You create a table Sales with all the details:
Do you see a problem here? Every time you sell an item to Sheela or Vaibhav or any other customer (client) you
need to store the details again. So, what is the solution? Create one table for client details and another for sale
details. Since each record has to be unique, you can insert a ClientID field to uniquely identify each client in the
client table. In the Sales table, you would give a point of reference which “points” to a particular record in the
Client table.
In the example here, the field ClientID occurs once in the Client table, but since one client can place many
orders, it occurs a number of times in the Sales table. Since we cannot have an order without a customer, we
call Client the parent and Sales the child table. Related tables like these share a common field. You store data
about people once, but refer to those people many times in the database.
When data is to be stored, maintained, and retrieved from multiple tables then special database software are
required known as Relational Database Management System. In the RDBMS data can be integrated using keys.
These are Primary Key, Composite Primary Key, and Foreign Key.
This unique field is called the Primary Key (PK). A primary key is a unique value that identifies a row in a
table. In our example, ClientID is the primary key in the Client table. Primary Keys are also indexed in the
database, making it faster for the database to search for a record. When primary key constraint is applied on
one or more columns then it is known as Composite Primary Key.
The referred field ClientID which occurs in the Sales table is called the Foreign key (FK). Hence, 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. The “one” side of a relation is always the parent, and provides the PK attributes to
be copied. The “many” side of a relation is always the child, into which the FK attributes are copied. Memorize
it: one, parent, PK; many, child, FK.
Another point to remember is that the end users will/may never have direct access to the database. They can
only see what you permit them to and can select only from the options you give them.
RDBMS
A relational database is a type of database. It uses a structure that allows us to identify and access data in
relation to another piece of data in the database. Often, data in a relational database is organized into tables.
Relevant Knowledge
Data in a relational database management system (RDBMS) is organized in the form of tables.
You will now quickly recap what you learnt in the last session and assimilate more concepts.
RDBMS
A relational database is a collective set of multiple data sets organized by tables, records and columns.
Relational database establish a well-defined relationship between database tables. Tables communicate and
share information, which facilitates data searcheability, organization and reporting. A Relational database use
Structured Query Language (SQL), which is a standard user application that provides an easy programming
interface for database interaction.
To practice questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams.
DATABASE OBJECTS
Tables: A table is a set of data elements (values) that is organized using a model of vertical columns(which are
identified by their name) and horizontal rows. A table has a defined number of columns, but can have any
number of rows. Each row is identified by the values appearing in a particular column identified as a unique
key index or the key field.
Columns or Fields or Attributes: A column is a set of data values of a particular simple type, one for each row
of the table. The columns provide the structure according to which the rows are composed. For example,
cFirstName, or cLastName are fields in a row.
Rows or Records or Tuples: A row also called a Record or Tuple represents a single, data item in a table. In
simple terms, a database table can be visualized as consisting of rows and columns or fields. Each row in a table
represents a set of related data, and every row in the table has the same structure.
To open OpenOffice, click Start > Programs > OpenOffice.org 4 > OpenOffice.org.
Alternatively, you can also double-click on the OpenOffice.org 4 shortcut on the desktop if available.
You should see a Window similar to the one displayed below
Select the option database to open the base application. You can also directly open the OpenOffice Base
Application by doing the following:
Click Start>Programs>OpenOffice.org 4>OpenOffice.org Base.
You should be guided through the Database Wizard for creating a database.
You will see a dialog box similar to the one displayed below.
You can create a new database by selecting the option Create a new database. You can also
open an existing database file that you have already created by selecting the option Open an
existing database file. Click Next.
A dialog box similar to the one displayed below appears.
Click Finish. The Save As dialog box appears as shown below. Specify a name for the database
in the File name: field and click Save. A window similar to the one displayed below.
Click Finish. The Save As dialog box appears as shown below.
Specify a name for the database in the File name: field and click Save. A window similar to the
one displayed below.
Now that you have created a database, you can work with the database as outlined in the next
few sessions.
the previous exercise you have learnt how to create database objects in OpenOffice.
In this exercise you will learn how to create a table in a database.
After creating the database, you see a window as shown below.
There are different ways to create a table:
Click the Select Fields > Choose Category > Select the table (in the picture shown below “Business” category and
“Customer” table has been chosen) > Click on Next Button.
Select the fields as per the requirements and select on buttons to add the predefined columns or select
to remove the fields from the Selected Fields Box. After selecting the fields click on Next Button.
Once the fields will be selected the window to set the data types will open, By default all the fields will have
Text[VARCHAR] data type which can be and other properties with default values but all of them can be selected
as per the requirement.
Click on Next Button
After setting the properties of the fields such as field name, type etc. The window to set the primary will open.
Base automatically adds the column to be set as Primary Key which will help the user to enter the unique
values and helps in creating the relationship with the other table to extract the data from multiple tables.
After setting the Primary Key click on Next Button.
When the Primary Key will be set then window to rename the table will open. A user can either go ahead with
the same table name or can change it.
In the same window options to work with the table will be given as:
The option to insert the data immediately will be selected by default . Click on Finish to insert the data in the
table.
1. Click on Create Table in Design View… option available under Tasks and a Table Design window appears as
shown below.
Specify the field name and data type of the field to be created by selecting the appropriate type available
under Field type dropdown list.
Now create a table with the following fields displayed below:
Specify the field name and the data type for each field name. For example, the table contains the Name
field and the data type of the Name is TEXT [VARCHAR]. You can specify the length of the field value.
Field Name Data type Length
Name VARCHAR 50
Rollno TINYINT 3
Class Char 1
Phone INTEGER 10
Email VARCHAR 75
Colour VARCHAR 15
Location VARCHAR 30
After specifying the field name and data type for the field variables, save the table by clicking on File>Save
shown below.
To practice questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams.
Notice the table by the name SDetails created and visible under Tables section.
Data Types:
Datatypes are used to identify which type of data (value) we are going to store in the database.
Fields themselves can be of different types depending on the data they contain. Data types in OpenOffice base
are broadly classified into five categories listed below.
Numeric Types
Alphanumeric Types
Binary Types
Date time
Other Variable types
Numeric Types:
Numeric data types are used for describing numeric values for the field used in the table of a database.
Numeric data types in a database can be used for storing information such as mobile number, roll number,
door number, year of school admission, true or false statements, statistical values, etc. The different types of
numeric data types available are listed here.
Alphanumeric Types:
Data
Name Description
type
Stores up to the max length or number indicated by user. It accepts any UTF 8
LONGVARCHAR Memo
Character.
Stores exactly the length specified by user. Pads with trailing spaces for
CHAR Text(fix)
shorter strings. Accepts any UTF 8 Character.
VARCHAR Text Stores up to the specified length. No padding (Same as long var char)
VARCHAR_IGNORE Stores up the specified length. Comparisons are not case sensitive but stores
Text
CASE capitals as you type them.
Binary Types: Binary data types are used for storing data in binary formats. Binary data types in a database
can be using for storing photos, music files, etc. In general, files of any format can be stored using the binary
data type. The different types of binary data types available are listed here.
LONGVARBINARY Image Stores any array of bytes (images, sounds, etc.). No validation required.
DATE TIME:
Date time data types are used for describing date and time values for the field used in the table of a database.
Date time data types in a database can be used for storing information such as date of birth, date of admission,
date of product sale, etc.
The different types of date time data types available are listed here.
Time Stores hour, minute and second information Seconds since 1/1/1970
Name Description
Other/Object Stores serialized Java objects â " user application must supply serialization routines
To insert values into the table, just double-click the table name, you should see a window similar to the one
displayed below.
Start typing the records in the table with the data provided in the excel sheet and select File > Save Current
record to save data in the table.
Relevant Knowledge
In Base, data is stored in tables which can be inserted, modified and removed using appropriate options.
You will now quickly recap what you learnt in the last session and assimilate more concepts.
To practice questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams.
The table will open in Datasheet View in which data new data can be inserted and existing data can be updated
or removed.
To edit the data either click on edit icon or double on the data in the cell of a table and modifications
can be done.
Field Properties
To change the field properties table structure in design view has to be changed. To set the field properties, steps
will be followed as:
Select the table > Right click > Select the option Edit > the table Design View window will open
In design view there are different properties of fields according to the data type set for each field.
The properties of numeric type data is shown below in the figure.
Like AutoValue – if set to yes then field will get the auto numeric values.
Length – By default length of the field is 10 but the size of the field can be set to maximum length.
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.
Format example – This property helps to set the format of the data entered in the field such as 91-222-333.
Sorting Data
Sorting means to arrange the data in either ascending order of descending order. Select the column(s) then click
on sort buttons. The data will be displayed accordingly.
Referential Integrity
Adding records to a related table if there is no associated record available in the primary key table.
Changing values in a primary if any dependent records are present in associated table(s).
Deleting records from a primary key table if there are any matching related records available in
associated table(s).
Save time as there is no need to enter the same data in separate tables.
Reduce data-entry errors
Summarize data from related tables.
You can create a relationship between any two tables by selecting Relationships… option from the Tools menu.
Add the tables in amongst which you want to create the relationship. Select the tables and click on Add button.
1. ONE to ONE
2. ONE to MANY OR MANY to ONE
3. MANY to MANY
There are two ways to create the relationships between the tables:
a. Click on Insert option and select New Relation… option in Relation Design window.
b. Drag the primary key column from one table and drop it on the key column of another table.
Relevant Knowledge
Having created the tables and entering data into them, now you want to extract some information.
That’s when you query the database. As the name suggests, query is to collect specific information from the pool
of data. A query helps us join information from different tables and filter that information. Filtering means
that the query uses criteria you provide to hide some data and present only what you want to see.
To practice questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams.
Click on Finish
You can type the query in the above window and execute it by using the F5 function key or by clicking the
To practice questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams.
For example, if you want to display all the data in the table that you created in the early session, then the select
statement will be:
Select * from SDetails;
After executing the select query the output will be shown similar to the one displayed below.
Performing calculations
In Base, simple calculations can be done on the data using arithmetic operators.
Example: To display the salary of all the employees after incrementing by 1000 then the following SQL
command will be executed in Base SQL Design
Select “EmployeeID”, “FirstName”, “Salary” + 1000 from “Employee”
To display the salary of all the employees after decreasing by 10000 then the following SQL command will be
executed in Base SQL Design
Select “EmployeeID”, “FirstName”, “Salary” - 10000 from “Employee”
To display the salary of all the employees after incrementing it as twice the amount of present salary, then the
following SQL command will be executed in Base SQL Design.
Select “EmployeeID”, “FirstName”, “Salary” * 2 from “Employee”
To display half of the salary amount paid to the employees, then the following SQL command will be executed
in Base SQL Design.
Select “EmployeeID”, “FirstName”, “Salary”/2 from “Employee”
Grouping of Data
To display the records containing the same type of values “WHERE” clause can be used with the Select SQL
Command.
To get details about the list of students whose favorite color is blue, you can use:
select * from SDetails where Color=’Blue’;
After executing the select query the output will be shown similar to the one displayed below.
To view records in ascending order of RollNo, from the table the select statement will be: select * from SDetails
order by “Rollno” ASC;
You can add, modify or delete records using the Insert, Update and Delete commands.
To type and execute SQL commands, click on Tools > SQL. A window similar to the one below will be displayed.
You can type the SQL Commands in the Command to execute space and click on Execute.
UPDATE statement
Update statement is used for modifying records in a database. The general syntax of the update statement is as
follows:
UPDATE < table_name>
SET <column_name> = value[,column_name = value ...]
[WHERE <condition>];
To update a record using an update statement, type the following and click Execute.
Update SDetails set Location = ‘Bhubaneswar’ where Rollno = 14;
Execute select query to view the updated table. After execution you should see a window similar to the one
displayed below.
Relevant Knowledge
A form provides the user a systematic way of storing information into the database. It is an interface in a user
specified layout that lets users to view, enter, and change data directly in database objects such as tables.
In this session, you will learn to create a form.
To practice questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams.
You can select selective fields to be sent onto the form by selecting the field name and clicking > button. You can
Click Next >. You see the Set up a sub form step dialog box of the wizard as shown below
You can select the option Add Subform if you need to insert the contents in the table in a separate form. Click
Next>.
Now you need to arrange selected fields in a form. You can use different styles from the list displayed below:
Click Next >. You should see a dialog box wherein you can specify the styles to be used in the form.
To practice questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams.
Click Next >. You see a dialog box where you can specify the name of the form. Click Finish.
A form window appears. Notice that the records in the table are displayed automatically within the form that
you just created.
You can add new records to the table using the form by clicking the symbol located at the bottom as
shown below.
Once you click the symbol, you will be displayed with a window for creating records (Figure below).
You have learnt to create records using design view in the earlier sessions. You can add records using the form
as displayed below. Type the following data in the textbox provided in the box as shown below:
Name Gautam
Rollno 43
DOB 10/12/99
Class X
Phone 325476
Color Pink
Email [email protected]
Location Assam
To view the saved records, Double-click SDetails (Table name) under Tables section. A window similar to the
one below will be displayed; notice the record that you created using a form is also displayed along with other
records (Figure below).
Now enter three more records using the form and view them using the above mentioned procedure.
Reports
A report helps to display the data in a summarized manner. It is used to generate the overall work outcome in a
clear format. You can create reports in the database.
Now we can generate the report for the table created earlier.
Click on Use Wizard to Create Report… option available under Tasks.
Once you select the Use Wizard to Create Report… option.
You should see a window similar to one displayed below.
You have to select all the table fields by selecting the >> button, once you click the button >> you should see a
dialog box similar to the one displayed below.
Once you click Next>.you should see a dialog box similar to the one displayed below.
You can redefine the label of the fields in the reports or else you can set the default name. Once you click Next
>, you should see a dialog box similar to the one displayed below.
You can sort the field variables in the report by selecting the appropriate field and sorting method.
Once you click Next >, you should see a dialog box similar to the one displayed below.
You can select the layout of the report by selecting the appropriate option available under the Layout of data
down list and you can also select the orientation of the report.
Once you click Next >, you should see a dialog box similar to the one displayed below.
You can define a name for the report or you can use the name of the table itself for the report also.
Click Finish.
Once you click Finish you should see a window similar to the one displayed below with the report.
Now create a report containing only Name, RollNo and Phone details. Use different layouts for the report
design.