It - 802 - Study Material
It - 802 - Study Material
Fundamentals of Computer
Introduction
In today’s world we can see that almost all our work is being done with the help
of computers. Applications of computers can be seen in every electrical device
nowadays whether it is television, washing machine, watches, mobile phones
and the list is endless. With the advancement in use and technology, use of
electronic devices has increased manifold. All this is possible because of the
ease and accuracy we get with these devices. Life has taken a fast pace and
distances make hardly any difference with the help of these machines. Let us
have an insight to the basics of computers in this chapter.
Evolution of Computers
The data and/or instructions given by the user to the machine are termed as
Input and the result generated by the machine after processing the data is the
Output.
Characteristics of a Computer
speed : A remarkable quality of computers is their ability to process data and
instructions at a very high speed.
Accuracy: Not only does the machine perform varied jobs with high speed, but
also does them with high precision and accuracy.
Memory: One of the notable features of a computer is its memory. However,
the computer’s main memory is volatile, i.e., it is lost when we switch off the
computer.
Therefore, computers are provided another form of memory that does not fade
away when it is switched off. It is called secondary memory and is available in
the form of floppy disks, pen drives, portable hard disks.
Components of a Computer
The computer is the combination of hardware and software. Hardware are the
physical components of a computer like motherboard, memory devices,
monitor, keyboard etc. while software is the set of programs or instructions.
Both hardware and software together make the computer system function.
Every task given to a computer follows an Input- Process- Output Cycle (IPO
cycle). It needs certain input, processes that input and produces the desired
output. The input unit takes the input, the central processing unit does the
processing of data and the output unit produces the output. The memory unit
holds the data and instructions during the processing.
Input: To initiate the process, the computer needs to be told of the problem to
be solved. For this purpose, a set of instructions and data is provided through
the input devices such as keyboard and mouse. A set of instructions provided
to the computer for doing a task is called a program.
Storage:
Every bit of information in computer is stored in terms of Bits (Binary Digits) i.e.
0s and 1s
The smallest unit of memory is Byte. The other units of memory are
1 nibble = 4 bits
1 byte = 8 bits
1024 bytes = 1 Kilobyte (KB)
1.RAM ( Random Access Memory) : It is a primary volatile memory i.e. its data
gets lost once the power supply is stopped.
Processing: The inputs provided by the user are processed by the central
processing unit as per the specified instructions. The result of the processing is
then either directed to the output devices or to a memory location for storage.
CPU: The motherboard houses the main processor or the CPU (Central
Processing Unit). CPU executes the user instructions and coordinates amongst
all other units of the computer. Thus, it is primarily responsible for the
performance of the machine
Input Devices
Input devices takes input from the user. The input may be in the form of text,
image, sound, video etc. a wide range of input devices have been devised for
supporting varying types of input. Following are examples of some of the input
devices of computer:
- Keyboard: this is a standard input device and takes data in the form of text.
- Mouse : it is a pointing input device.
- Webcam: it takes data in the form of video/image
- Scanner : it generally stores data in the form of graphics
- Microphone : it is used for voice input/ audio input
- Handwriting input board: it is used for giving input from
Output Devices:
Devices that are used to give output to the user. Output may be in the form
of visuals, text, audio, printout etc. different types of output devices are there
to support various types of output. Following are some examples of output
devices:
- Monitor/ VDU ( Visual Display Unit) : it is the standard output device and is
similar to a television screen.
- Speaker : it is an output device that gives output in the form of an audio/
voice.
- Printer : it is also a very commonly known output device that gives output in
the form of print out also called as hard copy.
- Plotter : it is a large printer like device that is used to take print of large maps,
architectural designs.
- Projector : it is an output device that gives an enlarged view of the output on
a large screen. It is generally used for giving a view of output to a large
audience.
Operating System :
Operating system is the software that acts as an interface between user and
computer hardware. A computer needs to communicate with both the
hardware and software.The popular operating system are Windows, Linux,
Unix, MS-DOS, SOLARIS, MAC OS
Single Task Operating System : such operating systems allow execution of only
a single program at any given instant.
Single-user operating systems allow only one user to use the system. The
desktop systems can be classified as typical single user systems
Operating systems which ensure that the response time is fixed are categorized
as real-time operating systems. They are intended for applications where data
needs to be processed quickly, without any significant delays
In a batch processing system, similar jobs are clubbed together and submitted
as a block to the processor for execution. User intervention is minimal in such
systems. The jobs are picked up one by one and executed.
Self assessment Exercises:
Define the following :
• Hardware
• Input Device
• Output Device
• Processor
• Operating System
Expand the following :
a. ALU
b. CPU
c. CU
d. RAM
e. ROM
Answer the following
a. Differentiate between RAM and ROM
b. Explain input and output devices.
c. Explain storage devices of a computer.
d. Describe secondary and primary storage devices of a computer
Relational Database
In the database the data is organized into separate tables. Once the tables
have been set up, a relationship can be created to link them together. Such
a database that stores data in separate tables that are related through the
use of a common column is called a Relational database.
RDBMS Terminology
1. Domain
It is pool of values or the collection (set) of possible values from which the
value for a column is derived.
Primary Key: The group of one or more columns used to uniquely identify
each row of a relation is called its Primary Key.
A primary key is a field in a table that is unique for each record. Every
database table should have a column or a group of columns designated as
the primary key. The value this key holds should be unique for each record
in the table. Some more examples of Primary key are: Accession Number
of a Book in the Book table, Employee ID of an employee in the Employee
Table, Item Code of an item in the Stock table, Flight Number of a flight in
the Flight Master Table, etc.
In a table, there may be more than one field that uniquely identifies a record.
All such fields are called candidate keys. A Candidate key is an attribute (or
set of attributes) that uniquely identifies a row. A Primary Key is one of the
candidate keys. A table may have more than one candidate keys but
definitely has one and only one primary key.
Alternate Key: A candidate key of a table which is not selected as the primary
key is called its Alternate Key.
Introduction to MySQL:
Characteristics of MySQL:
Creating a Database
Before creating a table we will first create a database. To create a database
we will give
Using a database
Creating a Table
After creating a database, the next step is creation of tables in the database.
For this CREATE TABLE statement is used.
Syntax:
CREATE TABLE <TableName>(<ColumnName1> <Data Type1>,
<ColumnName2> <Data Type2>,… ,<ColumnNameN> <Data TypeN>);
Constraint Purpose
Primary Key Sets a column or a group of columns as a
primary key of the table. Therefore, NULLs
and Duplicate values in this column are not
accepted.
NOT NULL Makes sure that NULLs are not accepted in
the specified column.
DEFAULT Gives default value if the user does not give
the value in the specified column
EXAMPLE:
After creating database and relations, we can add data in the relations.
INSERT INTO command is used to enter values in a table. Syntax of insert
command is as follows :
Main purpose after storing the data in a table is to retrieve the data for
generating various reports. Data from tables can be retrieved/ fetched using
Select Command.
SELECT COMMAND :
SELECT command is used to view the data from a relation in a database. It
returns a result set of data/ records from one or more relations.
Syntax of SELECT Command :
SELECT <column name> FROM <table name >;
Command to retrieve
single column display
select Rno from
STUDENT;
+---------- +
| r no |
+---------- +
| 1|
| 2|
The output displayed the data in same order as the order of columns given
in the command.
Command to display all the columns : ‘* ‘ symbol is used to display all the
columns of the table. Select * from Student;
* is the wild card character ( means ALL) that is used to display names of
all the columns.
If a column contains repeated values then the select statement gives the
result set with repeated values like if a command is given to display
DISTINCT keyword is used to eliminate repeated values
Consider the query: Select marks from student: mysql> select marks from student;
+---------+
| marks |
+---------+
| 98 | | 92 | | 95 | | 94 || 93 | | 84 | | 84 || NULL |
+---------+
For example :
+---------+
| marks |
+---------+
| 98 | | 92 | | 95 | | 94 | | 93 | | 84 || NULL |
+---------+
ALL
Keyword ALL when used with Select statement is used to display values of
all columns in the row. It displays even the duplicate values.
WHERE Clause
Syntax:
For example if we wish to display records of students who have a got marks
greater than we will 90 then following command needs to be entered:
mysql> select fname, marks from student where marks > 90;
Operator Description
+ For addition of values
- Subtraction of values
* For finding the product of values
/ Divide
% Modulo operator. Returns the remainder
| fname | marks |
+----------------------------+--------+
| ABHISHEK | 108 |
| BHISHEK | 102 |
| BHUSHAN | 105 |
| CHETALI | 104 |
| CHETANYA | 103 |
+-----------------------------+---------+
+------------------- +---------------------------+
| empname | salary+salary*0.1 |
+--------------------+---------------------------+
| ABHINAV | 69803.20 |
| VISHESH | 49290.70 |
| B.RATNAKAR | 118982.95 |
| CHETANYA | 198675.45 |
| SOURABH | 99456. 93 |
+-----------------------+-------------------------+
5 rows in set (0.11 sec)
Note that the calculations done on column values only appear on the
output screen and does not make any changes in the records of the table.
The values remain the same in table. Actually the operation is performed
over the result set and not on the actual table. For making any changes
within a UPDATE command that is discussed after this topic.
Relational Operators
Relational Operators compare two values and gives a result in the form of
true of false. Every row is filtered using the relational operator in the
expression in where clause. Given below are the relational operators used
in MySQL alongwith their functions:
BETWEEN operator
Keyword BETWEEN is used to fetch data based on a range of values on a
column. The result set includes the values of the upper and lower bound
given in the range.
For example , following command displays firstname, last name and marks
of the students whose marks are from 92 to 95;
mysql> select fname, lname, marks
FROM student
WHERE marks BETWEEN 92 and 95;
Output will be :
OR operator returns True if either one of the conditions is True.
For example : to view list of all the sports coach who give coaching for either
football or hockey;
mysql> select Coachname, game from Sports
Coachname Game
NOT Operator
Not is used for negation. It returns the result set that is opposite to the
given condition For example : following command displays name and
salary of employees whose salary is not less than 50000.00
Following command displays name and zone of employees who are not in
north zone:
mysql>select empname, zone from employee where NOT(zone=’North’);
mysql> select empname, zone from employee where zone IS NOT NULL;
Note: the operations = NULL and <> NULL are not defined!
LIKE keyword
LIKE is used for pattern matching and is very useful. Following characters
used for applying pattern matching:
% percent symbol is used to match none or more characters
_ underscore character is used to match occurrence of one character
in the string
For example : To search for records having first name starting with letter ‘R’;
Following command displays list of students whose name starts and ends
with a specified letter.
Notice that in case no record matches the given pattern then the query
returns empty set on execution.
Similarly many more patterns may be given as follows :
‘_ _ _ _’ matches any string with exactly four characters
‘S_ _ _ _’ matches any string of length of exactly 5 characters and starts with letter ‘S’
‘S_ _ _ %’ matches any string of length of 4 or more characters and starts with letter ‘S’
‘_ _ _H matches any string of length of exactly 4 characters and terminates with letter
‘_ _ _ %’ matches any string with at least three or more characters
‘%in% matches any string which containing ‘in’
ORDER BY
The result set fetched by the query can be displayed in sorted order. The
sorting can be on the basis of any particular column from the table using
ORDER BY clause.
Syntax is :
SELECT <column name>, [<column name >…]
FROM <table name>
[ WHERE <condition> ]
ORDER BY < column name> [DESC];
By default the records are displayed in ascending order of the column
name. Keyword ASC is used with ORDER BY clause for displaying the list
in ascending order and keyword DESC is used with ORDER BY clause to
display the records in descending order.
It can be observed that the output is displayed in the sorted order of marks.
NULL value is displayed first and records are displayed in ascending order.
Following command displays the records in descending order of fname:
mysql> select fname, lname from STUDENT ORDER BY name DESC;
ORDER By clause can be used to sort the records on the basis of two
columns also. Following command displays the result based on order of
marks and then on fname.