You are on page 1of 104

oliveboard

Specialist Officer - IT

CLICK HERE TO PREPARE FOR


IBPS, SSC, SBI, RAILWAYS & RBI EXAMS IN ONE PLACE
Bolt is a series of GK Summary ebooks by Oliveboard for quick revision
oliveboard.in
www.oliveboard.in

Table of Contents
Lesson 1: Basic concepts of computer system ........................................................................................... 3
Lesson 2: Operating System................................................................................................................................ 15
Lesson 3: Database Management System................................................................................................... 29
Lesson 4: Overview of Computer Network ................................................................................................. 54
Lesson 5: Data Structure ....................................................................................................................................... 66
Lesson 6: Software Engineering and SDLC models ............................................................................... 77
Lesson 7: Programming Languages (C/JAVA/UNIX) .......................................................................... 87

www.oliveboard.in
www.oliveboard.in

Lesson 1: Basic concepts of computer system


Computer is an electronic device that is designed to perform logical and arithmetic operations sequentially. It takes
input (Data) from users via input devices and gives the desired output (Information) via output devices.
Computer Organization: Figure given below shows the block diagram of functional unit computer system:

• Input unit: Input unit is used to enter raw data or information into computer system for processing.
• Storage unit: Storage unit is used to store input data, intermediate data while processing and output data
after processing.
• Processing unit: Processing unit performs all the logical and arithmetic operations on the data provided by
the user. It consists of Arithmetic Logic Unit (ALU): It performs all the arithmetic functions and Control Unit
(CU): takes care of all the operations performed.
• Output unit: Output unit is used to store the result provided by computer system after processing.
Computer Memory: Any physical device capable of storing data or information in it either temporary or permanent
is known as Computer memory. Computer memory can be divided into many categories:
a) Primary or Main memory: It is directly accessed by the CPU for program execution and also known as Main
memory or Primary Storage and it is further divided into two parts:
• RAM (Random Access Memory): OS and programs in execution are kept temporarily in RAM and also
known as Volatile memory.
• ROM (Read Only memory): It is a special type of memory and its content can’t be changed, and it mainly
contains manufacturer’s instruction and ‘Bootstrap Loader’ ROM is also known as Non-volatile memory.
b) Secondary memory: It is a place in the computer where the data or programs are kept for long term and also a
Non-volatile memory. It is of two types: Magnetic disks and Optical disks.
c) Cache memory: Cache memory acts as a buffer between CPU and main memory and stores the data that is
frequently used so that the future request to that data can be served faster.
Cache Performance: Performance of a cache memory is measured by a term called Hit Ratio. If the processor finds
the required memory location in the cache, then Cache Hit is occurred, and otherwise Cache Miss is occurred. In
case of Cache Miss, a new entry is made in the cache and data is copied from the main memory to cache memory.
Hit
HitRatio =
Hit + Miss
Input and Output (I/O) devices: I/O devices in a computer are used to receive raw information and data as input
from the user and give processed and useful information as desired output to the users.
• Input device: Some of major examples of Input devices are Keyboard and Mouse. Some other example of
input devices: Joystick, Track ball, Light pen, Scanner, Microphone, Bar code Reader, Optical Character
Reader (OCR), Optical Mark Reader (OMR) and Magnetic Ink Character Reader (MICR).
• Output device: Some of major examples of Output devices are Monitor and Printer. Some other examples
of output devices: Projector, Headphone, Plotter, Speaker, Sound Card and Facsimile (FAX)
• Compute Software: Set of program or instruction that enables computer to perform well defined functions
and is classified into two categories: System Software and Application Software.
• System Software: System software is a group of programs that is designed to run a computer’s hardware
and provide a platform for other software. There are two major categories of System Software: Operating
System such as Windows, DOS, Android and Apples iOS etc and Utility Software such as Device driver,
Antivirus software, Disk defragmenter and Backup Software etc.

www.oliveboard.in
www.oliveboard.in

• Programming Software: Programming software is a program or set of programs which helps the software
developers to develop other software. Programming Software are also known as Programming tool or
Software development tool. Ex: Compilers, Interpreters, Debuggers, Text editors and Linkers etc.
• Application Software: Application Software is a program or group of programs that is designed for end
users for a specific purpose. Some of the types of application software:
Application Suite: An Application suite or Software suite is a group of different but interrelated software
programs that are combined and packaged together. Ex: MS – Office
Software in MS – Office Package: MS – Word, MS – Excel, MS – OneNote, MS – Outlook, MS –
PowerPoint, MS – Access, MS – Publisher and, SharePoint.
i) Horizontal Software: Software that is widely used from individual users to big organizations and also known as
Productivity software. Ex: MS – Office, Web browsers and Financial software etc.
ii) Vertical Software: Software that is designed to keep specific users in mind and targets a smaller number of
users. Ex: ERP (Enterprise Resource Planning) and CRM (Customer Relationship Management) etc.
Software Licensing: Software licensing is legal instrument between the software application author and end user
that governs the use or redistribution of software. It is also known as End User License Agreement (EULA).
Type of Software License:
• Registerware: Requires user’s personal information in order to download or use the program through
registration. Ex: Home edition of Avast.
• Shareware: Computer software that is initially distributed on a free trial basis without payment with limited.
After the trial period the user is obliged to pay fee to continue the use the software. Ex: Antivirus and WinZip
etc. Type of Shareware: Adware, Donationware, Nagware, Freemium, Demoware (Cripple ware and
Trialware).
• Freeware: Freeware is type of software that is distributed with no monetary cost small fee. Ex: Adobe reader
and Skype etc.
• Open Source Software: It is a software that is distributed with its source code that can be modify and share
by the users. Ex: Apache HTTP server, Mozilla Firefox and Blender etc.
• Abandonware: It is a software that is no longer sold or used by its owner and for which no product support
is available from the manufacturer. Ex: Alley Cat and Old versions of photoshop etc.
License Key and Software piracy: Software license key is a data string that verifies and validates the authorization
of software product purchase and Software piracy is the illegal or unauthorized use, copying and distribution of a
software. Various type of software piracy is: Counterfeiting, Internet Piracy, End user Piracy, Client-Server Overuse
and Hard-disk loading.
Computer Architecture referrers to those attributes of a computer system that are visible to the programmer such
as instruction set, instruction opcodes, addressing technique, register and data memory etc and Computer
Organization is concerned with the way operational units (Hardware) operate and their interconnection that forms
the computer system. Computer Architecture tells “What does a computer system do” while the Computer
Organization tells “How to implement”.
Computer System Architecture: Based on the general-purpose processors used, types of computer system are of
two types: Single Processor System and Multiprocessor System.
Multiprocessor systems are also known as Parallel Systems or Tightly Coupled System. There are two types of
multiprocessor system: Symmetric Multiprocessor System: (Two or more identical processors are connected to a
single shared memory) and Asymmetric Multiprocessor System (Not all the processors connected with each other
are treated equally).
Clustered System: Like Multiprocessor system, clustered system is also composed of more than one processor to
accomplish the task, but they are different from parallel systems. They are composed of two or more individual
systems coupled together.
General System Architecture: Parallel processing is a method of breaking a problem in small parts and executing
those parts simultaneously on different processors. Parallel systems are more difficult to program as compared to
single processors system because the architecture of parallel processors is varying, and all the processors must be
synchronised and co-ordinated. General System Architecture is mainly classified into two types:
1) Flynn's classification of computers: Based on number of instruction and data items that can be processed
simultaneously, the organization of computer system is given below:

www.oliveboard.in
www.oliveboard.in

Organization of Definition
computer system

SISD Single processor system capable of executing a single instruction, operating on a


Single-instruction, Single- single data stream. Instructions are executed sequentially.
data

SIMD Multiprocessor system and capable of executing same instruction on all the processors
Single-instruction, but operating on different data streams.
Multiple-data

MISD Multiprocessor system capable of executing different instruction on different processor


Multiple-instruction, but all of them are operating on same data stream.
Single-data

MIMD Multiprocessor system capable of executing different instruction on different processor


Multiple-instruction, and all of them are operating on different data stream.
Multiple-data

2) Store Program Control Concept: Stored program concepts refers to the storage of instruction computer
memory and allow it to perform various tasks in sequence automatically by processor. Classification of Stored
Program concepts:
a) Von-Neumann Model: The computer architecture proposed by Von-Neumann is called Von-Neumann
architecture. Von-Neumann model consists of a control Unit, Arithmetic and Logic Unit, Input/Output devices and
Registers. Von-Neuman computers uses single processor, one memory for both instruction and data and execute
programs following the fetch-decode-execute cycle.
Components of Von-Neuman model: There are mainly following components of this model: Central Processing Unit
(ALU and CU), Memory and Registers, I/O devices, Buses.
Register is a type of storage unit that is used to store data and instruction in execution. Various type of registers
used: AC (Accumulator), PC (Program Counter), CIR (Current Instruction Register), MDR (Memory Data Register),
MAR (Memory Address Register) and IBR (Instruction Buffer Register).
Buses: Data from one part of the computer system to another part is transferred by the means of Buses. Three types
of buses are used: Data Bus, Address Bus and Control Bus.
b) General Purpose System: General purpose system are the architecture of modern-day computer system and it
is the modified version of Von-Neumann architecture.
Components of general-purpose system are Central Processing Unit (CPU) that consists Arithmetic/Logic Unit (ALU),
Control Unit (CU) and various process register. All the components of general-purpose system are connected by the
system busses (Data bus, Address bus and Control bus).
Computer Instruction: A processor performs tasks based on instructions provided and these instructions are a set
of machine language instructions that a processor or computer can understand easily.

A basic computer has 16-bit instruction registers (IR) and an instruction can be divided into three parts:
• First 12-bits specifies the Address filed that stores the address of the memory where the data (operand) is
stored.
• Next 3-bits specifies the Operation code (Opcode) that specifies the operation to be performed.
• Left most bit specifies the Mode field that specifies the addressing mode.
• I = 0 for Direct addressing (Address field stores the address of the operand.)
• I = 1 for Indirect addressing (Address field stores the address where the address of the operand is stored.)
Basic computer has three type of instruction code format:
1) Memory reference instruction: In memory reference instruction, Address filed is denoted by 3 x’s in
hexadecimal notation which is equivalent to 12-bit address. These instructions refer to memory address as operand
and another operand is always accumulator. Some of Memory reference instruction are: AND, ADD, LDA, STA, BUN,
BSA, ISZ
2) Register reference instruction: In register reference instruction, first 12-bit represents the Register operations,
next 3-bits represents the opcode which is equivalent to ‘111’ and Left most bit represents the addressing mode
which is equivalent to ‘0’. Last four bits (from left) instruction is always equal to hexadecimal 7. Some of Register
reference instruction are: CLA, CLE, CMA, CIR, CIL, INC, SPA, SNA, SZA, SE, HLT

www.oliveboard.in
www.oliveboard.in

3) Input-Output instruction: In Input-Output instruction, first 12-bit represents the I/O operations, next 3-bits
represents the opcode which is equivalent to ‘111’ and left most bit represents the addressing mode which is
equivalent to ‘1’. Some of Register reference instruction are: INP, OUT, SKI, SKO, ION, IOF
Instruction Cycle: Instruction cycle also known as fetch-execute cycle. A program in the main memory is a
sequence of instruction and these instructions are executed by CPU by following the given instruction cycle and each
instruction cycle consists of fetch, decode and execute phases.

Digital System: Digital system is a system that operates on discrete levels of input represented in binary form- 0/1
or TRUE/FALSE or ON/OFF.
Boolean Algebra: Boolean algebra is a branch of algebra that deals with binary numbers and has truth values either
TRUE or FALSE represented by ‘1’ or ‘0’ respectively and also known as Switching Algebra.
Boolean Laws: Boolean Algebra uses a set of laws and rules to define the operation of a digital logic circuit. The
basic laws of Boolean Algebra are given below:

Boolean Laws Description

Annulment Law A.0 = 0 and A + 1 = 1

Commutative Law A.B = B.A and A + B = B + A

Identity Law A.1 = A and A + 0 = A

Associative Law A.(B.C) = (A.B).C and A + (B + C) = (A + B) + C

Distributive Law A.(B + C) = (A.B) + (A.C) and A + (B.C) = (A + B).(A + C)

Idempotent Law A.A = A and A + A = A

Complement Law A.A` = 0 and A + A` = 1

Double Negation Law (A`)` = A

Absorption Law A.(A + B) = A and A + AB = A

De Morgan’s Law (A.B)` = A` + B` and (A + B)` = A`.B`

Logic Gates: A logic gate is basic building block of any digital circuit and it mainly has two inputs and one output.
There are three types of logic gate: Basic logic gates (AND, OR and NOT), Universal gate (NAND and NOR) and
Special gates (XOR and XNOR).

www.oliveboard.in
www.oliveboard.in

Gate Representation Operation Truth Table

AND Y = A.B A B Y

0 0 0

1 0 0

0 1 0

1 1 1

OR Y=A+B A B Y

0 0 0

1 0 1

0 1 1

1 1 1

NOT Y = A` A Y

0 1

1 0

NAND Y = (A.B)` = A` + B` A B Y

0 0 1

1 0 1

0 1 1

1 1 0

NOR Y = (A + B)` = A`.B` A B Y

0 0 1

1 0 0

0 1 0

1 1 0

XOR Y = A ⊕ B = A.B` + A`.B A B Y

0 0 0

1 0 1

0 1 1

1 1 0

XNOR Y = A ⊙ B = A.B + A`.B` A B Y

0 0 1

1 0 0

0 1 0

1 1 1

Number System: Number system is the technique of writing or expressing numerals of different types. There are
various categories of numbers:
• Binary numbers: Binary numbers are expressed in base 2 or radix 2 numeral system. Ex: 101102 is a
binary number.
• Octal numbers: Octal numbers are expressed in base 8 or radix 8 numeral system. Ex: 9458 is an octal
number.
• Decimal numbers: Decimal numbers are expressed in base 10 or radix 10 numeral system. Ex: 68310 is a
decimal number.

www.oliveboard.in
www.oliveboard.in

• Hexadecimal numbers: Hexadecimal numbers are expressed in base 16 or radix 16 numeral system. Ex:
3D6A16 is a hexadecimal number.
Number System Conversion: The process of changing the base or radix of numbers is known as number system
conversion:
1. Decimal to any other base system: Conversion process is given below:
• Divide the decimal number by new base value in which the decimal number is to be converted and record the
remainder which will be LSB (least significant bit) of new base number.
• Continue to divide the quotient until the quotient becomes zero.
• Record the remainder of each division process from last to first and remainder of last division process will be
MSB (most significant bit) of new base number.
Ex: Decimal to Binary: Convert 2510 to binary system-

2 25

2 12 1

2 6 0

2 3 0

2 1 1

0 1

2510 = 110012
2. Any other base to decimal system: Conversion process is given below:
• Determine the positional value of each digits according to the base of number system.
• Multiply the positional value by digits at the corresponding position.
• Add the product calculated in previous step.
Ex: Binary to Decimal: Convert 101102 into decimal-
101102 = (1 * 24) + (0 * 23) + (1 * 22) + (1 * 21) + (0 * 20) = 16 + 0 + 4 + 2 + 0 = 2210
3. Binary system to Octal system: Conversion process is given below:
• Divide the binary digits into group of three from LSB (rightmost side).
• Write octal equivalent of each group to find the octal number.
Ex: Convert 11010112 into octal-
11010112 = (1) (101) (011) = (001) (101) (011) = 1538
4. Octal system to Binary system: Conversion process is given below:
• Convert each digit of octal number to three digits binary equivalent.
• Combine all the groups of binary numbers into a single group to find the required binary number.
Ex: Convert 7248 into binary-
7248 = (111) (010) (100) = 1110101002
5. Binary system to Hexadecimal system: Conversion process is given below:
• Divide the binary digits into group of four from LSB (rightmost side).
• Write hexadecimal equivalent of each group to find the hexadecimal number.
Ex: Convert 11011102 into hexadecimal-
11011102 = (110) (1110) = (0110) (1110) = 6E16
6. Hexadecimal system to Binary system: Conversion process is given below:
• Convert each digit of hexadecimal number to four digits binary equivalent.
• Combine all the groups of binary numbers into a single group to find the required binary number.
Ex: Convert B916 into binary-
B916 = (1011) (1001) = 101110012
7. Octal system to Hexadecimal system: Conversion process is given below:
• Convert each digit of octal number to three digits binary equivalent.
• Divide the obtained binary equivalent into the group of four from LSB.
• Write hexadecimal equivalent of each group to find the hexadecimal number.
Ex: Convert 658 into hexadecimal-

www.oliveboard.in
www.oliveboard.in

658 = (110) (101) = 110101 = (11) (0101) = (0011) (0101) = 35 16


8. Hexadecimal system to Octal system: Conversion process is given below:
• Convert each digit of hexadecimal number to four digits binary equivalent.
• Divide the obtained binary equivalent into the group of three from LSB.
• Write octal equivalent of each group to find the octal number.
Ex: Convert EC16 into octal-
EC16 = (1110) (1100) = 111011002 = (11) (101) (100) = (011) (101) (100) = 3548
1. Weighted Binary code: In weighted binary code, ‘weight’ is assigned to each binary bit and value depends on the
position of binary bit. Ex: Binary weighted code for Decimal 1 in 84-2-1 format = 0111 since 1 = 4 – 2 – 1. Hence,
bits for ‘4’, ‘-2’ and ‘-1’ will be on.

Decimal 8421 2421 84-2-1

0 0000 0000 0000

1 0001 0001 0111

2 0010 0010 0110

3 0011 0011 0101

4 0100 0100 0100

5 0101 1011 1011

6 0110 1100 1010

7 0111 1101 1001

8 1000 1110 1000

9 1001 1111 1111

Binary Coded Decimal (BCD) code: BCD is a type of binary representation for decimal value where each digit is
represented by group of four binary bits.

Decimal BCD Decimal BCD

0 0000 8 1000

1 0001 9 1001

2 0010 10 0001 0000

3 0011 11 0001 0001

4 0100 12 0001 0010

5 0101 13 0001 0011

6 0110 14 0001 0100

7 0111 15 0001 0101

2. Non-weighted Binary code: In Non-weighted binary codes, the positional weights are not assigned. Ex: Excess-3
(XS-3) code and Gray code.
Excess-3 Code: Excess- (XS-3) code is unweighted binary code that is obtained after adding (0011)2 to binary of
each digit or 310 to decimal of each digit of a number. Binary form refers to the 8421 BCD of a number.
Excess-3 = (BCD + 0011) or (Decimal + 3)
Gray Code: Gray code is a binary code in which code for each successive pair is differed by one bit only. Hence, it is
also known as Unit distance code or Reflective code.
Process of converting BCD to Gray code:
Let B = b3b2b1b0 is a binary number and G = g3g2g1g0 is Gray code, then-
• g3 = b3
• g2 = b3 ⊕ b2
• g1 = b2 ⊕ b1
• g0 = b1 ⊕ b0

www.oliveboard.in
www.oliveboard.in

Alphanumeric codes: These are binary codes also known as character codes used to represent alphanumeric data
(alphabets, numbers and symbols). Commonly used alphanumeric codes are:
• American Standard code of Information Interchange (ASCII): ASCII code is used worldwide and is 7-
bit long.
• Extended Binary Coded Decimal Interchange Code (EBCDIC): EBCDIC code is primarily used in large
IBM computers and is 8-bit long.
1’s complement: 1’s complement of a numbers is derived after changing all 1’s with 0’s and all 0’s with 1’s.
Ex: 1’s complement of ‘101101’ is ‘010010’.
2’s complement: 2’s complement of a numbers is derived after adding ‘1’ to the LSB of 1’s complement of that
number.
Ex: Calculate the 2’s complement of ‘01010110’.
1’s complement of 01010110 = 10101001
2’s complement of 01010110 = 10101001 + 1 = 10101010
Binary arithmetic operations: Binary arithmetic operations are: Addition, Subtraction, Multiplication and Division.

Binary Operations Rules

Binary Addition A B Carry Sum

0 0 0 0

0 1 0 1

1 0 0 1

1 1 1 0

Binary Subtraction A B Borrow Difference

0 0 0 0

0 1 1 1

1 0 0 1

1 1 0 0

Binary Multiplication A B Multiplication

0 0 0

0 1 0

1 0 0

1 1 1

Binary Division Binary division is similar to the decimal division.

Boolean algebraic functions: A Boolean function is described by an algebraic expression consisting of binary
variables. Boolean functions can be represented in two forms:
• Canonical form: Boolean expression in which each individual term contains every variable either in TRUE
form or Complimented form is known as Canonical form. Ex: F = ABC + AB`C + A`BC`
• Standard form: Standard form is the simplified version of Canonical form. Ex: ABC + BC`
Two standard forms of Boolean function:
Standard Sum of Product (SOP): In the SOP form of Boolean function representation, variables are first operated
by AND (product) gate and then these product terms are operated by OR (sum) gate, hence known as Sum of Product
form. SOP form is also known as Disjunctive Normal Form (DNF) and logical OR operator in Boolean algebra is known
as Disjunctive operator. Example: F = ABC + AB`C + AB + A`B`C`
Min-term: Each individual term in SOP form that contains every variable either in TRUE or Complimented form is
called min-term. Sum of Product form is also called Sum of Min-terms.
Standard Product of Sum (POS): In this form POS form of Boolean function representation, variables are first
operated by OR (sum) gate and then these sum terms are operated by AND (product) gate, hence known as Product
of Sum form. POS form is also known as Conjunctive Normal Form (CNF) and logical AND operator in Boolean algebra
is known as Conjunctive operator. Example: F = (A + B + C).(A + B` + C).(A + B).(A` + B` + C`)

www.oliveboard.in
www.oliveboard.in

Max-term: Each individual term in POS form that contains every variable either in TRUE or Complimented form is
called max-term. Product of Sum form is also called Product of Max-terms.
Convert standard SOP to Canonical SOP:
• F = A + BC`
• F = A.(B + B`).(C + C`) + (A + A`).BC` [A + A` = 1]
• F = (AB + AB`).(C + C`) + ABC` + A`BC`
• F = ABC + ABC` + AB`C + AB`C` + ABC` + A`BC` [A + A = A]
• F = ABC + ABC` + AB`C + AB`C` + A`BC`
Convert standard POS to Canonical POS:
• F = (A + B).(A + C`)
• F = (A + B + C.C`).(A + B.B` + C`) [A.A` = 0]
• F = (A + B + C).(A + B + C`).(A + B + C`).(A + B` + C`)
• F = (A + B + C).(A + B + C`).(A + B` + C`) [A.A = A]
K-Maps: K-map is a table of rows and column with all its entries as 1’s and 0’s in the form of SOP and POS
representation. Total number of cells in a K-map of ‘n’ variable is 2n where each cell represents a value which
corresponds to ‘n’ variable truth table value. If in a K-map,
• mi is the min-term of a Boolean function, then place ‘1’ at ith cell of K-map.
• Mi is the max term of a Boolean function, then place ‘0’ at ith cell of K-map.
• di is the don’t care of a Boolean function, then place either ‘d’ or ‘x’ at i th cell of K-map.
2 variable K-map: K-map for function of two variables is given below:
Cells in two variable K-map = 22 = 4

Similarly, we can maintain k-map for variables more than 2.


Combinational circuit: It is a circuit in which we combine different logic gates in the circuit and output of the circuit
at any instance depends only on the present input given to the circuit irrespective of the previous input.
Block diagram of Combination circuit:

Binary Adder: In digital electronic, adder is a logic circuit that performs addition of binary numbers. There are two
types of adder:
1) Half Adder: Half adder adds two binary input variables called Augend and Addend and produces two binary
output as Sum and Carry.
S = A ⊕ B = A.B` + A`.B and C = A.B
2) Full Adder: Full adder takes three input variables; two input variables represent the two significant bits to be
added and third bit is considered as the previous carry bit. It produces two output variables as Sum and Carry.
S = A`B`P + ABP + AB`P` + A`BP`
C = AB + AP + BP
Binary Subtractor: Binary subtractor is logic circuit used to perform subtraction operation on two binary digits.
Binary subtractor can be designed using same approach as that of a Binary adder. There are two type of Binary
subtractor:
Half Subtractor: It has two inputs; one is Minuend and other is Subtrahend and it produces two outputs; one is
Difference and other is Borrow.
D = A ⊕ B = A.B` + A`.B
Bout = A`.B
Full Subtractor: It is logic circuit used to perform subtraction on three input bits; Minuend, Subtrahend and Borrow
in (Bin). It produces two outputs; Difference and Borrow out (Bout).

www.oliveboard.in
www.oliveboard.in

D = A ⊕ B ⊕ Bin = A`B`Bin + ABBin + AB`Bin` + A`BBin`


Bout = A`B + (A` ⊕ B) Bin = A`B + A`Bin + BBin
Digital Comparator: It is combinational logic circuits that is used to compare two binary numbers and find the
relationship between those two numbers.
1-bit digital comparator: Comparator used to compare two bits is called a single bit comparator.
Truth Table:

A B C (A < B) D (A = B) E (A > B)

0 0 0 1 0

0 1 1 0 0

1 0 0 0 1

1 1 0 1 0

Multiplexer: A multiplexer is logic circuit that selects any one of the inputs given to circuit and passed it as output.
Hence, it is also known as Data selector and selection of input depends on set of Control signals passed to the
circuit which is also known as Select inputs. Multiplexer is also called MUX, Data selector, Parallel to serial convertor
and many to one circuit.
For 2n input lines, there will be ‘n’ select lines and only one output.
Block diagram of 2: 1 MUX:

Demultiplexer: Demultiplexer is a combinational circuit that works opposite operation as that of Multiplexer. It has
one input lines, ‘n’ selection lines and maximum of 2n outputs. Demultiplexer is also known as De-MUX.
Block diagram of 1: 2 De-MUX:

Decoder: Decoder is combinational logic circuit that translate or decode a coded information from one format to
another format. It takes ‘n’ inputs and can produce up to ‘2n’ coded outputs.
Block diagram of a decoder:

Decoder will work only when the value of E = 1 (Circuit is enabled).


2 to 4 Decoder: It is a decoder that takes 2 input and produces 4 output.
Block diagram:

Encoder: Encoders is a combinational logic circuits that performs the reverse operation as that of Decoder. It has
maximum of 2n input and ‘n’ output lines and enable line is optional in the encoders.

www.oliveboard.in
www.oliveboard.in

Block diagram of Encoders:

4 to 2 Encoder: It is a type of encoder that takes 4 input and produces 2 output lines.
Block diagram:

Sequential Logic Circuits: Sequential circuits are nothing but combinational logic circuit with memory. Memory is
used to store the present state (Past Output) of the circuit and output of the circuit depends on the present input and
present state (past output). The present output of the circuit is stored in the memory and works as next state of the
circuit.
Block diagram of Sequential Circuits is given below:

There are two types of sequential circuits:


1) Asynchronous Circuit: Asynchronous sequential circuit runs with different clock pulse that means whatever
sequential are there those elements are not going to use the same clock pulse. Ex: Latches.
2) Synchronous Circuit: Synchronous sequential circuit runs with same clock pulse or similar clock pulse. Ex: Flip-
Flop.
Pipelining: Pipelining is a process where a program is divided into sub-programs (set of data processing elements)
and then executed sequentially (serially).
Microprocessor: Microprocessor is an electronic device that incorporates the function of CPU on a single IC on a
computer system and that computer system is known as Microcomputer. A microprocessor has three components:
Arithmetic and Logic unit, Register Array and Control Unit.
Instruction set: Instruction in a microprocessor is a command intended to tell microprocessor to perform operations
on given data. Instruction set is a collection of such instruction or commands in microprocessor.
Word length: Word length of microprocessor is a maximum number of bits it can accept as input, process or produce
as output. Based on word length, processors are of two types: RISC (Reduced Instruction Set Computer) and CISC
(Complex Instruction Set Computer)
Microprocessor Architecture: 8085 is widely known 8-bit microprocessor, designed by Intel in 1977 by using NMOS
technology.
Configuration of 8085 microprocessor:
• 8-bit data bus and 16-bit address bus.
• 16-bit stack point and 16-bit program counter.
• Six 8-bit registers pairs BC, DE and HL.
• Require +5V direct current supply for its operation.
Architecture of 8085 microprocessor:
1. Arithmetic and Logic Unit (ALU): ALU consists of accumulator, flag register and temporary register. It takes
input from memory and accumulator and then perform arithmetic operations such as addition and subtraction and
logical operation AND, OR on them.
• Accumulator: It is denoted as ‘A’ and it is an 8-bit register used to stored 8-bit data.
• Flag register: Flag register is 8-bit register but only 5-bits are active.
o Sign flag: S = 0 indicates the result is positive and vice versa.
o Zero flag: Z = 1 indicates the result is zero and vice versa.

www.oliveboard.in
www.oliveboard.in

o Auxiliary carry flag: AC = 1 indicates the carry is generated and vice versa and it is used in BCD (0-
9) number system.
o Parity flag: P = 1 indicates result is even parity and vice versa.
o Carry flag: CY = 1 indicates carry or borrow is generated and vice versa.
Interrupt Control: INTR, INTA, RST 5.5, RST 6.5, RST 7.5 and TRAP.
Serial I/O control: (Serial Input Data) and SOD (Serial Output Data).
Timing and Control unit: Generates timing and control signals and controls the flow of the data between
microprocessor and peripherals.
Instruction register and decoder: Part of ALU and is not programmable.

www.oliveboard.in
www.oliveboard.in

Lesson 2: Operating System


What is Operating System: An Operating System (OS) is a collection of software that manages software and
hardware resources and provides services to computer programs and manages the resources (CPU, Main memory,
Secondary storage and I/O devices) of computer. It is a software that acts as an interface between computer
hardware and a user.

Type of Operating System OS: Some of the widely used operating System types are mentioned below:
1. Batch processing operating System: In Batch OS, user doesn’t interact with OS directly. Users submit their
jobs and an operator groups these jobs into batches. Jobs with similar requirements are grouped in the same batch
and then these batches are processed by the processor one by one.

2. Multi-programming operating System: In this OS, more than one process can be processed by the processor
simultaneously. The Scheduler decides which process to run by the processor and this process is known as CPU
scheduling. The process of switching from one job to other job is known as Context Switching.
* The main focus is to maximize the processor (CPU) usage.

3. Multi-tasking operating System: Multi-tasking also known as Time Sharing Operating system is a logical
extension of Multi-programming operating system. It allows users to share the resources simultaneously and in this,
context switching is performed along with time sharing. The main focus is to minimize the response time.

4. Multi-processing operating System: In multi-processing OS, more than one processor (CPUs) can be used
within a single computer system.

www.oliveboard.in
www.oliveboard.in

5. Network operating System: Network OS allows users to share resources available on their computer to other
users and access resources available on other’s computer.
a) Peer – to – peer: In peer – to – peer, all workstations are considered equal and have same privilege to use the
resources available on the network.

b) Client/server: In Client/server operating system, all functions and applications are centralized to single dedicated
system called Server. All other systems (known as Clients) are connected to the dedicated system.

6. Distributed operating System: In Distributed operating system, various independent systems are connected
with each other using a shared communication network but physically separated where they have their own processor
and memory. A system can always access the resources that are not available on their system but on other system in
the network. This type of OS is an advancement of Network operating system and also known as Loosely Coupled
System.

7. Real Time operating System: Real time operating system (RTOS) are used in applications where the result is
guaranteed in specified time constraint. These are very fast and quick in response and used in applications where
large events are to be executed in a short time.
• Hard real time OS: In Hard real time OS, the process should be executed within specified time and it can’t
miss its deadline. Missing the deadline can cause disasters consequences and system will fail. Ex: Anti – lock
brakes, Flight control system.
• Soft real time OS: In Soft real time OS, it is not mandatory that an execution must be finished in the
specified time every time. Ex: Digital camera, telephone switches.
Components of OS: All the user software programs can’t directly access the computer hardware; they need to go
through OS to access the hardware. Various components of operating system are:
1. Kernel: Kernel is a central component in the computer’s OS. It is a computer program that has complete control
over everything of computer system. It is the first program after boot loader that loaded, and its critical code is

www.oliveboard.in
www.oliveboard.in

loaded in the protected area of the memory called Kernel Space while other application programs are loaded in
separate area of memory called User space.
Kernel is a low-level abstraction layer of OS, user uses System calls to interact with the system, system call invokes
the kernel and then kernel perform the user’s operation.

Based on their design and functions, Kernel is divided mainly into three parts:
• Monolithic Kernel: A monolithic kernel performs all the OS instructions in the same address space and
hence increases the speed.
• Micro Kernel: A microkernel runs mostly all the processes in User space and hence increases the Modularity.
• Hybrid Kernel: A hybrid kernel is an extension of Micro kernel with some added functionality of Monolithic
kernel.
2. Interrupts: An interrupt is an input signal that indicates an event and need the immediate attention of the
processor. When an interrupt occurs and request is accepted, the processor halt the current execution immediately
and executes a function called Interrupt handler. After the interrupt handler finishes its activities, the processor
resumes its normal activities.
There are mainly two type of Interrupts in operating system:
• Software interrupts: Caused by software itself which is usually a program code in the user space. Software
interrupts are typically called Traps or Exceptions.
• Hardware interrupts: An electronic signal created and sent to the processor by performing some actions by
the hardware components are known as Hardware interrupts.
3. Program Execution: OS provides an interface between application software and hardware components. Program
execution is the process by which a computer executes the instructions of a computer program.
4. Memory management: It is the process of controlling and handling the primary memory. It is the process of
partitioning the memory into small blocks and assign these blocks to a running process to optimize the overall system
performance.
All the programs must be loaded into the main memory (RAM) for its execution. Sometimes the whole program is
loaded into the RAM while sometimes a part of the program is loaded when called by the program and this process is
known as Dynamic Loading.
Sometimes a running program need another program that is not present in the main memory. So instead, of loading
all the related programs in the main memory, processor links the related programs to the executing program in the
main memory, this process is known as Dynamic Linking.
5. Disk access and file management: The systematic way in which the data is stored in available storage space is
called File system. File system is the process in which the files are named properly and stored logically in the disk for
easy storage and fast retrieval.
6. Device drivers: Hardware devices need a program to communicate with the OS of the computer system. A
computer program with which the hardware devices such as printer can communicate with the kernel of computer
system are known as Driver or Device driver.

www.oliveboard.in
www.oliveboard.in

The device drivers can be broadly categorized into three groups:


• Character driver: Deals with the character devices that communicate by sending and receiving
single characters.
• Block driver: Deals with the devices in that communicates by sending and receiving entire block of data.
• Network driver: The network driver allows us to connect to an external network by sending and receiving
data packets.
7. User interface: A user interface is that part of operating system by which a user interacts with the computer
system and provides platform for Human – computer interaction. There are different types of user interfaces:
• Command line interface (CLI) or Character user interface (CUI): It is the oldest user interface, which is
a text-based user interface which involves the commands types by the user and respond of computer based
on those commands. Ex: Disk operating system (DOS).
• Graphical user interface (GUI): GUI is the most attractive way of interaction between user and computer.
It deals with the graphical images, icons and it allows users to interact with the machine by those images,
icons and visual indicators. Ex: Windows and Android.
• Menu driven interface (MDI): A menu driven interface is the simplest and easiest way to communicate
with the computer system. It deals with the series of screens (menus) where user has to choose one option
what to do next out of available options in the menu. Ex: Cash machines (ATM), ticket booking machine and
information kiosk.
Functions of Operating System: Following are some functions of operating system:
1. Booting: Booting is the start-up sequence of operating system and boot process loads the operating system
into main memory of the computer system.
2. Loading and execution of program: A program resides in the secondary memory must be loaded in the
main memory of computer for execution.
3. Security: Security refers to integrity, confidentiality and availability of data which of provided by Operating
system.
4. Control over system performance: Operating system has complete control over computer system so as to
improve the performance of the system.
5. Job accounting: The operating system keeps track of time and resources used by a process and maintain
this information in a log record.
6. Acts as an interface between software and user: It coordinate between software and user and assigns
software such as assembler, interpreter, compiler and other software whenever user need them.
Some other major important functions of Operating System:
• Process management
• Memory management
• File management
• I/O device management
Program: A computer program is lines of codes or collection of instructions that performs a specific task when
executed. A process is a program in execution, any program written by programmer reside in the hard disk or
secondary storage of a computer. A processor can execute programs in the main memory, so a program must bring
into main memory from secondary storage.
A process in main memory can be divided into four sections:
• Stack: A process stack contains temporary data such as functions/methods parameters, return
value/address, local variables etc.
• Heap: Heap is an area of main memory that is assigned dynamically at the runtime of process to store
temporary variables and data.

www.oliveboard.in
www.oliveboard.in

• Data: Data section of a process contains global and static variables.


• Text: Text section of a process includes the current activity represented by the value of Program counter and
it also includes the content of Processor’s register.
Process Control Block (PCB): In a multiprogramming OS, track of all the processes must be kept and PCB is a data
structure maintained by OS of each process which contains all the attributed or characteristics of a process.
• Process Id
• Process State
• Program Counter
• Priority
• Registers
• List of Open devices
• List of Open files
Process Life cycle: A process in execution from its completion passes through different states in its life cycle:

Process Scheduling: Process scheduling is the act of process manager that determine the removal of a running
process and inclusion of a new process into the main memory. A single processor can execute one process at a time
and remaining process must wait until the CPU gets free. But in multiprogramming system, more than one processes
can be executed simultaneously and hence to increase CPU utilization, there is a need of Process scheduling.
Type of Scheduling: The main perspective of the process scheduling is to keep the processor (CPU) busy all the
time. There are two types of process scheduling:
• Non-Pre-emptive Scheduling: A process which is assigned CPU will complete its execution and another
process in the ready queue will wait for its turn for its execution.
• Pre-emptive Scheduling: Processor is assigned to a process for a limited time and then it is moved back to
the ready queue and process is assigned to some other process for limited time.
Queues used in Process scheduling: There are three type of queues used in process scheduling:
a) Job queue: All the processes enter into the system are kept in this queue.
b) Ready queue: All the processes that are in the ready state and waiting for processor for its execution are
kept in this queue.
c) Device queue: The processes in the block/wait state waiting for I/O device are kept in this queue.
Process types: Based on the CPU utilization and I/O device utilization, processes can be divided into two types:
a) CPU bound process: Processes whose CPU utilization is more then I/O device utilization.
b) I/O bound process: Processes whose CPU utilization is less then I/O device utilization. These types of
processes mainly reside in the block/wait state.
Process schedulers: The process schedulers are programs that schedules processes from one state to another state.
There are three types of process schedulers used in process scheduling:
a) Long term (Job) scheduler: Job scheduler brings the newly created processes to the Ready state.
b) Short term (CPU) scheduler: CPU scheduler selects one process from the ready queue and allocates CPU to
them for execution. Short term scheduler is also known as Dispatcher.
Context Switching: Process of storing the state of a process so that at a later time the process can be resumed from
the same point which is done by Dispatcher.
c) Medium term scheduler (Swapper): Medium term scheduler removes the processes from main memory to
secondary storage and vice versa and this process is known as Process Swapping, It is also known as
Swapper.
Scheduling Criteria: The Scheduling criteria for process scheduling is mentioned below:
• CPU utilization: CPU utilization must be kept as high and it ranges from 0% to 100% and CPU must be kept
busy all the time.

www.oliveboard.in
www.oliveboard.in

• Throughput: Number of processes that completes its execution per unit time.
• Turnaround time: Time taken by process to complete its execution from its submission.
• Waiting time: Time taken by a process in the ready queue from its creation waiting for allocation of process.
• Response time: Time taken by processor to response for the first time from the time when the request for
the processor is made by the processor.
• Load average: Average number of processes waiting in the ready queue for their turn.
Scheduling Algorithms: There are various process scheduling algorithm based on two factors: Non pre-emptive CPU
scheduling and Pre-emptive scheduling.
1. First come first serve (FCFS) CPU scheduling: In FCFS scheduling algorithm, the process which arrives first,
get executed first. First come first serve follows FIFO queue data structure.
Note: Performance of scheduling algorithm depends on Average time, Lower the Average Waiting Time, better the
scheduling algorithm.
2. Shortest Job First (SJF) scheduling algorithm: In FCFS scheduling algorithm, CPU is allocated to the processes
according to their Arrival time but in Shortest Job First (SJF) scheduling algorithm, CPU is allocated to the processes
according to their CPU burst time. Process with lowest CPU burst time will get the CPU first.
3. Shortest remaining time first (SRTF) scheduling: Shortest remaining time (SRT) is the pre-emptive version of
SJF scheduling. The process with least remaining CPU burst time is executed first by the processor. At the arrival of
each process, remaining CPU burst time of all the ready process is compared and processor is allocated to the process
with least remaining CPU burst time.
4(a). Priority based Scheduling (Non-pre-emptive): In Priority scheduling, each process is given a priority and
CPU is assigned to a process according to their priority. Process with high priority will get the processor first and so
on. Priority of a process can be decided on the basis of memory requirement, time requirement or remaining CPU
burst time. Processes with the same priority are executed on first come first serve basis.
4(b). Priority based Scheduling (Pre-emptive): In Pre-emptive priority scheduling, at the time of arrival of new
process, priority of the running process is compared with the newly arrived process and priority of other waiting
process in the ready queue. If the running process has highest priority, then it continues its execution otherwise it is
taken out from the processor and other process with high priority gets the processor for execution.
5. Round Robin (RR) Scheduling: Round Robin scheduling is the pre-emptive version of first come first serve
scheduling. Each process is provided a fix amount of time called time quantum for its execution. If a process finishes
its execution in that time quantum, then the process terminates otherwise the process go back to the ready queue
and wait for its next turn to complete its execution.
6. Highest Response Ratio Next (HRRN) scheduling: In this scheduling algorithm, processor is allocated to a
process on the basis of Response Ratio of that process. A process with higher response ratio will get the processor
first.
Response ratio = (Waiting time + CPU burst time)/CPU burst time
Thread: A thread is a path of execution within a process, it contains its own program counter, stack and set of
registers. A thread is also known as lightweight process, a process can be divided into multiple threads to increase
parallelism. The CPU switches rapidly between the threads of a process and gives us an illusion that the threads are
running in parallel.
Type of threads: There are two type of threads:
• User Level Thread: User level threads are managed by user level library (applications) and its
implementation is easy. If user level thread performs blocking operation, then the entire process will be
blocked.
• Kernel Level Thread: Kernel level threads are managed by integral part of operating system (kernel) and its
implementation is not easy. If kernel level thread performs blocking operation, then another thread can
continue its execution.
Multithreading model: When multiple parts (threads) of a process are allowed to execute simultaneously, this is
known as Multithreading model. There are three types of Multithreading models:
• One to one: In one to one model, each user level thread is mapped with a kernel level thread.
• Many to one: In many to one model, many user level threads are mapped with a kernel level thread.
• Many to many: In many to many, many user level threads are mapped with equal or lesser number of
threads.
* Many to many doesn’t have the disadvantages of one to one and many to one multithreading models.
Memory Management: CPU can process that are in the main memory while a program mainly resides in the
secondary storage. For its execution it must be brought into the main memory hence, Memory Management is the

www.oliveboard.in
www.oliveboard.in

technique by which the OS manages the main memory of the system. Once the execution of process is completed by
the CPU, the process is moved back to the secondary storage by OS
Logical and Physical addresses in operating system: Logical address is generated by the CPU while the Physical
address represents a physical location in the memory.
Address Binding: Process of mapping logical address to corresponding physical address and address binding is done
by three ways:
• Compile Time: Process of translation of logical address to physical address at the time of process
compilation. If we know at compile time where the process will reside in main memory, then absolute code
is generated, and address is translated at the compile time.
• Load Time: If it is not known where the process will reside in main memory, then binding is delayed till load
time and compiler generates relocatable code and address is translated at the load time.
• Execute/Run Time: In multi-programming systems, there is need to shift physical address from one location
to another location, then binding is delayed till run time or execute time.
Compile time and Load time address binding generates similar logical and physical address while Execute time
address binding generates different logical and physical address. Set of all logical addresses and all physical
addresses is called Logical Address Space and Physical Address Space respectively.
Loading and Linking: Carrying the executable program from secondary storage into main memory for execution is
called Loading while Linking is the process of binding all the different modules of a process to a single executable
module.
Swapping: Process of swapping out processes from the main memory and moved to the secondary storage and later
the process is swapped back to the main memory from the secondary storage. Swapping is useful to run multiple
program on a single processor simultaneously and is also called as the Technique for Memory Compaction.
Swap time is mainly the transfer time of processes between main memory and secondary storage and transfer time is
directly proportional to the amount of memory swapped.
Contiguous Memory Allocation: In contiguous memory allocation, all the available memory space is not scattered
and is available at one place and each process is contained in a single contiguous section of memory. Contiguous
memory allocation is of two type:
1. Fixed/Static size partition: Simplest form of memory allocation, where memory block is divided into several
fixed size partitions of same or different size and one partition can contain one process at a time. When the partition
is available, a process from ready queue is loaded into that partition and once the execution is finished, the process is
moved back to the secondary storage and partition becomes available for another process. The processes that are
coming from ready queue must be of size equal to or less than the size of partition because spanning is not allowed
in contiguous memory allocation.
Spanning: A part of process is allocated to one part and remaining part is allocated to some other partition.
Limitation of Fixed size partitioning:
• If size of a processes is less than the allocated block size of memory which leads to wastage of memory and
known as Internal Fragmentation.
• Total size of scattered memory block is more than the new arriving process, but the memory can’t be
allocated since spanning is not allowed which leads to External Fragmentation.
• Fixed Degree of multiprogramming.
• Limitation on Size of a process.
Whenever there is internal fragmentation, external fragmentation will be always there.
2. Variable/Dynamic size partition: In this, partition is not made before the execution. Whenever the processes
are coming, then the space is allocated to the processes. Partitions are made during the run time and according the
size of process.
Advantage/Disadvantage of Fixed size partitioning:
• No Internal Fragmentation.
• No limitation on Degree of Multiprogramming.
• No limit on size of process.
• External Fragmentation.
Algorithms used in memory allocation: There are basically four algorithms of memory allocation: First fit, Nest fit,
Best fit and Worst fit.
Non-Contiguous Memory Allocation: Free memory space is not available at one place and it is scattered in the
main memory and spanning is allowed in non-contiguous memory allocation. Internal and external fragmentation is
not occurred in non-contiguous memory allocation. Non-contiguous memory allocation is also known as Virtual

www.oliveboard.in
www.oliveboard.in

Memory allocation as it gives an illusion to the user that his whole program is loaded into the main memory which is
not true.
Non-contiguous never means not contiguous. If contiguous memory blocks are available, then memory will be
allocated contiguously.
Classification of non-contiguous memory allocation:
Paging: Paging is a fixed size partitioning scheme and in which a process is divided into sub-processes known as
Pages before it is loaded into the main memory and memory is also divided into partitions of same size known as
Frames. Size of each frame must be equal to the size of each page and now, each frame is allocated to each page of
the process to avoid the external fragmentation and maintain the optimum use of the memory.
Logical address is mapped with physical address by Memory Management Unit (MMU) that uses Page Table for
this purpose. Each process has its own page table that contains the frame numbers which tells where a particular
page is present in the main memory.
Advantage/Disadvantage of Paging:
• It suffers from internal fragmentation because it has frames of fixes size.
• It reduces external fragmentation.
• Swapping is easy due to equal size of pages and frames.
Demand paging: In paging, only few pages are stored in the main memory while remaining are in the secondary
storage and gives an illusion that main memory is big enough to store the complete program, this is called Virtual
memory. Demand paging or Virtual Memory Management is a concept that decides which pages need to be kept
in the main memory and which need to be kept in the secondary storage.
Page Fault: If the referred page is not present in the main memory, the Page Fault or Page Miss occurs, and that
missing page is swapped from secondary storage to main memory.
Thrashing: When page fault is very high, CPU remains busy in swapping pages and effective access time will be
equal to the time taken to swap pages which is called Thrashing.
Page Replacement Algorithm: Technique which decide which page need to be swapped out when a new page is
loaded into main memory. If a referenced page is not found in the main memory, page fault occurs and that
referenced page from the secondary storage is loaded into main memory that replaces one existing page in the main
memory.
• First In First Out (FIFO): Operating system keeps track of all the pages in the main memory in a queue.
Oldest page in the main memory is always selected for replacement.
• Optimal Page Replacement: In this algorithm, pages that would not be used for longest period of time are
replaced.
• Least Recent Used (LRU): In this algorithm, the pages which in the main memory which are not used from
the long period of time are selected for replacement.
Belady’s Anomaly: In all page replacement algorithm, number of page faults decreased when number of frames are
increased while in case of FIFO page replacement algorithm, number of page faults increases when number of frames
are increases and this strange behaviour is shown by FIFO algorithm in some cases which is called Belady’s
Anomaly.
Segmentation: Memory management technique in which a process is divided into variable size part and each part is
known as Segment. Each segment has its own segment table that contains two information: Base address and Size
of segment.
In segmentation, each segment contains one complete module and when that module is loaded into main memory
there is no need to load another segment and thus reduces page fault.
Advantage/Disadvantage of Segmentation:
• No internal fragmentation.
• Less page faults.
I/O Management: The role of OS in a computer’s I/O management is to manage I/O operations and I/O devices. In
computer system, I/O devices are responsible for accepting inputs from users and presenting output to the user
based on the mentioned operations performed on the input. I/O devices can be divided into two types:
• Block oriented devices: Block devices performed the communication by sending entire block of data
(chunk). Ex: All the disks should be considered as the block-oriented device.
• Character oriented devices: Character devices performed the communication by transmitting single byte of
data. Ex: Mouse, Printer and Keyboard.
I/O Hardware: I/O hardware devices can be categorized into:
• Storage devices (tapes and disks)

www.oliveboard.in
www.oliveboard.in

• Transmission devices (modems and network cards)


• Human-interface devices (monitor, keyboard and mouse)
I/O hardware devices are connected with each other using PCI bus. An I/O port typically consist of four registers:
• Data-in register: Read by the host to get input from the devices.
• Data-out register: Written by the host to send output.
• Status register: It contains bits that is read by host and these bits indicates the states such as: ready, bust,
idle, transaction complete and error etc.
• Control register: It contains bits that is written by the host to start command or to change the mode of the
device.
The process of detecting the arrival of input can be done by two ways: Polling and Interrupts.
Pooling: Process in which the processors periodically checks for the status of devices to determine whether any I/O
operation is requested or not. Processor uses busy bit in status register to indicate whether it is available to
execute I/O operation or not. Busy bit 1 indicates processor is performing some other function and bust bit 0 indicates
processor is ready to execute I/O operation.
Host devices uses command-ready bit in the command register to indicates whether the host is ready with it I/O
data or not.
Interrupts: Interrupts are another method by which I/O request of the devices can be handled by the micro-
controller (processor). The processor uses interrupts-request line to detect the request generated by I/O devices.
When processor senses any interrupt request on the interrupts-request line, it performs save state to the current
execution and jumps to the interrupt-handler routine. Performs the desired I/O operations and after servicing the
interrupt, return to the execution state prior to the interrupt.
Polling and Interrupts are useful when relatively small amount of data needs to be transferred between CPU, main
memory and I/O devices.
I/O Software: I/O software are classified into three layers:
• User level libraries: This provides an interface to the user program so that input and output operations can
be performed.
• Kernel level modules: It contains device independent operating system software, Device drivers and
Interrupt handlers.
• Hardware: At this layer, hardware and hardware controller exists which interact with the device driver and
makes software alive.
Kernel I/O Subsystem: The kernel is a core of OS and provides many services to other part of OS and the kernel
I/O subsystem is responsible for many services related to I/O as give below:
• I/O scheduling: Kernel receives various I/O request and arrange them in good order to increase the overall
system efficiency. This I/O scheduling is also known as Disk Scheduling.
• I/O protection: Kernel I/O subsystem provided I/O protection from illegal I/O instructions and ensures that
I/O must perform only on system calls.
• Buffering: Kernel I/O subsystem maintains a memory called buffer in between storage devices and data is
stored in buffer while transferring between devices.
• Caching: Caching is a process of holding the copy of a data for faster access and for this a cache memory is
placed that stores the frequently used data.
• Error Handling: An operating system can provide error handling for various failures such as disk read/write,
buffer overload, device unavailable and Device and I/O transfer.
• Spooling: Spool is a buffer that holds the output of a process for devices that can’t accept interleaved data
and spooling process copies the entire queued spool once at a time to that device.
Disk Scheduling: It is also known as I/O scheduling and is one of the important functions of operating system. In
I/O scheduling OS schedule the I/O request for the disks.
Important terms in Disk scheduling:
• Seek Time: Seek time is the time taken to look for the disk arm to a specified track where the data needs to
be accessed (read or write).
• Rotational Latency: Rotational latency is the time taken by desired sector of the disk to rotate itself to the
position where it can access the read/write head.
• Transfer Time: Transfer time is the time taken to transfer the data and it depends on the number of bytes to
be transferred.
• Disk Access Time: Disk access time is the sum of Seek time, Rotational Latency and Transfer time and is
give as:

www.oliveboard.in
www.oliveboard.in

Disk Access Time = Seek Time + Rotational Latency + Transfer Time


• Disk Response Time: Disk response time is the average of time spent by each request waiting for I/O
operation. Mean response time is the response time of all the requests and Variance response time is the
measure of how each request is serviced with respect to mean response time.
Disk Scheduling Algorithms: There are various disk algorithms given below:
• First Come First Serve (FCFS) scheduling: It is simplest scheduling algorithm and follow the FIFO policy,
I/O requests are serviced in the order in which they arrive. As every request in the waiting queue is serviced
so there is no starvation and every request are honoured.
• Shortest Seek Time First (SSTF) algorithm: SSTF is improved version of FCFS scheduling. In this, the
seek time of each request is calculate before scheduling and then the requests are scheduled according to
their seek time, request which requires least disk arm movement from its current position regardless of
direction is scheduled first and so on and hence reduces the total seek time.
File Management: File is a collection of logically related information that is stored in the secondary storage. File
management is the process of manipulating (creating, modifying and deleting) the files in the computer system. Files
in the computer system of different types:
1. Ordinary File: Most common files used to store either text or binary data. Ordinary files are also known as
Regular files or Simple files.
• Text files: Files that contains information in ASCII format and that can be read by the user.
• Binary files: Files that contains data or information in binary format and are readable by the computer
system.
2. Directory File: Directory files are the files that contains information about files or folders in the system but
doesn’t contain the actual file data.
3. Device File: Device files are also known as Special files and these are the files which represents the physical
devices such as disks and printers. Devices files are of two types:
• Character special files: These are the device files which read or write data character by character. Ex:
Mouse and Printer.
• Block special files: In these type of special files, data is handled in blocks. Ex: Disks and Tapes
Attributed of file: A file has following attributes:
• Name
• Type
• Location
• Identifier: Identifier is also known as extension of file such ‘.txt’, ‘.jpeg’, ‘.exe’ and ‘.mp3’ etc.
• Size
• Protection
• Time and Date
File Structure: A file has various kind of structure as given below:
• No define Structure: It contains sequence of bytes and words.
• Simple record Structure: It contains lines of fixed and variable length records.
• Complex Structure: It contains formatted document and relocatable load files.
File Allocation Methods: OS allocates disk spaces to the file and there are various methods which are used to
allocate disk space to any file which are given below:
• Contiguous Allocation: In this allocation method, block of memory is allocated to the file in such a way that
all the logical blocks of the file get the contiguous physical block of the memory.
• Linked Allocation: In linked allocation, each file carries a list of links to disk blocks and the disk blocks
allocated to a particular file need not be contiguous in the memory. The directory contains a pointer to the
first block of the file which points to the next disk block allocated to the same file.
• Indexed Allocation: There is a problem with linked allocation that random access is not allowed in it since,
each block can be found from the previous block. An index block is created that contains all the disk pointers
to file. Index block holds the pointers to all the disk block allocated to that particular file.
Operating System Virtualization: Virtualization in operating system allows to run different type of applications on a
single computer system by many users and operating system may appear different to each user.

www.oliveboard.in
www.oliveboard.in

Operating System Security: Security management is a function to make computer system secure and protect
internally as well as externally. Security refers to provide protection to computer resources such as CPU, memory,
software and hardware program and most importantly the data stored in the system against unauthorised access and
malicious programs.
1. Authentication: Authentication means the person using the computer system is genuine and allowed to use that
computer system. This can be done in different ways: Username/Password, One Time Password (OTP) and Biometric
data.
2. Access Control: Access control decides who or what can access (view or use) the resources of computer system.
3. Program and Software Threats: When user program designed to perform malicious task, it is called program
threat. While system threat referred to misuse of system services that leads to loss or modification of data or physical
damage to any hardware device.
a) Type of Program threats:
• Virus: Virus is any program inserted in user’s computer without his/her knowledge and performs malicious
functions when executed. It can replicate itself and can modify other computer programs.
• Trojan Horse: Malware that presents itself as a legitimate program and tricks user to enter his/her
confidential details which later can be used for malicious activities.
• Logic Bomb: Logic bomb is a piece of code that is inserted into user’s computer system and execute itself
when certain condition is met which often lead to harmful effects.
• Trap Door: Trap door is also known as Back Door which provides a secret and unauthorised access to
unauthorised user without the knowledge of authorised user.
b) Type of Software threats:
• Denial of Service (DoS): In DoS attack attacker makes the resources unavailable to its legitimate user.
• Port Scanning: Port is a place (door) where information goes in and comes out from computer system and
port scanning is a process to scan all the ports to check for open doors to break into the computer system.
• Worm: Worm is a standalone malware computer program that replicate itself and uses computer network to
spread itself to other computers connected to that network.
Type of Security breaches:
• Breach of Availability: Unauthorised access of data and resources and its destruction.
• Breach of Confidentiality: Theft of private or confidential information/data.
• Breach of Integrity: Unauthorised modification of private or confidential data.
• Denial of Service: Prevents the legitimate use of the information to the authorised user.
• Theft of Service: Unauthorised use of the information by an unauthorised user.
Process Synchronisation: Process Synchronisation is a way in which concurrent access to resources by the
processes are handled and shared data consistency is maintained. Data inconsistency can result to Race Condition.
Race condition: Two or more processes try to access the same resource without any proper sequence.
Critical Section: A critical section is a code segment that can be accessed by only one process at a certain instance
of time.
Critical Section Problem: It contains the shared resources that is to be accessed by the other processes as well and
execution of shared variables need to be synchronised so that only process at a time can enter into the critical section
and other processes are allowed to enter the critical section only after when previous process releases the shared
resources.

www.oliveboard.in
www.oliveboard.in

Solution to Critical Section Problem: Any solution to critical section problem must follow the following three
conditions:
• Mutual Exclusion: From a group of processes only one process at a time can enter into critical section and
no other process is allowed to execute in the critical section.
• Progress: If no process is executing in the critical section, then only those waiting processes that are not
executing their remainder section can participate in the selection of process that can execute its critical
section and selection can’t be postponed indefinitely.
• Bounded Waiting: Bounded waiting means no process should wait for the allocation of resource for indefinite
amount of time. There must be bound on the number of time the process can enter into critical section.
Semaphores: A semaphore S is an integer variable that can be accessed through only two operations wait() and
signal(). The wait() operation is termed as P(S) and signal operation is termed as V(S).
Definition of wait() and signal() variables is as follows:

Bounded Buffer Problem: It is also known Producer-Consumer problem in which there are two processes:
Producer and Consumer and both share a common fixed size buffer. Producer tries to put data into empty slot of
buffer and consumer tries to remove data from filled slot of buffer. The problem is Producer may try to put data into
buffer when it is full, and Consumer may try to remove data from buffer when it is empty.
Solution: The solution to this problem is: The producer either sleep or discard the data when the buffer is full and
Consumer sleep when it finds buffer empty. Once the producer puts the data in the buffer, he wakes up the sleeping
consumer similarly, once the consumer removes the data from buffer, he wakes up sleeping producer, Hence, this
problem is also known as Sleep and Wake Problem.
Dining Philosopher Problem: Consider there are five philosopher sitting around a circular table with bowls of
spaghetti and five forks are placed between each pair of adjacent philosopher. At any instant, a philosopher can either
eat or think and when a philosopher wants to eat, he uses two forks: one from his left and one from his right and
when a philosopher thinks he puts down both the forks.
• When a philosopher wants to eat, he will wait for fork at his left and picks up when available.
• He waits for fork at his right and picks up when available.
• Start eating.
• Puts down left fork when finishes eating.
• Puts down right fork also and start thinking.
In this case, there is a situation when all the philosopher picks up fork from his left and no one can eat as fork to their
right is not available. This situation is called Deadlock and leads to Starvation.
Solution: Since, all the philosophers are picking his left fork. In this solution, make one philosopher to pick right fork
first.
• P1 picks fork from his left which is F1 and when he tries to pick his right fork which is F2 it is already picked by
P2 as it is his left fork. So, P1 has to wait.
• When P2 tries to pick his right fork, which is F3 it is already picked by P3 as it is his left fork. So, P2 has to wait.
• When P3 tries to pick his right fork, which is F4 it is already picked by P4 as it is his left fork. So, P3 has to wait.

www.oliveboard.in
www.oliveboard.in

• Now, P4 has his left fork F4 and P5 is made pick his right fork first which is not available so, P5 has to wait and
P4 easily get fork F5 also.
• Now, P4 will finish his eating and free his both forks after P3, P2 and P1 will finish his eating in the same order.
Finally, P5 can also finish his eating.
Reader’s Writer’s Problem: There are two type of processes one is called Reader process and other is called Writer
process and all the processes try to access the shared resources.
There are total four cases:
• Case 1: When is reader is reading the resource, a writer can’t write or modify that resource at that time.
• Case 2: When a writer is writing or modifying the resource no reader can read the resource.
• Case 3: When a writer is writing or modifying the resource no other writer can modify or write the resource.
• Case 4: Any number of reader can read the resource simultaneously and this case doesn’t create any
problem.
Deadlock: Every process needs some resources to complete its execution in the following way: request a Resource,
use the Resource and release the Resource
Deadlock is a situation in which a process holds a resource and waits for another resource that is blocked by another
process and that process is also waiting for another resource that is blocked by some another process and all the
process are blocked which is known as Deadlock.
Necessary condition for Deadlock:
• Mutual Exclusion: Resources are non-sharable.
• Hold and Wait: A process is waiting for another resource while holding a resource.
• No Pre-emption: Process once scheduled will be executed till its completion.
• Circular Wait: All the processes are waiting for some resources in a circular manner.
Methods for handling deadlock: There are for methods for handling deadlock:
1. Deadlock Ignorance: If deadlock is very rare and it happens only 1 out of 100 times, then to use deadlock
handling mechanism is of no use and completely unnecessary and performance of system also decreases if deadlock
handling mechanism is used all the times.
2. Deadlock Prevention: Deadlock occurs only when one of the four necessary conditions hold simultaneously and if
by any means we can violate any one condition, then deadlock will never occur.
• Mutual Exclusion: It can be avoided if resources are shared among processes but some resources like
printers and tape drivers are non-sharable. So, mutual exclusion can’t be avoided completely.
• Hold and Wait: Try to give the all the required resources to process before the start of execution. But this
will lead to low device utilization as the resource which is required for less time is blocked till the
completion of execution.
• No Pre-emption: No pre-emption can be avoided by using time quantum or priority.
• Circular Wait: All the resources are given some priority number and a process can use those resources in
either increasing or decreasing order of priority.
3. Deadlock Avoidance: Deadlock avoidance is a mechanism in which deadlock is avoided by allocating resources to
a process only when it doesn’t lead to deadlock. Each process must declare the maximum number of resources it
needs. A state where no deadlock occurs is called Safe State, conversely a deadlock state is known as Unsafe
State.
Banker’s Algorithm to avoid deadlock: Banker’s algorithm is a resource allocation and deadlock avoidance
algorithm. Inputs to this algorithm are maximum number of resources needed by a processor, maximum freely
available resources and currently blocked resources by each process. Request for resources by any process is granted
only when the requested resources are less than both maximum freely available resources and maximum needed
resources by that process.
4. Deadlock Detection and Recovery: For deadlock detection and recovery, Resource Allocation Graph (RAG) is
used. So, we must learn about RAG first.
Resource Allocation Graph (RAG): It is a pictorial representation in which processes are represented using circle
and resources are represented using a rectangle.
Resources allocation to a process is shown by an arrow in which head of arrow is attached to process and tail of the
arrow is attached to resource. Resource request is shown by an arrow in which tail of arrow is attached to process and
head of the arrow is attached to resource.
When all the resources have single instance of resources and any cycle is formed in RAG, then the system is in
deadlock state. When all the resources have more than one instances of resources, then cycle in RAG is not sufficient
condition to detect deadlock in the system.

www.oliveboard.in
www.oliveboard.in

The OS detects the deadlock in the system by using RAG and perform the recovery operation by considering either
processes or resources:
• By process killing: By killing a single process or all the processes that causes deadlock. While killing a single
process, OS chooses that process to kill which has done least amount of work.
• Pre-empt the resource and rollback to a safe state: Resources are pre-empted from a deadlock causing
process and allocated to other process. OS keeps track of every state and in case of deadlock, OS can roll
back the system to a previous safe state.
• Starvation and Aging: Starvation occurs when a process doesn’t get the required resources for a long time.
Aging is technique to avoid starvation in the system by using aging factor called priority. It increases the
priority of a process depending on the waiting time. As the waiting time of a process increases, aging factor
(priority) of that process will be also increases.

www.oliveboard.in
www.oliveboard.in

Lesson 3: Database Management System


Database Management System: Database is collection of data/items/fields which contains information and DBMS is
a set of interrelated data and a group of programs (or set of rules) to access those data. DBMS helps efficient
retrieval, insertion, manipulation and deletion of data from database.
Database System Application: Databases are widely used. Here are some representative applications: Finance,
Universities, Airlines, Human resources, Banking, Manufacturing and Sales.
File-processing system: Stores permanent records in various files, and it needs different application programs to
extract records from, and add records to, the appropriate files.
Application Architectures: Users of a database system do not use the database directly but connect to the
database through a network. Users work on client machine and database system runs on server machine. Application
architecture is of two types:
1. Two-tier architecture: It is similar to a basic client-server model. In this, the application is divided into a module
that resides at the client machine, which communicate directly to the database system at the server machine through
query language commands.
2. Three-tier architecture: In this architecture, the client machine does not communicate with database system
directly. Instead, the client end send request to an application server, through a network which in turn communicates
with a database system to access data. This type of model prevents direct interaction of the client with the server
thereby reducing unauthorized access to data. Hence, it is more secure.
Data Abstraction: There are three level of data abstraction in database systems.
1. Physical Level: The lowest level of abstraction describes how the data is actually stored. It is also known as
Internal level. For example- student, customer, employee, account records.
2. Logical/Conceptual Level: The next-higher level of abstraction describes what data are stored in the database,
and what relationships exist among those data.
3. View/External Level: The highest level of abstraction describes the database part that a particular user group is
interested and hides the remaining database from that user group. The view level of abstraction exists to simplify
their interaction with the database system.
Instances and Schemas:
▪ The group of data/information stored in the database at a particular point of time is called an Instance of the
database.
▪ The logical structure of database is called the database schemas.
▪ The physical schema describes the database design at the physical level.
▪ The logical schema describes the database design at the logical level.
▪ The view or subschema describe the database design at the view level.
▪ The ability to modify physical schema without changing the logical schema is called as Physical Data
Independence.
Data Model: It is a collection of conceptual tools for describing data, relationship of data, data semantics and
consistency constrains. There are many types of data models:
1. Entity Relationship (E-R) data Model: It is based on a notion of a real-world objects, called entities, and
relationships among these objects. It defines the conceptual view of the database and represent the database as a
diagram.
Entity Relationship Diagram: An Entity Relationship (E-R) diagram can describe graphically the overall conceptual
or logical structure of a database. It consists of the following components as given in the below table:

www.oliveboard.in
www.oliveboard.in

Figure Description

Entity Set is represented by rectangle.

Weak Entity Set is represented by double rectangle.

Attribute is represented by ellipse.

Primary key or key attribute is represented by an ellipse with the text underlined.

Multivalued attribute is represented by double ellipse.

Derived attribute is represented by a dashed ellipse.

Discriminating attribute or partial attribute of weak entity set is represented by


ellipse with text underlined with a dashed line.

Relationship set is represented by a diamond.

Identifying relationship set for weak entity set is represented by double diamond.

Many-to-Many relationship is represented by undirected lines on both sides

Many-to-One relationship is represented by undirected line on left side and directed


line on the right side.

One-to-One relationship is represented by directed line on both sides.

One-to-Many relationship is represented by directed line on left side and undirected


line on the right side.

There are three basic concept of E-R data model:


a. Entity Set: An entity is a “thing” or “object” in the real world that is distinguishable from other objects.
b. Attributes: Attributes are described as the properties own by each entity of an entity set and an entity is
represented by the set of attributes. For each attribute, there is a set of permitted values, called the domain, or
value set, of that attribute.
Types of Attributes:
• Simple Attributes: Attributes that can’t be partitioned into subparts. Ex: Phone number.
• Composite Attributes: Composed of more than one simple attribute. Ex: A name can be further divided into
three simple attributes; first-name, middle-name and last-name.

www.oliveboard.in
www.oliveboard.in

• Key Attribute: Attribute which uniquely identifies each entity in the entity set and also called as primary
key. Ex: Roll number is a key attribute

• Single valued Attributes: Attribute which have only one value for a particular entity. Ex: Department-name.
• Multivalued Attributes: Attribute that has a set of values for a specific entity. Ex: A student can have one
or more than one phone number or email id.

• Derived Attribute: The value of an attribute can be derived from the values of another related attributes is
called derived attribute. The attribute from which derived attribute is derived or calculated is called base
attribute or stored attribute and the value of a derived attribute is computed when required. Ex: Student’s
age can be derived from his DOB. So, age is derived attribute and DOB is base attribute.

c. Relationship set: A relationship is an association among several entities and a relationship set is a set of
relationships of the same type. Ex: the relationship set “enroll-in” is the relationship between two entity sets
“student” and “course” and the relationship set “depositor” is the relationship between the two entity sets “customer”
and “account”.
A relationship may also have attributes called descriptive attributes. Ex: The descriptive attribute of the
relationship set “depositor” can be “access-date”, which can store the access date of the customers when they access
their account.

Degree of relationship: The number of participating entities in a relationship defines the degree of the relationship.
• Unary relationship: It is the relationship when there is only one entity set. Ex: “Assistant manager” works-
under “Manager”. So, one employee works under another employee.

• Binary relationship: It is the relationship when there are two entity sets. Ex: an “employee” “working in” a
“company”.

www.oliveboard.in
www.oliveboard.in

• Ternary relationship: It is the relationship when there are three entity sets. Ex: consider the entity sets
employee, branch, and job (manager, clerk, assistant etc.) and the relationship set works-on among employee,
branch, and job.

• n-ary relationship: n-ary relationship is the relationship when there are “n” number of entity sets are
participating in the relation.
Constraints: It restrict limits to the data or type of data and its main purpose is to maintain the data integrity.
Mapping cardinalities and participation constraints, which are two of the most important types of constraints
Mapping Cardinalities: It describes the number of entities in one entity set which can be associated with number of
entities in another entity set via a relationship set. It is also known as cardinalities ratios. There are mainly four
types of mapping cardinalities for binary relationship set:

Mapping Description Diagram Example


Cardinalities

One to One An entity in entity set “A” is related One team member can
with at most one entity in another become the “captain” of
entity set “B”, and also an entity in the “team” and there can
entity set “B” is related with at most have only one “captain”
one entity in entity set “A”. in a “team”.

One to Many An entity in entity set “A” is related One “manager” manages
with any number (zero or more) of more than one “team”.
entities in another entity set “B”. An
entity in entity set “B” can be related
with at most one entity in entity set
“A”.

Many to One An entity in entity set “A” is related Many “employees” “work-
with at most one entity in another on” one “project”.
entity set “B”. An entity in entity set
“B” can be related with any number
(zero or more) of entities in entity set
“A”.

Many to An entity in entity set “A” is related More than one “teacher”
Many with any number (zero or more) of can teach one or more
entities in another entity set “B”, and than one “student” and
an entity in entity set “B” is related vice versa.
with any number (zero or more) of
entities in entity set “A”.

Participation constrains: There are mainly two types of participation constrains:

www.oliveboard.in
www.oliveboard.in

Total participation: If every entity in entity set “E” participates in at least one relationship in relationship set “R”,
then the participation of the entity set “E” in the relationship set “R” is known as total participation. It is
represented by double line.
Partial participation: If only some entities in entity set “E” participate in relationships in relationship set “R”, then
the participation of entity set “E” in relationship set “R” is known as partial participation. It is represented by single
line.

Weak entity set: An entity set which may not have enough attributes to form a primary key is called weak entity
set. A weak entity set must be associated with another entity set which is called the identifying or owner entity
set. The relationship associating the weak entity set with the identifying entity set is called the identifying
relationship. The identifying relationship is many to one from the weak entity set to the identifying entity set, and
the participation of the weak entity set in the relationship is total.
The discriminator of a weak entity set is a set of attributes that allows this distinction to be made. The discriminator
of a weak entity set is also called the partial key of the entity set. The primary key of a weak entity set is formed
by the primary key of the identifying entity set, plus the weak entity set’s discriminator.
Ex: “Flat” is a weak entity set and “Building” is its identifying entity set. “Building-Flat” is the identifying relationship
between “Building” and “Flat” entity sets and “Flat-No” is the partial attribute of the weak entity set. Primary key for
“Flat” entity set is {B-No, Flat-No}.

Specialization: An entity set may include subgroupings of entities that are distinct in some way from other entities
in the set. The process of designating subgroupings within an entity set is called specialization and is a top-down
approach. Ex: An entity set “person” in a university can be further classified as “professor”, “student” and “staff”.
Specialization is represented by a triangle component labelled ISA. The label ISA stands for “is a” and represents, for
example, that a Student “is a” person. The ISA relationship is also be called superclass-subclass relationship.

Generalization: Generalization is a reverse of specialization and it is bottom-up approach, in which multiple entity
sets are synthesized into a higher-level entity set based on common features. It is used to emphasize the similarities
among lower-level entity sets and to hide the differences; it also permits an economy of representation in that shared
attributes are not repeated.
Aggregation: Aggregation is an abstraction through which relationships are treated as higher-level entities. In this,
the ternary relationship is treated as a single higher-level entity set and relationship with its corresponding entities is
aggregated into a higher-level entity.

www.oliveboard.in
www.oliveboard.in

2. Relational Model: The relational model is represented as a table with rows and column. Each table has multiple
columns and each column has unique name.

Student_id Student_name Student_phone_no

1001 Ram 9820839208

1002 Shyam 9937298327

1003 Mohan 9382819083

Relational Database: A relational database consists of a collection of tables or relations, each of which is assigned a
unique name. A row in a table represents a relationship among a set of values.
Terminologies of the relational model:
• The column of the table is called attributes.
• For each attribute, there is a set of permitted values, called the domain of that attribute.
• Each row of a relation is known as tuple.
• One domain value that is a member of any possible domain is the null value, which signifies that the value is
unknown or does not exist.
• A relation schema consists of a list of attributes and their corresponding domains.
• The set of values present in a relation at a particular instance of time is known as relational instance.
For example: the “student” table which has four columns: “Roll-no”, “Name”, “Department-name”, and “Phone-no”.

Roll-no Name Department-name Phone-no

701 John ECE 9989866393

702 Tom Mechanical 9837093831

703 Jill CS NULL

704 Jack Civil 9840273493

705 Hope ECE 9983672532

The relational Algebra: The relational algebra is also known as procedural query language or formal query
language. The operations in relational algebra is as follows:
1. The Select Operation: The select operation selects tuples that satisfy a given predicate (condition) and it is
represented by “σ”. we can use comparison conditions such as =, ≠, <, ≤, >, and ≥ in the selection predicate and
also can use connectives and (∧), or (∨), and not (¬) in it.
Syntax: σ Predicate (table name)
For example: To select those tuples of the Student relation where the Department-name is “ECE”. We write: σ
department-name = “ECE” (Student)

Roll-no Name Department-name Phone-no

701 John ECE 9989866393

705 Hope ECE 9983672532

2. The Project Operation: The Project operation is used to retrieve only a certain set of attributes (column) of a
relation (table) and it is denoted by “Π”. This operation eliminates the duplicated values from the resultant table.
Syntax: Π attributes (A1, A2…An) (table name)

www.oliveboard.in
www.oliveboard.in

For example: To show all the name and roll-no of the students from “Student” table, then we can use project
operation. We write: Π Roll-no, Name (Student)

Roll-no Name

701 John

702 Tom

703 Jill

704 Jack

705 Hope

3. Composition of Relational Operations: The relational-algebra operation is of the same type (relation) as its
inputs, relational-algebra operations can be composed together into another relational-algebra expression. For
example: Find the Roll-no of those students from “CS” department.
We write: Π Roll-no (σ Department-name = “CS” (student))

Roll-no

703

4. The Union Operation: This operation is used to fetch data from two relations(tables) and both the relations
(tables) have same number of attributes (columns) and same attribute domain and also eliminated duplicate tuples
from the result table. For example: Two tables “Depositor” and “Borrower”. “Depositor” table is given below.

Customer-name Account-no

Denial 9999101

Bob 9999102

Cruse 9999103

Joseph 9999104

Denial 9999105

Davina 9999106

Cruse 9999107

And “Borrower” table is given below.

Customer-name loan-no

Harry 7171001

Bob 7171002

Gia 7171003

Marcel 7171004

Cruse 7171005

Bob 7171006

Davina 7171007

Then to find the name of all customers from both tables, we write: Π customer-name (Depositor) ∪ Π customer-name
(Borrower)

www.oliveboard.in
www.oliveboard.in

Customer-name

Denial

Bob

Cruse

Joseph

Davina

Harry

Gia

Marcel

5. The Set Difference Operation: This operation is used to fetch the tuples that are in one relation but not in
another. It is represented by “–“. For example: We can find all customers of the bank who have taken loan but not
have an account.
We write: Π customer-name (Borrower) – Π customer-name (Depositor)

Customer-name

Harry

Gia

Marcel

6. The Cartesian-Product Operation: The Cartesian-product operation is used to combine information from any
two relations (tables) and denoted by a cross (×). This is also called as Cross product operation. The Cartesian
product of relations r1 and r2 is written as r1 × r2. If number of tuples in r1 relation is X and number of tuples in r2
relation is Y, then number of tuples in the resultant relation of Cartesian-product operation will be X * Y. For
example: There is “Lab-Exam” table.

Lab-Exam-name Department-name Time

AS-00F ECE 10:00 am

AP-01H CS 2:00 pm

BK-02G Mechanical 5:00 pm

R = “Student” × “Lab-Exam”

www.oliveboard.in
www.oliveboard.in

Roll- Name Student.Department- Phone-no Lab-Exam- Lab-Exam.Department- Time


no name name name

701 John ECE 9989866393 AS-00F ECE 10:00


am

701 John ECE 9989866393 AP-01H CS 2:00


pm

701 John ECE 9989866393 BK-02G Mechanical 5:00


pm

702 Tom Mechanical 9837093831 AS-00F ECE 10:00


am

702 Tom Mechanical 9837093831 AP-01H CS 2:00


pm

702 Tom Mechanical 9837093831 BK-02G Mechanical 5:00


pm

703 Jill CS NULL AS-00F ECE 10:00


am

703 Jill CS NULL AP-01H CS 2:00


pm

703 Jill CS NULL BK-02G Mechanical 5:00


pm

704 Jack Civil 9840273493 AS-00F ECE 10:00


am

704 Jack Civil 9840273493 AP-01H CS 2:00


pm

704 Jack Civil 9840273493 BK-02G Mechanical 5:00


pm

705 Hope ECE 9983672532 AS-00F ECE 10:00


am

705 Hope ECE 9983672532 AP-01H CS 2:00


pm

705 Hope ECE 9983672532 BK-02G Mechanical 5:00


pm

7. The Rename Operation: The rename operation is used to give a name to the resultant relation (table) of
relational-algebra expressions and also rename the attributes of the resultant relation (table) and it is denoted by
geek letter rho (ρ).
• Syntax to give name the resultant table and rename the attributes of resultant table of relational-algebra
expression: ρ x (A1, A2, … An) (E)
8. The Set-Intersection Operation: The Set-Intersection operation is used to fetch the common information from
two tables. It is denoted by (∩). For example: To fetch the customer’s name who have both a loan and an account.
We write: Π customer-name (borrower) ∩ Π customer-name (depositor)

Customer-name

Bob

Cruse

Davina

9. The Natural-Join Operation: The natural join is a binary operation that allows us to combine certain selections
and a Cartesian product into one operation. It is denoted by the “join” symbol “⋈”. There should be at least one
common attribute in two or more than two relations and natural-join operation considers only pairs of tuples that
have the same value on common attribute.

www.oliveboard.in
www.oliveboard.in

For Example: To show the Roll-no and name of the students and lab-exam time, then We first form the Cartesian
product of the Student and Lab-Exam relations. Then, we select those tuples that pertain to only the same
Department-name, followed by the projection of the resulting Roll-no, name, and time:
Π Roll-no, name, time (σ Student.Department-name = Lab-Exam.Department-name (Student × Lab-Exam))
Then, we can write same query by using natural-join operation as follows:
Π Roll-no, name, time (Student ⋈ Lab-exam)
So, the resultant table is given below.

Roll-no Name Time

701 John 10:00 am

702 Tom 5:00 pm

703 Jill 2:00 pm

705 Hope 10:00 am

10. Outer Join Operation: There are three forms of outer join operations:
• Left Outer Join Operation: It fetches all the tuples in the left relation that did not match with any tuple in
the right relation, fills the tuples with null values for all other attributes from the right relation, and adds them
to the result of the natural join. It is denoted by “⟕”.
For Example: A company has many branches in different cities and customer can purchase products from any of
these branches. There are two relations “Customer” and “Order-Details”. In Customer schema = (customer-name,
city, email-id) and Order-details schema = (customer-name, purchase, branch). Customer and Order-detail table is
given below:

Customer-name City Email-id

Piyush Delhi pjk@gmail.com

Ram Lucknow ram@yahoo.com

Nitin Bangalore n.g@gmail.com

Prakash Delhi Pr.jav@yahoo.com

Umesh Chennai ush@gmail.com

Kamal Bangalore kml@gmail.com

Order-detail table is given below:

Customer-name purchase branch

Nitin 1200 Koramangala

Ram 800 Aliganj

Ramesh 500 Ameerpet

Rahul 1500 Ashok Nagar

Kamal 2500 HSR

Piyush 1600 GTB Nagar

So, Customer ⟕ Order-detail


So, resultant table:

Customer-name City Email-id purchase branch

Piyush Delhi pjk@gmail.com 1600 GTB Nagar

Ram Lucknow ram@yahoo.com 800 Aliganj

Nitin Bangalore n.g@gmail.com 1200 Koramangala

Prakash Delhi Pr.jav@yahoo.com NULL NULL

Umesh Chennai ush@gmail.com NULL NULL

Kamal Bangalore kml@gmail.com 2500 HSR

www.oliveboard.in
www.oliveboard.in

• Right Outer Join Operation: It fills tuples from the right relation that did not match any from the left
relation with nulls and adds them to the result of the natural join. All information from the right relation is
present in the result of the right outer join and it denoted by “⟖”
For example: Right outer join of Customer and Order-details (Customer ⟖ Order-detail) and resultant table is given
below:

Customer-name City Email-id purchase branch

Nitin Bangalore n.g@gmail.com 1200 Koramangala

Ram Lucknow ram@yahoo.com 800 Aliganj

Ramesh NULL NULL 500 Ameerpet

Rahul NULL NULL 1500 Ashok Nagar

Kamal Bangalore kml@gmail.com 2500 HSR

Piyush Delhi pjk@gmail.com 1600 GTB Nagar

• Full Outer Join Operation: It is a combination of both left and right outer join operation, fills the tuples
from the left relation that did not match any from the right relation, as well as tuples from the right relation
that did not match any from the left relation and adding them to the result of the natural join. It is denoted by
“⟗”
For example: Full outer join of Customer and Order-details (Customer ⟗ Order-details) and the resultant table is
given below:

Customer-name City Email-id purchase branch

Nitin Bangalore n.g@gmail.com 1200 Koramangala

Ram Lucknow ram@yahoo.com 800 Aliganj

Ramesh NULL NULL 500 Ameerpet

Rahul NULL NULL 1500 Ashok Nagar

Kamal Bangalore kml@gmail.com 2500 HSR

Piyush Delhi pjk@gmail.com 1600 GTB Nagar

Prakash Delhi Pr.jav@yahoo.com NULL NULL

Umesh Chennai ush@gmail.com NULL NULL

Keys: It is used to identify a set of attributes (or records or data) from an entity or table and also help uniquely
identify relationships, and thus distinguish relationships from each other. There are many types of keys and let us
understand these keys by two tables “Student” and “Course”.
Student Schema = (Roll-no, Name, email-id, Phone, Course-id, Age)
Course Schema = (Course-id, Course-name, Professor-name)
Student table is given below:

Roll-no Name Email-id Phone Course-id Age

19/CA/901 Klaus k.t@gmail.com 8472934333 C02 23

19/CA/902 Denial den@gmail.com 7927291991 C05 22

19/CA/903 Ivy iy@gmail.com 9473292743 C01 20

19/CA/904 Vince vin@gmail.com 2648302843 C02 18

19/CA/905 Camille cami@gmail.com 3846382639 C03 24

19/CA/906 Rebekah bek@gmail.com 7930303738 C04 19

19/CA/907 Joe j.e@gmail.com 4759364840 C01 22

www.oliveboard.in
www.oliveboard.in

Course table is given below:

Course-id Course-name Professor-name

C01 Data Structure S. S Saha

C02 Networking M. S Bhattacharjee

C03 DBMS P. Choudhary

C04 Operating System T. V Abhijit

C05 Programming Language C. V Raman

Types of keys:
I: Candidate key: The minimal set of attributes (or column) which can uniquely identify a tuple (or a row) is known
as candidate key. Its value cannot be NULL, and every value of candidate key is unique. A candidate key can be a
combination of more than one column (attributes). For example: “Roll-no”, {“Phone”, “age”}, {“Name”, ”Course-
id”} and {“Name”, “email-id”} are the candidate keys for the table student.
II: Primary Key: There can be more than one candidate key in relation out of which only one can be chosen as the
primary key. It is a key that can uniquely identify each record in a table. The value of primary Key cannot be NULL
and duplicate. The value in a primary key column can never be modified or updated if any foreign key refers to that
primary key. The chosen primary key must contain minimal attributes. For example: “Roll-no” is the primary key for
student table and “Course-id” is the primary key for Course table.
III: Super Key: It is a set of one or more attributes (or column) that uniquely identify a tuple in the relation or table
and Super key is a superset of a candidate key. A candidate key is a super key but vice versa is not true. For
example: {“Name”, “email-id”, “phone”} is the super key for student table.
IV: Alternative Key: The candidates key which are not selected as primary key are known as secondary keys or
alternative keys. For example: If “Roll-no” is the primary key, then {“Phone”, “age”}, {“Name”,” Course-id”} and
{“Name”, “email-id”} are alternative keys for student table.
V: Foreign Key: Foreign key is the column (attribute) of the table which is used to point to the primary key of
another table. Foreign Key can be NULL as well as may contain duplicate values. It is used to create a relationship
with another table. The relation which is being referenced is called referenced relation and the corresponding
attribute is called referenced attribute. For example: “Course-id” in Student table is foreign key which points to
“course-id” in course table.
VI: Composite key: A composite key is a candidate key that consists of two or more attributes (table columns) that
uniquely identify a tuple (table row). For example: “Name” and “Phone” together can be the composite key for
student table.
VII: Compound Key: A compound key is a composite key for which each attribute that makes up the key is a
foreign key in its own right. The difference between compound and the composite key is that any part of the
compound key can be a foreign key, but the composite key may or maybe not a part of the foreign key. For
example: {Roll-no, course-id} can be the compound key.
VIII: Unique key: A unique key of a table is a minimal super key for that table, and it is a set of attributes such that
the table does not have two tuples with the same value of these attributes.
IX: Natural Key: A natural key is a type of unique key for which attributes that exist and are used in the external
work outside the database (i.e. in the business domain or domain of discourse) and it is also known as domain key.
It is used for identification for data and remains unique within an information system. For example: Login name,
passport number etc.
3. Object-oriented data model: It is based on the perception of real-world objects and each object distinguished
from other objects. An object-oriented data model consists of the following basic object-oriented concepts:
• An object is a real-world entity with some attributes which is called object structure.
• Encapsulation is provided by binding an object into single unit and data Abstraction is provided by hiding the
implementation details.
• Message, methods and variables are the components of object structure.
• An object which is a real-world entity is an instance of a class. It also supports the concept of inheritance.
4. Network data model: The network data model, data is organized like graph structure and one node can have
more than one parent node and follows many to many relationships. This was the most widely used database model,
before Relational Model was introduced.
5. Hierarchical data model: In this model, data is organized into tree like structure with a single root and all other
data is linked to it. A child node can have only a single parent and it follows one to many relationships. For example,
one college can have many departments and one department can have many professors.

www.oliveboard.in
www.oliveboard.in

Database languages: There are many types of database languages:


1. Data-Definition Language (DDL): A database system provides a data definition language to specify the
database schema. DDL compiler generates or update a special set of tables called the data dictionary or data
directory. A data dictionary contains metadata which is the schema of a table. There are following commands which
comes under DDL:
▪ CREATE: Create the database and its objects (like tables, indexes etc.)
▪ RENAME: Rename the objects existing in the database.
▪ DROP: Delete the objects from the database.
▪ TRUNCATE: Remove all the records from the table.
▪ ALTER: Alter the structure of the database.
▪ COMMENT: Add comments to the data dictionary.
2. Data-Manipulation Language (DML): It is a language that provides users to access or manipulate data in the
database. There are basically two types of DMLs: Procedural DMLs enable a user to specify what data are needed
and how to retrieve those data and Declarative DMLs also known as nonprocedural DMLs enable a user to specify
what data are needed without specifying how to get those data.
▪ INSERT: Insert data into a table.
▪ UPDATE: Update existing data within a table.
▪ DELETE: Delete records from a database table.
3. Data-Query Language (DQL): It is a language which is used to retrieve some schema relation based on the
query provided by user.
▪ SELECT: Get data from the database.
4. Transaction Control Language (TCL): It is used to manage transactions in the database and manage the
changes made by Data manipulation language (DML) commands. There is some command which comes under TCL:
▪ COMMIT: Save the transaction on the database.
▪ ROLLBACK: Restore the database to original since the last Commit.
▪ SAVEPOINT: Temporarily save a transaction so that you can roll back to that point.
5. Data Control Language (DCL): It is used to control access or permission to data stored in a database
(Authorization).
▪ GRANT: Allow specified users to perform specified tasks.
▪ REVOKE: Cancel previously granted permissions or removes privilege to the database objects.
Database users: Different users interacted in a different way with database system, so we categorized them into
four types.
• Naive users: The users who interact with the database system by invoking one of the application programs
that have been written previously are called Naive users or unsophisticated users. For example- a student
who wishes to check his result on WWW.
• Application programmers: A computer professionals who write application programs and interacted with
the database by means of DML queries are called Application programmers. They can choose from many tools
like C, C++, Java, PHP etc. to develop user interface in which DML queries are written.
• Sophisticated users: Users who directly interact with database system by database language (like DCL, DML
etc.) and without writing any program. They do not use any application or programs to request the database.
• Specialized users: sophisticated users who write specialized database application programs are known as
specialized users. They are the developers who develop the complex programs as per the requirement.
Database Administrator: The database administrator (DBA) is a high-level user with the ability to create users and
grant users’ access to the database and its objects. Users require system privileges to gain access to the database
and object privileges to manipulate the content of the objects in the database. There are following function of DBA:
▪ Granting of authorization for data access.
▪ Schema definition.
▪ Schema and physical-organization modification.
▪ Routine maintenance.
Types of Database Administrators:
▪ Administrative DBA: Installing, memory management, backups, security and maintaining Database
Management system is the main task of Administrative DBA

www.oliveboard.in
www.oliveboard.in

▪ Application DBA: The mediator between the database and the application program is Application DBA. He
ensures that all the activities of application program are optimized to interact with database.
▪ Database Architect: Creating and maintaining the users, constraints, roles, access rights, views, tables are
the main task for Database Architect.
▪ OLAP DBA: Installing and maintaining the database in OLAP (online analytical processing) system is done by
OLAP DBA.
▪ Data Warehouse DBA: Maintain the data and procedures from various sources in the data warehouse and
keep the performance and function levels from these sources at same pace to make the warehouse work are
the main task of Data warehouse DBA.
▪ Development DBA: He is mainly responsible for creating queries and procedure as per the requirement.
Database System Structure: A database system is divided into components that deal with each of the
functionalities of the overall database system. The functional modules of a database system are partitioned into two
parts: storage manager and query processor
1. Storage Manager: It is a program module that provides the interface between the low-level data stored in the
database and the application programs and queries submitted to the system. It translated the various DML commands
into low-level file system commands and responsible for storing, retrieving, and updating data in the database. The
storage manager components include:
▪ Buffer manager
▪ Transaction manager
▪ File manager
▪ Authorization and integrity manager
The storage manager implements several data structures as part of the physical system implementation:
▪ Data dictionary
▪ Indices
▪ Data files
2. The Query Processor: The components of query processors are as follows:
▪ DML compiler: It translates DML commands in a query language into an evaluation plan consisting of low-
level instructions that the query evaluation engine understands. It also performs query optimization, that is, it
picks the lowest cost evaluation plan from among the alternatives.
▪ DDL interpreter: It interprets DDL commands and stores the definitions in the data dictionary.
▪ Query evaluation engine: It executes low level instructions generated by the DML complier.
Functional Dependency: It is a constraint between two sets of attributes in a relation from a database. A functional
dependency is denoted by arrow (→). If an attributed A functionally determines B, then it is written as A → B.
Let us understand by an example: There is a table with two attributes A and B.
Case 1: If for two same values of attribute A, we’re getting similar values for attribute B-

A B

A1 B1

A1 B1

Then, A functionally determines B (A → B)


Case 2: If for two different values of attribute A, we’re getting similar values for attribute B-

A B

A1 B1

A2 B1

Then, A functionally determines B (A → B)


Case 3: If for two different values of attribute A, we’re getting different values for attribute B-

A B

A1 B1

A2 B2

Then, A functionally determines B (A → B)

www.oliveboard.in
www.oliveboard.in

Case 4: If for two same values of attribute A, we’re getting different values for attribute B-

A B

A1 B1

A1 B2

Then, A does not functionally determine B (A !→ B)


Types of functional dependency:
1. Trivial Functional Dependency: If A → B is a trivial functional dependency when B is the subset of A (i.e., B ⊆ A)
and A intersection B is not null i.e., (A ⋂ B ≠ Ø). For Example: Roll-no, Name, City are the attributes of Student table.
• {Roll-no, Name, City} → Name
• {Roll-no, Name, City} → {Roll-no, City}
• {Roll-no, Name, City} → {Roll-no, Name, City}
2. Non-trivial Functional Dependency: If A → B is non-trivial functional dependency when B is not the subset of A
i.e., B ⊄ A and A intersection B is null i.e., (A ⋂ B = Ø). For Example: Roll-no, Name, City, age, Department-name are
the attributes of Student table.
• Name → City
• {Name, age} → Department-name
3. Semi Non-trivial Functional Dependency: If A → B is semi non-trivial functional dependency when A
intersection B is not null i.e., (A ⋂ B ≠ Ø). For Example: Roll-no, Name, City, Department-name are the attributes of
Student table.
• {Name, City} → {City, Department-name}
• {City, name} → {roll-no, name}
4. Fully Functional Dependency: If A → B, then B is said to be fully functional dependent when B cannot be
determined by any of the proper subset of A. For example: XYZ → W, then W is not determined by X, Y, Z, XY, YZ, or
YZ.
5. Partial Functional Dependency: If A → B, then B is said to be partial functional dependent when B can be
determined by any of the proper subset of A. For example: XYZ → W and YZ → W,
Armstrong’s axioms of Functional Dependency:
• Reflexivity rule: If X is a set of attributes and Y ⊆ X, then X → Y.
• Augmentation rule: If X → Y and Z is a set of attributes, then ZX → ZY.
• Transitivity rule: If X → Y and Y → Z, then X → Z.
• Union rule: If X → Y and X → Z, then X → YZ.
• Decomposition rule: If X → YZ, then X → Y and X → Z.
• Pseudo-transitivity rule: If X → Y and ZY → W, then XZ → W.
• Composition rule: If X → Y and Z → W, then XZ → YW.
Database Anomaly: Database anomalies occurs in non-normalized database due to poor management of data and
can cause too much redundancy. There are three types of database anomalies:
• Update Anomaly
• Insertion Anomaly
• Deletion Anomaly
Normalization: It is the technique of reducing redundancy from a relation (table) or set of relations (tables) and
redundancy occurs in any relation due to insertion anomaly, update anomaly and deletion anomaly. It divides the
larger table into the smaller table and links them using relationship. So, it helps to reduce the redundancy in
relations. Normal forms are used to eliminate or minimize redundancy in database tables.
Types of Normal Forms:
1) First Normal Forms (1NF): A relation is in first normal form if it and only if the following conditions are satisfied:
Values of each attribute is atomic. It does not contain any composite or multi-valued attribute. All entities in any
column must be of the same kind. Each column must have a unique name. No two rows are identical.
2) Second Normal Forms (2NF): A relation is said to be in second normal form (2NF) if it is in 1NF and there
should not be partial functional dependency in the relation.
Partial Functional Dependency: All the non-prime attributes should depend on proper subset of candidate key.
3) Third Normal Forms (3NF): A relation is said to be in third normal form (3NF) if it is in 2NF and there should not
be transitive functional dependency in the relation.

www.oliveboard.in
www.oliveboard.in

Transitive Functional Dependency: All the non-prime attributes should depend on another non-prime attribute.
For example: A relation R(M, N, O, P, Q) is in 3NF with functional dependency set {OP → Q, M → NO, Q → M, N → P}
4) Boyce–Codd Normal Form (BCNF): A relation is said to be in Boyce–Codd normal form (BCNF) if it is in 3NF and
for each functional dependency X determines Y (X → Y), X should be a super key. Ex: A relation R(A, B, C, D) is in
BCNF with functional dependency set {A → B, A → C, A → D}.
The candidate key for the above relation is {A} and all the attribute are on left sides of functional dependencies are
super key.
5) Fourth Normal Forms (4NF): A relation is said to be in fourth normal form (4NF) if it is in Boyce-Codd normal
form and it contains no multi-valued dependencies.
Multi-valued dependencies: Multi-values dependency occurs when two attributes (or columns) in a table are
independent of one another, but both depend on a third attribute.
6) Fifth Normal Forms (5NF): A relation is said to be in fifth normal form (5NF) if it is in fourth normal form and
not contains any join dependency and joining should be lossless. 5NF is also known as Project-join normal form
(PJNF).
Joint dependency: Join decomposition is a further generalization of Multivalued dependencies. If the join of R1 and
R2 over C is equal to relation R, then we can say that a join dependency (JD) exists. Where R1 and R2 are the
decompositions R1(A, B, C) and R2(C, D) of a given relations R (A, B, C, D). Alternatively, R1 and R2 are a lossless
decomposition of R.
Transaction: Collections of operations that form a single logical unit of work are called transactions. A database
system must ensure proper execution of transactions despite failures—either the entire transaction executes, or none
of it does.
Transactions access data using two operations:
• read(X), which stores the data item X from the database to a local buffer belonging to the transaction that
executed the read operation and it is represented by R(X).
• write(X), which stores the data item X from the local buffer of the transaction is executed the write back to
the database and it is represented by W(X).
ACID Property: To ensure integrity of the data, we require that the database system maintain the ACID properties
of the transactions:
• Atomicity: Either all operations of the transaction are reflected properly in the database, or none are.
• Consistency: Execution of a transaction in isolation (that is, with no other transaction executing
concurrently) preserves the consistency of the database.
• Isolation: Even though multiple transactions may execute concurrently, the system guarantees that, for
every pair of transactions Ti and Tj, it appears to Ti that either Tj finished execution before Ti started, or Tj
started execution after Ti finished. Thus, each transaction is unaware of other transaction executing
concurrently in the system.
• Durability: After a transaction completes successfully, the changes it has made to the database persist, even
if there are system failures.
Transaction State: A transaction must be in one of the following states:
• Active: It is the initial state; the transaction stays in this state while it is executing.
• Partially committed: After the final statement has been executed.
• Failed: After the discovery that normal execution can no longer proceed.
• Aborted: After the transaction has been rolled back and the database has been restored to its state prior to
the start of the transaction.
• Committed: After successful completion.
Structured Query Language (SQL): Structured Query Language is a standard Database language which is used to
create, manipulate, update, delete and retrieve the relational database.
Rules of SQL Statements:
▪ SQL statements are not case-sensitive.
▪ SQL statements can be on one or more lines.
▪ Keywords cannot be abbreviated or split across lines.
▪ Clauses are usually placed on separate lines.
▪ Indents are used to enhance readability.
▪ SQL statements can optionally be terminated by a semicolon (;). Semicolons are required if you execute
multiple SQL statements.

www.oliveboard.in
www.oliveboard.in

Null Values: If a row lacks a data value for a particular column, that value is said to be null or to contain a null. A
null is a value that is unavailable, unassigned, unknown, or inapplicable. A null is not same as a zero or a space. Zero
is a number, and a space is a character.
Three tables “Employees”, “Department” and “Location” is given below:
“EMPLOYEES” Table

Emp_ID First_name Last_name Email Phone Hire_Date Job_ID Salary Dept_ID

202 Ram Verma rv@abc.com 8527 12-APR-18 AD_ASST 20000 10

144 Vaishali Gupta vg@abc.com 6272 01-JUN-17 MK_MAN 30000 20

214 Jitu Kumar jk@abc.com 9326 17-JUL-16 MK_REP 22000 90

196 Mangal Goswami mg@abc.com 9363 01-APR-17 AC_MGR 35000 20

200 Geeta Rai gr@abc.com 9421 03-JAN-12 AC_ACCO 18000 110

210 Kush Mittal km@xyz.com NULL 08-JAN-13 AD_PRES 15000 90

178 Jitu Sharma js@xyz.com 4729 19-FEB-16 AD_VP 30000 90

212 Vipul Kumar vk@xyz.com 4739 20-MAR-12 AD_VP 45000 10

165 Geeta Verma gv@abc.com 9433 18-JUN-17 IT_PROG 40000 60

149 Keshav Sharma ks@abc.com NULL 20-SEP-18 IT_PROG 42000 60

“Department” Table:

Dept_ID Dept_name Manager_ID Location_ID

10 Administration 202 GA_16

20 Marketing 144 NA_14

60 IT 165 HF_19

90 Executive 210 GA_16

110 Accounting 218 GA_16

“Location” Table:

Location_ID City

GA_16 Delhi

NA_14 Nagpur

GJ_38 Jaipur

HF_19 Hyderabad

TG_23 Telangana

Basic Structure: Basic structure of an SQL expression consists of three clauses:


The SELECT clause corresponds to the projection operation of the relational algebra. It is used to list the attributes
desired in the result of a query.
The FROM clause corresponds to the Cartesian-product operation of the relational algebra. It lists the relations to be
scanned in the evaluation of the expression.
The WHERE clause corresponds to the selection predicate of the relational algebra. It consists of a predicate
involving attributes of the relations that appear in the from clause.
Syntax: SELECT * | {[DISTINCT] Column_name | expression [alias], …} FROM table_name WHERE
condition (s);

www.oliveboard.in
www.oliveboard.in

SELECT Is a list of one or more columns

* Selects all columns

DISTINCT Suppresses duplicates

Column_name | Expression Select the named column or the expression

Alias Gives selected columns different heading

From table_name Specifies the table containing the columns

WHERE restricts the query to rows that meet a condition

Condition is composed of column names, expressions, constants, and a comparison operator

Arithmetic Expressions: An arithmetic expression can contain column names, constant numeric values, and the
arithmetic operators (+, -, *, /). Only addition and subtraction operators are used with DATE and TIMESTAMP data
types.
For example: Find the First_name, Salary and annual salary of the employees.
SELECT First_name, Salary, 12*Salary From Employees;

FIRST_NAME SALARY 12*SALARY

Ram 20000 240000

Vaishali 30000 360000

Jitu 22000 264000

Mangal 35000 420000

Geeta 18000 216000

Kush 15000 180000

Jitu 30000 360000

Vipul 45000 540000

Geeta 40000 480000

Keshav 42000 504000

Defining a Column Alias: When displaying the result of a query, SQL Developer normally uses the name of the
selected column as the column heading. we can change a column heading by using a column alias.
Specify the alias after the column in the SELECT list using a space as a separator. By default, alias headings appear in
upper0case. If the alias contains spaces or special characters (such as # or $), or if it is case-sensitive, enclose the
alias in double quotation marks (" ").
SELECT First_name AS name, 12*Salary AS annual FROM employees;

NAME ANNUAL

Ram 240000

Vaishali 360000

Jitu 264000

Mangal 420000

Geeta 216000

Kush 180000

Jitu 360000

Vipul 540000

Geeta 480000

Keshav 504000

www.oliveboard.in
www.oliveboard.in

SELECT First_name "Name", salary*12 "Annual Salary" FROM employees;

Name Annual Salary

Ram 240000

Vaishali 360000

Jitu 264000

Mangal 420000

Geeta 216000

Kush 180000

Jitu 360000

Vipul 540000

Geeta 480000

Keshav 504000

Concatenation Operator: We can link columns to other columns, arithmetic expressions, or constant values to
create a character expression by using the concatenation operator (||). Columns on either side of the operator are
combined to make a single output column.
SELECT Last_name||Job_ID AS "Employees" FROM employees;

Employees

VermaAD_ASST

GuptaMK_MAN

KumarMK_REP

GoswamiAC_MGR

RaiAC_ACCO

MittalAD_PRES

SharmaAD_VP

KumarAD_VP

VermaIT_PROG

SharmaIT_PROG

Note: If you concatenate a null value with a character string, the result is a character string. LAST_NAME || NULL
results in LAST_NAME.
Displaying the Table Structure: We can display the structure of a table by using the DESCRIBE command. The
command displays the column names and the data types, and it shows you whether a column must contain data (that
is, whether the column has a NOT NULL constraint).
In the syntax, table name is the name of any existing table, view, or synonym that is accessible to the user.
Describe Employees;
Name NULL Type
Emp_ID NOT NULL NUMBER(6)
First_name VARCHAR(20)
Last_name NOT NULL VARCHAR(25)
Email NOT NULL VARCHAR(25)
Phone VARCHAR(10)
Hire_date NOT NULL DATE
Job_ID NOT NULL VARCHAR(10)
Salary Number(8, 2)
Dept_ID NUMBER(4)

www.oliveboard.in
www.oliveboard.in

Using the WHERE Clause: SELECT statement retrieves the employee ID, First_name, job ID of all employees whose
salary is greater than 30000
SELECT Emp_id, First_name, Job_ID FROM employees WHERE Salary > 30000;

Emp_ID First_name Job_ID

196 Mangal AC_MGR

212 Vipul AD_VP

165 Geeta IT_PROG

149 Keshav IT_PROG

Character Strings and Dates in WHERE Clause: Character strings and dates in the WHERE clause must be
enclosed in single quotation marks (' '). Number constants should not be enclosed in single quotation marks. All
character searches are case sensitive.
Comparison Conditions: Comparison conditions are used in conditions that compare one expression to another
value or expression. They are used in the WHERE clause in the following format:

OPERATOR MEANING

= Equal to

> Greater than

>= Greater than or equal to

< Less than

<= Less than or equal to

<> Not equal to

BETWEEN (-- AND --) Between two values (inclusive)

IN (SET) Match any of a list of values

LIKE Match a character pattern

IS NULL Is a null value

Note: The symbols != and ^= can also represent the not equal to condition.
Using the BETWEEN Condition: You can display rows based on a range of values using the BETWEEN range
condition. The range that you specify contains a lower limit and an upper limit.
SELECT First_name, salary FROM employees WHERE salary BETWEEN 25000 AND 45000;

First_name Salary

Vaishali 30000

Mangal 35000

Jitu 30000

Vipul 45000

Geeta 40000

Keshav 42000

Using the IN Condition: To test for values in a specified set of values, use the IN condition. The IN condition is also
known as the membership condition. The IN condition can be used with any data type.
SELECT Emp_ID, Last_name, salary FROM employees WHERE salary IN (18000, 42000, 35000);

Emp_ID Last_name Salary

196 Goswami 35000

200 Rai 18000

149 Sharma 42000

Using the LIKE Condition: You can select rows that match a character pattern by using the LIKE condition it is also
referred to as a wildcard search.

www.oliveboard.in
www.oliveboard.in

Symbol Description

% Represents any sequence of zero or more characters

- Represents any single character

SELECT First_name FROM employees WHERE First_name LIKE 'V%';

First_name

Vaishali

Vipul

Combine pattern-matching characters:


SELECT Last_name FROM employees WHERE Last_name LIKE '_a%';

Last_name

Rai

Using the IS NULL Conditions: The NULL conditions include the IS NULL condition and the IS NOT NULL condition.
SELECT First_name, Phone FROM employees WHERE Phone IS NULL;

First_name Phone

Kush NULL

Keshav NULL

Logical Conditions: A logical condition combines the result of two component conditions to produce a single result
based on those conditions, or it inverts the result of a single condition. A row is returned only if the overall result of
the condition is true.
Three logical operators are available in SQL:
AND: Returns TRUE if both component conditions are true.
SELECT Emp_ID, Last_name, Job_ID, salary FROM employees WHERE salary >=28000 AND Job_ID LIKE
'%MAN%';

Emp_ID Last_name Job_ID Salary

144 Gupta MK_MAN 30000

OR: Returns TRUE if either component condition is true.


SELECT Emp_ID, Last_name, Job_ID, salary FROM employees WHERE salary >= 28000 OR Job_ID LIKE
'%MAN%';

Emp_ID Last_name Job_ID Salary

144 Gupta MK_MAN 30000

196 Goswami AC_MGR 35000

178 Sharma AD_VP 30000

212 Kumar AD_VP 45000

165 Verma IT_PROG 40000

149 Sharma IT_PROG 42000

NOT: Returns TRUE if the following condition is false.


SELECT Last_name, Job_ID FROM employees WHERE Job_ID NOT IN ('IT_PROG', 'ST_CLERK', 'AD_VP');
Last_name Job_ID
Verma AD_ASST
Gupta MK_MAN
Kumar MK_REP
Goswami AC_MGR
Rai AC_ACCO
Mittal AD_PRES

www.oliveboard.in
www.oliveboard.in

Rules of Precedence: The rules of precedence determine the order in which expressions are evaluated and
calculated.

Precedence Operator

1 Arithmetic operators

2 Concatenation Operator

3 Comparison Conditions

4 IS [NOT] NULL, LIKE, [NOT] IN

5 [NOT] BETWEEN

6 Not equal to

7 NOT logical condition

8 AND logical condition

9 OR logical condition

Using the ORDER BY Clause: The ORDER BY clause can be used to sort the rows. If you use the ORDER BY clause,
it must be the last clause of the SQL statement. You can specify an expression, an alias, or a column position as the
sort condition.
Syntax: SELECT expr FROM table [WHERE condition(s)] [ORDER BY {column, expr, numeric_position} [ASC|DESC]];
SQL Functions: There are two types of functions: Single-row functions and Multiple-row functions
Single-Row Functions: These functions operate on single rows only and return one result per row. There are
different types of single-row functions.
▪ Character functions: Accept character input and can return both character and number values. Character
functions can be divided into the following:
Case-manipulation functions:
o LOWER(column|expression): Converts all letters in a string into lowercase.
o UPPER(column|expression): Converts all the letters in a string into uppercase.
o INITCAP(column|expression): Converts the first letter of each word in a string to uppercase, and
converts any remaining characters in each word to lowercase.
Character-manipulation functions:
o CONCAT(column1|expression1,column2|expression2): Adds two or more strings together.
o SUBSTR(column|expression, m, [n]): Returns specified characters from character value starting at
character position m, n characters long (If m is negative, the count starts from the end of the character
value. If n is omitted, all characters to the end of the string are returned.)
o LENGTH(column|expression): Returns the number of characters in the expression
o INSTR(column|expression,’string’, [,m], [n] ): Returns the numeric position of a named string.
Optionally, you can provide a position m to start searching, and the occurrence n of the string. m and n
default to 1, meaning start the search at the beginning of the search and report the first occurrence
o TRIM(leading|trailing|both, trim_character FROM trim_source): Enables you to trim heading or
trailing characters (or both) from a character string. If trim_character or trim_source is a character literal,
you must enclose it in single quotation marks.
▪ Number functions: Accept numeric input and return numeric values. ROUND, TRUNC and MOD are number
functions.
o ROUND(column|expression, n): Rounds a number to a specified number of decimal places.
o TRUNC(column|expression, n): Truncates the column, expression, or value to n decimal places or,
if n is omitted, n defaults to zero.
o MOD(m, n): Returns the remainder of m divided by n.
Multiple-Row Functions: Functions can manipulate groups of rows to give one result per group of rows. These
functions are also known as group functions.
Types of group functions:
▪ AVG([DISTINCT|ALL]n): Average value of n, ignoring null values.
▪ COUNT({*|[DISTINCT|ALL]expr}): Number of rows, where expression evaluates to something other than
null (count all selected rows using *, including duplicates and rows with nulls)

www.oliveboard.in
www.oliveboard.in

▪ MAX([DISTINCT|ALL]expr): Maximum value of expr, ignoring null values.


▪ MIN([DISTINCT|ALL]expr): Minimum value of expr, ignoring null values.
▪ STDDEV([DISTINCT|ALL]n): Standard deviation of n, ignoring null values.
▪ SUM([DISTINCT|ALL]n): Sum values of n, ignoring null values.
▪ VARIANCE([DISTINCT|ALL]n): Variance of n, ignoring null values.
GROUP BY Clause: GROUP BY clause is used to divide the rows in a table into groups. You can then use the group
functions to return summary information for each group.
SELECT column, group_function(column) FROM table [WHERE condition] [GROUP BY
group_by_expression] [ORDER BY column];
Subquery: The inner query (or subquery) returns a value that is used by the outer query (or main query). Using a
subquery is equivalent to performing two sequential queries and using the result of the first query as the search value
in the second query.
You can place the subquery in a number of SQL clauses, including the following:
o WHERE clause
o HAVING clause
o FROM clause
Syntax: SELECT select_list FROM table WHERE expr operator (SELECT select_list FROM table);
Types of Subqueries
o Single-row subqueries: Queries that return only one row from the inner SELECT statement. This type of
subquery uses a single-row operator (=, >, >=, <, <=, <>)
o Multiple-row subqueries: Queries that return more than one row from the inner SELECT statement.
Multiple-row subqueries returns more than one row.
o IN: Equal to any member in the list.
o ANY: Compare value to each value returned by the subquery. <ANY means less than the maximum.
>ANY means more than the minimum. =ANY is equivalent to IN.
o ALL: Compare value to every value returned by the subquery. >ALL means more than the maximum,
and <ALL means less than the minimum.
The NOT operator can be used with IN, ANY, and ALL operators.
Data Manipulation Language: A DML statement is executed when you:
▪ Add new rows to a table
▪ Modify existing rows in a table
▪ Remove existing rows from a table
A transaction consists of a collection of DML statements that form a logical unit of work.
1. INSERT Statement:
▪ Insert a new row containing values for each column.
▪ List values in the default order of the columns in the table
▪ Enclose character and date values in single quotation marks.
INSERT INTO table [(column1, column2...)] VALUES (value, value...);
With this syntax, only one row is inserted at a time.
2. UPDATE Statement: Modify existing rows with the UPDATE statement:
Syntax: UPDATE table SET column = value, column = value, ... WHERE condition;
• Specific row or rows are modified if you specify the WHERE clause:
• All rows in the table are modified if you omit the WHERE clause:
3. DELETE Statement: You can remove existing rows from a table by using the DELETE statement:
Syntax: DELETE [FROM] table [WHERE condition];
▪ Specific rows are deleted if you specify the WHERE clause:
▪ All rows in the table are deleted if you omit the WHERE clause:
4. TRUNCATE Statement: A more efficient method of emptying a table is with the TRUNCATE statement. You can
use the TRUNCATE statement to quickly remove all rows from a table or cluster. Removing rows with the TRUNCATE
statement is faster than removing them with the DELETE statement for the following reasons:
• The TRUNCATE statement is a data definition language (DDL) statement and generates no rollback information.

www.oliveboard.in
www.oliveboard.in

• Truncating a table does not fire the delete triggers of the table.
• If the table is the parent of a referential integrity constraint, you cannot truncate the table. You need to disable
the constraint before issuing the TRUNCATE statement.
Syntax: TRUNCATE TABLE table_name;
Database Transactions: Transactions give you more flexibility and control when changing data, and they ensure
data consistency in the event of user process failure or system failure.
A transaction begins when the first DML statement is encountered and ends when one of the following occurs:
▪ A COMMIT or ROLLBACK statement is issued.
▪ A DDL statement, such as CREATE, is issued.
▪ A DCL statement is issued.
▪ The user exits SQL Developer or SQL*Plus.
▪ A machine fails or the system crashes.
After one transaction ends, the next executable SQL statement automatically starts the next transaction. An DDL
statement or a DCL statement is automatically committed and therefore implicitly ends a transaction.
Transaction Control Statements: It can control the logic of transactions by using the following statements:
▪ COMMIT: Ends the current transaction by making all pending data changes permanent.
▪ SAVEPOINT name: Marks a savepoint within the current transaction
▪ ROLLBACK: ROLLBACK ends the current transaction by discarding all pending data changes.
▪ ROLLBACK TO SAVEPOINT name: ROLLBACK TO SAVEPOINT rolls back the current transaction to the
specified savepoint, thereby discarding any changes and or savepoints that were created after the savepoint
to which you are rolling back.
Drop table: A SQL drop table is used to delete a table definition and all the data from a table. When this command is
executed, all the information available in the table is lost forever, so you have to very careful while using this
command.
Syntax: DROP TABLE "table_name";
Index: An index is a schema object. It is used by the server to speed up the retrieval of rows by using a pointer. It
is used to retrieve data from the database very fast. An Index is used to speed up select queries and where clauses.
Indexes can be created or dropped without affecting the data.
Syntax for single column: CREATE INDEX index_name ON TABLE column;
Syntax for multiple columns: CREATE INDEX index_name ON TABLE (cloumn1, column2,.....);
File Organization: A file is organized logically as a sequence of records and it is collection of related information.
These records are mapped onto disk blocks. Blocks are of a fixed size determined by the physical properties of the
disk and by the operating system, record sizes vary. In a relational database, tuples of distinct relations are generally
of different sizes.
Types of File Organization: There are various ways for organizing files:
• Sequential file organization: It is the simplest method for organizing files. There are two types of
sequential file organization methods:
o Pile File Method: In this method we store records one after another in a sequence in which they
inserted into the tables and records are nothing but a row in the table.
o Sorted File Method: It is designed for efficient processing of records in sorted order based on some
search key. A search key is any attribute or set of attributes; it need not be the primary key, or even
a super-key.
• Cluster file organization: A clustering file organization is a file organization that stores related records of
two or more relations in same file and these files will have two or more tables in the same data block and the
key attributes which are used to map these table together are stored only once. Two type of Cluster File
Organization:
o Indexed Clusters: In this, records are grouped based on the cluster key and stored together.
o Hash Clusters: This is very much similar to indexed cluster with only difference that instead of
storing the records based on cluster key, we generate hash key value and store the records with same
hash key value.
• Heap file organization: Heap File Organization is the simplest and most basic type of organization and it
works with data blocks. In this method records are inserted at the end of the file, into the data blocks. No
Sorting or Ordering is required in this method. If a data block is full, the new record is stored in some other

www.oliveboard.in
www.oliveboard.in

block, Here the other data block need not be the very next data block, but it can be any block in the memory.
This is also known as an unordered file.
• Hash file organization: In a hash file organization, we obtain the address of the disk block containing a
desired record directly by computing a function on the search-key value of the record. In our description of
hashing, we shall use the term bucket to denote a unit of storage that can store one or more records. A
bucket is typically a disk block but could be chosen to be smaller or larger than a disk block.
Indexing: Indexing is used to gain fast random access to records in file structure. Each index structure is associated
with a particular search key. Indexing is a data structure technique which is used to quickly locate and access the
data in a database.
An index record, or index entry, consists of a search-key value, and pointers or data reference to one or more
records with that value as their search-key value. The pointer to a record consists of the identifier of a disk block and
an offset within the disk block to identify the record within the block.
A file may have several indices, on different search keys.
Primary index is an index whose search key also defines the sequential order of the file. Primary indices are also
called clustering indices. The search key of a primary index is usually the primary key, although that is not
necessarily. Such files, with a primary index on the search key, are called index-sequential files.
Indices whose search key specifies an order different from the sequential order of the file are called secondary
indices, or non-clustering indices.
Two types of ordered Indices:
▪ Dense Indices: An index record appears for every search-key value in the file and the number of records in
the index table is same as the number of records in the main table.
▪ Sparse Indices: An index record appears for only some of the search-key values.
Multilevel Indices: If our file is extremely large, even the outer index may grow too large to fit in main memory. In
such a case, we can create yet another level of index. Indeed, we can repeat this process as many times as
necessary. Indices with two or more levels are called multilevel indices.
Hashing: In a huge database structure, it is very inefficient to search all the index values and reach the desired data.
The memory location where these records are stored is called as data block or data bucket.
In this, a hash function can choose any of the column value to generate the address. Most of the time, the hash
function uses the primary key to generate the address of the data block.
Two types of Hashing:
1) Static Hashing: In static hashing, when a search-key value is provided, the hash function always computes the
same address.
If we want to insert some new record into the file but the address of a data bucket generated by the hash function is
not empty, or data already exists in that address. This situation in the static hashing is known as bucket overflow.
This is a critical situation in this method. There are various methods to overcome this situation:
a) Open Hashing: In Open hashing method, next available data block is used to enter the new record, instead of
overwriting older one. This method is also called linear probing.
b) Close Hashing: In Closed hashing method, a new data bucket is allocated with same address and is linked it after
the full data bucket. This method is also known as overflow chaining.
2) Dynamic Hashing: In Dynamic hashing, data buckets grow or shrink (added or removed dynamically) as the
records increases or decreases. Dynamic hashing is also known as extended hashing.

www.oliveboard.in
www.oliveboard.in

Lesson 4: Overview of Computer Network


Computer Network: Computer network is a set of devices that are connected through a transmission medium and
used for communication between different devices. Connected devices are called Nodes and cable, wires and optical
fibres are used as transmission medium.

Basic components: Five basic components of computer network are as follows:


• Sender: Device that sends data/information over network.
• Receiver: Device that receives data/information sent by the sender over network.
• Transmission Media: Physical path through which communication between sender and receiver takes place
in a network.
• Message: Piece of code/data/information that is transferred from one device to another device in computer
network through transmission media.
• Protocol: Set of rules or convention for the communication between devices in a computer network.
Hardware components used in computer network:
▪ Network Interface Card (NIC): NIC is a chip or circuit board installed on a computer to provide dedicated
network connection that helps to communicate with other devices. It is also known as Network Interface
Controller or Network Adaptor or LAN Adaptor.
▪ Hub: Basic networking device used to connect multiple devices in a network, and it is a broadcast device.
▪ Switch: Connects multiple devices on a network and it doesn’t broadcast. It sends the message from source
to destination directly.
▪ Router: Network device used to connect two or more networks together.
▪ Modem: Abbreviation for Modulator-Demodulator and used for data transfer between two or more computer
network using telephone lines.
▪ Cable: Used to connect one device to another device in a network and share resources such as printers and
scanners etc.
▪ Router: Networking device used to receive, analyse and forward data packets between computer networks.
▪ Bridge: Connect two or more communication networks to form a single aggregate network and this function
is called Bridging.
▪ Brouter: Networking device that functions as both bridge and router.
▪ Repeater: Networking device that regenerate or replicate a distorted signal. It receives a signal and relay
those messages between subnetworks after regenerating them.
Features of Computer Network: Basic features of computer network are as follows:
• Performance: Performance of a network depends on Transit time: Total time taken to travel a message
from one device to another device and Response time: Elapsed time between an inquiry on a system and
response to that inquiry.
• File/Data Sharing
• Backup and Recovery
• Scalability
• Reliability
• Security
• Software and Hardware compatibility
Architecture of Computer Network: Computer network architecture is the design of computer network that
specifies the physical components and their functional organisation, operational procedures and protocols used in the
network. There are two types of computer network architecture:
1. Peer-to-peer network: In peer-to-peer computer network, all the computers in the network are connected with
each other and each computer shared the equal privilege in the network, and it doesn’t have any central server.

www.oliveboard.in
www.oliveboard.in

2. Client/Server network: Mostly designed for end users to access resources from a central computer known as
server. Central computer acts as server and manages the request from client. All the shared data is stored in server
computer and make available to the client when a request is made.

Type of Computer Network: A computer network is group of computers that are connected to each other and
communicated with each other using transmission media in a network. Different type of computer networks are as
follows:
• Personal Area Network (PAN): PAN is computer network that enables communication near an individual
person who is also the owner of that network. It ranges approximately 10 meters and it can be both wired
such as USB and wireless such Bluetooth.
• Local Area Network (LAN): LAN is a computer network that connects computers within a limited
geographical area such as room, office and building etc. Devices in LAN are connected together by switch or
cable. Type of LAN network: LAN network is classified into two types:
• Ethernet: Ethernet is a way of connecting devices over LAN through twisted pair cable mostly RJ-45 port.
o Wireless LAN (WLAN): WLAN is also known as Local Area Wireless Network (LAWN) and
Wireless Fidelity (Wi-Fi) which is used to connect devices to a LAN through wireless connection.
Instead of cables radio waves are used for transmission. Four standards of wireless LANs are used:
802.11a, 802.11b, 802.11g and 802.11n
o Wide Area Network (WAN): Wide area network is computer network that is spread over a large
geographical space such as a state of country. A WAN connection is not limited to a single region, it
can be connection of many LANs connected together through telephone lines or fibre optic cables etc.
Since, WAN is spread over large geographical space hence data transmission rate of WAN is slow as
compared to LAN.
• Metropolitan Area Network (MAN): A metropolitan area network is a computer network that covers larger
geographical space than LAN but lesser that WAN by connecting two or more LAN networks through telephone
exchange line. It serves as an Internet Service Provider (ISP), but a MAN is not owned by a single
organization.
Network Topology: Network topology is the physical arrangement of network devices in a network. It tells how
devices are physically connected to each other within a computer network. There are different types of network
topology in the computer network:
1. Point-to-point topology: In point-to-point topology, exactly two hosts/devices are connected directly to each
other. There may be multiple intermediate devices between them, but the hosts are not aware of that it seems that
they connected to each other directly.

2. Bus topology: Bus topology is a network type in which all the devices are connected through a single cable known
as Backbone Cable or Bus. Each node is connected to this bus either directly or indirectly and it transmits the data

www.oliveboard.in
www.oliveboard.in

in only one direction. When a node wants to send a message, it places the message in the bus and every node
connected to that bus receives that message.

3. Ring topology: In Ring topology, each host is connected to its next host and final host in the network is
connected to first host thus form a ring. It is like a bus topology in which both the ends are connected to each other.
Token is used as carrier which is passed from one host to next host until it reaches its destination.

4. Star topology: In start topology, all the hosts are connected to single central host which is known as Hub or
Server and all the devices which is connected to the server are known as Clients.

5. Tree topology: Tree topology is also known as Hierarchal topology and most widely used presently. It combines
the characteristics of both Star and Bus topology. Top-most node in the hierarchy is known as root node and there is
only one path exists between any two nodes for data transmission.

6. Mesh topology: In mesh topology, each host is connected to all the other host present in the network. This
topology follows peer-to-peer network type in which there is connection between each and every host. There are two
types of Mesh topology:
a) Full Mesh: In full mesh, there is a direct connection between each and every node in the network. Thus, in a
full mesh topology of ‘n’ host total connections would be [n (n – 1)/2]
b) Partial Mesh: In partial mesh, not all the host have direct connection between them.

www.oliveboard.in
www.oliveboard.in

Note: Figure given above is the example of full mesh topology.


7. Hybrid topology: A network topology which is a combination of more than one network topologies is called Hybrid
topology. If two or more similar topologies are connected together, then there will be no Hybrid topology.

Transmission modes: In computer network, data is transferred from one device to another device for
communication. The data is transferred through a transmission mode and this transmission mode decides the
direction of flow of data. Transmission mode is divided into three categories:
1. Simplex Mode: Data is transferred between two devices in one direction only. A device can either send the data
or receive the data, it can’t both send and receive the data. Ex: Television, keyboard, monitor and Radio etc.

2. Half-duplex Mode: Data can be transferred in both ways but not simultaneously. A host/device can work as both
sender or receiver but not at the same time. Ex: Walkie-Talkie.

3. Full-duplex Mode: In full-duplex mode of data transfer, data can be transferred in both the direction
simultaneously. A device works as both sender and receiver and can receive or send the data simultaneously. Ex:
Telephone network.

Network Models: Computer network model is responsible for establishing a connection between sender and receiver
in a computer network. Networking concept is divided into different layers and each layer has its particular task. This
is called layered approach of network model and there are two network models: OSI model and TCP/IP model.
Layered Architecture: In layered architecture whole task is divided into subtasks and each subtask is assigned to a
particular layer. These layers are connected with each other and each lower layer adds its services to the higher layer
to manage the communication. The number of layers and function of each layer depends on the network and varies
from network to network.
OSI Model: OSI models stands for Open System Interconnection model and it is reference model that describes how
data/information from one device is transferred to another device. This model is established by International Standard
Organization (ISO) and it is a seven layers architecture model:

www.oliveboard.in
www.oliveboard.in

These seven layers architecture is divided into two group: Upper layer and Lower layer.
Upper Layer: Upper layer of the OSI model consists of four layers: Application, Presentation, Session and Transport
layer. Upper layer is the responsibility of the host and it deals mainly with the application related issues. So,
application layer is closed to the end user.
Lower Layer: Lower layer of OSI model consists of three remaining layers: Network, Data Link and Physical layer.
Lower layer deals with the data transfer issues and it the responsibility of the network. In lower layer, Physical layer is
closest to the Physical medium.
Functions of the OSI layers:
1. Physical Layer: Physical layer is the lowest layer in the OSI model, and it contains information in the form of bits.
The main function of physical layer is to transmit individual bits from one device to another device and is responsible
for actual physical connection between devices. Function of physical layer:
• Bit representation: This layer contains data in the form of stream of bits and for transmission these bits (0s
and 1s) must be converted into signals.
• Transmission rate: This layer also defines the data rate (bits per second) at which the transmission of bit
take place.
• Bit synchronization: This layer controls both sender and receiver by providing a clock thus sender and
receiver both are synchronised at bit level.
• Physical topology: This layer also defines the way in which devices are connected to each other physically.
• Transmission mode: It also defines the direction of transmission between two devices. Transmission mode
may either simplex, duplex or full duplex.
Devices used: Hub, Repeater, Cable and ISDN Adapter etc.
Protocols used: Digital Subscriber Line (DSL), CSMA/CD, USB protocol and IEEE standards.
Important IEEE standards are given below:
• IEEE 802.2: Logical link control.
• IEEE 802.3: Ethernet.
• IEEE 802.5: Token ring.
• IEEE 802.11: Wireless network standard.
Multiplexing: Multiplexing is the process of combining the data streams and sending them over a single shared
medium. The device used for multiplexing is called Multiplexer (MUX) which follows many-to-one. Multiplexing
techniques can be divided into three types:
a. Frequency-division Multiplexing (FDM): FDM is analog technique in which available bandwidth of single
transmission medium is subdivided into different frequency channels and each channel is given to different
users/devices for exclusive access.
b. Wavelength-division Multiplexing (WDM): WDM is similar to FDM as it is also an analog technique, but it is
used when optical signals (light waves) transmitted through fibre optics cable. Light has multiple wavelength and
multiple optical signals are multiplexed by using different wavelength in fibre optics.
c. Time-division Multiplexing (TDM): In TDM, each user gets the entire bandwidth of the channel for small period
of time and data is not transmitted simultaneously rather it is transmitted one by one. In TDM, signals are
transmitted in the form of frames. There are two types of TDM:
• Synchronous TDM: In synchronous TDM, time slot is preassigned to every devices and both sender and
receiver must agree to that.
• Asynchronous TDM: In asynchronous TDM, time slot is not fixed, and time slot is allocated to only those
devices which have the data to send.

www.oliveboard.in
www.oliveboard.in

2. Data Link Layer: Data Link Layer is the second layer of OSI model, and it receives data packets from Network
layer and further divides them into frames. This layer is responsible for error free transfer of data frames between
devices. This layer is further divided into two parts:
1) Logical Link Layer: It deals with error control, flow control and multiplexing of different protocols.
2) Media Access Control Layer: This layer is a link between logical link layer (LLC) and physical later of OSI
model and it deals with the actual control of data transmission.
Function of data link layer:
• Framing: Data link layer receives packets of data from network layer and converts them into frames. It also
adds header and trailer to frame, header contains the destination address and trailer contains the CRC to
control error.
• Physical Addressing: Header of the frame contains the address of destination.
• Error detection and control: CRC at the end of frame detects error or duplication in the frame. Once error
is detected that frame is retransmitted.
• Flow control: Provide constant data flow between sender and receiver so that no data get corrupted.
• Access control: Protocols in this layers determine which device has control over the communication link at
any given time.
Devices used: Layer-2 switch, Bridge and Modem etc.
Protocols used: Point-to-point protocol (PPP), Serial Line Internet Protocol (SLIP), Address Resolution Protocol
(ARP) and Asynchronous Transfer Mode (ATM).
Switching: Switching is a process of forwarding packets from source node to destination node through various
intermediate nodes in a network. Data comes on a port is called ingress and data that leaves or goes out from a port
is called egress. Following are given the switching techniques:
1) Circuit Switching: Circuit switching a method to establish a dedicated communication link between sender and
receiver for data transfer before the start of communication. To establish a dedicated path, sender sent a request
signal to receiver which sends acknowledge to the sender to ensure the availability of the path.
2) Message Switching: Message switching is a method in which whole message is treated as a data unit and is
transferred as a complete unit. Establishment of dedicated path between nodes is not necessary and it follows the
concept of store and forward. Message switching uses dynamic routing; address of destination is appended to the
message which is routed through intermediate nodes. Each node stores the entire message and forward it to next
node based on the information available in the message hence, it is known as store and forward network.
3) Packet Switching: Packet switching is switching techniques of sending data over network in one go. In this
technique, complete message is divided into smaller part known as packet and every packet contains some
information such as sequence number, source and destination address.
All the packets are treated as individual entity and travel across network by following same or different routes. Every
packets are received at receiver end in correct order of sequence number. A resend request is sent for any missing or
corrupted packet and acknowledge is sent for correct order of packets.
3. Network Layer: Layer 3 in the OSI model is known as network layer which deals with the transmission of data
from one device to another device in different network. This layer is responsible for routing and forwarding the
packets across multiple networks. Functions of network layer:
• Logical Addressing: Network layer adds sender’s and receiver’s IP address to data packet so that correct
destination is identified in the network and data packet reach the correct destination.
• Routing: There are various routes available for transmitting data packets from sender to receiver. Routing is
the mechanism of detecting the best optimal route out of available routes
• Internetworking: Internetworking is the main responsibility of network layer which provides the logical
connection between devices over network.
Devices Used: Router, Brouter and Layer-3 Switch etc.
Protocol Used: IPv4/IPv6 Internet Protocol, Routing Information Protocol (RIP), Internet Control Message Protocol
(ICMP), Internet Group Management Protocol (IGMP) and Exterior Gateway Protocol (EGP).
Network Addressing: Network addressing is one of the major function of network layer and network addresses are
logical address also known as IP address. A network address can represent a node (client or server) or whole
network. IP address is 32-bit long (4 bytes) and is represented using ‘dot-decimal’ or ‘dot-binary’ notation. Each IP
address has two parts: first part represents the network and second part represents the Host. IP addressing are of
two types:
• Static IP address: IP addresses that once assigned to a network or network element remains same. These
are assigned manually and permanent IP addresses.

www.oliveboard.in
www.oliveboard.in

• Dynamic IP address: Temporarily assigned IP address to a network or network element are called Dynamic
IP address.
An IP address is divided into two parts: Network ID (Represent the number of networks) and Host ID (Represents
the number of Hosts).
IP addresses can be represented using binary notation or decimal notation. Ex: 00101101.10101101.01010110.
01110111 or 45.173.86.119
Classful addressing: In Classful addressing, IP addresses are divided into 5 classes:
Class A: First 8 bits are used for network ID and remaining 24 bits are used for host ID.
First bit of network ID is set to ‘0’.
• Number of networks = 27
• Number of Hosts = 224
• Total IP addresses = 231
• Range of IP addresses = 0.0.0.0 to 127.255.255.255
Class B: First 16 bits are used for network ID and remaining 16 bits are used for host ID
First two bits of network ID is set to ‘10’.
• Number of networks = 214
• Number of Hosts = 216
• Total IP addresses = 230
• Range of IP addresses = 128.0.0.0 to 191.255.255.255
Class C: First 24 bits are used for network ID and remaining 8 bits are used for host ID
First three bits of network ID is set to ‘110’.
• Number of networks = 221
• Number of Hosts = 28
• Total IP addresses = 229
• Range of IP addresses = 192.0.0.0 to 223.255.255.255
Class D: Class D is not divided into Network ID and Host ID and is reserved for Multicast address.
First fours bits are set to ‘1110’ and remaining 28 bits determines the possible host in any network.
• Possible hosts = 228
• Range of IP addresses = 224.0.0.0 to 239.255.255.255
Class E: Class E is also not divided into Network ID and Host ID and is reserved for future use and or for the research
and development purpose.
First fours bits are set to ‘1111’ and remaining 28 bits determines the possible host in any network.
• Possible hosts = 228
• Range of IP addresses = 240.0.0.0 to 255.255.255.255
Classless Addressing: In classless addressing, there is no concept of classes. It follows the concept of Classless
Inter Domain Routing (CIDR) blocks. It is an improved version of classful addressing as there is no wastage of IP
addresses. It is represented as x.y.z.w/n where ‘x’, ‘y’, ‘z’ and ‘w’ are octet while ‘n‘ works as mask which represents
the number of blocks or network.
Ex: 196.172.56.28/20
Number of block ID = 20
Number of Host ID = 32 – 20 = 12, number of hosts in the network = 212
4. Transport Layer: Transport layer is the 4th layer in the OSI model and it receives the data from its above layer
and converts them into smaller data unit called segments and each segment is assigned with a segment number that
uniquely identifies each segment. Functions of Transport layer:

www.oliveboard.in
www.oliveboard.in

• Service point addressing: Transport layer adds Service point addressing (port address) to the header and
passes that data with header to network layer.
• Segmentation and Reassembly: Transport layer divided the message from upper layer into segments at
sender’s end.
• Connection control: It provides two type of connections:
o Connection oriented: This includes three phases: Connection establishment, Data transfer and
Disconnection.
o Connectionless: In this type of transmission only data transfer takes place and receiver didn’t send
any acknowledge to the sender.
• Flow control: This layer is responsible to provide end-to-end flow control.
• Error control: This layer is responsible for end-to-end error control and ensures the error free delivery of
data.
Devices Used: Gateways and Firewalls.
Protocols Used: Transmission Control Protocol (TCP/IP), User Datagram Protocol (UDP) and Datagram Congestion
Control Protocol (DCCP).
5. Session Layer: Session layer is the 5th layer and is responsible for connection establishment, session
maintenance, authentication and security. Functions of Session layer:
• Session management: Session layer is responsible for establishment, maintenance and termination of
session between two processes.
• Synchronization and recovery: This layer add some checkpoints before the transmission which allows the
recovery from checkpoint in case of error of failure.
• Dialog Control: This layers works as a dialog controller between two processes and allows two processes to
communicate either in half duplex or in full duplex.
Devices Used: Gateways and Protocols.
Protocols Used: Real-time Transport Protocol (RTP), Point-to-point Tunnelling Protocol (PPTP), Session
Announcement Protocol (SAP) and Socket Secure (SOCKS).
6. Presentation Layer: Presentation layer takes care of the syntax and semantics of the information exchanged
between two processes. It receives the data from application layer and extract that from one format to another
format as per the requirement. Hence, this layer is also known as translation layer. Functions of Presentation layer:
• Translation: Data or information received from application layer is in the form of characters and numbers.
Presentation layer translate this data into other formats as per the requirement.
• Encryption/Decryption: This layer performs encryption operation to protect the actual data from
unauthorised access at sender’s end and decryption operation at receiver’s end.
• Compression: Data compression is also performed by presentation layer. Compression is the process of
reducing numbers of bits to be transmitted for faster transmission over network.
Devices Used: Gateways and Firewalls.
Protocols Used: Multipurpose International Mail Extension (MIME), Apple Filling Protocol (AFP), Netware Core
Protocol (NCP) and Network Data Representation (NDR).
7. Application Layer: Application layer is the top-most layer of OSI model and works as the window for end users
and application programs to access network services. Functions of Application layer:
• File Transfer Access and Management (FTAM): Application layers allows end user to access and manage
files and users can also access files from a remote computer.
• Mail service: This layer provides services for e-mail forwarding and storage.
• Directory service: Application layer provides access to global information about various objects stored in
distributed database.
Devices Used: Gateways, Firewalls and all end user devices such as PC, Mobile phones etc.
Protocols Used: Dynamic Host Configuration Protocol (DHCP), Domain Name Server (DNS), File Transfer Protocol
(FTP), TELecommunication NETwork (TELNET), Internet Message Access Protocol (IMAP), Post Office Protocol
(POP), Hyper Text Transfer Protocol (HTTP), Simple Mail Transfer Protocol (SMTP) and Simple Network Management
Protocol (SNMP).
TCP/IP Model: TCP/IP model is designed before the OSI model by the Department of Defence (DoD) and is based on
standard protocols and this model consists of four layers.

www.oliveboard.in
www.oliveboard.in

Transmission Medium: Transmission medium is the communication mean by which data/information is transferred
from sender to receiver. Transmission medium is responsible for carrying the data/information from source to
destination and it is a physical between sender and receiver. Classification of Transmission Medium: Guided Media
and Unguided Media.
Guided Media: Transmission medium in which signals are transmitted in a directed way in a physical limit of medium
using physical links. It is also known as Wired or Bounded transmission medium.
Types of Guided Media:
1. Twisted Pair cable: Twisted pair cables are generally two separated cables (mostly copper) twisted together.
Twisted pair cable is of two types:
a) Unshielded Twisted Pair (UTP): It is the most common type of twisted pair cable used for
telecommunication. Each cable that is twisted has its own colour plastic insulator for identification and this
type of cable has the ability to block interference without physical shield.
b) Shielded Twisted Pair (STP): A shielded twisted pair is a twisted pair cable that contains the shield around
the wires to reduce external interference and to achieve higher transmission rate.
2. Coaxial Cable: Coaxial cable is commonly used in transmission media and as the name suggest it has two
conductors parallel to each other with shielding. Coaxial cable is of two types:
a) Baseband: It is signalling technology that sends digital signal over a signal frequency.
b) Broadband: Signalling technology that sends digital signals simultaneously over a range of different
frequency.
3. Fibre Optics: Fibre optics cable is made up of glass or plastic and it uses the total internal reflection (TIR)
property of light. In TIR, when light ray hits at critical angle it tends to refract at 90 0. In this, Core is made up of
glass or plastic which is surrounded by less dense glass or plastic called Cladding. The cladding is surrounded by
protective coating of plastic known as Jacket that protect the cable from shock, distortion and preserve its strength.
Unguided media: In unguided media no physical medium is required for transmission hence, it is also called
Wireless or Unbounded media. In unguided media, air is the medium through which electromagnetic signals travels
and there is no need for physical conductor. Unguided media is broadly classified into following types:
1. Radio wave: Electromagnetic waves of frequency range from 3KHz to 1GHz are called Radio waves and these
waves can be transmitted in all direction hence called Omnidirectional.
2. Microwave: Electromagnetic waves of frequency range from 1GHz to 300GHz are called Microwaves and these
waves cannot be transmitted in all direction. These are unidirectional and can transmit in one direction only.
3. Infrared: Electromagnetic waves of frequency range from 300GHz to 400THz are called Infrared waves and used
for short range communication.
Network Security: Network security is the security provided to a computer network by network administrator to
monitor and prevent unauthorised access to the network from outside attackers. In network security CIA triad is most
important model, in which CIA stands for: Confidentiality, Integrity and Availability.
• Confidentiality: Confidentiality means to avoid unauthorised access or misuse of data or information that is
sent over a network.
• Integrity: Integrity mean to avoid alteration of data from unauthorised user.
• Availability: Availability means the uninterrupted and timely access to the data from authorised user.
Non-repudiation: The receiver of the data must be able to prove that the received data has come from the specific
sender. The sender can’t deny later on that he/she didn’t send that data.
Cryptography: Cryptography is the process of converting original plain text message into non-readable cipher text
and vice versa. Some components of cryptography are:

www.oliveboard.in
www.oliveboard.in

• Plain Text: Original data.


• Cipher Text: Coded data.
• Encryption Algorithm: Process of encoding plain text to cipher text.
• Decryption Algorithm: Process of decoding cipher text to plain text.
• Encryption Key: Encryption key is a value known to the sender used to transform the plain text into cipher
text.
• Decryption Key: Decryption key is a value known to the receiver used to transform the cipher text into plain
text.
There are two types of encryption/decryption technique:
1. Secret (Private) key encryption/decryption: In secret key encryption/decryption, both sender and receiver
use the same key to encrypt and decrypt the message. Sender uses secret key and encryption algorithm to decode
the message and then send the cipher text and secret key separately to the receiver. Receiver after receiving the
cipher text uses the same secret key and decryption algorithm to decode the cipher text. This is also known as
Private key cryptography or Symmetric key Cryptography.
2. Public key encryption/decryption: In public key encryption/decryption, two different keys are used for
encryption and decryption. Each user has its own private key and single public key which is announced publicly. Both
public and private key of a user is different but mathematically related. Sender uses receiver’s public key along with
encryption algorithm to encrypt the plain text into cipher text and receiver uses its private key and decryption
algorithm to decrypt the cipher text into plain text. It is also known as Asymmetric key cryptography.
Digital Signature: Digital signature is a process of signing a document digitally and it is a cryptographic value that is
calculated from the data and a secret key known by only signer.
Digital signature can’t be done by using secret key cryptography. Three aspects of network security such as: Data
Integrity, Authentication and Non-repudiation are maintained using digital signature except Data privacy. Any
unauthorised user can decrypt the signed document using sender’s public key.
Digital signature by signing the digest: Message digest is created by using hash function and this process of
creating digest from original message is known as hashing. Encrypted digest is sent along with the original plain text.
Receiver receives the original plain text along with digest and separates the both. Checks the signature of digest and
decrypt it and creates another digest from the original message using the same hash function. If both the digests are
same, then it is ensured that all the four aspects of network are preserved.
Hashing: Hashing a mathematical function that converts a variable length message into a fixed length compressed
message. Input to hash function can be of variable length but the output will always be a fixed length message. Two
common hash functions used are:
• Message Digest 5 (MD5): MD5 is a widely used Hash function developed by Ron Rivest. It is a
cryptographic hash function which is very fast and generates a 128-bit hash value.
• Secure Hash Algorithm 1 (SHA1): SHA1 is a cryptographic hash function developed by United States
National Security Agency. It takes input and produces a 160-bit hash value.
Pretty Good Privacy (PGP): PGP is an encryption algorithm that provides all four aspects of network security:
Privacy, Integrity, Authentication and Non-repudiation. PGP is used for signing, encrypting and decrypting e-mail,
texts, files and directories etc and uses a digital signature (combination of hashing and public key encryption) to
ensure integrity, authentication and non-repudiation and uses secret key encryption and public key encryption to
ensure privacy.
Steps involved in PGP at Sender’s side:
• Using hash function, digest is created after hashing the message.
• This digest is encrypted using sender’s private key to create signed digest and then this signed digest is
added to the original message.
• Original message and signed digest together are encrypted by using one-time secret key created by sender.
• Sender encrypted this one-time secret key using receiver’s public key.
• Now, both message along with signed digest and encrypted secret key is sent together.
Steps involved in PGP at Receiver’s side:
• Encrypted (Message + Signed digest + Secret key) together is received by Receiver.

www.oliveboard.in
www.oliveboard.in

• Receiver decrypted this secret key using receiver’s public key to get one-time secret key.
• Encrypted (Message + Signed digest) are decrypted by using one-time secret key created by sender to get
signed digest and original message.
• Signed digest is decrypted using sender’s public key to get digest and from the original message by using
hash function, digest is created.
• Two digests are compared to check the message security.
Network Security Threats: Network security is an important aspects and some of the network security threat is
given below:
• Virus: A computer virus is a program that infects a computer system or network by replicating itself or by
injecting its own code.
• Spyware: A software code that gathers information flowing through communication media and provides that
knowledge to another unauthorised customer.
• Adware: Adware or Advertising supported software are computer programs that are displayed as a banner
while a program is running.
• Trojan Horse: Computer program that is downloaded and installed on a computer which misleads users of its
real intent and appears harmless.
• Worms: Standalone malware program that is intended to spread itself to other computers through network in
order to breach security on targeted computers.
• Phishing: Phishing is false attempt to obtains sensitive information while disguising himself as a trustworthy
entity or user.
• Denial of Service (DoS) attack: DoS is cyber-attack in which the attacker makes the machine and
resources unavailable for its legitimate user by malicious cyber-attack.
Phases of Virus: During its lifetime a computer goes through different phases:
• Dormant Phases: Waiting for some event to happen to activate itself.
• Propagation Phase: Places an identical copy into other computer in order to affect those.
• Triggering Phase: Activated to perform the functions for which it is created or designed.
• Execution Phase: In this phase the function of the virus is performed for which it is designed.
Type of Virus: There are various type of viruses:
• Resident Virus: Virus that stores itself in the RAM of computer and infect other files or programs even the
infected file is no longer exist.
• Multipartite Virus: Virus that can spread itself and affect computer system in many ways. It can affect both
executable file and boot sector file.
• Boot Sector Virus: Virus that activates when the booting of computer takes place and can affect the master
boot record (MBR) of hard disk.
• Macro Virus: Virus that is written in same language in which software programs are written. It can spread to
other computers through software programs that utilize macros.
• Non-resident Virus: Virus that are not stored in computer’s RAM and need to be executed before it can
affect.
• Stealth Virus: Virus designed to keep itself hidden from the antivirus programs.
• Polymorphic Virus: Virus that can upgrade itself to a modified version in order to make its detection
impossible by the antivirus programs.
• Metamorphic Virus: Polymorphic can upgrade itself so that its detection becomes difficult but metamorphic
virus can change its code as well as its behaviour in order to hide itself.
Online Spying tools/common hacking methods:
• Cookies: Small text files stored on a user’s computer and contains modest information such as IP address
and make it easy for the server to find and manage your preferences.
• Web Bugs: Also known as Web beacon, is a small file object typically used by third party to monitor the user
activity.
• Spyware: Unwanted software programs that can record or steal user’s information by keeping track of
individual keyword, web pages and other type of data.
• Sniffing: Process of stealing and capturing the sensitive information of users such as password, pin and CVV
by monitoring all the packets passing through a given network.
• Spoofing: A situation in which an unauthorised person or user can pretend to be a legitimate user to gain
illegitimate advantages.

www.oliveboard.in
www.oliveboard.in

• Social Engineering: Social engineering is the art of manipulating users/people to get confidential
information.
Firewalls: In information security, firewall is a network security system that monitors and controls the incoming and
outgoing data into a network by predetermined rules. Firewall is designed in such a way that the unauthorised access
to or from the network can be prevented and it can be both software and hardware or combination of both. A firewall
works as a barriers between internal network and external network. Firewall can be categorised into following
categories:
1. Packet-filtering firewall: Each incoming and outgoing packets are inspect based on certain rule defined,
host and destination IP address, packet type, port number and other information without opening the packet.
2. Circuit-level gateway: Works at the session layer of OSI model and monitors TCP handshake to determine
whether the packet is legitimate or not. It allows only those packets which has right TCP handshake without
knowing the content of the packet.
3. Stateful Inspection firewall: Also known as dynamic filtering and uses combination of both packet
inspection technology and TCP handshake to increase the level of protection.
4. Application-level gateway (Proxy firewall): Proxy firewall works at application layer of OSI model hence
also called Application-level gateway. Proxy firewall first establish a connection to the source of the traffic and
based on the inspection filter the incoming traffic between your network and the traffic source.
5. Next-generation firewall: Next-generation firewall is a technology that combine traditional firewall
functionality such as packet inspection technology, TCP handshaking and deep packet inspection along with
intrusion prevention system.

www.oliveboard.in
www.oliveboard.in

Lesson 5: Data Structure


Data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.
Classification of data structure: Data structure are generally categorized into two types:
• Primitive Data Structure: Basic data types such as Integer, Real, Character and Boolean are known as primitive
data structure. They are also known as simple data types.
• Non-Primitive Data structure: Based on structure and arrangement of data, non-primitive data structures are
further classified into two types:
o Linear Data Structure: In linear data structure, data is arranged in a linear manner or in a sequence but the
way they stored into the memory need not to be in the sequential.
▪ Arrays
▪ Linked Lists
▪ Stacks
▪ Queues
o Non-Linear Data structure: A data structure said to non-linear if the data is not arranged in sequence.
▪ Trees
▪ Graphs
Data structure operations: The following four operations used in Data structure:
• Traversing: Accessing each record exactly once.
• Searching: Finding the location of the record with a given key value.
• Inserting: Adding a new record to the structure.
• Deleting: Deleting a new record to the structure.
• Sorting: Arranging the records in some logical order.
• Merging: Combining the records in two different sorted files into a single file.
Abstract Data Type: An abstract data type (ADT) is a set of values and associated operations that specified
precisely, and it does not have any particular implementation details. With an ADT, we know what a specific data type
can do, but how it actually does is hidden.
Algorithm: An algorithm is any well-defined computational procedure that takes some value, or set of values, as
input and produces some value, or set of values, as output. An algorithm is thus a sequence of computational steps
that transform the input into the output. The two major aspects of the efficiency of an algorithm are uses of time and
space. The complexity of an algorithm is the function which gives the running time or space in terms of input size.
Complexity of an Algorithm: The complexity of an algorithm is the function f(n), which gives the running time or
storage space requirement of the algorithm in terms of the size n of the input data. There are three cases for
complexity of an algorithm:
• Worst Case: The maximum values of f(n) for any possible input for which the algorithm takes a long time
(slowest time to complete).
• Average Case: The expected values of f(n) which provides a prediction about the running time of the
algorithm.
• Best Case: The minimum values of f(n) for any possible input for which the algorithm takes the least time
(fastest time to complete).
Array: An array is a collection of variables of the same data type that are referred to a common name. A specific
element in an array is accessed by an index. The elements of array share the same variable name but each one
carries a different index number known as subscript. The array can be one dimensional, two dimensional or
multidimensional.

Linked List: A linked list is a data structure used for storing collections of data. A linked list has the following
properties.

www.oliveboard.in
www.oliveboard.in

• Successive elements are connected by pointers.


• The last element points to NULL.
• Can grow or shrink in size during execution of a program.
• Can be made just as long as required (until systems memory exhausts).
• Does not waste memory space (but takes some extra memory for pointers). It allocates memory as list
grows.
There are three types of Linked List:
Singly Linked Lists: Generally, “linked list” means a singly linked list. This list consists of a number of nodes in
which each node has a next pointer to the following element. The link of the last node in the list is NULL, which
indicates the end of the list.

Doubly Linked Lists: A Doubly Linked List (DLL) contains an extra pointer, typically called previous pointer, together
with next pointer and data which are there in singly linked list.

Circular Linked Lists: In singly linked lists and doubly linked lists, the end of lists is indicated with NULL value. But
circular linked lists do not have ends. In circular linked lists, each node has a successor. A circular linked list can be a
singly circular linked list or doubly circular linked list.

Uses of Circular Linked List:


Circular linked lists are used in managing the computing resources of a computer. We can use circular lists for
implementing stacks and queues.
Singly Circular Linked List: Singly Circular Linked List has properties of both singly linked list and circular linked
list. In Singly circular Linked List, the next pointer of the last node points to the first node.

Doubly Circular Linked List: Circular Doubly Linked List has properties of both doubly linked list and circular linked
list in which two consecutive elements are linked or connected by previous and next pointer and the last node points
to first node by next pointer and also the first node points to last node by previous pointer.

Stack: A stack is a list of elements in which insertion and deletion are done at one end, called top. The last element
inserted is the first one to be deleted. Hence, it is called the Last in First out (LIFO) or First in Last out (FILO) list.

www.oliveboard.in
www.oliveboard.in

Stack operations:
• Push(): Inserts data onto stack.
• Pop(): Removes and returns the last inserted element from the stack.
• Top(): Returns the last inserted element without removing it.
• Size(): Returns the number of elements stored in the stack.
• IsEmptyStack(): Indicates whether any elements are stored in the stack or not.
• IsFullStack(): Indicates whether the stack is full or not.
There are two exceptions in a stack: Trying to pop out an empty stack is called underflow and trying to push an
element in a full stack is called overflow.
• Infix Notation: When an operator is in-between every pair of operands is called Infix Notation. For example:
(a + b), (a – b) etc.
• Postfix Notation: When an operator is followed by every pair of operands is called Postfix Notation. This is
also known as reverse polish notation. For example: ab+, ab* etc.
• Prefix Notation: When an operator is preceded by every pair of operands is called prefix Notation. This is
also known as polish notation. For example: +ab, -ab, *ab etc.
Level of Precedence:
• Highest: Parenthesis and brackets (“[]”, “{}”, “()”).
• Next Highest: Exponential (“^”).
• Next Highest: (“*”, “/”)
• Lowest: (“+”, “-”)
Queue: A queue is a linear list of elements in which insertions are done at one end (rear) and deletions are done at
another end (front). The first element to be inserted is the first one to be deleted. Hence, it is called First in First out
(FIFO) or Last in Last out (LILO) list.

When an element is inserted in a queue, the concept is called EnQueue, and when an element is removed from the
queue, the concept is called DeQueue.
Queue Operations:
• EnQueue(): Inserts an element at the end of the queue
• DeQueue(): Removes and returns the element at the front of the queue
• Front(): Returns the element at the front without removing it
• Rear(): Returns the element at the rear without removing it
• QueueSize(): Returns the number of elements stored in the queue
• IsEmptyQueue(): Indicates whether no elements are stored in the queue or not
• IsFullQueue(): Indicates whether the queue is full or not.
Circular Queue: Circular Queue is a linear data structure in which the operations are performed based on FIFO (First
In First Out) principle and the last position is connected back to the first position to make a circle. It is also called
‘Ring Buffer’.

www.oliveboard.in
www.oliveboard.in

Priority Queue: A priority queue is a collection of elements such that each element assigned a priority and such that
the order in which elements are Dequeued and processed comes from the following rules:
• An element with high priority is processed before any element of lower priority.
• Two elements with the same priority are processed according to the order in which they were added to the
queue.
Operation of priority queue:
• insert(item, priority): Inserts an item with given priority.
• getHighestPriority(): Returns the highest priority item.
• deleteHighestPriority(): Removes the highest priority item.
Application of Priority Queue:
• All Queue applications where priority is used.
• Graph algorithm (for example: Dijkstra Shortest Path algorithm, Minimum Spanning tree problem etc.)
• CPU Scheduling.
Tree: Tree is a nonlinear data structure and it is a way of representing the hierarchical nature of a structure in a
graphical form.

Basic Terminologies:
• A node in the tree with one or more than one successor is called parent node and all the successors of parent
node called child nodes of the parent node. (I node is the parent node of J and L nodes and K is the child node of
H).
• The root of a tree is the node with no parents. There can be at most one root node in a tree (node X is the root of
the tree).
• An edge refers to the link from parent to child (all links in the figure).
• A node with no children is called leaf node (Y, G, M, Z, J and L).
• Children of same parent are called siblings (R, H and I are siblings).
• A node p is an ancestor of node q if there exists a path from root to q and p appears on the path. The node q is
called a descendant of p. For example, X, H, K are the ancestors of M.
• The set of all nodes at a given depth is called the level of the tree (R, H and I are the same level). The root node
is at level zero.
• The height of a node is the length of the path from that node to the deepest node. The height of a tree is the
length of the path from the root to the deepest node in the tree.
• If every node in a tree has only one child (except leaf nodes) then we call such trees skew trees. If every node
has only left child then we call them left skew trees. Similarly, if every node has only right child then we call
them right skew trees.

www.oliveboard.in
www.oliveboard.in

• Degree of a node is equal to number of children, a node has. Degree of a leaf node is always 0 while in a
complete binary tree, degree of each node is equal to 2. (for example; the degree of node X is 3.)
• Degree of tree is maximum degree among all node.
Binary Tree: A tree is called binary tree if each node has zero child, one child or two children.

Properties of Binary Tree:


• The maximum number of nodes at level ‘k’ of a binary tree is (2 k).
• Maximum number of nodes in a binary tree of height ‘h’ is (2h – 1).
• In a Binary Tree with N nodes, minimum possible height or minimum number of levels is [Log2(N+1)]
• In Binary tree where every node has 0 or 2 children, number of leaf nodes is always one more than nodes
with two children.
• L = I + 1 Where, L = Number of leaf nodes and I = Number of internal nodes with two children
• If there are n nodes, there exist (2n – n) different binary trees.
Types of Binary Trees:
1) Strict Binary Tree: A binary tree is called strict binary tree if each node has exactly two children or no children.

2) Full Binary Tree: A binary tree is called full binary tree or perfect binary tree if each node has exactly two
children and all leaf nodes are at the same level.

3) Complete Binary Tree: A Binary Tree is complete Binary Tree if all levels are completely filled except possibly the
last level and the last level has all nodes as left as possible.

www.oliveboard.in
www.oliveboard.in

Operations on Binary Trees:


• Inserting an element into a tree
• Deleting an element from a tree
• Searching for an element
• Traversing the tree
Binary Tree Traversal: The process of visiting all nodes of a tree is called tree traversal.
Depth First Traversal:
• Preorder (Root Left Right) Traversal.
• Inorder (Left Root Right) Traversal.
• Postorder (Left Right Root) Traversal.

Preorder Traversal: Preorder traversal is defined as follows:


• Visit the root → Traverse the left subtree in Preorder → Traverse the right subtree in Preorder.
The nodes of tree would be visited in the order: 1 2 4 5 3 6 7
Inorder Traversal: Inorder traversal is defined as follows:
• Traverse the left subtree in Inorder → Visit the root → Traverse the right subtree in Inorder.
The nodes of tree would be visited in the order: 4 2 5 1 6 3 7
Postorder Traversal: Postorder traversal is defined as follows:
• Traverse the left subtree in Postorder → Traverse the right subtree in Postorder → Visit the root.
The nodes of the tree would be visited in the order: 4 5 2 6 7 3 1
Breadth First Traversal: It is also known as level order traversal. Level order traversal is defined as follows:
• Visit the root → While traversing level (traverse all the nodes at same level) → Go to the next level and visit
all the nodes at that level → Repeat this until all levels are completed.
The nodes of the tree are visited in the order: 1 2 3 4 5 6 7
Binary Search Tree: A binary tree is called a binary search tree (or binary sorted tree) if each of the node of the
binary tree has the following properties: The value of any node is greater than every value in the left subtree of the
node and is less than the every value in the right subtree of the node. There must be no duplicate nodes.

www.oliveboard.in
www.oliveboard.in

Note- Since root data is always between left subtree data and right subtree data, performing inorder traversal on
binary search tree produces a sorted list.
AVL (Adelson-Velskii and Landis) Tree: AVL tree is also known as self-balancing tree. A binary tree is said to be
an AVL tree, if:
• It is a binary search tree, and
• Given that TL and TR are the left and right subtree of the binary tree and h(TL) and h(TR) to be the heights of
the subtree TL and TR respectively. [h(TL) – h(TR)] is known as the balance factor and for an AVL tree the
balance factor of a node can be either 0, 1 or -1.

Red Black Tree: A binary tree is said to be a Red Black tree, if it satisfies the following properties:
• Every node is either red or black.
• The root is black.
• Every leaf (NIL) is black.
• If a node is red, then both its children are black.
• For each node, all simple paths from the node to descendant leaves contain the same number of black nodes.

www.oliveboard.in
www.oliveboard.in

Graphs: Data contain a relationship between pairs of elements which is not necessarily in hierarchical in nature. The
data structure which reflect this relationship is called Graph. It is a pictorial representation of set of elements which is
called vertices connected by the links known as edges.

Basic Terminologies of graph:


• Directed edge is ordered pair of vertices (u, v) where, first vertex u is the origin and, second vertex v is the
destination.

• Undirected edge is unordered pair of vertices (u, v).

• Directed graph is also called a diagraph and its all the edges are directed.
• A graph is called undirected graph if it’s all the edges are undirected.
• When an edge connects two vertices, the vertices are said to be adjacent to each other and the edge is
incident on both vertices.
• A graph with no cycles is called a tree. A tree is an acyclic connected graph.

• A self-loop is an edge that connects a vertex to itself.

• Two edges are parallel if they connect the same pair of vertices.

• The Degree of a vertex is the number of edges incident on it.


• A path in a graph is a sequence of adjacent vertices. Simple path is a path with no repeated vertices. In the
graph below, the dotted lines represent a path from G to E.

www.oliveboard.in
www.oliveboard.in

• A cycle is a path where the first and last vertices are the same. A simple cycle is a cycle with no repeated
vertices or edges (except the first and last vertices).

• A graph is connected if there is a path from every vertex to every other vertex.
• A directed acyclic graph [DAG] is a directed graph with no cycles.
• In weighted graphs integers (weights) are assigned to each edge to represent (distances or costs).

• Graphs with all edges present are called complete graphs.

• Dense graph is a graph in which the number of edges is close to the maximal number of edges.
• Sparse graph is a graph in which the number of edges is close to the minimal number of edges.
Shortest Path Algorithm: Given a graph G = (V, E) and a distinguished vertex s, we need to find the shortest path
from s to every other vertex in G.
Dijkstra’s algorithm: Dijkstra’s algorithm solves the single-source shortest-paths problem on a weighted, directed
graph G = (V, E) for the case in which all edge weights are nonnegative.
Dijkstra’s algorithm maintains a set S of vertices whose final shortest-path weights from the sources have already
been determined. The algorithm repeatedly selects the vertex u ∈ (V – S) with the minimum shortest-path estimate,
adds u to S, and relaxes all edges leaving u. In the following implementation, we use a min-priority queue Q of
vertices, keyed by their d values.
• It uses greedy method: Always pick the next closest vertex to the source.
• It uses priority queue to store unvisited vertices by distance from s.
• It does not work with negative weights.
Searching: Searching is the process of finding an item with specified properties from a collection of items. Types of
Searching:
• Unordered Linear Search
• Sorted/Ordered Linear Search
• Binary Search
• Interpolation search

www.oliveboard.in
www.oliveboard.in

Unordered Linear Search: When the elements of the array or list are not sorted. In this case, to search for an
element we have to scan the complete array and see if the element is there in the given list or not. This searching
technique is called unordered linear search.
Time complexity: O(n), in the worst case we need to scan the complete array.
Space complexity: O(1).
Sorted/Ordered Linear Search: If the elements of the array are already sorted either in ascending order or
descending order, then in many cases we don’t have to scan the complete array to see if the element is there in the
given array or not.
Binary Search: In this algorithm, we directly go to the middle point and start searching from that point. If the data
that we are searching is the same, then the search is complete. If the element is less than the selected point, then
apply the same process for the first half; otherwise apply the same process to the second half.
Time Complexity: O(logn). Space Complexity: O(1) [for iterative algorithm].
Sorting: Sorting is an algorithm that arranges the elements of a list in a certain order [either ascending or
descending]. Sorting can significantly reduce the complexity of a problem and is often used for database algorithms
and searches.
1) Bubble Sort: Bubble sort is the simplest sorting algorithm. It works by iterating the input array from the first
element to the last, comparing each pair of elements and swapping them if needed. Bubble sort continues its
iterations until no more swaps are needed.
2) Selection Sort: Selection sort works well for small files. It is used for sorting the files with very large values and
small keys. This is because selection is made based on keys and swaps are made only when required. The selection
sort algorithm for sorting an array works as follows: First find the smallest element and put it in the first position.
Then, find the second smallest element and put it in the second position and repeat this process until the entire array
is sorted.
3) Insertion Sort: Insertion sort is a simple and efficient comparison sort. In this algorithm, each iteration removes
an element from the input data and inserts it into the correct position in the list being sorted. The choice of the
element being removed from the input is random and this process is repeated until all input elements have gone
through.
Insertion sort is more efficient than selection and bubble sorts, even though all of them have O(n2) worst case
complexity.
4) Shell Sort: Shell sort (also called diminishing increment sort) was invented by Donald Shell. This sorting
algorithm is a generalization of insertion sort. Shell sort is also known as n-gap insertion sort. Instead of comparing
only the adjacent pair, shell sort makes several passes and uses various gaps between adjacent elements (ending
with the gap of 1 or classical insertion sort).
5) Quick sort: Quick sort is an example of a divide-and-conquer algorithmic technique. It is also called partition
exchange sort. It uses recursive calls for sorting the elements, and it is one of the famous algorithms among
comparison-based sorting algorithms.
Divide: The array A[low ...high] is partitioned into two non-empty sub arrays A[low ...q] and A[q+ 1... high], such
that each element of A[low ... q] is less than or equal to each element of A[q+ 1... high]. The index q is computed as
part of this partitioning procedure.
Conquer: The two sub arrays A[low ...q] and A[q + 1 ...high] are sorted by recursive calls to Quick sort.
6) Merge Sort: Merge sort is an example of the divide and conquer strategy. Merging is the process of combining
two sorted files to make one bigger sorted file. Selection is the process of dividing a file into two parts: k smallest
elements and (n – k) largest elements. Selection and merging are opposite operations. Selection splits a list into two
lists and merging joins two files to make one file. Merge sort is Quick sort’s complement. Merge sort accesses the
data in a sequential manner. This algorithm is used for sorting a linked list
7) Heap Sort: Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar
to selection sort where we first find the maximum element and place the maximum element at the end. We repeat
the same process for remaining element.
Binary Heap: Since a Binary Heap is a Complete Binary Tree, it can be easily represented as array and array-based
representation is space efficient. If the parent node is stored at index I, the left child can be calculated by 2 * I + 1
and right child by 2 * I + 2 (assuming the indexing starts at 0).
A complete binary tree is called a heap or maxheap, if each node of the tree has the following property: The value at
node N is greater than or equal to the value at each of the children node of N and the value at N is greater than or
equal to the value at any of the descendant of N.
A complete binary tree is called minheap, if each node of the tree has the following property: the value at node N is
less than or equal to the value of at each of the children node of N and the value at N is less than or equal to the
value at any of the descendant of N.

www.oliveboard.in
www.oliveboard.in

Algorithm:
• Build a max heap from the input data.
• At this point, the largest item is stored at the root of the heap. Replace it with the last item of the heap
followed by reducing the size of heap by 1. Finally, heapify the root of tree.
• Repeat above steps while size of heap is greater than 1.
8) Counting Sort: Counting sort is not a comparison sort algorithm and gives O(n) complexity for sorting. Counting
sort assumes that each of the elements is an integer in the range 1 to K, for some integer K. The basic idea of
Counting sort is to determine, for each input element X, the number of elements less than X. This information can be
used to place it directly into its correct position. For example, if 10 elements are less than X, then X belongs to
position 11 in the output.
9) Bucket Sort: Bucket sort works well if the input is drawn from fixed set. Bucket sort is the generalization of
Counting Sort. For example, assume that all the input elements from {0, 1, . . . , K – 1}, i.e., the set of integers in
the interval [0, K – 1]. That means, K is the number of distant elements in the input. Bucket sort uses K counters.
The ith counter keeps track of the number of occurrences of the i th element.
10) Radix Sort: Similar to Counting sort and Bucket sort, this sorting algorithm also assumes some kind of
information about the input elements. Suppose that the input values to be sorted are from base d. That means all
numbers are d-digit numbers.
In Radix sort, first sort the elements based on the last digit [the least significant digit]. These results are again sorted
by second digit [the next to least significant digit]. Continue this process for all digits until we reach the most
significant digits.

www.oliveboard.in
www.oliveboard.in

Lesson 6: Software Engineering and SDLC models


The term software engineering is related to the development of software product using well defined rules,
principles, theories and techniques. Software engineering is important because almost every industry and businesses
needed specific software for specific function.
Characteristics of a good software: A software need to have followed characteristics: Maintainability, Correctness,
Reusability, Reliability, Portability and Efficiency.
Software Process: In its lifecycle a software goes through various phases and these phases are known as software
processes which are common to all software:
• Software Specification
• Software Development
• Software Validation
• Software Evaluation
A software is more than a program, a program is a subset of software. Program with documentation and operating
procedures is known as a software.
Software Development Life Cycle (SDLC): Software development life cycle (SDLC) is a combination of well-
defined stages in software engineering to develop the software. It is a pictorial representation of process stages of
software life cycle and hence is also known as Process model. To build a software in a disciplined and systematic way,
there is need of step by step framework which is provided by SDLC. Various stages of SDLC are given below:

• Planning: In planning and requirement analysis phase, project team met with the customer to know the
requirement of the project in order to deliver the expected project.
• Defining: In defining requirement phase, software requirements are documented and accepted by the project
stakeholders which is done by Software Requirement Specification.
• Designing: In designing phase, a high-level design architecture (Blueprint) of the software is created based
on the requirement in order to deliver each requirement to the customer.
• Building: In building phases, actual development of the software starts. Developers started writing
programming codes and database administrators (DBAs) started creating and maintaining database.
• Testing: Testing phase is the critical phase, in which all the modules of software are integrated together and
deployed in testing environment. Software is tested against the requirement to check for errors, bugs and
defects.
• Deployment: In this phase, the developed and certified software without any errors and bugs is handed over
to the customer.
• Maintenance: This phase includes software upgrades, updates, repairs and fixes.
SDLC Models: SDLC model is a conceptual framework of step by step description of all the activities in a software
development process. Some of the important SDLC models are given below:
1. Waterfall Model: Waterfall model was the first process model which is introduced. In this model, the project
activities are broken down into linear sequential phases and it is also referred as Linear sequential life cycle
model. The phases in this model do not overlap and each phase must be completed before the start of next phase.

www.oliveboard.in
www.oliveboard.in

2. V-Model: V-model is considered as the extension of waterfall model. Unlike waterfall model, where the processes
are moving down in a linear way, the processes can also go upwards after the coding phase and form a typical V
shape.
V-model is also called Verification and Validation model where for each corresponding development phase, a testing
phase is associated, and next phase starts only after the completion of previous phase.

Phases of V-model:
• Verification Phase: Process of evaluation of product development phase to check whether the product meet
the specified requirements or not. Various verification phases of this model are given below: Requirement
Design, System Design, Architecture Design and Module Design.
• Coding phase: In this phase, actual coding of the different module of software is started which is performed
based on the coding guidelines and standards.
• Validation Phase: Process to check the software after the completion of the development phase whether it
meets the expectations and requirements of the customer or not. Various validation phases of this model are
given below: Unit Testing, Integration Testing, System Testing and Acceptance Testing.
3. Iterative Incremental Model: Iterative incremental model is an SDLC model to develop a software through
repeated cycle (iteration) and in smaller part in a time (incremental). This model is a combination of both Iterative
method and Incremental model for development of a software.
This model focuses on initial, simplified implementation which then progressively lead to more complex phases until
the final system is completed. Result of each iteration is a new version of the software.

Phase of Iterative and Incremental model:


• Inception phase: Deals with the planning, requirements, analysis & design and risks at higher level of this
model.
• Elaboration phase: Delivers the working architecture and resolves the risks that are identifies in the
inception phase.
• Construction phase: Deals with the implementation of the software based on the requirement analysis,
design created by the project designers and testing.
• Transition phase: Developed software is deployed to the customer to use it.

www.oliveboard.in
www.oliveboard.in

4. RAD Model: Rapid Application Development (RAD) model is based on prototyping and iterative development with
no specific planning involved. In this model, the components or functions of the product are developed in parallel as
prototype by considering them as the mini or small projects and are integrated to make the complete product.
RAD model follows the concepts of iterative and incremental model and most important aspects of this model is that
the prototype developed are reusable or not.

5. Agile Model: Agile model is a SDLC model that allows us to develop a software in small and quick segments. In
Agile model, entire project is divided into small incremental builds and each build follows iteration which last for some
time boxes (usually one to three weeks). Iterative approach is taken and after each iteration, software becomes
incremental in terms of features and after final iteration required software is obtained.

6. Spiral Model: Spiral model is a risk-driven process model and is one of the most flexible SDLC method to build a
software. Spiral model is a combination of iterative model and one of the sequential models such a waterfall model. It
has four phases: Determine objectives, Identify and resolve risk, Development and Test and Plan the next iteration
and software process repeatedly goes through these phases in iteration called Spiral.
Based on the unique risk patterns, this model considers risk, which remain un-noticed in other models. Hence, it is
also known as Risk-driven model. The number of spirals is not fixed and vary according to the project.

www.oliveboard.in
www.oliveboard.in

7. Big-bang Model: The Big bang model is more flexible SDLC model that requires no or very less planning. In this
model, we don’t follow any specific planning and development of the software starts with the required money and
efforts as the input and the output produced is the software that may or may not meet the client’s expectation
because in this model client’s requirements are defined. This model works well for small projects with smaller size
development in which the requirements are understood and implemented when they come.

8. Prototype Model: Prototyping model is most widely used SDLC model in which the customer didn’t know the
exact project requirement in advance. This model starts with the requirement gathering and based on the
requirement, a quick design (prototype) is created that is visible to the customer. Prototype is then checked and
tested by the customer and based on the customer’s feedback changes are made to the prototype until the prototype
is finally accepted by the customer. Finally, actual software from the prototype is developed by keeping all the
aspects of quality and security and deployed to the customer.

Project Estimation: Accurate estimation of various measures of a software need to be estimated for effective
project. It included various aspects such as: Size of Software, Quality of Software, Communication, Hardware,
Support and Training, Skilled Manpower and Software Tools.
Project Estimation Techniques: To development any new software, it is necessary to estimate the various
parameters such as cost to develop, time taken to build the project, size of the project team. Two project estimation
techniques are given below:
A. Decomposition technique: It is assumed that the software is a product of various compositions. Two important
decomposition techniques are used for project estimation:
• Line of Code: Line of Code (LOC) is the number of lines of source codes in a project and estimation is done
on behalf of number of lines of code in the software product.

www.oliveboard.in
www.oliveboard.in

• Function points: Number and type of functions supported by software are used to find the function point
count (FPC) and estimation is done on behalf of number of function points in the software product.
B. Empirical estimation technique: The estimation is done by empirically driving formulae. These formulae are
based on Line of code (LOC) and Function point (FP). There are two model that uses empirical estimation technique
for project estimation:
i) COCOMO Model: Constructive Cost Model (COCOMO) is a basic regression model based on LOC. COCOMO predicts
the efforts and cost of product based on size of product. In COCOMO model, projects are divided into three
categories:
• Organic: A software project is said to be organic if the problem of the project is well understood, team size is
reasonably small and project team have prior experience in developing similar project in the past. Ex: Simple
Business System, Simple Inventory System and Data Processing System.
• Semi-detached: A software project is said to be semi-detached if the team size is enough and mixture of
experienced and inexperienced staff. Project team has adequate experience about developing the project and
only few aspects are unknown to them. Ex: New OS, DBMS and Complex Inventory system.
• Embedded: A software project is said to be embedded if it requires high level of complexity and creativity.
For serving this purpose, the project team need to be quite big and well experienced. Ex: Air Traffic Control
and ATM.
ii) Putnam Model: This model is made by Lawrence H. Putnam, which is based on Norden’s frequency distribution
(Rayleigh curve). Putnam model maps time and efforts required with software size.
Formula to calculate project estimation using Putnam’s model is given below: L = CkK1/3td4/3
Where-
• L = Product estimate in KLOC.
• Ck = State of technology constant and reflects requirements that impede the development of the program.
• Ck = 2 for poor development.
• Ck = 8 for Good software development environments.
• Ck = 11 for an excellent environment.
• K = Total effort expended (in PM) in product development.
• td = Time required for developing the product.
Project Risk Management: Risk management is the process of analysing, addressing and eliminating those risk
before they can damage the project. Risks can be of any type: Project Risk, Technical Risk and Business Risk.
Risk management activities: Risk management activities can be classified into two types:
1. Risk Assessment: Risk assessment is a term used to identify the combined effort of identifying and analysing the
risks factors and problems caused by them. Risk assessment includes: Risk Identification and Risk Analysis.
2. Risk Control: Process of managing risks to achieve desired outcome. Risk control can be done in three ways:
Avoid the risk, Transfer the risk and Reduce the risk.
Project Management Tools: Project risks in the project development will increase as the size of project increases
even if the project is developed according to the set methods. Here are some of the important project management
tools:
Gantt Chart: A Gantt chart is a horizontal bar chart used in project management to track projects from start to
finish.

PERT Chart: The Program Evaluation and Review Technique (PERT) is a statistical tool used in project management
which uses network diagram to analyse and represent the tasks involved in completing a given project. It contains a
network of boxes and arrows, where the boxes show activities, and the arrows represent function dependencies.

www.oliveboard.in
www.oliveboard.in

Resource Histogram: Resource histogram is specifically a bar chart that is used for the purposes of displaying the
specific amounts of time that a particular resource is scheduled to be worked on over a predetermined and specific
time period. Resource Histogram is an effective tool for staff planning and coordination.
Software requirement: Software requirement is a description of functionalities and features of a software that is
being developed. Software requirement describes the expectations of users from the software product.
Software Requirement Specification: A formal report or document that contains all the stages of software
development process is called Software Requirement Specification (SRS). SRS is also called requirement documents
that contains user’s requirements for a system and requirements of the system to develop it.
Characteristics of a good SRS: Following are the characteristics of a good SRS: Correctness, Completeness,
Consistency, Unambiguousness, Modifiability, Verifiability, Traceability, Testability, Right level of abstraction, Design
Independence, Understandable by customer and Ranking for importance and stability.
Requirement analysis: Requirement analysis is the process of defining the user expectations from a newly built
product or modified product, it is also called requirement engineering. Requirement analysis is divided into various
steps:
• Draw the context diagram: Context diagram is a simple model that identifies the entities outside the
proposed system that interact with the system.
• Develop prototype: To understand the customer’s expectation in a clear and efficient manner prototype of
the model need to be developed.
• Model the requirement: Various graphical representation, functions, entities and relationship among them
are contained in this step.
• Finalize the requirement: After collecting all the requirements and modelling them, system’s behaviour,
inconsistencies and ambiguities can be understood easily.
Software Configuration Management (SCM): SCM is the process of tracking and controlling the changes in the
software. SCM is the process of identifying changes, monitor and control changes, ensures the proper implementation
of the changes and auditing and reporting on the changes made.
Software Quality Assurance (SQA): SQA is a set of activities that ensure quality in the software and this process
works to the development process of the software. It improves the process of development so that the problem that
will become major issues can be prevented in the earlier stage.
Module Coupling: Coupling is the measure of degree of interdependence between software modules. A good
software will have low coupling while two modules that are tightly coupled are strongly dependent on each
other. There is various type of module coupling:
• No direct coupling
• Data coupling
• Stamp coupling
• Control coupling
• External coupling
• Common coupling
• Content coupling
Module Cohesion: Cohesion is a measure of the degree to which the elements of the module are functionally
related. It measures the strength of relationships between pieces of functionality within a given module and a good
software design will have high cohesion. There is various type of module cohesion:
• Functional cohesion
• Sequential cohesion
• Communication cohesion
• Procedural cohesion
• Temporal cohesion
• Logical cohesion
• Coincidental cohesion
Reliability metrics: Reliability metrics are used to quantitatively expressed the reliability of the software
product. Some of the reliability metrics to measure the reliability of the software are given below:
• Mean time to failure (MTTF): Length of time a software is expected to last in operation. Ex: An MTTF of
100 mean that one failure can be expected each 200 units time.

www.oliveboard.in
www.oliveboard.in

• Mean time to repair (MTTR): Average time required to troubleshoot and repair failed equipment. Ex:
Suppose a software fails 3 times and total time taken to repair all the failures is 60 units time, then MTTR
would be 60/3 = 20 units time.
• Mean time between failure (MTBF): Predicted elapsed time between inherent failures of a mechanical or
electronic system, during normal system operation. Ex: MTBF of 120 units time denoted that once the failure
appears, the next failure is expected to appear only after 120 units time.
• Rate of occurrence of failure (ROCOF): Frequency of occurrence of unexpected events over a specific time
of operation. Ex: ROCOF of 0.25 = 25/100 means that 25 failures are likely to occur in each 100 operational
time unit steps.
• Probability of failure on Demand (POFOD): Probability that the system will fail when a service is
requested. Ex: A POFOD of 0.3 = 3/10 means that one out of ten service requests may fail.
• Availability (AVAIL): Probability that the system is applicable for use at a given time. It considers the repair
time & the restart time for the system. Ex: An availability of 0.95 means that in every 100 units time, the
system is feasible to be available for 95 units time.
Software maintenance: Software maintenance is a part of SDLC, and its primary goals is to manage and correct
errors and improve performance after it has been delivered to the customer.
Types of software maintenance: Software maintenance can be divided into following four types:
• Corrective maintenance: It aims to correct some bugs observed while the system is in use, or to enhance
the performance of the system.
• Adaptive maintenance: It includes modifications and updating when the customers need the product to run
on new platforms or interface with new hardware and software
• Preventive maintenance: It includes modifications and updations to prevent future problems of the
software.
• Perfective maintenance: In this, software needs to be maintained to support new features and functionality
according to the demand of customer.
Software re-engineering: Process of updating software without affecting its functionality. In software
reengineering, the software is improved so that it can become more effective and efficient. Software reengineering
includes following given activities:
• Reverse engineering: It is a process to achieve system specification by thoroughly analysing and
understanding the existing system. Reverse engineering tools extracts data, architectural and procedural
design information from an existing program.
• Forward engineering: Process of building from a high-level model or concept to build in complexities and
lower-level details. It is also called as renovation or reclamation not only for recovers design information from
existing software but uses this information to alter or reconstitute the existing system in an effort to improve
its overall quality.
Software Testing: Process to evaluate the functionality of a software application with an intent to find whether the
developed software met the specified requirements or not. Software testing means verification of software under test.
Software Testing Life Cycle (STLC): The procedure of software testing is also known as STLC

Software Testing Types: There are different type of software testing in software engineering:
• Manual Testing: Testing where Testers manually execute test cases without using any automation tools.
• Automation Testing: Testing technique where Tester write Scripts by own and uses
suitable Software or Automation Tool to test the software.
Testing methods: There are two types of testing methods:
• Static Testing: Software Testing method which is performed to check the defects in software without actually
executing the code of the software application. It is also known as Verification in Software Testing.

www.oliveboard.in
www.oliveboard.in

• Dynamic Testing: Dynamic testing is used to describe the testing of the dynamic behaviour of code and it is
also known as Validation in Software.
Level of testing: Four main levels of testing are given below:
1. Unit testing: Software testing where individual units/ components of a software are tested. This testing is done to
check whether the individual modules of the source code are working properly. iIt is also known as Module Testing
or Component Testing.
2. Integration Testing: software testing where individual units are combined and tested as a group. It is also known
as I&T Testing and String Testing.
3. System Testing: Software testing that is performed on a complete integrated system to evaluate the compliance
of the system with the corresponding requirements. Different type of system testing is given below:
• Usability testing: Software testing where a small set of target end-users, of a software system, "use" it to
expose usability defects.
• Load testing: Load testing is performance testing technique using which the response of the system is
measured under various load conditions.
• Regression testing: Process of testing that modified parts of the code and the parts that might get affected
due to the modifications to ensure that no new errors have been introduced in the software after the
modifications have been made.
• Recovery testing: Testing technique performed in order to determine how quickly the system
can recover after it has gone through system crash or hardware failure.
• Migration testing: Verification process of migration of the legacy system to the new system with minimal
disruption/downtime, with data integrity and no loss of data.
a) Black Box Testing: Method of software testing that examines the functionality of an application without peering
into its internal structures or workings and it is also known as Behavioural Testing.
b) White Box Testing: It analyse the internal structures that used data structures, internal design, code structure
and the working of the software rather than just the functionality as in black box testing. It is also known as Clear
Box Testing, Open Box Testing, Glass Box Testing, Transparent Box Testing, Code-Based Testing or
Structural Testing.
c) Gray Box Testing: It is a combination of white-box and black-box testing and is a technique to test the software
product or application with partial knowledge of the internal workings.
Other type of software testing is given below:
• Smoke Testing: Process where the software build is deployed to quality assurance environment and is
verified to ensure the stability of the application. It is also known as Confidence or Build Verification
Testing.
• Sanity Testing: Software Testing performed after receiving a software build, with minor changes in code, or
functionality, to check that the bugs have been fixed and no further issues are introduced due to these
changes.
• Alpha Testing: Software testing performed to identify bugs before releasing the product.
• Beta Testing: Performed by real users in a real environment and is also known as Acceptance testing.
• Stress Testing: Software testing activity that determines the robustness of software by testing beyond the
limits of normal operation and is also known as Endurance Testing.
• Performance Testing: Software testing that intends to determine how a system performs in terms of
responsiveness and stability under a certain load.
• Spike Testing: Type of performance testing in which an application receives a sudden and extreme increase
or decrease in load.
• Security Testing: Process intended to reveal flaws in the security mechanisms of an information system that
protect data and maintain functionality as intended.
• Compliance Testing: Testing technique, which is done to validate, whether the system developed meets the
organization’s prescribed standards or not and it is also known as Conformance testing.
Data warehouse is a process of collecting and managing integrated data from multiple heterogeneous sources.
Collecting data is used to connect, analyse and provide meaningful business insights.
Features of data warehouse: Key features of data warehouse is given below: Subject Oriented, Integrated, Time-
Variant and Non-Volatile.
Types of data warehouse: There are three types of data warehouse:

www.oliveboard.in
www.oliveboard.in

• Enterprise Data Warehouse: EDW is a database, or collection of databases, that centralizes a business's
information from multiple sources and applications and makes it available for analytics and use across the
organization.
• Operational Data Store: ODS is a type of database that collects data from multiple sources for processing,
after which it sends the data to operational systems and data warehouses.
• Data Mart: A data mart is a subset of a data warehouse oriented to a specific business line that contains
repositories of summarized data collected for analysis on a specific section.
ETL is defined as a process that extracts the data from different RDBMS source systems, then transforms the data
and finally loads the data into the Data Warehouse system.
• Data Extraction: Process that involves retrieval of data from various sources.
• Data Transformation: Process of converting data from one format or to another format.
• Data Loading: Process of copying and loading data from a source file/folder to a database.
Metadata: Metadata is data about data which defines the data warehouse and it is used for building, maintaining and
managing the data warehouse. The data that are used to represent other data is known as metadata.
Data Cube: Data cubes usually model n-dimensional data that enables data to be modelled and viewed in multiple
dimensions and is defined by dimensions and facts.
Data Mart: A data mart is a subset of a data warehouse oriented to a specific business line. A data mart is a
structure / access pattern specific to data warehouse environments, used to retrieve client-facing data.
Online Analytical Process (OLAP): OLAP is a category of a software that allows users to analyse information from
multiple database systems at the same time. Characteristics of OLAP is given below: Fast, Analysis, Shared,
Multidimensional and Informative.
OLAP operations: Some popular OLAP operations for multidimensional data are:
1) Roll-up: The roll-up operation performs aggregation on a data cube either by climbing up the hierarchy or by
dimension reduction.
2) Drill-down: Drill-down is the reverse operation of roll-up which is performed by either stepping down a
concept hierarchy for a dimension or introducing a new dimension.
3) Slice and Dice: The slice operation selects one particular dimension from a given cube and provides a new
sub-cube.
Dice selects two or more dimensions from a given cube and provides a new sub-cube.
4) Pivot: The pivot operation is also known as rotation. It rotates the data axes in view in order to provide an
alternative presentation of data.
Types of OLAP servers:
• Relational OLAP (ROLAP): ROLAP is a form of online analytical processing (OLAP) that performs dynamic
multidimensional analysis of data stored in a relational database rather than in a multidimensional database.
• Multidimensional OLAP (MOLAP): MOLAP is a classical OLAP that facilitates data analysis by using
a multidimensional data cube.
• Hybrid OLAP (HOLAP): HOLAP is a mode of storage that uses a combination of multidimensional data
structures and relational database for storing multidimensional data.
• Specialized SQL server: Specialized SQL servers provide advanced query language and query processing
support for SQL queries over star and snowflake schemas in a read-only environment.
Data Warehouse Schema: A schema is a collection of database objects, including tables, views, indexes, and
synonyms. Based on the ways of arranging schema objects, schemas can be classified into different types:
1. Star Schema: The star schema is perhaps the simplest data warehouse schema. It is called a star schema
because the entity-relationship diagram of this schema resembles a star, with points radiating from a central table. In
this, data are organized into facts and dimensions where a fact is an event that is counted or measured while a
dimension includes reference data about the fact, such as date, item, or customer.
• Fact table: Contains facts and connected to dimensions and mainly consists of business facts and foreign
keys that refer to primary keys in the dimension tables.
• Dimension table: A dimension is an architecture usually composed of one or more hierarchies that
categorize data. Dimension tables provides descriptive information for all the measurements recorded in fact
table.
2. Snowflake Schema: Snowflake schema is a logical arrangement of tables in a multidimensional database such
that the entity relationship diagram resembles a snowflake shape. A schema is known as a snowflake if one or more-
dimension tables do not connect directly to the fact table but must join through other dimension tables.

www.oliveboard.in
www.oliveboard.in

3. Fact Constellation Schema: Fact constellation is a measure of online analytical processing, which is a collection
of multiple fact tables sharing dimension tables, viewed as a collection of stars. A Fact constellation means two or
more fact tables sharing one or more dimensions and it is also called Galaxy schema.

www.oliveboard.in
www.oliveboard.in

Lesson 7: Programming Languages (C/JAVA/UNIX)


C is a programming language developed at AT & T’s Bell Laboratories of USA in 1972. It was designed and written by
a man named Dennis Ritchie.
Identifiers: Identifiers refers to the name of variables, functions and arrays. These are user-defined names and
consists of sequence of letters and digits. Both uppercase and lowercase letters are permitted. Rules for identifiers:
Cannot use keywords. Must not contain white space. Only first 31 characters are significant. Must contains of only
letter, digits and underscore. First character must be an alphabet or underscore.
Backslash Character Constants: C supports some special backslash character constants that are used in output
functions.

Constant Meaning Constant Meaning

‘\a’ Audible alert (bell) ‘\v’ Vertical tab

‘\b’ Back space ‘\’’ Single quote

‘\f’ Form feed ‘\”’ Double quote

‘\n’ New line ‘\?’ Question mark

‘\r’ Carriage return ‘\\’ Back slash

‘\t’ Horizontal tab ‘\0’ Null

Variables: A variable is a name to memory location or storage area where the data is stored for manipulation. Rules
for defining the variable names is given below:
• It can have alphabets, digits and underscore.
• A variable name can start with only alphabet and digit not with underscore.
• Whitespace is not allowed while defining a variable name.
• Name of the variable can’t be any special or reserved keyword.
• Upper and lower case are distinct in variable names.
Definition of variable in C: Syntax to declare variable name in C: type variable_list;
Below given is the list of important variable type used in C:
• Local variables: Variables declared inside the function or block.
• Global variables: Variables declared outside the function or block and are available to all the function and
any function can change the value of global variables.
• Static variables: Variables that are declared with keyword static and these variables retains its value
between multiple function calls.
• Automatic variables: Any variables that are declared inside the function are automatic by default and it can
be defined by using auto keyword.
• External variables: Variables declared using extern keyword and can be shared in multiple C source file.
Data type: Data type in C specifies the type of data that any C variable can store. Classification of data types in C is
given below:

Constant: Constants in C are the fixed values that are used in a program. The fixed values are also called literals
and constants are treated like regular variables whose values can’t be modified.
Definition of constants: Constants in C can be defined in two ways:
1. Using #define preprocessor directive: #define identifier value
2. Using cosnt keyword: const type variable = value;
Type of constants: C constants are of different types:
• Integer constants = 10

www.oliveboard.in
www.oliveboard.in

• Floating-point constants = 3.14159


• Character constants = ‘A’
• String constants = ‘”ABC”
Keywords in C: In C programming language there are some reserved words which can’t be used to define variable
name or constant name, these reserved words are known as keywords in C. There are total 32 keywords in C which
are given below in table:

auto break case char const continue default do

double else enum extern float for goto if

int long register return short signed sizeof static

struct switch typedef union unsigned void volatile while

Storage classes in C: Below given table shows the scope, lifetime, default value and storage place of the storage
classes:

Storage Class Keyword Storage Place Default value Scope Lifetime

Automatic auto RAM Garbage Local Within function

External extern RAM Zero Global Till the end of main program

Static static RAM Zero Local Till the end of main program

Register register Register Garbage Local Within function

Operator and Expressions: C operators are nothing but simply a symbol that tells the compiler to perform
operation (mathematical and logical etc.). C language has many built-in operators and below given are the types of
operators:
1. Arithmetic operator: Arithmetic operators are given below:

Operator Description

+ Add two operands

– Subtract second operands from first operands

* Multiply two operands

/ Divides numerator by de-numerator

% Gives remainder after dividing numerator by de-numerator

++ Increment the value by one

–– Decrement the value by one

2. Relational operator: Relational operators are given below:

Operator Description

== First operand is equal to second operand

!= First operand is not equal to second operand

> First operand is greater than second operand

< First operand is less than second operand

>= First operand is greater than or equal to second operand

<= First operand is less than or equal to second operand

3. Logical operator: Logical operators are given below:

Operator Description

&& Logical AND

|| Logical OR

! Logical NOT

4. Assignment operator: Assignment Operator are given below:

www.oliveboard.in
www.oliveboard.in

Operator Description

= x = y (Assigns value of y to x)

+= x += y => x = x + y

-= x -= y => x = x - y

*= x *= y => x = x * y

/= x /= y => x = x / y

%= x %= y => x = x % y

5. Conditional operator: Conditional operators are also called as ternary operator. Syntax for ternary operator is
given below:

6. Bitwise operator: Bitwise operator works on bits and perform bit-by-bit operation such as:

Operator Description

AND (&) Takes two operands and performs AND operations on both operands bitwise.

OR (|) Takes two operands and performs OR operations on both operands bitwise.

XOR (^) Takes two operands and performs XOR operations on both operands bitwise.

Not (~) Takes one number and inverts all bits of it.

Left shift (<<) Takes numbers, left shift the bits of first number and second number decides the number of
places to shift.

Right shift Takes numbers, right shift the bits of first number and second number decides the number of
(>>) places to shift.

7. Increment and Decrement Operator: In C language, increment and decrement operators are used for
increment or decrement value of an integer by one.

Operator Description

Pre- When pre-increment operator is placed before the variable name, its value is incremented instantly
increment before execution of current statement. For example, ++x.

Post- When post-increment operator is placed after the variable name, its value is preserved temporarily
increment until the execution of this statement and it gets updated before the execution of the next
statement. For example, x++.

Pre- When pre-decrement operator placed before the variable name, its value is decremented instantly
decrement before execution of current statement. For example, – – x

Post- when post-decrement operator is placed after the variable name, its value is preserved temporarily
decrement until the execution of this statement and it gets updated before the execution of the next
statement. For example, x – –.

www.oliveboard.in
www.oliveboard.in

8. Special operator: C language also supports some special operators such as:

Operator Description

Comma (,) The comma operator (represented by the token) is a binary operator that evaluates its first
operand and discards the result, it then evaluates the second operand and returns this value (and
type). The comma operator has the lowest precedence of any C operator, and acts as a sequence
point.

Address Returns the address of memory location.


operator (&)

Pointer Pointer to a variable.


operator (*)

sizeof() Returns the size of memory location.

Comments in C: C Comments are widely used to provide information about lines of code. There are two types of
comments in C:
• Single line comment: Syntax for writing single line comment: // Single line comment
• Multi line comment: Syntax for writing multi-line comment:

Decision making: Decision making is about deciding the order of execution of statements based on certain
conditions. In C, decision making can be done in two ways:
1. Branching: When control flow of the program is split into two or more pathways, which are usually result of
conditional statements such as ‘if’, ‘if then else’ and ‘nested if else’ etc are called branching.

• if statement: An if statement consists of a Boolean expression followed by one or more statements. Syntax:

• if-else statement: An if statement can be followed by an optional else statement, which executes when the
Boolean expression is false. Syntax:

www.oliveboard.in
www.oliveboard.in

• if-else-if ladder or nested if-else statement: Nested if-else statements, which means you can use one if
or else if statement inside another if or else if statement(s). Syntax:

• switch statement: A switch statement allows a variable to be tested for equality against a list of values.
Each value is called a case, and the variable being switched on is checked for each switch case. Syntax:

2. Looping: Looping is another control flow “mechanism” where several states may be visited an arbitrary amount of
times.

www.oliveboard.in
www.oliveboard.in

• while loop: while loop can be addressed as an entry control loop and it repeatedly executes a target
statement as long as a given condition is true. The while loop is to be used in the scenario where we don't
know the number of iterations in advance. It is also called pre-tested loop. Syntax:

• for loop: A for loop is a repetition control structure that allows you to efficiently write a loop that needs to
execute a specific number of times and it is also called open ended loop. This loop is also called as a per-
tested loop. It is better to use for loop if the number of iterations is known in advance. Syntax:

• do-while loop: A do while loop is similar to while loop with one exception that it executes the statements

inside the body of do-while before checking the condition. Syntax:


• nested loops: C programming allows to use one loop inside another loop and any loop type can
be nested within another type. Syntax:

Syntax for ‘nested while loop’ is given below:

www.oliveboard.in
www.oliveboard.in

Syntax for ‘nested do-while loop’ is given below:

Break statement in C: The break is a keyword in C which is used to bring the program control out of the loop. The
break statement in C can be used in the following two scenarios:
• With switch case
• With loop

Continue statement in C: Continue is also a loop control statement but it is different form break statement from the
fact that it doesn’t force the termination of loop or switch case. It forces the next iteration of the loop to take place,
skipping any code in between.

goto statement in C: goto is a jumping statement in c language, which transfer the program's control from
one statement to another statement.

www.oliveboard.in
www.oliveboard.in

Type casting in C: Type casting refers to changing a variable of one data type into another. Type casting can be
done in two ways:
• Implicit type conversion: Implicit type conversion, also known as coercion, is an automatic type
conversion by the compiler. Syntax: int num = 5 + 12.75;
• Explicit type conversion: Explicit typecasting allows us to convert one data type into other by using cast
operator for typecasting which is denoted by (type). Syntax: (data_type)expression;
Functions in C: A function is a group of statements that together perform a task. A function can be called multiple
times to provide reusability and modularity to the C program and every C program must have at least one function
which is main(). C function is a self-contained block of statements that can be executed repeatedly whenever we need
it. There are three aspects of function:
• Function declaration: Function declaration consists of function name, parameters name and return type.
Syntac: return type functionName (type[argname] [, type, …]);
• Function definition: Function definition includes all the statements inside a function that need to be
executed when function is called. Syntax:

• Function call: Function can be called from anywhere in the program and function calls enables the actual
calling of function. Syntax: functionName (argument1, argument2, …);
Function arguments: An argument of a function is a value that must be provided to obtain the function's result.
Variables must be declared to accept the values for these arguments and these variables are called formal
parameters and actual values that are passed to these variables are called actual parameters. There are two types
of functions in C:
• Built-in (Library) function: The functions which are declared in the C header files such as scanf(), printf(),
gets(), puts(), ceil(), floor() etc are called Library functions.
• User defined function: The functions are defined by the user at the time of writing the program are called
user defined function.
Functions in C can be called by two different types:
• Call by value: The call by value method of passing arguments to a function copies the actual value of an
argument into the formal parameter of the function. Any changes made inside functions are not reflected in
actual parameters of caller function. By default, C uses call be value to pass arguments.
• Call be reference: The call by reference method of passing arguments to a function copies the address of an
argument into the formal parameter. Inside the function, the address is used to access the actual argument
used in the call. Any changes made inside the function are actually reflected in actual parameters of caller
function.
Recursion in C: Recursion is a programming technique that allows the programmer to express operations in terms of
themselves. Any function which calls itself is called recursive function, and such function calls are called recursive
calls. Ex:

www.oliveboard.in
www.oliveboard.in

Arrays: An array is a collection of similar type of data items stored at contiguous memory locations. It is a kind of
data structure that can store a fixed-size sequential collection of elements of the same type. Lowest address of the
array corresponds to the first element and the highest address to the last element.

Declaration of array in C: Syntax to declare array in C: data_type array_name [array_size];


Initialization of array in C: Syntax to initialize array in C:

Declaration of array with initialization in C: We can initialize the c array at the time of declaration. Below given in
the syntax: data_type array_name[] = {data0, data1, data2, …….., dataN};
Accessing array elements: An element is accessed by indexing the array name. Below given is the syntax to access
array elements: data = array_name[N];
Multi-dimensional array: C programming language allows multidimensional arrays and syntax to declare multi-
dimensional array is given below: type name [size1] [size2] …. [sizeN]];
Most popular multi-dimensional array is 2-D array:
Two-dimensional (2-D) array: The two-dimensional array can be defined as an array of arrays which is organized
as matrices and can be represented as the collection of rows and columns.
Declaration of 2-D array: data_type array_name [rows] [columns];
Initialization of 2-D array: data_type array_name [m] [n] = {{a, b, …}, {c, d, ….}, ……, {e, f, …}};
Accessing 2-D array elements: data_type data = array_name [m] [n];
Character Arrays and Strings: String is a sequence of characters that is treated as a single data item and
terminated by null character '\0' which is main difference between a character array and a string. In C language,
string is not declared as a valid data type, it is actually a one-dimensional array of characters.
Declaration of string: char str_name [size];
Initialization of string:

String functions in C: Commonly used string functions are given below:


• strcat: Concatenate two strings.
• strncat: Concatenate first ‘n’ character of a string at the end of another string.
• strchr: String scanning operation
• strcmp: Compare two strings
• strncmp: Compare parts of two strings
• strcmpi: Compares two string by ignoring case.
• stricmp: Compares two string by ignoring case.
• strcpy: Copy a string

www.oliveboard.in
www.oliveboard.in

• strncpy: Copy part of a string


• strlen: Get string length
• strlwr: Coverts a string to lowercase.
• strupr: Coverts a string to uppercase.
• strncat: Concatenate one string with part of another
• strrchr: String scanning operation
• strdup: Used for duplicating a string.
• strstr: Finds out first occurrence of a given character in a string.
• strrev: Reverses a string.
Structure and Union: The structure is a user-defined data type in C, which is used to store a collection of different
kinds of data. Arrays allow to define type of variables that can hold several data items of the same kind while
structure allows to define type of variables that can hold several data items of the different kind. Variables inside the
structure are members of structure.
Defining a structure:

Array of structure: An array of structure in C can be defined as the collection of multiple structures variables where
each variable contains information about different entities. The array of structures in C are used to store information
about multiple entities of different data types.
Pointers in C: Pointers in C language is a variable that stores/points the address of another variable. This variable
can be of type int, char, array, function, or any other pointer.
Declaring a pointer: data_type *ptr;
Whenever a variable is declared, then a location is allocated to that variable. The location or address of that variable
is also an integer which can be stored in another integer variable. The variables which are used to store the address
of another variable is called pointer variable.
Points to remember while using pointers:
• Sign (*) indicates that the declared variable is pointer.
• Address of any variable can be obtained by preceding the variable name with Ampersand (&) operator.
• Declaration int *a means ‘a’ contains the address of a variable that contains an integer.
• To read the value of a variable whose address is stored by a pointer value at operator (*) is used.
File Management: A file represents a sequence of bytes on the disk where a group of related data is stored. File
handling in C enables us to create, update, read, and delete the files stored on the local file system through our C
program. Different operations that can be performed on a file are:
Function Description
fopen() create a new file or open an existing file
fclose() closes a file
getc() reads a character from a file
putc() writes a character to a file
fscanf() reads a set of data from a file
fprintf() writes a set of data to a file
getw() reads an integer from a file
putw() writes an integer to a file
fseek() set the position to desire point
ftell() gives current position in the file
rewind() set the position to the beginning point

www.oliveboard.in
www.oliveboard.in

1. Opening a file: To read, write or update a file we must first open the file. Syntax to open a file is give below:
FILE *fopen (const char *filename, const char *mode);
A file can be opened in any one of the given modes:

Mode Description

r opens a text file in read mode

w opens a text file in write mode

a opens a text file in append mode

r+ opens a text file in read and write mode

w+ opens a text file in read and write mode

a+ opens a text file in read and write mode

rb opens a binary file in read mode

wb opens a binary file in write mode

ab opens a binary file in append mode

rb+ opens a binary file in read and write mode

wb+ opens a binary file in read and write mode

ab+ opens a binary file in read and write mode

2. Closing file: The file must be closed after performing all the operations on it and syntax to close the file is given
below: int fclose (FILE *fp); and function returns ZERO after successfully closing the file.
3. Input/Output operation on file: I/O operations are used to perform reading and writing on file.

4. Reading and Writing to file: fprintf() function is used to write set of characters into file while fscanf() function is
used to read set of characters from file.
5. fread() and fwrite(): These functions are used to read and write is a binary file.
6. fseek(): Move the reading control to different positions.
7. ftell(): Tells the byte location of current position of cursor in file pointer.
8. rewind(): Moves the control to beginning of the file.
Object-Oriented Programming: Object oriented programming is an approach that provides a way of modularizing
programs by creating partitioned memory area for both data and functions that can be used as templates for creating
copies of such modules on demand.
Basic concept of Object-Oriented Programming:
• Objects: Objects are the basic run-time entities in an object-oriented system. The term object means a
combination of data and program that represent some real word entity.
• Classes: A group of objects that share common properties for data part and some program parts are
collectively called as class.
• Data abstraction: Abstraction refers to the act of representing essential features without including the back-
ground details or explanations.
• Data Encapsulation: The wrapping up of data and function into a single unit (called class) is known as
encapsulation.
• Inheritance: Inheritance is the process by which objects of one class acquire the properties of another class.
• Polymorphism: Polymorphism means the ability to take more than one form.
• Dynamic binding: Binding refers to the linking of a procedure call to the code to be executed in response to
the call. Dynamic binding means the code associated with a given procedure call is not known until the time of
the call at run-time.
• Message passing: A message for an object is a request for execution of a procedure and therefore will
invoke a function (procedure) in the receiving object that generates the desired result.

www.oliveboard.in
www.oliveboard.in

Function Overloading: Overloading refers to the use of the same thing for different purposes. This means that we
can use the same function name to creates functions that perform a variety of different tasks. This is known as
polymorphism in OOPs. Using the concepts of function overloading, a family of functions with one function name but
with different argument lists in the functions call. The correct function to be invoked is determined by checking the
number and type of the arguments but not on the function type.
A function call first matches the prototype having the same number and type of arguments and then calls the
appropriate function for execution.
Access Specifiers: The access specifier or the visibility mode is optional and, if present, may be public, private or
protected. By default, it is private. Visibility mode describes the status of derived features.
Class: A class is a new data type that contains member variables and member functions that operates on the
variables. A class is defined with the keyword class. It allows the data to be hidden, if necessary, from external use.
When we define a class, we are creating a new abstract data type that can be treated like any other built in data type.
Generally, a class specification has two parts:
a) Class Declaration: describes the type and scope of its members.
b) Class Function Definition: describes how the class functions are implemented.
The members that have been declared as private can be accessed only from within the class. On the other hand,
public members can be accessed from outside the class also. The data hiding is the key feature of OOPs. The use of
keywords private is optional by default, the members of a class are private. The variables declared inside the class
are known as data members and the functions are known as members functions. The binding of data and functions
together into a single class type variable is referred to as encapsulation.
Creating Objects: An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is
instantiated (i.e. an object is created) memory is allocated. Once a class has been declared we can create variables of
that type by using the class name.
Objects can also be created when a class is defined by placing their names immediately after the closing brace. For
example:
Private member functions: A private member function can only be called by another function that is a member of
its class. Even an object cannot invoke a private function using the dot operator.
Friendly Functions: Since, private members cannot be accessed from outside the class. That is a non-member
function can't have access to the private data of a class. The function declaration should be preceded by the keyword
friend. The function definition does not use either the keyword friend or the scope operator ‘::’. The functions that are
declared with the keyword friend are known as friend functions. A function can be declared as a friend in any
number of classes. A friend function, although not a member function, has full access rights to the private members
of the class.
Const Member Functions: If a member function does not alter any data in the class, then we may declare as a
const member function as follows:
Local Classes: Classes can be defined and used inside a function or a block. Such classes are called local classes.
Constructor: A constructor is a special member function whose task is to initialize the objects of its class. The
constructor is invoked whenever an object of its associated class is created. It is called constructor because it
constructs the values of data members of the class.
A constructor that accepts no parameters is called the default constructors. If no such constructor is defined, then
the compiler supplies a default constructor.
Parameterized Constructors: The constructors that can take arguments are called parameterized constructors.
Using parameterized constructor, we can initialize the various data elements of different objects with different values
when they are created.
Copy Constructors: A copy constructor is used to declare and initialize an object from another object. The process of
initializing through a copy constructor is known as copy initialization.
Dynamic Constructors: The constructors can also be used to allocate memory while creating objects. Allocation of
memory to objects at the time of their construction is known as dynamic constructors of objects. The memory is
allocated with the help of new operator.
Destructors: A destructor is used to destroy the objects that have been created by a constructor. Like a constructor,
the destructor is a member function whose name is the same as the class name but is preceded by a tilde.
Inheritance: The mechanism of deriving a new class from an old one is called 'INHERTTENCE'. The old class is
called 'BASE' class and the new one is called 'DERIEVED' class.
Types of Inheritance:
Single Inheritance: When a class inherits from a single base class, it is known as single inheritance.

www.oliveboard.in
www.oliveboard.in

Making a Private Member Inheritable: Basically, we have visibility modes to specify that in which mode you are
deriving another class from the already existing base class. The below mentioned table summarizes how the visibility
of members undergo modifications when they are inherited:

Base class Visibility Derived Class Visibility

Public derivation Private derivation Protected derivation

Private Not Inherited Not Inherited Not Inherited

Protected Protected Private Protected

Public Public Private Protected

Multilevel Inheritance: When the inheritance is such that, the class A serves as a base class for a derived class B
which in turn serves as a base class for the derived class C. This type of inheritance is called ‘MULTILEVEL
INHERITENCE’. The class B is known as the ‘INTERMEDIATE BASE CLASS’ since it provides a link for the
inheritance between A and C. The chain ABC is called ‘ITNHERITENCE PATH’ for example:

Multiple Inheritance: A class can inherit the attributes of two or more classes. This mechanism is known as
‘MULTIPLE INHERITENCE’.

Hierarchical Inheritance: In this type of inheritance, more than one sub class is inherited from a single base class.
i.e. more than one derived class is created from a single base class.

Hybrid Inheritance: Hybrid Inheritance is implemented by combining more than one type of inheritance. For
example: Combining Hierarchical inheritance and Multiple Inheritance.

www.oliveboard.in
www.oliveboard.in

Abstract classes: An abstract class is one that is not used to create objects. An Abstract class is designed only to act
as a base class (to be inherited by other classes). It is a design concept in program development and provides a base
upon which other classes may be built.
this pointer: Unique keyword called "this" is used to represent an object that invokes a member function. 'this' is a
pointer that points to the object for which this function was called.
Polymorphism: It simply means “one name multiple forms”.
Types of polymorphism:
• Compile time polymorphism: The overloaded functions are invoked by matching the type and number of
arguments. This information is available at the compile time and, therefore, compiler selects the appropriate
function at the compile time. It is achieved by function overloading and operator overloading which is also
known as static binding or early binding.
• Run time polymorphism: Run time polymorphism is achieved when the object's method is invoked at the
run time instead of compile time. It is achieved by method overriding which is also known as dynamic binding
or late binding.
Virtual Function: A virtual function is a member function in the base class that you redefine in a derived class. It is
declared using the virtual keyword. It is used to tell the compiler to perform dynamic linkage or late binding on the
function. A 'virtual' is a keyword preceding the normal declaration of a function.
super keyword in java: The super keyword in java is a reference variable which is used to refer immediate parent
class object. Whenever you create the instance of subclass, an instance of parent class is created implicitly which is
referred by super reference variable.
final Keyword in Java: The final keyword in java is used to restrict the user. The java final keyword can be used in
many contexts. final can be: variable, method and class.
The final keyword can be applied with the variables, a final variable that have no value it is called blank final variable
or uninitialized final variable. It can be initialized in the constructor only. The blank final variable can be static also
which will be initialized in the static block only.
Method Overriding in Java: If subclass (child class) has the same method as declared in the parent class, it is
known as method overriding in java.
▪ Method overriding is used to provide specific implementation of a method that is already provided by its super
class.
▪ Method overriding is used for runtime polymorphism
Rules for Java Method Overriding:
▪ method must have same name as in the parent class
▪ method must have same parameter as in the parent class.
▪ must be IS-A relationship (inheritance).
Abstract class in Java: A class that is declared with abstract keyword is known as abstract class in java. It can have
abstract and non-abstract methods (method with body). It needs to be extended and its method implemented. It
cannot be instantiated.
Interface in Java: An interface in java is a blueprint of a class. It has static constants and abstract methods. The
interface in java is a mechanism to achieve abstraction. There can be only abstract methods in the java interface not
method body. It is used to achieve abstraction and multiple inheritance in Java. Java Interface also represents IS-A
relationship. It cannot be instantiated just like abstract class.

www.oliveboard.in
www.oliveboard.in

Abstract class Interface

Abstract class can have abstract and non-abstract Interface can have only abstract methods. It can have default
methods. and static methods also.

Abstract class doesn't support multiple inheritance. Interface supports multiple inheritance.

Abstract class can have final, nonfinal, static and Interface has only static and final variables.
non-static variables.

The abstract keyword is used to declare abstract The interface keyword is used to declare
class. interface.

Abstract class can provide the implementation of Interface can't provide the implementation of abstract class.
interface.

Java Package: A java package is a group of similar types of classes, interfaces and sub-packages. Package in java
can be categorized in two form, built-in package and user-defined package. There are many built-in packages such as
java, lang, awt, javax, swing, net, io, util, sql etc.
Exception Handling: The exception handling in java is one of the powerful mechanisms to handle the runtime errors
so that normal flow of the application can be maintained. In java, exception is an event that disrupts the normal flow
of the program. It is an object which is thrown at runtime.
Types of Exception: There are mainly two types of exceptions: checked and unchecked where error is considered as
unchecked exception.
• Checked Exception: The classes that extend Throwable class except RuntimeException and Error are known
as checked exceptions e.g.IOException, SQLException etc. Checked exceptions are checked at compile-time.
• Unchecked Exception: The classes that extend RuntimeException are known as unchecked exceptions e.g.
ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException etc. Unchecked exceptions are
not checked at compile-time rather they are checked at runtime.
• Error: Error is irrecoverable e.g. OutOfMemoryError, VirtualMachineError, AssertionError etc.
Java try block: Java try block is used to enclose the code that might throw an exception. It must be used within the
method. Java try block must be followed by either catch or finally block.
Java catch block: Java catch block is used to handle the Exception. It must be used after the try block only. You can
use multiple catch block with a single try.
Java finally block: Java finally block is a block that is used to execute important code such as closing connection,
stream etc. Java finally block is always executed whether exception is handled or not. Java finally block follows try or
catch block.
Java throw keyword: The Java throw keyword is used to explicitly throw an exception. We can throw either checked
or unchecked exception in java by throw keyword. The throw keyword is mainly used to throw custom exception.
Java throws keyword: The Java throws keyword is used to declare an exception. It gives an information to the
programmer that there may occur an exception so it is better for the programmer to provide the exception handling
code so that normal flow can be maintained.
Java Custom Exception: If you are creating your own Exception that is known as custom exception or user-defined
exception. Java custom exceptions are used to customize the exception according to user need. By the help of custom
exception, you can have your own exception and message.
UNIX: AT&T Bell Labs released an operating system called Unix written in C, which allows quicker modification,
acceptance, and portability. The Unix OS works on CLI (Command Line Interface), but recently, there have been
developments for GUI on Unix systems.
Due to its portability, flexibility and power, UNIX has become a leading operating system for workstations. Example of
UNIX operating system are: AIX, ONX, Solaris, Darwin, Tru64 and IRIX etc.
• LINUX is the most popular and fastest growing of all the UNIX like operating System.
Key features of UNIX system:
• It uses centralized OS kernel that manages system and process activities.
• UNIX system supports multiple process to run at the same time, hence it is multitasking.
• UNIX system are multiuser and most robust operating system.
Basic commands in UNIX: Some of the basic commands of UNIX OS is given below:
1. User creation and changing password command:
• who: The standard Unix command who displays a list of users who are currently logged into the computer.

www.oliveboard.in
www.oliveboard.in

• whoami: This command is basically the concatenation of the strings “who”,”am”,”i” as whoami and displays
the username of the current user when invoked.
• w: This command provides a quick summary of every user logged into a computer, what each user is
currently doing, and what load all the activity is imposing on the computer itself.
• useradd: This command is used to add a user.
• passwd: This command is used to change the password of a user account.
• sudo: The sudo command allows users to run programs with the security privileges of another user (by
default, as the superuser or root user).
2. File system commands:
• ls<option>: ls command is a command-line utility for listing the contents of a directory or directories given
to it via standard input.

Option Description

ls -a list all files including hidden file starting with '.'

ls --color colored list [=always/never/auto]

ls -d list directories - with ' */'

ls -F add one char of */=>@| to entries

ls -i list file's index number

ls -l list with long format - show permissions

ls -la list long format including hidden files

ls -lh list long format with readable file size

ls -ls list with long format with file size

ls -r list in reverse order

ls -R list recursively directory tree

ls -s list file size

ls -S sort by file size

ls -t sort by time & date

ls -X sort by extension name

• cat<file name>: To view file


• cat><file name>: To create file
• clear: Used to bring the command line on top of the computer terminal.
• mkdir<directory name>: Allows users to create directories or folders.
• rmdir<directory name>: Used remove empty directories from the filesystem in UNIX.
• rm<file name>: used to remove objects such as files, directories, symbolic links and so on from the file
system like UNIX.
• cd: Used to change the current working directory in Unix-like operating systems.
• script: Used to make typescript or record all the terminal activities.
• exit: Used to exit the shell where it is currently running.
• cp<option>: This command in UNIX is used for copying files and directories.

www.oliveboard.in
www.oliveboard.in

Option Description

cp –f If the system is unable to open destination file for writing operation because the user doesn’t
have writing permission for this file then by using -f option with cp command, destination file
is deleted first and then copying of content is done from source to destination file.

cp –H This makes the cp command follow symbolic links so that the destination has the target file
rather that a symlink to the target.

cp –i i stands for Interactive copying. With this option system first warns the user before overwriting
the destination file. cp prompts for a response, if you press y then it overwrites the file and
with any other option leave it uncopied.

Cp –R or Copying directory structure. With this option cp command shows its recursive behaviour by
cp – r copying the entire directory structure recursively.

cp –p With -p option cp preserves the following characteristics of each source file in the
corresponding destination file: the time of the last data modification and the time of the last
access, the ownership, and the file permission-bits.

• mv<option>: Moves one or more files or directories from place to other.

Option Description

mv – f Force overwriting the destination.

mv – I Interactively process move action.

mv<filename><new filename> Used for renaming the file.

UNIX file system: UNIX file system is the method that an operating system uses to keep track of the file on a disk
or partition. Several different types of files are used in UNIX file system such as:
• Ordinary files: File on the system that contains data, text, or program instructions.
• Special files: Special files are used to represent a real physical device such as a printer, tape drive or
terminal, used for Input/Output (I/O) operations. A special file is sometimes also called a device file.
• Directories: Directories store both special and ordinary files.
• Named Pipes: UNIX allows users to link commands together using a pipe. Which acts a temporary file which
only exists to hold data from one command until it is read by another.
• Sockets: Sockets are also tools used for inter-process communication.
• Symbolic links: A link is a tool used for having multiple filenames that reference a single file on a physical
disk.
Other UNIX commands:
• pg: Displays the contents of text files, one page at a time.
• more: Used to view the text files in the command prompt, displaying one screen at a time in case the file is
large.
• split: Used to split or break a file into the pieces.
• cmp: Used to compare two files.
• comm: Used to find what is common between two files.
• diff: Used to display files differences.
Some General-Purpose Utilities:
• Display calendar: cal
• Display system date and time: date
• Display a message on screen: echo
• Display calculator: bc
• To check the users logged on to UNIX system: who
• Record your session: script
• Display a blown-up message: banner

www.oliveboard.in
FREE Ebooks Current Affairs
Download Now Explore Now

FREE MOCK TESTS + TOPIC TESTS + SECTIONAL TESTS

For Banking, Insurance, SSC & Railways Exams


Web APP

BLOG FORUM

Your one-stop destination Interact with peers & experts,


for all exam related exchange scores
information & preparation & improve your preparation.
resources.

Explore Now Explore Now

www.OliveBoard.in

You might also like