0% found this document useful (0 votes)
16 views367 pages

Feb 6th BSC Material All Subjects

The document provides an overview of Database Management Systems (DBMS), explaining key concepts such as data, information, data hierarchy, and the differences between file-based and database approaches. It outlines the operations, applications, advantages, and disadvantages of DBMS, as well as its classification based on various criteria. Additionally, it discusses the importance of data independence and the components of a DBMS, emphasizing its role in managing data efficiently.

Uploaded by

cpe sri chanakya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views367 pages

Feb 6th BSC Material All Subjects

The document provides an overview of Database Management Systems (DBMS), explaining key concepts such as data, information, data hierarchy, and the differences between file-based and database approaches. It outlines the operations, applications, advantages, and disadvantages of DBMS, as well as its classification based on various criteria. Additionally, it discusses the importance of data independence and the components of a DBMS, emphasizing its role in managing data efficiently.

Uploaded by

cpe sri chanakya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 367

SRI CHANAKYA DEGREE COLLEGE [Pick t

UNIT – I

1. Database Management System

Data:
Data is nothing but a raw fact used as input.
Information:
It is processed data obtained as output of data processing.
The activity of processing data using a computer is called data processing.

Data Information
1) Data is a raw factor and figures. 1) Information is a process of
Ex: 32 is a data. data. Ex: Age: 32.
2) It is not significant to a business. 2) It is significant to a business
3) It doesn’t help in decision 3) It helps in decision making
making.
4) Input to any system may be 4) Output after processing the
treated as data. system is information.
5) It is difficult to understand 5) It is easy to understand
properly. properly.
6) It may not be in the order. 6) It should be in the order.

Data Hierarchy:
It refers to the systematic organization of data. It involves bit, byte, field, record, file
and database.
i. Bit: - All data is stored in the memory in the form of bits or binary digits. It can be
either 1 or 0 on or off.
ii. Byte: - It is a collection of 8 bits; one byte can represent one character.
iii. Field: - It is a group of characters.
Ex: Name, Job, Salary etc… bit
iv. Record:- It is a collection of related fields holding byte
All the information about one person or Field
Entity. Record
Ex: Name, Salary, Id, Address etc… File
v. File:- It is a collection of related records. Database
vi. Database: - It is a collection of related files.

Database:
It can be defined as well organised collection of data that are related in a meaningful
way, which can be accessed by different users but stored only once.
1

DBMS 1
SRI CHANAKYA DEGREE COLLEGE [Pick t
Database Operations:
To maintain huge databases we need certain operations which help in maintaining the
data in the database efficiently.
The most commonly used operations are

Insertion: To add new data into the database.


Selection: To view or retrieve the stored data.
Updation: To modify or edit the existing data.
Deletion: To remove or delete the existing data from database.
Sorting: To arrange the data in a desired order (A.O or D.O)

Database Applications:
a) Banking: For customer information, accounts and loans, banking transactions.
b) Universities: 1st student information, course, registrations, results and grades.
c) Air lines: For reservations & schedule information
d) Sales: For customer products purchase information
e) Tele communication: For keeping records of calls made generating monthly bills &
storing information about the communication network.
f) Manufacturing: For tracking production of items in factories & order for items.
g) Human Resources: For information about employees salaries and taxes etc…
There are two approaches used for data management through computers
1) File based system
2) DBMS based system

File Based System:


It was an early attempt to computerize the manual filing system. It is basically a
collection of applications programs that performed services for the end users. Each program
within a file based system defines and manages its own data. In this system a large number of
files are needed to perform various tasks. This is called traditional file approach.

Characteristics of file based system:


 It is a group of files storing data of an organization.
 Each file is independent from one another.
 Each file is called a flat file.
 Each file contained and processed information for one special task.
 Files are designed by using programs such as C, C++
 Each file must have its own file management system.

Drawbacks of File Based System:


a) Data Redundancy:
Data redundancy means duplications of data values i.e, some information is

DBMS 2
SRI CHANAKYA DEGREE COLLEGE [Pick t
duplicated in several files. This makes data redundancy. It costs time and money to
enter the data more than once and also takes up additional storage space.
b) Data Inconsistency:
Data Inconsistency means different versions of same basic data are existing in
different files. This occurs as the result of update operations that are not updating same
data stored at different places.

c) Data Isolation:
Data are scattered in various files and files may be in different format, writing new
application program to retrieve data is difficult.
d) Integrity problems:
The data values may need to satisfy some integrity constraints.
e) Atomicity problem:
It is difficult to ensure atomicity in the file processing system. For eg: Transferring $
100 from account A to B. If a failure occurs during execution there could be situation
like $ 100 is detected from account A and not credited in account B.
f) Concurrent Access variation:
If multiple users are updating same data simultaneously it will result in inconsistent
data state. In this system it is very difficult to handle this using program code. This
results in concurrent access variation.
g) Security problems:
Enforcing security constraints in file processing system is very difficult as the
application programs are added to the system in an unplanned or informal manner.

Database Approach:
In order to remove all the limitations of the file based approach a new approach was
required. This approach is known as database approach.
A database is a single large repository of the data which can be used simultaneously by
many users and departments.

Characteristics of Database Approach:


 It is central repository of shared data. It allows several users to access the data base
concurrently.
 In this approach the database system doesn’t only contain the data but also the complete
definition and description of these data. This kind of stored data is called metadata
(“data about data”)
 Data should be protected from un authorized access.
 Duplication of data is minimised.
 Data in database exist permanently.

DBMS 3
SRI CHANAKYA DEGREE COLLEGE [Pick t
Drawbacks of Database Approach:
 Database management systems difficult to setup and operate.
 With the file management system, a failure of a file only effects a single program. But
with database management system, a failure can shut down entire database.
 It can be more expensive to purchase and operate.
 Recovery is more complex.

Difference between Filebased Appraoch Vs Database Approach

File based Data based


1) In file based system, each 1) It is a collection of interrelated files
application has its own private data & set of application programs to
files. access and modify the files.
2) It is used in small systems which 2) It is used in large systems which
require few files to represent it. inter relate many files.
3) It is cheaper to design. 3) It is very expensive.
4) It is simple structure. 4) Its structure is relatively complex.
5) In this system there exists lot of 5) The problem of data redundancy as
duplication of data which may lead well as inconsistency is controlled.
to data inconsistency.
6) Isolated data. 6) Data can be shared.
7) Recovery Backup is simple. 7) Recovery Backup is more complex.

8) Multiple user access is difficult to 8) Allow multiple users to access the


provide. database at same time.
9) Ex: C, Cobol etc… 9) Ex: Oracle, SQL, My SQL

Introduction of DBMS:
It is a software system used to manage database and its various operations like insertion,
deletion, updation and retrival.
It enables users to store, modify and extract information from a database as per the
requirements. It is an intermediator between the usesr and database.

Objectives of DBMS:
Data Availability: It refers to the fact that the data are made available to large variety of
users at quality cost. So that the users can easily access the data.
Data Integrity: It refers to the completeness correctness and consistency of data.
Integrity is related to quality of data which is maintained with the help of integrity constraints.

DBMS 4
SRI CHANAKYA DEGREE COLLEGE [Pick t
Data Security: It refers to the fact that only authorized users can access the data. It can be
enforced by password.
Data Independence: DBMS supports the concept of data independence. Since its
represents a system for managing data separately from the programs that use the data.

Advantages of DBMS:
1) Minimized Redundancy:
Minimizing Redundancy can reduce the cost of storing information on hard drives
& other storage devices. The data in a DBMS is more clear because the
information in it appears just once. This reduces data redundancy creats several
problems like requiring extra storage base, entering same data more than one place
during deletion.
2) Elimination of Inconsistency:
In the file processing system information is duplicated throughout the system. So
changes made in a one file may be necessary be carried over to another file. This
may lead to inconsistent data. So we need to remove this duplication of data in
multiple point to eliminate in consistency. DBMS centralize the entire database, so
that changes once made are reflected all the tables where a particular field is stored.
3) Sharing of data:
In a paper based recording keeping data cannot be shared among many users. But in
centralized DBMS many users can share the data base, if they are connected to a
network.
4) Data Security:
We can restrict certain people from accessing the database or allow them to see
certain portion of the database while blocking sensitive information. This is not
possible very easily in a backup case record keeping.
5) Flexibility:
Since changes are often necessary to the contents of the data stored in any system,
these changes are made more easily in a centralized database than conventional (file
based) system. Application programs need not be changed on changing the data in
the database.
6) Data Integrity:
Accurate consistent and up-to-date data is called data integrity. DBMS supports data
integrity. Therefore data values being entered for storage would be checked to
ensure that they fall within a specified range and are of the correct format. Moreover
updates and changes to the data only have to be made in one place.
7) Provides and backup and recovery:
Centralizing a database provide the schemes such as recovery and backups from the
failures including power failures, software errors, dish crash which may help the
database to recover from the inconsistent state to the normal state.

DBMS 5
SRI CHANAKYA DEGREE COLLEGE [Pick t
Disadvantages of DBMS:
There could be a few disadvantages of using DBMS
1) Highcost:
As DBMS needs computers we have to invest a good amount in acquiring the hardware,
software and installation facilities.
2) Security Threats:
Even with safe guards in place it may be possible for some unauthorized users to access
the database.
3) Complexity of backup& recovery:
Backup and recovery operations are fairaly complex in a DBMS environment we have
to keep regular backups is a lengthy process and the computer system cannot perform
any another job at this time.
4) Classification of DBMS:
The DBMS can be classified into different categories on the basis of several criteria.
Based on data models:
Depending on the datamodels they use, the DBMS can be classified as hierarchical,
network and relational.
1) Hierarchical DBMS:
It organises the data records in a tree structure i.e hierarchy of parent, child
relationship. A parent record may have more than one child but a child always has
only one parent this is called one to many relationships.
2) Network:
DBMS organises the data records linked to one another through pointers which is an
association between two records. It is similar to hierarchical database except that each child
can have more than one parent record. This is called many to many relationships.
3) Relational:
It organises the data records in the form of tables and relationships among the
tables are set using common fields. It is simple because data is represented in
tabular format.
Based on number of users:
Depending on the number of users, it is divided into two categories
1) Single user system
2) Multi user system
1) Single user system:
The database resides on one computer and only accessed by one user at a time, the user
may design, maintain and manipulating the database according to the requirements.
2) Multiuser system:
Multiple users can access the database simultaneously; this system the data is both
integrated and shared.
Based on number of sites:
Depending on the number of sites it is divided into 2 types centralized and distributed

DBMS 6
SRI CHANAKYA DEGREE COLLEGE [Pick t
data system.
1) Centralised database systems:
It runs on a single computer system. Both the database and the DBMS software
received a single computer site.
2) Distributed database systems:
The database and DBMS software are distributed over several computers located at
different sites. The computers communicate with each other through various
communication media such as highspeed networks.

Based on purpose:
Depending on the purpose it can be classified as general purpose & special purpose.
DBMS is a general purpose software system. It can be design for specific purpose such
as airline or railway reservation. Such systems cannot be used for other applications. These
data base systems fall under the category of OLTP (Online transaction processing
systems). It is specially used for Data entry and retriever. An ATM is an example of OLTP
application.

Data Independence:
DBMS supports the concept of data independence. Since it represents a system managing
data separately from the programs that use the data. The 3 levels of architecture of DBMS
provides the concept of data independence which means upper levels are unaffected
changes to lower level.
Types of data independence:
There two types of data independences
1) Logical Independence 2) Physical Independence

1) Logical Independence:
The ability to change the logical (or) conceptual schema of database without changing
the external schema. This is called logical data independence. External
Eg: the additional or removal of an altribute or field to the
conceptual should be possible without having to change
Conceptual
external schema.
Intermal
2) Physical Data Independence:
The ability to change the physical or internal schema without changing the logical schema
is called physical data independence.
Ex: A change to internal schema, such as using different storage devices should be
possible with out having to change the conceptual schema.

DBMS 7
SRI CHANAKYA DEGREE COLLEGE [Pick t
Components& Interfaces of DBMS:
DBMS acts as an interface between user and database. The user requests the DBMS
to perform various operations in D.B. The components of DBMS perform these operations
on database and provide necessary data to the users.
DBMS is composed of 4 major components
1) Data 2) Hardware 3) Software 4) Users

1) Data: It is very important component in DB system. The data acts as a bridge between
the machine parts i.e hardware and software and the users, which directly access
through some application programs. Data may be of 2 types
a) User data b) Meta data

a) User data: It consists of a table of data called relation, where columns are called fields,
rows are called tuples.
b) Meta data: It means data about data. It is the description about the structure of DB i.e
basic information about the design of each table.
2) Hardware: It consists of the secondary storage devices such as disks, optical and
magnetic disks etc. And it also includes input output devices, process etc. Which are
used for storing and retrieving the data in an efficient manner.
3) Software: It consists of DBMS, which acts as a bridge between user and database. On
request from users for access to the DB are handled by the DBMS. It allows the users to
perform all the operations. We can use the query languages like SQL, My SQL etc.
4) Users: The users are the people who manage the DBS and perform different operations
on the DB system. Users can be clerks, managers, programmers etc. The users can be
classified into following categories.
a) Native users: These users have no knowledge of DB system. An ATM user is in
these categories.
b) Online users: Online users are those who may communicate with DB via a user
interface. The users are aware of DB system.
c) Application programmers: Application programmers/ professional programmers
who are responsible for developing application.
These programmers work according to the some instructions (Database Administrator).

DBA: The DBA is a single person or group of persons responsible for implementing the
DB system within an organization. He is only the guardian of the organization.
End users or Data entry operators:
These are only to operate the computer and type the data in application program and to
executing according to the requirement.

DBMS 8
SRI CHANAKYA DEGREE COLLEGE [Pick t
Database Architecture:
It describes the location of all the pieces of information that make up the database
application. It can be classified into following types.
i. Single-tier architecture
ii. Two-tier architecture
iii. Three-tier architecture
iv. N-tier architecture

i. Single tier architecture:


It consists of a single computer that contains a database and front end to access
the database.
There is one computer which stores all the data on a single database. The interface
used to interact with the database. Generally this type of system is found in small
business.

In single tier the DBMS software and the data reside in one lacation and the dumb terminals
were used to access the database. In this architecture
user interface business logic and data storage are all located on the machine. They are
the easiest to design but the least scalable. (Adding of features of size).
Advantages:
1) A single tier system requires only one computer.
2) It also requires only one installation of software.
Disadvantages:
1) May be used by only one user at a time.
2) A single tier system is an impractical for an organisation, which requires more than one
user to interact with the data at the same time.
Dumb
Terminal

DBMS software
Dumb
Terminal
Data

Dumb
Terminal

ii. Two- tier Architecture:


It consists of 2 systems a client and a server. The database is stored under server
and a interface used to access database is installed on the client.
The client request services directly from server without the help of another server. In

DBMS 9
SRI CHANAKYA DEGREE COLLEGE [Pick t
2 tier model the user interface runs on the client and the database is stored on the
server. The application logic can run on client.

[Open database
ODBC connectivity]

Client system DB server

Advantages:
1) Least complicated to implement.
2) Tools are relatively in expensive.
3) It provides more attractive GUI (Graphical User Interface) applications
4) It maintains a persistent (proper) connection between the client and database.
5) It is a great deal of flexibility and simplicity in management.

Disadvantages:
1) As the application development is run on client side, maintenance cost of application,
tools are expensive.
2) Since actual processing of data takes on the client the data has to be transported over the
network. This leads to increased network issues.

iii. Three-tier Architecture:


In three-tier Architecture the client requests are handled by intermediate servers i.e
middle way which provides a way for clients of one DBMS to access the data from
another DBMS.
st
1 tier-client tier:
In this tier client sends request for the information the main responsibility of this tier is
to receive user events and to control the user interface and data.
2nd tier-Application server / Middle tier:
The complex application logic is loaded here and available to the client tier on request
from the client.
3rd tier-Database server:
The 3rd tier contains the data that is needed for the application i.e this tier is responsible
for data storage.
Advantages:
1) It improves data integrity.
2) Security is improved. Since the client doesn’t have direct access to the database business
logic is more secure.

DBMS 10
SRI CHANAKYA DEGREE COLLEGE [Pick t
3) Load balancing is easier with the separation of business logic from the database server.
4) It improves scalability.
Disadvantages:
1) More complex than 2-tier model because it is more difficult to build a 3-tier
applications.
2) A separate proxy-server (intermediate) may be required. Notwork traffic will be
increased.

Client system application logic DB server


Client tier middle tier

N-tier Architecture:
In N-tier Architecture the middle tier can be allowed to have multiple application
objects rare than a single application. Each of these application object must have a well
defined interface which allows them to contact and communicate with one another.

Advantages:
1) Overall performance has been improved.
2) The business logic is centralized.
3) Provides many services to many clients.
4) Enhance scalability and availability and enhance to security level is obtain.
5) It may applications more readable and reusable.
Disadvantages:
1) Much more complicated to design than 2-tier, 3-tier models.
2) More difficult to maintain software.
3) Loadbalancing is ordered.
4) Reliability is more difficult.

DBMS 11
SRI CHANAKYA DEGREE COLLEGE [Pick t

Level-1 Client

Level-2 Server

Level-3 Server

Server

Level-4 Server

Data Model:
It can be defined as an integrated collection of concepts that can be used to describe the
logical structure of the database including datatypes, relationships between data and
constraints that should apply on the data.
Components of data model:
A data model comprises of following three components
i. Structural part: It consists of a set of rules according to which databases can be
constructed.
ii. Manipulative part: It defines the types of operation that are allowed on the data. This
includes the operations that are used for updating a retrieving data from the database and
for changing the structure of the database.
iii. Integrity Rules: Rules which ensures that the data is accurate.

Data Models basic building blocks:


The basic building blocks of all data models are entities, attributes, relationships and
constraints.
 Entity: Anything about which data are to be collected and stored.
Eg: Student, Teacher, Employee and Manager.
 Attribute: A characteristic of an entity.
Eg: Name, Salary, Job of an entity employee.
 Relationship: An association among (two or more) entities.

a) One to one (1:1) Relationship:


Eg: Department Vs Manager.
b) One to many (1:M) Relationship:
Eg: Manager Vs Employee.

DBMS 12
SRI CHANAKYA DEGREE COLLEGE [Pick t
c) Many to one (M:1) Relationship:
Eg: Employee Vs Manager.
d) Many to many (M:N orM:M) Relationship:
Eg: Students Vs Course
Constraints: A constraint is a restriction placed on the data. Constraints are imp because
they help to ensure data integrity. Constraints are normally expressed in the form of rules.
Eg: An employee’s salary must be between 10000 & 50000
Each class must have one and only teacher.

Types of data models:


The most widely accepted data models are:
1) Hierarchical Model 2) Network Model 3) Relational Model

1) Hierarchical Model:
 Hierarchical database model is one of the oldest database models, dating from late
1950s.
 The general shape of this model is like an organizational chart. A node on the chart
represents a particular entity. The terms parent and child are often used in describing a
hierarchical model.
 This model used the tree as its basic structure. A tree is data structure that consists of a
hierarchy of nodes, with a single node, called the root, at the highest level.
 A node represents a particular entity. A node may have any number of children, but
each child node may have only one parent node.
 The nodes of the tree represent data records. The relationships are represented as links
or pointers between nodes.
University

Mathematics Computer
department department

Library Computer lab

 To locate a particular record in hierarchical database, you have to start at the top of the
tree with a parent record and trace down the tree to the child.

DBMS 13
SRI CHANAKYA DEGREE COLLEGE [Pick t

Advantages of Hierarchical Model:


i. Simplicity: Since the data based on the hierarchical structure, the relationship between
the various layers is logically simple.
ii. Data security: Hierarchical model was the 1st database model that offered the data
security that is provided by DBMS.
iii. Data Integrity: Since it is based on the parent child relationship, there is always a link
between the parent segment and the child segment under it.
iv. Efficiency: It is very efficient because when the database contains a large number of 1:
N relationship and when the user requires large number of transactions.
Disadvantages of Hierarchical:
i. Implementation Complexity: Although it is simple and easy to design, it is quite
complex implement.
ii. Database Management problem: If you make any changes in the database structure,
that you need to make changes in the entire application program that access the
database.
iii. Lack of Structural Independence: There is lack of structural independence because
when we change the structure then it becomes compulsory to change the applications
too.
iv. Operational Anomalies: Hierarchical model suffers from the insert, delete and update
anomalies also retrieval operation is difficult.

2) Network Model:
 The network data model was developed to overcome the limited scope of hierarchical
model. Here, multiple parent child relationships are used.
 In this model, there is no distriction between parent and child node as in the hierarchical
model. Each node may be related to more than one node.

 The main difference of network model with hierarchical model is that a network model
with hierarchical model is that a network model permits a child node to have more than
one parent nodes where as hierarchical model doesnot allows a childnode to have
multiple parent nodes.

Advantages of network model:


i. Conceptual simplicity:
Like hierarchical model, network model is also simple and easy to implement.
ii. Capability to handle more relationship types:
The network model can handle one to one (1:1) and many to many (N:N) relationships.
iii. Easy to access data:
Rapid and easy access to data is possible in this model due to multiple access paths to
the data elements.

DBMS 14
SRI CHANAKYA DEGREE COLLEGE [Pick t
iv. Data Integrity:
Since it is based on the parent child relationship, there is always a link between the
parent segment and the child segment under it.

v. Data Independence:
The network model is better than hierarchical model in case of data independence.
Disadvantages of Network model:
i. System Complexity: All the records have to maintain using pointers thus the data base
structure becomes more complex.
ii. Operation Anomalies: As discussed earlier in network model large number of printers
is required so insertion, deletion and updating more complex.
iii. Absence of structural independence: There is lack of structural independence because
when we change the structure then it becomes compulsory to change the application too.

3) Relation Model:
The most popular data model in DBMS is the relational model. The principles of the
relational model were 1st outlined by Dr E.F Codd in June 1970.
i. In relation model, data is organized interms of rows and columns in a table known as
relation. Each table consists of rows also known as tuples (A tuple represents a
collection of information that describes a person, place or thing) and columns also
known as attributes.
ii. The number of tuples in a relation determines its cardinality and the number of attributes
in tuple determines its degree.
Advantages of Relation Model:
i. Conceptual Simplicity: We have seen that both the hierarchical and network models are
conceptually simple, but relational model is simplier than both of these two.
ii. Structural Independence: In the relation model achieves both data independence and
structural independence.
iii. Design Implementation: The relational model achieves both data independence and
structural independence.
iv. Query capability: The presence of very powerful, flexible and easy to use capability is
one of the main resources for the immense popularity of the relational database model.
v. Security: Security control and authorization can also be implemented more easily by
moving sensitive altributes in a given table into a separate relation with its own
authorization controls.
Disadvantages of relational model:
i. Hardware overheads: Relational database system hides the implementation complexities
and the physical data storage details from the user.
ii. Cost: One disadvantage of relational databases is the expensive of setting up and
maintaining the database system.

DBMS 15
SRI CHANAKYA DEGREE COLLEGE [Pick t
Cost and Risks of Database Approach
The database approach emphasizes data integration and sharing across organizations. As with any
business decision, the database approach entails some additional costs and risks that must be
recognized and managed when implementing this approach. Mentionable some costs & risks of
database approach are as follows

New Specialized Personnel:


The rapid changes in technology new people will have to be retrained or upgraded on a regular basis.

Installation & Management Costs and complexity: A multi-user database management system is a large
and complex suite of software that has a high initial cost, requires a staff of trained personnel to install and
operate, and also has substantial annual maintenance & support costs.

Conversion Costs: The cost of converting the traditional file processing systems to modern database
technology: measured in terms of money, time, and organizational commitment.

Need for explicit Backup & Recovery: A shared corporate database must be accurate and available at all
times. These require that comprehensive procedures be developed and used for providing backup copies of
data and for restoring a database when damage occurs.

Organizational Conflict: A shared database requires a consensus on data definitions and ownership as well
as responsibilities for accurate data maintenance.

DBMS 16
SRI CHANAKYA DEGREE COLLEGE [Pick t
UNIT II
ENTITY RELATIONSHIP MODEL

***Q1. Explain components of ER diagram? or


The building blocks of an entity relationship diagram ?
The components of ER diagram are as follows −
 Entity
 Attributes
 Relationship
 Weak entity
 Strong entity
 Simple attribute
 Key attribute
 Composite attribute
 Derived attribute
 Multivalued attribute

The components of the ER diagram are pictorially represented as follows −

Entity
It may be an object, person, place or event that stores data in a database. In a relationship
diagram an entity is represented in rectangle form. For example, students, employees, managers,
etc. The entity is pictorially depicted as follows −

DBMS 17
SRI CHANAKYA DEGREE COLLEGE [Pick t

Entity set
It is a collection of entities of the same type which share similar properties. For example, a
group of students in a college and students are an entity set.
Entity is characterized into two types as follows −
 Strong entity set
 Weak entity set
Strong entity set
The entity types which consist of key attributes or if there are enough attributes for forming a
primary key attribute are called a strong entity set. It is represented by a single rectangle.
For Example,
Roll no of
student
EmpID of employee

Weak entity set


An entity does not have a primary key attribute and depends on another strong entity via
foreign key attribute. It is represented by a double rectangle.

Attributes
It is the name, thing etc. These are the data characteristics of entities or data elements and
data fields.

Types of attributes
The types of attributes in the Entity Relationship (ER) model are as follows −
Single value attribute − These attributes contain a single value. For example, age, salary
etc. Multivalued attribute − They contain more than one value of a single entity. For
example, phone numbers.
Composite attribute − The attributes which can be further divided. For example, Name-> First
name, Middle name, last name
Derived attribute − The attribute that can be derived from others. For example, Date of Birth.

DBMS 18
SRI CHANAKYA DEGREE COLLEGE [Pick t

Relationship
It is used to describe the relation between two or more entities. It is represented by a diamond
shape. For Example, students study in college and employees work in a department.
The relationship is pictorially represented as follows −

Here works for is a relation between two entities.


Degree of Relationship
A relationship where a number of different entities set participate is called a degree of a
relationship. It is categorized into the following −
 Unary Relationship
 Binary Relationship
 Ternary Relationship
 n-ary Relationship

***Q2. Classification of Entity Sets?


It is a collection of entities of the same type which share similar properties. For example, a group
of students in a college and students are an entity set. An entity set may be of the following two
types-

1. Strong entity set


2. Weak entity set

DBMS 19
SRI CHANAKYA DEGREE COLLEGE [Pick t
1. Strong Entity Set-
 A strong entity set is an entity set that contains sufficient attributes to uniquely identify
all its entities.
 In other words, a primary key exists for a strong entity set.
 Primary key of a strong entity set is represented by underlining it.
Symbols Used-
 A single rectangle is used for representing a strong entity set.
 A diamond symbol is used for representing the relationship that exists between two
strong entity sets.
 A single line is used for representing the connection of the strong entity set with the
relationship set.
 A double line is used for representing the total participation of an entity set with the
relationship set.
 Total participation may or may not exist in the relationship.

Example-
Consider the following ER diagram-

In this ER diagram,
Two strong entity sets “Student” and “Course” are related to each other.
 Student ID and Student name are the attributes of entity set “Student”.
 Student ID is the primary key using which any student can be identified uniquely.
 Course ID and Course name are the attributes of entity set “Course”.
 Course ID is the primary key using which any course can be identified uniquely.
 Double line between Student and relationship set signifies total participation.
 It suggests that each student must be enrolled in at least one course.
 Single line between Course and relationship set signifies partial participation.
 It suggests that there might exist some courses for which no enrollments are made.

DBMS 20
SRI CHANAKYA DEGREE COLLEGE [Pick t
2. Weak Entity Set-
 A weak entity set is an entity set that does not contain sufficient attributes to uniquely
identify its entities.
 In other words, a primary key does not exist for a weak entity set.
 However, it contains a partial key called as a discriminator.
 Discriminator can identify a group of entities from the entity set.
 Discriminator is represented by underlining with a dashed line.
Symbols Used-
 A double rectangle is used for representing a weak entity set.
 A double diamond symbol is used for representing the relationship that exists between
the strong and weak entity sets and this relationship is known as identifying
relationship.
 A double line is used for representing the connection of the weak entity set with the
relationship set.
 Total participation always exists in the identifying relationship.

Example-

Consider the following ER diagram-

In this ER diagram,
 One strong entity set “Building” and one weak entity set “Apartment” are related to each
other.
 Strong entity set “Building” has building number as its primary key.
 Door number is the discriminator of the weak entity set “Apartment”.
 This is because door number alone cannot identify an apartment uniquely as there may be
several other buildings having the same door number.
 Double line between Apartment and relationship set signifies total participation.
 It suggests that each apartment must be present in at least one building.
 Single line between Building and relationship set signifies partial participation.

DBMS 21
SRI CHANAKYA DEGREE COLLEGE [Pick t
 It suggests that there might exist some buildings which has no apartment.

***Q3. Differences between Strong entity set and Weak entity set-

Strong entity set Weak entity set

A single rectangle is used for the representation A double rectangle is used for the representation
of a strong entity set. of a weak entity set.

It contains sufficient attributes to form its It does not contain sufficient attributes to form
primary key. its primary key.

A diamond symbol is used for the representation A double diamond symbol is used for the
of the relationship that exists between the two representation of the identifying relationship that
strong entity sets. exists between the strong and weak entity set.

A single line is used for the representation of the A double line is used for the representation of
connection between the strong entity set and the the connection between the weak entity set and
relationship. the relationship set.

Total participation may or may not exist in the Total participation always exists in the
relationship. identifying relationship.

Q4. Classification of attributes?


The different types of attributes are as follows –

DBMS 22
SRI CHANAKYA DEGREE COLLEGE [Pick t
Composite attribute
It can be divided into smaller sub parts, each sub part can form an independent attribute.
For example −
Name
FirstName MiddelName LastName
Simple or Atomic attribute
Attributes that cannot be further subdivided are called atomic attributes.
For example −
Phone number
PIN code

Single valued Attribute


Attributes having a single value for a particular item is called a single valued attribute.
For example: Room Number

Multi-valued Attribute
Attribute having a set of values for a single entity is called a multi-valued attribute.
For example − e-mail, Tel.No , Hobbies

DBMS 23
SRI CHANAKYA DEGREE COLLEGE [Pick t

Derived Attributes or stored Attributes


When one attribute value is derived from the other is called a derived attribute.
For example: Age can be derived from date of birth, where,
 Age is the derived attribute.
 DOB is the stored attribute.

Complex Attribute
Nesting of composite and multi-valued attributes forms a complex attribute.
For example
If a person has more than one house and each house has more than one phone. Then, that
attribute phone is represented as a complex attribute.

***Q5. Explain Degree of Relationship?

A degree of relationship represents the number of entity types that associate in a relationship.
Types of degree
Now, based on the number of linked entity types, we have 4 types of degrees of relationships.
1. Unary
2. Binary
3. Ternary
4. N-ary

DBMS 24
SRI CHANAKYA DEGREE COLLEGE [Pick t
Unary

Unary relationships exist when both entity types are the same and we call them the degree of
relationship is 1. Or in other words, in a relation only one entity set is participating then such
type of relationship is known as a unary relationship.

Binary (degree 2)

Binary relationship exists when there are two types of entity and we call them a degree of
relationship is 2. Or in other words, in a relation when two entity sets are participating
then such type of relationship is known as a binary relationship.
Example: We have two entity types ‘Student’ and ‘ID’ where each ‘Student’ has his ‘ID’. So,
here two entity types are associating we can say it is a binary relationship.

Ternary(degree 3)

Ternary relationship exists when there are three types of entity and we call them a degree of
relationship is 3. Since the number of entities increases due to this, it becomes very complex
to turn E-R into a relational table.
Example: We have three entity types ‘Teacher’, ‘Course’, and ‘Class’. The relationship
between these entities is defined as the teacher teaching a particular course; also the teacher
teaches a particular class.

DBMS 25
SRI CHANAKYA DEGREE COLLEGE [Pick t
N-ary (n degree)

N-ary relationship exists when there are n types of entities. There is one limitation of the N-ary
relationship, as there are many entities so it is very hard to convert into an entity to rational
table. So, this is very uncommon, unlike binary which is very much popular.
Example: We have 5 entities Teacher, Class, Location, Salary, Course. So, here five entity
types are associating we can say an n-ary relationship is 5.

***Q6. Classification of Relationships


Any association between two entity types is called a relationship. Entities take part in the
relationship. It is represented by a diamond shape. There are three types of relationships that
can exist between two entities.

 One-to-One Relationship
 One-to-Many or Many-to-One Relationship
 Many-to-Many Relationship

One-to-One Relationship (1:1)


Such a relationship exists when each record of one table is related to only one record of the
other table. For example, If there are two entities ‘Person’ (Id, Name, Age, Address)and
‘Passport’(Passport_id, Passport_no). So, each person can have only one passport and each
passport belongs to only one person.

DBMS 26
SRI CHANAKYA DEGREE COLLEGE [Pick t
One-to-Many or Many-to-One Relationship
Such a relationship exists when each record of one table can be related to one or more than one
record of the other table. This relationship is the most common relationship found. A one-to-
many relationship can also be said as a many-to-one relationship. For example, If there are
two entity type ‘Customer’ and ‘Account’ then each ‘Customer’ can have more than one
‘Account’ but each ‘Account’ is held by only one ‘Customer’.

Many-to-Many Relationship
Such a relationship exists when each record of the first table can be related to one or more than
one record of the second table and a single record of the second table can be related to one or
more than one record of the first table. Example: If there are two entity type ‘Customer’ and
‘Product’ then each customer can buy more than one product and a product can be bought by
many different customers.

Notations for ER Diagram

DBMS 27
SRI CHANAKYA DEGREE COLLEGE [Pick t
Q7. Explain reducing ER Diagram to Tables. Or Explain how to convert ER diagram to
Tables.
Entity relationship diagram is the graphical representation of entities and relationships among
those entities in the database.
Example

Conversion of ER diagrams to tables


Follow the steps given below for the conversion of the ER diagrams to tables in the database
management system (DBMS) −
Step 1 − Conversion of strong entities
For each strong entity create a separate table with the same name.
Includes all attributes, if there is any composite attribute divided into simple attributes
and has to be included.
Ignore multivalued attributes at this stage.
Select the primary key for the table.
Step 2 − Conversion of weak entity
For each weak entity create a separate table with the same name.
Include all attributes.
Include the Primary key of a strong entity as foreign key is the weak entity.
 Declare the combination of foreign key and decimator attribute as Primary key from the
weak entity.
Step 3 − Conversion of one-to-one relationship
 For each one to one relation, say A and B modify either A side or B side to include the
Primary key of the other side as a foreign key.

DBMS 28
SRI CHANAKYA DEGREE COLLEGE [Pick t
 If A or B is having total participation, then that should be a modified table.

 If a relationship consists of attributes, include them also in the modified table.


Step 4 − Conversion of one-to-many relationship
 For each one to many relationships, modify the M side to include the Primary key of one
side as a foreign key.
 If relationships consist of attributes, include them as well.
Step 5 − Conversion of many-many relationship
 For each many-many relationship, create a separate table including the Primary key of M
side and N side as foreign keys in the new table.
 Declare the combination of foreign keys as Primary Key for the new table.
 If relationships consist of attributes, include them also in the new table.
Step 6 − Conversion of multivalued attributes
 For each multivalued attribute create a separate table and include the Primary key of the
present table as foreign key.
 Declare the combination of foreign key and multivalued attribute as Primary keys.
Step 7 − Conversion of n-ary relationship
 For each n-ary relationship create a separate table and include the Primary key of all
entities as foreign key.
 Declare the combination of foreign keys as Primary key.
Table
After successful conversion, the result will be as follows −

DBMS 29
SRI CHANAKYA DEGREE COLLEGE [Pick t

Q8. Explain Enhanced ER Model?

EER is a high-level data model that incorporates the extensions to the original ER model.

It is a diagrammatic technique for displaying the following concepts


A. Sub Class and Super Class
B. Specialization and Generalization
C. Union or Category
D. Aggregation

These concepts are used when the comes in EER schema and the resulting schema diagrams
called as EER Diagrams.

Features of EER Model

 EER creates a design more accurate to database schemas.


 It reflects the data properties and constraints more precisely.
 It includes all modeling concepts of the ER model.
 Diagrammatic technique helps for displaying the EER schema.
 It includes the concept of specialization and generalization.
 It is used to represent a collection of objects that is union of objects of different of
different entity types.

A. Sub Class and Super Class


 Sub class and Super class relationship leads the concept of Inheritance.
 The relationship between sub class and super class is denoted with symbol.
1. Super Class
 Super class is an entity type that has a relationship with one or more subtypes.
 An entity cannot exist in database merely by being member of any super class.
For example: Shape super class is having sub groups as Square, Circle, Triangle.
2. Sub Class
 Sub class is a group of entities with unique attributes.
 Sub class inherits properties and attributes from its super class.
For example: Square, Circle, Triangle are the sub class of Shape super class.

DBMS 30
SRI CHANAKYA DEGREE COLLEGE [Pick t

B. Specialization and Generalization

1. Generalization
 Generalization is the process of generalizing the entities which contain the properties of all the
generalized entities.
 It is a bottom approach, in which two lower level entities combine to form a higher level entity.
 Generalization is the reverse process of Specialization.
 It defines a general entity type from a set of specialized entity type.
 It minimizes the difference between the entities by identifying the common features.
For example:

In the above example, Tiger, Lion, Elephant can all be generalized as Animals.

DBMS 31
SRI CHANAKYA DEGREE COLLEGE [Pick t
2. Specialization
 Specialization is a process that defines a group entities which is divided into sub groups based
on their characteristic.
 It is a top down approach, in which one higher entity can be broken down into two lower level
entity.
It maximizes the difference between the members of an entity by identifying the unique
characteristic or attributes of each member.
It defines one or more sub class for the super class and also forms the superclass/subclass
relationship.
For example

In the above example, Employee can be specialized as Developer or Tester, based on what role
they play in an Organization.

C. Category or Union
Category represents a single super class or sub class relationship with more than one super
class. It can be a total or partial participation.


DBMS 32
SRI CHANAKYA DEGREE COLLEGE [Pick t

D. Aggregation
 Aggregation is a process that represent a relationship between a whole object and its component
parts. It abstracts a relationship between objects and viewing the relationship as an object.
 It is a process when two entity is treated as a single entity.

In the above example, the relation between College and Course is acting as an Entity in Relation
with Student.
***Q9. List advantages and disadvantages of ER Modeling?
Advantages of ER Model

 Conceptually it is very simple: ER model is very simple because if we know


relationship between entities and attributes, then we can easily draw an ER diagram.
 Better visual representation: ER model is a diagrammatic representation of any logical
structure of database. By seeing ER diagram, we can easily understand relationship
among entities and relationship.

 Effective communication tool: It is an effective communication tool for database


designer.

 Highly integrated with relational model: ER model can be easily converted into
relational model by simply converting ER model into tables.

 Easy conversion to any data model: ER model can be easily converted into another data
model like hierarchical data model, network data model and so on.

DBMS 33
SRI CHANAKYA DEGREE COLLEGE [Pick t
Disadvantages of ER Model

 Limited constraints and specification


 Loss of information content: Some information be lost or hidden in ER model
 Limited relationship representation: ER model represents limited relationship as
compared to another data models like relational model etc.
 No representation of data manipulation: It is difficult to show data manipulation in ER
model.
 Popular for high level design: ER model is very popular for designing high level design
 No industry standard for notation

Constraints of specialization and generalization:

The constraints on specialization and generalization can be brought classified as 2 types


i) Disjointness constraints
ii)completeness constraints

1) Disjointness constraints: It allows us to specify whether instance of a super type may simultaneously be a
member of 2 or more subtypes. It has 2 categories
1. Overlap constraints
2. Disjoint constraints
3.
Overlap constraints: It refers to the fact that the same entity instance may be a member of more than one sub
class of the specialization

Consider the example of animal entity which can be further subdivided in to land Animal
Animal And water animal. consider the example of frog and crockodial which can
live in both land and water. O Overlap
Construct

Land Water

Disjointness constrain: It refers to the fact that the same entity instance may be a
member of only One subclass of the specialization
Employ

Eg: consider the example of employee is the super class which can be further O
Sub divided in to part time employee and full time employee. This falls under
Disjointness because a employee entity can be Fulltime Part time
Either part time or full time.

Completeness constraints: In this constraint whether an instance of a super type must also be a member of
atleast one subtype. In this we have two categories.

1) Total specialization 2) partial specialization

DBMS 34
SRI CHANAKYA DEGREE COLLEGE [Pick t

Total specialization: Total specialization is an instance of the super type must be a member of atleast one
subtype
Eg: consider an example of Teacher
Teacher which can be further
Specialized in to Tutor, demonstrator and lecturer. here every O
member in the super class participate as a member of sub class. Lecturers
Tuter Demonstrative
ii) Partial specialization: It refers to the fact that an entity instance in the super class
need not be a number of any subclass need not be a number of any subclass in the specialization.

Eg: consider an entity person can be divided in to employee and student.


In this specialization that can be a person who is an un employee and does not study.

10) multiple inheritance

In multiple inheritance a sub class can be a sub class of more than one super class.A subclass
Inherits attributes not only of its direct super class but also all its predecer super class.

Eg: consider a person, aperson can be employee student. An employee entity can be staff or faculty.
The post graduate student can be a teaching assistant. If postgraduate a teaching assistant then he inherits the
characteristics of a faculty as well as a student class i.e the teaching assistant sub class is the subclass

DBMS 35
SRI CHANAKYA DEGREE COLLEGE

UNIT III- RELATIONAL MODEL

Q1. Explain Relational Model? / Explain Relational Data Model?

The relational model for database management is an approach to logically represent and manage
the data stored in a database.

In this model, the data is organized into a collection of two-dimensional inter-related tables,
also known as relations.

Each relation is a collection of columns and rows, where the column represents the attributes of
an entity and the rows (or tuples) represents the records.

This structured data can be easily stored in a table as described below:

Components based on the relational model

Relation : Two-dimensional table used to store a collection of data elements.


Tuple : Row of the relation, depicting a real-world entity.
Attribute/Field : Column of the relation.
Attribute Domain : Set of pre-defined atomic values that an attribute can take.
Degree : It is the total number of attributes present in the relation.
Cardinality : It specifies the number of entities involved in the relation.
Relational Schema : It is the logical blueprint of the relation. It contains the table name,
its attributes, and their types.

Relational Instance: It is the collection of records present in the relation at a given time.

DBMS 36
SRI CHANAKYA DEGREE COLLEGE

 Relation Key : It is an attribute or a group of attributes that can be used to uniquely


identify an entity in a table. Relation keys can be of 6 different types:
1. Candidate Key
2. Super Key
3. Composite Key
4. Primary Key
5. Alternate Key
6. Foreign Key

Constraints in Relational Model

Relational models make use of some rules to ensure the accuracy and accessibility of the data.
These rules or constraints are known as Relational Integrity Constraints.

These constraints are checked before performing any operation like insertion, deletion, or
updation on the data present in a relational database. These constraints include:

Domain Constraint : It specifies that every attribute is bound to have a value that lies
inside a specific range of values. It is implemented with the help of the Attribute Domain
concept.
Key Constraint : It states that every relation must contain an attribute or a set of
attributes (Primary Key) that can uniquely identify a tuple in that relation. This key can
never be NULL or contain the same value for two different tuples.
Referential Integrity Constraint : It is defined between two inter-related tables. It states
that if a given relation refers to a key attribute of a different or same table, then that key
must exist in the given relation.

Anomalies in Relational Model

When we notice any unexpected behavior while working with the relational databases, there may
be a presence of too much redundancy in the data stored in the database. This can cause
anomalies in the DBMS and it can be of various types such as:

Insertion Anomalies: It is the inability to insert data in the database due to the absence
of other data
Deletion Anomalies - It is the accidental loss of data in the database upon deletion of any
other data element.
Modification/Update Anomalies - It is the data inconsistency that arises from data
redundancy and partial updation of data in the database.

All these anomalies can lead to unexpected behavior and inconvenience for the user.
These anomalies can be removed with the help of a process known as normalization.

DBMS 37
SRI CHANAKYA DEGREE COLLEGE
Q2. Explain Codd Rules in DBMS?

Edgar F. Codd, the creator of the relational model proposed 13 rules known as Codd Rules that
states:

4. Foundation Rule - The database must be able to manage data in relational form.
5. Information Rule - All data stored in the database must exist as a value of some table
cell.
6. Guaranteed Access Rule - Every unique data element should be accessible by only a
combination of the table name, primary key value, and the column name.
7. Systematic Treatment of NULL values - Database must support NULL values.
8. Active Online Catalog - The organization of the database must exist in an online catalog
that can be queried by authorized users.
9. Comprehensive Data Sub-Language Rule - Database must support at least one
language that supports: data definition, view definition, data manipulation, integrity
constraints, authorization, and transaction boundaries.
10. View Updating Rule - All views should be theoretically and practically updatable by the
system.
11. Relational Level Operation Rule - The database must support high-level insertion,
updation, and deletion operations.
12. Physical Data Independence Rule - The data stored in the database must not depend on
any other data or an application.
13. Logical Data Independence Rule - Any change in the logical representation of the data
(structure of the tables) must not affect the user's view.
14. Integrity independence - Changing the integrity constraints at the database level should
not reflect any change at the application level.
15. Distribution independence - The database must work properly even if the data is stored
in multiple locations or is being used by multiple end-users.
16. Non-subversion Rule - Accessing the data by low-level relational language should not
be able to bypass the integrity rules and constraints expressed in the high-level relational
language.

Q3. Explain Advantages and Disadvantages of using the relational model?

Advantages:

Simple and Easy To Use - Storing data in tables is much easier to understand and
implement as compared to other storage techniques.
Manageability - Because of the independent nature of each relation in a relational
database, it is easy to manipulate and manage. This improves the performance of the
database.
Query capability - With the introduction of relational algebra, relational databases
provide easy access to data via high-level query language like SQL.
Data integrity - With the introduction and implementation of relational constraints, the
relational model can maintain data integrity in the database.

DBMS 38
SRI CHANAKYA DEGREE COLLEGE

Disadvantages

The performance of the relational model depends upon the number of relations present in
the database.
Hence, as the number of tables increases, the requirement of physical memory increases.
The structure becomes complex and there is a decrease in the response time for the
queries.
Because of all these factors, the cost of implementing a relational database increase.

Q4. Explain Key Concept in Relational Model?

Keys are very important part of Relational database model. They are used to establish and
identify relationships between tables/ Relation and also to uniquely identify any record or row of
data inside a table.

A Key can be a single attribute or a group of attributes, where the combination may act as a key.

1. Super Key

Super Key is defined as a set of attributes within a table that can uniquely identify each record
within a table. Super Key is a superset of Candidate key.

In the table defined above super key would include student_id, (student_id, name), phone etc.

2. Candidate Key

Candidate keys are defined as the minimal set of fields which can uniquely identify each record
in a table. It is an attribute or a set of attributes that can act as a Primary Key for a table to
uniquely identify each record in that table. There can be more than one candidate key.

In our example, student id and phone both are candidate keys for table Student.

DBMS 39
SRI CHANAKYA DEGREE COLLEGE

 A candiate key can never be NULL or empty. And its value should be unique.
 There can be more than one candidate keys for a table.
 A candidate key can be a combination of more than one columns (attributes).

3. Primary Key

Primary key is a candidate key that is most appropriate to become the main key for any table. It
is a key that can uniquely identify each record in a table.

For the table Student we can make the student_id column as the primary key.

4. Composite Key

Key that consists of two or more attributes that uniquely identify any record in a table is
called Composite key.

In the above picture we have a Score table which stores the marks scored by a student in a
particular subject.

In this table student_id and subject_id together will form the primary key, hence it is a composite
key.

DBMS 40
SRI CHANAKYA DEGREE COLLEGE

5. Secondary or Alternative key

The candidate key which are not selected as primary key are known as secondary keys or
alternative keys.

6. Foreign Key:

A foreign key is an attribute whose values match the primary key values in the related table.

Q5. Explain Relational Algebra? / Explain Relational Algebra Operators?

Relational Algebra is procedural query language, which takes Relation as input and generate
relation as output. Relational algebra mainly provides theoretical foundation for relational
databases and SQL.

Projection (π)

Projection Operator (π) is a unary operator in relational algebra that performs a projection
operation. It displays the columns of a relation or table based on the specified attributes.
Syntax : π (Attribute List) R

DBMS 41
SRI CHANAKYA DEGREE COLLEGE

Selection (σ)

Selection Operator (σ) is a unary operator in relational algebra that performs a selection
operation. It selects those rows or tuples from the relation that satisfies the selection condition.

Example : σ (c>3)R
will select the tuples which have c more than 3.

Union (U)
Union operation in relational algebra is same as union operation in set theory, only constraint
is for union of two relation both relation must have same set of Attributes.

Set Difference (-)


Set Difference in relational algebra is same set difference operation as in set theory with the
constraint that both relation should have same set of attributes.

Rename (ρ)
Rename is a unary operation used for renaming attributes of a relation.
ρ (a/b)R will rename the attribute ‘b’ of relation by ‘a’.

Cross Product (X)


Cross product between two relations let say A and B, so cross product between A X B will
results all the attributes of A followed by each attribute of B. Each record of A will pairs with
every record of B.
below is the example

DBMS 42
SRI CHANAKYA DEGREE COLLEGE

Natural Join (⋈)


Natural join is a binary operator. Natural join between two or more relations will result set of
all combination of tuples where they have equal common attribute.
Let us see below example

Conditional Join
Conditional join works similar to natural join. In natural join, by default condition is equal
between common attribute while in conditional join we can specify the any condition such as
greater than, less than, not equal

Q6. Advantages and Limitations of Relational Algebra?


Advantages

 Relational algebra is based on the set theory which is a mathematical concept due to which it has
a scope of development.
 Like mathematics there can be many expressions for the same operation, in a similar way if there
are two relational algebraic expressions for the same operation then the query optimizer will
switch to the most efficient query.
 It is a high-level query language.

Limitations

 Relational algebra cannot perform arithmetic operations.


 It is unable to do aggregation operations even it cannot compute transitive closure.
 It cannot modify the data present in the database.

DBMS 43
SRI CHANAKYA DEGREE COLLEGE

Q7. Explain Relational Integrity / Explain Relational Integrity Constraints?


Integrity Constraints

 Integrity constraints are a set of rules. It is used to maintain the quality of information.
 Integrity constraints ensure that the data insertion, updating, and other processes have to
be performed in such a way that data integrity is not affected.
 Thus, integrity constraint is used to guard against accidental damage to the database.

Types of Integrity Constraint

1. Domain constraints

 Domain constraints can be defined as the definition of a valid set of values for an
attribute.
 The data type of domain includes string, character, integer, time, date, currency, etc. The
value of the attribute must be available in the corresponding domain.
Example:

DBMS 44
SRI CHANAKYA DEGREE COLLEGE

2. Entity integrity constraints

 The entity integrity constraint states that primary key value can't be null.
 This is because the primary key value is used to identify individual rows in relation and if
the primary key has a null value, then we can't identify those rows.
 A table can contain a null value other than the primary key field.
Example:

3. Referential Integrity Constraints

 A referential integrity constraint is specified between two tables.


 In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary
Key of Table 2, then every value of the Foreign Key in Table 1 must be null or be
available in Table 2.
Example:

DBMS 45
SRI CHANAKYA DEGREE COLLEGE
DBMS

4. Key constraints

 Keys are the entity set that is used to identify an entity within its entity set uniquely.
 An entity set can have multiple keys, but out of which one key will be the primary key. A
primary key can contain a unique and null value in the relational table.
Example:

Q8. Explain Relational Calculus and its types?

Relational calculus is a non-procedural query language. In the non-procedural query


language, the user is concerned with the details of how to obtain the end results. The relational
calculus tells what to do but never explains how to do.

Types of Relational calculus:

1. Tuple Relational Calculus (TRC)


The tuple relational calculus is specified to select the tuples in a relation. In TRC, filtering
variable uses the tuples of a relation. The result of the relation can have one or more tuples.

Notation:
{T | P (T)} or {T | Condition (T)}
Where
T is the resulting tuples
P(T) is the condition used to fetch T.

DBMS 46
SRI CHANAKYA DEGREE COLLEGE

For example:
{ T.name | Author(T) AND T.article = 'database' }

OUTPUT: This query selects the tuples from the AUTHOR relation. It returns a tuple with
'name' from Author who has written an article on 'database'.

2. Domain Relational Calculus (DRC)

The second form of relation is known as Domain relational calculus. In domain relational
calculus, filtering variable uses the domain of attributes. Domain relational calculus uses the
same operators as tuple calculus. It uses logical connectives 𝖠 (and), ∨ (or) and ┓ (not). It uses
Existential (∃) and Universal Quantifiers (∀) to bind the variable.

Notation:
{ a1, a2, a3, ..., an | P (a1, a2, a3, ... ,an)}
Where
a1, a2 are attributes
P stands for formula built by inner attributes
For example:
{< article, page, subject > | ∈ DPoint 𝖠 subject = 'database'}
Output: This query will yield the article, page, and subject from the relational Dpoint, where the
subject is a database.

Q9. Explain Functional Dependency?

The functional dependency is a relationship that exists between two attributes. It typically exists
between the primary key and non-key attribute within a table.

X → Y

The left side of FD is known as a determinant, the right side of the production is known as a
dependent.

For example:

Assume we have an employee table with attributes: Emp_Id, Emp_Name, Emp_Address.

Here Emp_Id attribute can uniquely identify the Emp_Name attribute of employee table because
if we know the Emp_Id, we can tell that employee name associated with it.

Functional dependency can be written as:

Emp_Id → Emp_Name

DBMS 47
SRI CHANAKYA DEGREE COLLEGE

We can say that Emp_Name is functionally dependent on Emp_Id.

Types of Functional dependency

1. Trivial functional dependency

A → B has trivial functional dependency if B is a subset of A.


The following dependencies are also trivial like: A → A, B → B

Example:

Consider a table with two columns Employee_Id and Employee_Name.


{Employee_id, Employee_Name} → Employee_Id is a trivial functional dependency as
Employee_Id is a subset of {Employee_Id, Employee_Name}.
Also, Employee_Id → Employee_Id and Employee_Name → Employee_Name are trivial de
pendencies too.

2. Non-trivial functional dependency


A → B has a non-trivial functional dependency if B is not a subset of A.
When A intersection B is NULL, then A → B is called as complete non-trivial.

Example:

ID → Name,
Name → DOB

DBMS 48
SRI CHANAKYA DEGREE COLLEGE

Q10. Explain Normalization and Normal Forms?


 Normalization is the process of organizing the data in the database.
 Normalization is used to minimize the redundancy from a relation or set of relations. It is
also used to eliminate the undesirable characteristics like Insertion, Update and Deletion
Anomalies.
 Normalization divides the larger table into the smaller table and links them using
relationship.
 The normal form is used to reduce redundancy from the database table.

Types of Normal Forms


There are the four types of normal forms:

Normal Form Description

1NF A relation is in 1NF if it contains an atomic value.

2NF A relation will be in 2NF if it is in 1NF and all non-key attributes are fully
functional dependent on the primary key.

3NF A relation will be in 3NF if it is in 2NF and no transition dependency exists.

4NF A relation will be in 4NF if it is in Boyce Codd normal form and has no multi-
valued dependency.

5NF A relation is in 5NF if it is in 4NF and not contains any join dependency and
joining should be lossless.

First Normal Form (1NF)

 A relation will be 1NF if it contains an atomic value.


 It states that an attribute of a table cannot hold multiple values. It must hold only single-
valued attribute.
 First normal form disallows the multi-valued attribute, composite attribute, and their
combinations.

DBMS 49
SRI CHANAKYA DEGREE COLLEGE

Example: Relation EMPLOYEE is not in 1NF because of multi-valued attribute EMP_PHONE.

EMPLOYEE table:
EMP_ID EMP_NAME EMP_PHONE EMP_STATE

14 John 7272826385, UP
9064738238

20 Harry 8574783832 Bihar

12 Sam 7390372389, Punjab


8589830302
The decomposition of the EMPLOYEE table into 1NF has been shown below:
EMP_ID EMP_NAME EMP_PHONE EMP_STATE

14 John 7272826385 UP

14 John 9064738238 UP

20 Harry 8574783832 Bihar

12 Sam 7390372389 Punjab

12 Sam 8589830302 Punjab

Second Normal Form (2NF)


 In the 2NF, relational must be in 1NF.
 In the second normal form, all non-key attributes are fully functional dependent on the
primary key
Example: Let's assume, a school can store the data of teachers and the subjects they teach. In a
school, a teacher can teach more than one subject.
TEACHER table
TEACHER_ID SUBJECT TEACHER_AGE

25 Chemistry 30

25 Biology 30

47 English 35

83 Math 38

83 Computer 38
In the given table, non-prime attribute TEACHER_AGE is dependent on TEACHER_ID which is a proper
subset of a candidate key. That's why it violates the rule for 2NF.

DBMS 50
SRI CHANAKYA DEGREE COLLEGE

To convert the given table into 2NF, we decompose it into two tables:
TEACHER_DETAIL table:

TEACHER_ID TEACHER_AGE

25 30

47 35

83 38
TEACHER_SUBJECT table:
TEACHER_ID SUBJECT

25 Chemistry

25 Biology

47 English

83 Math

83 Computer

Third Normal Form (3NF)


 A relation will be in 3NF if it is in 2NF and not contain any transitive partial dependency.
 3NF is used to reduce the data duplication. It is also used to achieve the data integrity.
 If there is no transitive dependency for non-prime attributes, then the relation must be in
third normal form.
 A relation is in third normal form if it holds at least one of the following conditions for
every non-trivial function dependency X → Y.
 X is a super key.
 Y is a prime attribute, i.e., each element of Y is part of some candidate key.
Example:
EMPLOYEE_DETAIL table:
EMP_ID EMP_NAME EMP_ZIP EMP_STATE EMP_CITY

222 Harry 201010 UP Noida

333 Stephan 02228 US Boston

444 Lan 60007 US Chicago

555 Katharine 06389 UK Norwich

666 John 462007 MP Bhopal

DBMS 51
SRI CHANAKYA DEGREE COLLEGE

Super key in the table above:


{EMP_ID}, {EMP_ID, EMP_NAME}, {EMP_ID, EMP_NAME, EMP_ZIP}. so on
Candidate key: {EMP_ID}
Non-prime attributes: In the given table, all attributes except EMP_ID are non-prime.
Here, EMP_STATE & EMP_CITY dependent on EMP_ZIP and EMP_ZIP dependent on EMP_ID. The non-
prime attributes (EMP_STATE, EMP_CITY) transitively dependent on super key(EMP_ID). It violates the
rule of third normal form.
That's why we need to move the EMP_CITY and EMP_STATE to the new <EMPLOYEE_ZIP> table, with
EMP_ZIP as a Primary key.
EMPLOYEE table:
EMP_ID EMP_NAME EMP_ZIP

222 Harry 201010

333 Stephan 02228

444 Lan 60007

555 Katharine 06389

666 John 462007


EMPLOYEE_ZIP table:
EMP_ZIP EMP_STATE EMP_CITY

201010 UP Noida

02228 US Boston

60007 US Chicago

06389 UK Norwich

462007 MP Bhopal

DBMS 52
SRI CHANAKYA DEGREE COLLEGE

UNIT IV- SQL

***Q1. What is SQL and give brief History and its benefits?

 SQL, which is an abbreviation for Structured Query Language, is a language to request


data from a database, to add, update, or remove data within a database, or to manipulate
the metadata of the database.
 SQL is extremely accessible across various platforms and generally user-friendly.
 SQL uses a set of commands to manipulate the data in databases.

The SQL programming language was developed in the 1970s by IBM researchers Raymond
Boyce and Donald Chamberlin. The programming language, known then as SEQUEL, was
created following Edgar Frank Codd's paper, "A Relational Model of Data for Large Shared Data
Banks," in 1970.

Benefits of SQL

 SQL is portable. You can use it on PCs, servers, laptops and some mobile devices. It
runs on local internet and intranet systems.
 It processes queries quickly. No matter how large data might be, SQL can retrieve it
quickly and efficiently.
 It doesn't require coding skills. SQL does not require coding skills, just the use of
simple keywords like "select," "insert into" and "update."
 It uses standardized language. The standardized language used in SQL makes it highly
accessible to all users.
 It provides multiple data views. When using SQL, you can create multiple data views,
giving different users various views of the database's structure and content.

 It has open source code. MySQL, MariaDB and PostGres offer free SQL databases that
large communities can use at a low cost.
 It's used by major database management system vendors. Most major database
management systems – such as those from IBM, Oracle and Microsoft – use SQL. SQL's
accessibility is a great benefit to keep in mind.
 It's highly interactive. SQL is an interactive language for all users, so you don't have to
worry about miscommunications or misunderstandings.

Q2. Explain SQL Commands


o SQL commands are instructions. It is used to communicate with the database. It is also
used to perform specific tasks, functions, and queries of data.
o SQL can perform various tasks like create a table, add data to tables, drop the table,
modify the table, set permission for users.

DBMS 53
SRI CHANAKYA DEGREE COLLEGE

Types of SQL Commands

There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.

1. Data Definition Language (DDL)

DDL changes the structure of the table like creating a table, deleting a table, altering a
table, etc.
All the command of DDL are auto-committed that means it permanently save all the
changes in the database.

Here are some commands that come under DDL:

CREATE
ALTER
DROP
TRUNCATE

a. CREATE It is used to create a new table in the database.

Syntax: CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,. ..]);

Example:

DBMS 54
SRI CHANAKYA DEGREE COLLEGE

CREATE TABLE EMPLOYEE

( Name VARCHAR2(20),
Email VARCHAR2(100),
DOB DATE );

b. DROP: It is used to delete both the structure and record stored in the table.

Syntax DROP TABLE table_name;

Example DROP TABLE EMPLOYEE;

c. ALTER: It is used to alter the structure of the database. This change could be either to modify
the characteristics of an existing attribute or probably to add a new attribute.

Syntax: ALTER TABLE table_name ADD column_name COLUMN-definition;

To modify existing column in the table:

ALTER TABLE table_name MODIFY(column_definitions... );


EXAMPLE
ALTER TABLE STU_DETAILS ADD (ADDRESS VARCHAR2(20));
ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));

d. TRUNCATE: It is used to delete all the rows from the table and free the space containing the
table.

Syntax: TRUNCATE TABLE table_name;

Example TRUNCATE TABLE EMPLOYEE;

2. Data Manipulation Language

o DML commands are used to modify the database. It is responsible for all form of changes
in the database.
o The command of DML is not auto-committed that means it can't permanently save all the
changes in the database. They can be rollback.

Here are some commands that come under DML:


a) INSERT
b) UPDATE
c) DELETE

DBMS 55
SRI CHANAKYA DEGREE COLLEGE

a. INSERT: The INSERT statement is a SQL query. It is used to insert data into the row of a
table.

Syntax INSERT INTO TABLE_NAME (col1, col2) VALUES (value1, value2);

INSERT INTO BOOK (Author, Subject) VALUES ("Sonoo", "DBMS");

b. UPDATE: This command is used to update or modify the value of a column in the table.

Syntax: UPDATE table_name SET [column_name1= value1] [WHERE CONDITION]

For example: UPDATE students SET User_Name = 'Sonoo' WHERE Student_Id = '3'

c. DELETE: It is used to remove one or more row from a table.

Syntax: DELETE FROM table_name [WHERE condition];

For example: DELETE FROM BOOK WHERE Author="Sonoo";

3. Data Control Language

DCL commands are used to grant and take back authority from any database user.
Here are some commands that come under DCL:
 Grant
 Revoke

a. Grant: It is used to give user access privileges to a database.

Example
GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;

b. Revoke: It is used to take back permissions from the user.

Example REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;

4. Transaction Control Language

TCL commands can only use with DML commands like INSERT, DELETE and UPDATE only.
These operations are automatically committed in the database that's why they cannot be used
while creating tables or dropping them. Here are some commands that come under TCL:
a) COMMIT
b) ROLLBACK
c) SAVEPOINT

a. Commit: Commit command is used to save all the transactions to the database.

DBMS 56
SRI CHANAKYA DEGREE COLLEGE

Syntax: COMMIT;

Example: DELETE FROM CUSTOMERS WHERE AGE = 25;

COMMIT;

b. Rollback: Rollback command is used to undo transactions that have not already been saved to
the database.

Syntax: ROLLBACK;

Example: DELETE FROM CUSTOMERS WHERE AGE = 25; ROLLBACK;

c. SAVEPOINT: It is used to roll the transaction back to a certain point without rolling back the
entire transaction.

Syntax: SAVEPOINT SAVEPOINT_NAME;

5. Data Query Language

DQL is used to fetch the data from the database. It uses only one command: SELECT

a. SELECT: This is the same as the projection operation of relational algebra. It is used to select
the attribute based on the condition described by WHERE clause.

Syntax: SELECT [field name] FROM TABLES WHERE conditions;

For example: SELECT emp_name FROM employee WHERE age > 20;

Q|3. Explain SQL Data types?


 SQL Datatype is used to define the values that a column can contain.
 Every column is required to have a name and data type in the database table.

DBMS 57
SRI CHANAKYA DEGREE COLLEGE

1. Binary Data types

There are Three types of binary Datatypes which are given below:

Data Type Description

binary It has a maximum length of 8000 bytes. It contains fixed-length binary data.

varbinary It has a maximum length of 8000 bytes. It contains variable-length binary data.

image It has a maximum length of 2,147,483,647 bytes. It contains variable-length


binary data.

2. Approximate Numeric Data type :

The subtypes are given below:

Data type From To Description

float -1.79E + 308 1.79E + 308 It is used to specify a floating-point value e.g.
6.2, 2.9 etc.

real -3.40e + 38 3.40E + 38 It specifies a single precision floating point


number

3. Exact Numeric Data type

The subtypes are given below:

Data type Description

int It is used to specify an integer value.

smallint It is used to specify small integer value.

bit It has the number of bits to store.

decimal It specifies a numeric value that can have a decimal number.

numeric It is used to specify a numeric value.

4. Character String Data type

DBMS 58
SRI CHANAKYA DEGREE COLLEGE

The subtypes are given below:

Data Description
type

char It has a maximum length of 8000 characters. It contains Fixed-length non-unicode


characters.

varchar It has a maximum length of 8000 characters. It contains variable-length non-


unicode characters.

text It has a maximum length of 2,147,483,647 characters. It contains variable-length


non-unicode characters.

5. Date and time Data types

The subtypes are given below:

Data type Description

date It is used to store the year, month, and days value.

time It is used to store the hour, minute, and second values.

timestamp It stores the year, month, day, hour, minute, and the second value.

***Q4. Explain Data Definition Language (DDL)

Data Definition Language(DDL) is a subset of SQL and a part of DBMS(Database Management


System). DDL consist of Commands to commands like CREATE, ALTER, TRUNCATE and
DROP. These commands are used to create or modify the tables in SQL.

DDL Commands :
In this section, We will cover the following DDL commands as follows.
1. Create
2. Alter
3. truncate
4. drop

DBMS 59
SRI CHANAKYA DEGREE COLLEGE

Command-1 :
CREATE :
This command is used to create a new table in SQL. The user has to give information like table
name, column names, and their datatypes.

Syntax –
CREATE TABLE table_name
(
column_1 datatype,
column_2 datatype,
column_3 datatype,
....
);

Example –
We need to create a table for storing Student information of a particular College. Create syntax
would be as below.
CREATE TABLE Student_info
(
College_Id number(2),
College_name varchar(30),
Branch varchar(10)
);
Command-2 :
ALTER :
This command is used to add, delete or change columns in the existing table. The user needs to
know the existing table name and can do add, delete or modify tasks easily.
Syntax –
Syntax to add a column to an existing table.
ALTER TABLE table_name ADD column_name datatype;
Example –
In our Student_info table, we want to add a new column for CGPA. The syntax would be as
below as follows.
ALTER TABLE Student_info ADD CGPA number;
Command-3 :
TRUNCATE :
This command is used to remove all rows from the table, but the structure of the table still exists.

DBMS 60
SRI CHANAKYA DEGREE COLLEGE

Syntax –
Syntax to remove an existing table.
TRUNCATE TABLE table_name;
Example –
The College Authority wants to remove the details of all students for new batches but wants to
keep the table structure. The command they can use is as follows.
TRUNCATE TABLE Student_info;
Command-4 :
DROP :
This command is used to remove an existing table along with its structure from the Database.
Syntax –
Syntax to drop an existing table.
DROP TABLE table_name;
Example –
If the College Authority wants to change their Database by deleting the Student_info Table.
DROP TABLE Student_info;

***Q5. Explain Selection operation in SQL?

A select operation selects a subset of rows (records) in a table (relation) that satisfy a selection
condition. The ability to select rows from out of complete result set is called Selection. It
involves conditional filtering and data staging.
Basic SELECT statement
The basic syntax for a SELECT statement is presented below.
SELECT [DISTINCT | ALL] {* | select_list}
FROM {table_name [alias] | view_name}
[{table_name [alias] | view_name}]...
[WHERE condition]
[GROUP BY condition_list]
[HAVING condition]
[ORDER BY {column_name | column_# [ ASC | DESC ] } ...

 The SELECT clause is mandatory and carries out the relational project operation.
 The FROM clause is also mandatory. It identifies one or more tables and/or views from
which to retrieve the column data displayed in a result table.
 The WHERE clause is optional and carries out the relational select operation. It specifies
which rows are to be selected.
 The GROUP BY clause is optional. It organizes data into groups by one or more column
names listed in the SELECT clause.

DBMS 61
SRI CHANAKYA DEGREE COLLEGE

 The optional HAVING clause sets conditions regarding which groups to include in a
result table. The groups are specified by the GROUP BY clause.
 The ORDER BY clause is optional. It sorts query results by one or more columns in
ascending or descending order.

Arithmetic operators

Operators act upon the columns (known as operands) to result into a different result.
SELECT salary + 1500 FROM employees;

Column Alias

An alias is used to rename a column or an expression during display. The alias to a column or
an expression appears as the heading in the output of a query.
SELECT price * 2 as DOUBLE_PRICE FROM products;

DISTINCT Keyword

If the data is expected to have duplicate results, use DISTINCT keyword to eliminate duplicates
and display only the unique results in the query output.
SELECT DISTINCT DEPARTMENT_ID FROM employees;

***Q6. Explain Projection operation in SQL?


A project operation selects only certain columns (fields) from a table. The result table has a
subset of the available columns and can include anything from a single column to all available
columns.
 Projection Operator (π) is a unary operator in relational algebra that performs a projection
operation.
 Projection operator automatically removes all the duplicates while projecting the output
relation.
Eg. Result for Query πID , Name(Student)-

 Projection operator does not obey commutative property


 Selection Operator performs horizontal partitioning of the relation.
 Projection operator performs vertical partitioning of the relation.
 There is only one difference between projection operator of relational algebra and
SELECT operation of SQL. Projection operator does not allow duplicates while SELECT
operation allows duplicates.
 To avoid duplicates in SQL, we use “distinct” keyword and write SELECT distinct.
 Thus, projection operator of relational algebra is equivalent to SELECT operation of
SQL.

DBMS 62
SRI CHANAKYA DEGREE COLLEGE
***Q7. Explain SQL Aggregate Functions?

SQL aggregation function is used to perform the calculations on multiple rows of a single
column of a table. It returns a single value. It is also used to summarize the data.
Types of SQL Aggregation Function

1. COUNT FUNCTION
COUNT function is used to Count the number of rows in a database table. It can work on both
numeric and non-numeric data types.
COUNT function uses the COUNT(*) that returns the count of all the rows in a specified table.
COUNT(*) considers duplicate and Null.
Syntax
COUNT(*)
Example:
fference between JDK, JRE, and JVM
SELECT COUNT(*) FROM PRODUCT;
SELECT COUNT(*) FROM PRODUCT WHERE RATE>=20;
SELECT COUNT(DISTINCT COMPANY) FROM PRODUCT;
SELECT COMPANY, COUNT(*) FROM PRODUCT GROUP BY COMPANY;
SELECT COMPANY, COUNT(*) FROM PRODUCT GROUP BY COMPANY
HAVING COUNT(*)>2;
Com1 5
Com2 3
2. SUM Function
Sum function is used to calculate the sum of all selected columns. It works on numeric fields
only.
Syntax
SUM()

Example: SUM()
SELECT SUM(COST) FROM PRODUCT;
SELECT SUM(COST) FROM PRODUCT WHERE QTY>3;
SELECT SUM(COST) FROM PRODUCT WHERE QTY>3 GROUP BY COMPANY;
SELECT COMPANY, SUM(COST) FROM PRODUCT GROUP BY COMPANY
HAVING SUM(COST)>=170;

DBMS 63
SRI CHANAKYA DEGREE COLLEGE

m1 335
Com3 170
3. AVG function
The AVG function is used to calculate the average value of the numeric type. AVG function
returns the average of all non-Null values.
Syntax
AVG()
Example:
SELECT AVG(COST) FROM PRODUCT;

4. MAX Function
MAX function is used to find the maximum value of a certain column. This function determines
the largest value of all selected values of a column.
Syntax
MAX()
Example:
SELECT MAX(RATE) FROM PRODUCT;
30
5. MIN Function
MIN function is used to find the minimum value of a certain column. This function determines
the smallest value of all selected values of a column.
Syntax
MIN()
Example:
SELECT MIN(RATE) FROM PRODUCT;

***Q8. Explain Data Manipulation Language?


 DML stands for Data Manipulation Language.
 It is a language used for selecting, inserting, deleting and updating data in a database.
 It is used to retrieve and manipulate data in a relational database.
DDL commands are as follows,
1. SELECT
2. INSERT
3. UPDATE
4. DELETE
 DML performs read-only queries of data.

1. SELECT COMMAND

 SELECT command is used to retrieve data from the database.


 This command allows database users to retrieve the specific information they desire from an
operational database.

DBMS 64
SRI CHANAKYA DEGREE COLLEGE
 It returns a result set of records from one or more tables.
 SELECT Command has many optional clauses are as stated below:

Clause Description
WHERE It specifies which rows to retrieve.
GROUP BY It is used to arrange the data into groups.
HAVING It selects among the groups defined by the GROUP BY clause.
ORDER BY It specifies an order in which to return the rows.
AS It provides an alias which can be used to temporarily rename tables or columns.

Syntax:
SELECT * FROM <table_name>;

Example : SELECT Command

SELECT * FROM employee;

2. INSERT COMMAND
INSERT command is used for inserting a data into a table.
Using this command, you can add one or more records to any single table in a database.
It is also used to add records to an existing code.
Syntax:
INSERT INTO <table_name> (`column_name1` <datatype>, `column_name2` <datatype>, .
. . , `column_name_n` <database>) VALUES (`value1`, `value2`, . . . , `value n`);

Example:
INSERT INTO employee (`eid` int, `ename` varchar(20), `city` varchar(20))
VALUES (`1`, `ABC`, `PUNE`);

3. UPDATE COMMAND

UPDATE command is used to modify the records present in existing table.


 This command updates existing data within a table.
 It changes the data of one or more records in a table.
Syntax:
UPDATE <table_name>
SET <column_name = value>
WHERE condition;

DBMS 65
SRI CHANAKYA DEGREE COLLEGE
Example : UPDATE Command

UPDATE employee
SET salary=20000
WHERE ename='ABC';
4. DELETE COMMAND

 DELETE command is used to delete some or all records from the existing table.
 It deletes all the records from a table.

Syntax:
DELETE FROM <table_name> WHERE <condition>;

Example : DELETE Command

DELETE FROM employee


WHERE emp_id = '001';
***Q9. Explain Table modification commands?

ALTER TABLE is used to add, delete/drop or modify columns in the existing table. It is also used to
add and drop various constraints on the existing table.
ALTER TABLE – ADD
ADD is used to add columns into the existing table
Syntax:
ALTER TABLE table_name
ADD (Columnname_1 datatype,
Columnname_2 datatype,

Columnname_n datatype);

ALTER TABLE – DROP


DROP COLUMN is used to drop column in a table. Deleting the unwanted columns from the table.
Syntax:
ALTER TABLE table_name DROP COLUMN column_name;
ALTER TABLE-MODIFY
It is used to modify the existing columns in a table. Multiple columns can also be modified at once.

ALTER TABLE table_name MODIFY column_name column_type;


ALTER TABLE Student ADD (AGE number(3),COURSE varchar(40));
 DROP column COURSE in table Student.
ALTER TABLE Student DROP COLUMN COURSE;

***Q10 Explain Join Operation in SQL?


A SQL Join statement is used to combine data or rows from two or more tables based on a

DBMS 66
SRI CHANAKYA DEGREE COLLEGE

common field between them. Different types of Joins are:


 INNER JOIN
 LEFT JOIN
 RIGHT JOIN
 FULL JOIN

INNER JOIN: The INNER JOIN keyword selects all rows from both the tables as long as the
condition satisfies. This keyword will create the result-set by combining all rows from both the
tables where the condition satisfies i.e value of the common field will be same.
Syntax:
SELECT table1.column1, table1.column2, table2.column1,....
FROM table1
INNER JOIN table2
ON table1.matching_column = table2.matching_column;

SELECT StudentCourse.COURSE_ID, Student.NAME, Student.AGE FROM Student


INNER JOIN StudentCourse ON Student.ROLL_NO = StudentCourse.ROLL_NO;

LEFT JOIN: This join returns all the rows of the table on the left side of the join and
matching rows for the table on the right side of join. The rows for which there is no matching
row on right side, the result-set will contain null. LEFT JOIN is also known as LEFT OUTER
JOIN.
Syntax:
SELECT table1.column1,table1.column2,table2.column1,....

FROM table1
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;

DBMS 67
SRI CHANAKYA DEGREE COLLEGE
SELECT Student.NAME,StudentCourse.COURSE_ID
FROM Student
LEFT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;

RIGHT JOIN: RIGHT JOIN is similar to LEFT JOIN. This join returns all the rows of the
table on the right side of the join and matching rows for the table on the left side of join. The
rows for which there is no matching row on left side, the result-set will contain null. RIGHT
JOIN is also known as RIGHT OUTER JOIN.

Syntax:
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
RIGHT JOIN table2
ON table1.matching_column = table2.matching_column;

SELECT Student.NAME,StudentCourse.COURSE_ID
FROM Student
RIGHT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;

FULL JOIN: FULL JOIN creates the result-set by combining result of both LEFT JOIN and
RIGHT JOIN. The result-set will contain all the rows from both the tables. The rows for which
there is no matching, the result-set will contain NULL values.
Syntax:
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
FULL JOIN table2
ON table1.matching_column = table2.matching_column;

DBMS 68
SRI CHANAKYA DEGREE COLLEGE

***Q11. Explain SET Operators in SQL


SET operators are special type of operators which are used to combine the result of two queries.
Operators covered under SET operators are:
 UNION
 UNION ALL
 INTERSECT
 MINUS

There are certain rules which must be followed to perform operations using SET operators in
SQL. Rules are as follows:
The number and order of columns must be the same.
Data types must be compatible.

1. UNION:
UNION will be used to combine the result of two select statements. Duplicate rows will be
eliminated from the results obtained after performing the UNION operation.

SELECT *FROM t1_employees UNION SELECT *FROM t2_employees;

2. UNION ALL
This operator combines all the records from both the queries. Duplicate rows will be not be
eliminated from the results obtained after performing the UNION ALL operation.

Example 1:
Write a query to perform union all operation between the table t_employees and the table
t2_employees.
SELECT *FROM t_employees UNION ALL SELECT *FROM t2_employees;

3. INTERSECT:
It is used to combine two SELECT statements, but it only returns the records which are common
from both SELECT statements.

DBMS 69
SRI CHANAKYA DEGREE COLLEGE

Example 1:
Write a query to perform intersect operation between the table t_employees and the table
t2_employees.
Query:
SELECT *FROM t_employees INTERSECT SELECT *FROM t2_employees;

4. MINUS
It displays the rows which are present in the first query but absent in the second query with no
duplicates.
Example 1:
Write a query to perform a minus operation between the table t1_employees and the table
t2_employees.
Query:
mysql> SELECT *FROM t1_employees MINUS SELECT *FROM t2_employees;

***Q12. Explain Views in SQL?

Views in SQL are considered as a virtual table. A view also contains rows and columns.
To create the view, we can select the fields from one or more tables present in the database. A
view can either have specific rows based on certain condition or all the rows of a table.

1. Creating view
A view can be created using the CREATE VIEW statement. We can create a view from a single
table or multiple tables.
Syntax:

CREATE VIEW view_name AS


SELECT column1, column2.....
FROM table_name
WHERE condition;

2. Creating View from a single table


In this example, we create a View named DetailsView from the table Student_Detail.
Query:
CREATE VIEW DetailsView AS
SELECT NAME, ADDRESS
FROM Student_Details
WHERE STU_ID < 4;

Just like table query, we can query the view to view the data.
SELECT * FROM DetailsView;

DBMS 70
SRI CHANAKYA DEGREE COLLEGE
3. Creating View from multiple tables
View from multiple tables can be created by simply include multiple tables in the SELECT
statement.
Query:
CREATE VIEW MarksView AS
SELECT Student_Detail.NAME, Student_Detail.ADDRESS, Student_Marks.MARKS
FROM Student_Detail, Student_Mark
WHERE Student_Detail.NAME = Student_Marks.NAME;

4. Deleting View
A view can be deleted using the Drop View statement.
Syntax

DROP VIEW view_name;


Example:
If we want to delete the View MarksView, we can do this as:
DROP VIEW MarksView;

Q13. Explain Subquery in SQL?


A Subquery or Inner query or a Nested query is a query within another SQL query and
embedded within the WHERE clause.
A subquery is used to return data that will be used in the main query as a condition to further
restrict the data to be retrieved.
Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along
with the operators like =, <, >, >=, <=, IN, BETWEEN, etc.
There are a few rules that subqueries must follow −
 Subqueries must be enclosed within parentheses.
 A subquery can have only one column in the SELECT clause, unless multiple columns
are in the main query for the subquery to compare its selected columns.
 An ORDER BY command cannot be used in a subquery, although the main query can
use an ORDER BY. The GROUP BY command can be used to perform the same
function as the ORDER BY in a subquery.
 Subqueries that return more than one row can only be used with multiple value operators
such as the IN operator.
 The SELECT list cannot include any references to values that evaluate to a BLOB,
ARRAY, CLOB, or NCLOB.
 A subquery cannot be immediately enclosed in a set function.
 The BETWEEN operator cannot be used with a subquery. However, the BETWEEN
operator can be used within the subquery.

DBMS 71
SRI CHANAKYA DEGREE COLLEGE

The basic syntax is as follows −


SELECT column_name [, column_name ]
FROM table1 [, table2 ]
WHERE column_name OPERATOR
(SELECT column_name [, column_name ]
FROM table1 [, table2 ]
[WHERE])

***Q14. Explain SQL Operators?

There are various types of SQL operator:

SQL Arithmetic Operators

Let's assume 'variable a' and 'variable b'. Here, 'a' contains 20 and 'b' contains 10.

Operator Description Example

+ It adds the value of both operands. a+b will give


30

- It is used to subtract the right-hand operand from the left-hand a-b will give
operand. 10

* It is used to multiply the value of both operands. a*b will give


200

DBMS 72
SRI CHANAKYA DEGREE COLLEGE
/ It is used to divide the left-hand operand by the right-hand a/b will give 2
operand.

% It is used to divide the left-hand operand by the right-hand a%b will give
operand and returns reminder. 0

SQL Comparison Operators:


Let's assume 'variable a' and 'variable b'. Here, 'a' contains 20 and 'b' contains 10.

Operator Description Example

= It checks if two operands values are equal or not, (a=b) is not true
if the values are queal then condition becomes
true.

!= It checks if two operands values are equal or not, (a!=b) is true


if values are not equal, then condition becomes
true.

<> It checks if two operands values are equal or not, (a<>b) is true
if values are not equal then condition becomes
true.

> It checks if the left operand value is greater than (a>b) is not true
right operand value, if yes then condition
becomes true.

< It checks if the left operand value is less than right (a<b) is true
operand value, if yes then condition becomes true.

>= It checks if the left operand value is greater than (a>=b) is not
or equal to the right operand value, if yes then true
condition becomes true.

<= It checks if the left operand value is less than or (a<=b) is true
equal to the right operand value, if yes then
condition becomes true.

!< It checks if the left operand value is not less than (a!=b) is not
the right operand value, if yes then condition true
becomes true.

!> It checks if the left operand value is not greater (a!>b) is true
than the right operand value, if yes then condition
becomes true.

DBMS 73
SRI CHANAKYA DEGREE COLLEGE

SQL Logical Operators

There is the list of logical operator used in SQL:

Operator Description

ALL It compares a value to all values in another value set.

AND It allows the existence of multiple conditions in an SQL statement.

ANY It compares the values in the list according to the condition.

BETWEEN It is used to search for values that are within a set of values.

IN It compares a value to that specified list value.

NOT It reverses the meaning of any logical operator.

OR It combines multiple conditions in SQL statements.

EXISTS It is used to search for the presence of a row in a specified table.

LIKE It compares a value to similar values using wildcard operator.

DBMS 74
SRI CHANAKYA DEGREE COLLEGE
UNIT V- PL/ SQL

***Q1. Give brief introduction about PL/SQL? List Features and Advantages?

The PL/SQL programming language was developed by Oracle Corporation in the late 1980s as
procedural extension language for SQL and the Oracle relational database. Following are certain
notable facts about PL/SQL −
 PL/SQL is a completely portable, high-performance transaction-processing language.
 PL/SQL provides a built-in, interpreted and OS independent programming environment.
 PL/SQL can also directly be called from the command-line SQL*Plus interface.
 Direct call can also be made from external programming language calls to database.
 PL/SQL's general syntax is based on that of ADA and Pascal programming language.
 Apart from Oracle, PL/SQL is available in TimesTen in-memory database and IBM
DB2.

Features of PL/SQL
 PL/SQL has the following features −
 PL/SQL is tightly integrated with SQL.
 It offers extensive error checking.
 It offers numerous data types.
 It offers a variety of programming structures.
 It supports structured programming through functions and procedures.
 It supports object-oriented programming.
 It supports the development of web applications and server pages.

Advantages of PL/SQL
PL/SQL has the following advantages −
 SQL is the standard database language and PL/SQL is strongly integrated with SQL.
PL/SQL supports both static and dynamic SQL. Static SQL supports DML operations
and transaction control from PL/SQL block. In Dynamic SQL, SQL allows embedding
DDL statements in PL/SQL blocks.
 PL/SQL allows sending an entire block of statements to the database at one time. This
reduces network traffic and provides high performance for the applications.
 PL/SQL gives high productivity to programmers as it can query, transform, and update
data in a database.
 PL/SQL saves time on design and debugging by strong features, such as exception
handling, encapsulation, data hiding, and object-oriented data types.
 Applications written in PL/SQL are fully portable.
 PL/SQL provides high security level.
 PL/SQL provides access to predefined SQL packages.
 PL/SQL provides support for Object-Oriented Programming.
 PL/SQL provides support for developing Web Applications and Server Pages.

DBMS 75
SRI CHANAKYA DEGREE COLLEGE

***Q2. Disadvantages of SQL / Short comings of SQL?

1. Poor Interface
SQL has a poor interface as it makes look everything very complex even when it's not! Due to its
difficult interfacing, users find it difficult to deal with the databases.
2. Cost Inefficient
SQL Server Standard costs around $1,418/year. The high cost makes it difficult for some
programmers to use it.
3. Partial Control
SQL doesn't grant the complete control over databases to its users. This is due to some hidden
business rules.
4. Security
Regardless of the SQL version, databases in SQL is constantly under threat as it holds huge
amounts of sensitive data.

***Q3. Explain Structure of PL/SQL?

The Basic Syntax of PL/SQL which is a block-structured language; this means that the PL/SQL
programs are divided and written in logical blocks of code. Each block consists of three sub-parts

S.No Sections & Description

Declarations
1 This section starts with the keyword DECLARE. It is an optional section and defines all
variables, cursors, subprograms, and other elements to be used in the program.

Executable Commands
This section is enclosed between the keywords BEGIN and END and it is a mandatory
2 section. It consists of the executable PL/SQL statements of the program. It should have at
least one executable line of code, which may be just a NULL command to indicate that
nothing should be executed.

Exception Handling
3 This section starts with the keyword EXCEPTION. This optional section
contains exception(s) that handle errors in the program.

Every PL/SQL statement ends with a semicolon (;). PL/SQL blocks can be nested within other
PL/SQL blocks using BEGIN and END. Following is the basic structure of a PL/SQL block −
DECLARE
<declarations section>
BEGIN
<executable command(s)>
EXCEPTION
<exception handling>
END;

DBMS 76
SRI CHANAKYA DEGREE COLLEGE
The 'Hello World' Example

DECLARE
message varchar2(20):= 'Hello, World!';
BEGIN
dbms_output.put_line(message);
END;
/

The end; line signals the end of the PL/SQL block. To run the code from the SQL command
line, you may need to type / at the beginning of the first blank line after the last line of the code.

***Q4. Explain Data Types in PL/SQL?

PL/SQL data types are not just limited to writing SQL queries but they are used in the
PL/SQL block as well, just like any other programming language.

So we have 4 broader categories of data types and they are:

Scalar Types: These are basic data types which generally holds a single value like a number or a
string of characters. Scalar types have 4 different categories which are listed in the diagram
above, namely Number Types, Character and String, Boolean Types and Date and Time etc.
LOB Types: This data type deals with large objects and is used to specify location of these large
objects like text files, images etc which are generally not stored outside the database.
Reference Types: This data type is used to hold pointer values which generally stores address of
other program items.

DBMS 77
SRI CHANAKYA DEGREE COLLEGE
Composite Types: Last but not the least, as the name suggests this type of data is a composition
of individual data which can be manipulated/processed separate as well.

NUMBER(p,s)
Range: p= 1 to 38 s= -84 to 127
This datatype is used to store numeric data. Here, p is precision s is scale.
Example:
Age NUMBER(2); where , Age is a variable that can store 2 digits
percentage NUMBER(4,2); where, percentage is a variable that can store 4 (p) digits before
decimal and 2 (s) digits after decimal.

CHAR(size)
Range: 1 to 2000 bytes
This data type is used to store alphabetical string of fixed length. Its value is quoted in single
quotes. Occupies the whole declared size of memory even if the space is not utilized by the data.
Example:
rank CHAR(10); where, rank is a variable that can store upto 10 characters

VARCHAR(size)
Range: 1 to 2000 bytes
This data type is used to store alphanumeric string of variable length. Its value is quoted in single
quotes. Occupies the whole declared size of memory even if the space is not utilized by the data.
Example:
address VARCHAR(10); where, address is a variable that can occupy maximum 10 bytes of
memory space and can store alphanumeric value in it. Unused spaces are wasted.

VARCHAR2(size)
Range: 1 to 4000 bytes
This data type is used to store alphanumeric string of variable length. Its value is quoted in single
quotes.
It releases the unused space in memory, hence saving the unused space.
Example:
name VARCHAR2(10); where, name is a variable that can occupy maximum 10 bytes of
memory to store an alphanumeric value. The unused memory space is released.

DATE
Range: 01-Jan-4712 BC to 31-DEC-9999
It stores the data in date format DD-MON-YYYY. The value for this data type is written in
single quotes.
Example:
DOB DATE; where, DOB is a variable that stores date of birth in defined format (i.e,’13-FEB-
1991’)

%TYPE
It stores value of that variable whose data type is unknown and when we want the variable to
inherit the data type of the table column.

DBMS 78
SRI CHANAKYA DEGREE COLLEGE
Also, its value is generally being retrieved from an existing table in the database, hence it takes
the data type of the column for which it is used.
Example:
Student sno %TYPE;, where Student is the name of the table created in database and sno is
variable whose data type is unknown and %TYPE is used to store its value.

BOOLEAN
This data type is used in conditional statements. It stores logical values. It can be either TRUE
or FALSE
Example:
isAdmin BOOLEAN; where, isAdmin is a variable whose value can be TRUE or FALSE
depending upon the condition being checked.

***Q5. Explain operator precedence?

Operator precedence determines the grouping of terms in an expression. This affects how an
expression is evaluated. Certain operators have higher precedence than others; for example, the
multiplication operator has higher precedence than the addition operator.

For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has higher
precedence than +, so it first gets multiplied with 3*2 and then adds into 7.

Here, operators with the highest precedence appear at the top of the table, those with the lowest
appear at the bottom. Within an expression, higher precedence operators will be evaluated first.
The precedence of operators goes as follows: =, <, >, <=, >=, <>, !=, ~=, ^=, IS NULL, LIKE,
BETWEEN, IN.
Operator Operation

** exponentiation

+, - identity, negation

*, / multiplication, division

+, -, || addition, subtraction, concatenation

comparison

NOT logical negation

AND conjunction

OR inclusion

DBMS 79
SRI CHANAKYA DEGREE COLLEGE

***Q6. Explain control structures in pl/sql?

PL/SQL Control Structures are used to control flow of execution. PL/SQL provides different
kinds of statements to provide such type of procedural capabilities.These statements are almost
same as that of provided by other languages.

The flow of control statements can be classified into the following categories:
 Conditional Control
 Iterative Control
 Sequential Control
Conditional Control :
PL/SQL allows the use of an IF statement to control the execution of a block of code.
In PL/SQL, The IF -THEN construct in code blocks allow specifying certain conditions under
which a specific block of code should be executed.

Syntax:
IF < Condition > THEN
< Action >
ELSIF <Condition> THEN
< Action >
ELSE < Action >
END IF;

Example:
DECLARE
a Number := 30; b Number;
BEGIN
IF a > 40 THEN
b := a - 40;
DBMS_OUTPUT.PUT_LINE('b=' || b);
ELSEIF a = 30 then
b := a + 40;
DBMS_OUTPUT.PUT_LINE('b=' || b);
ELSE
b := 0;
DBMS_OUTPUT.PUT_LINE('b=' || b);
END IF;
END;
/

DBMS 80
SRI CHANAKYA DEGREE COLLEGE

Run SQL Command Line


SQL>set serveroutput on

SQL>start d://condi.sql
b=70

PL/SQL successfully completed.

Iterative Control :

Loop:

Iterative control indicates the ability to repeat or skip sections of a code block. A loop marks a
sequence of statements that has to be repeated. The keyword loop has to be placed before the
first statement in the sequence of statements to be repeated, while the keyword end loop is placed
immediately after the last statement in the sequence.

Syntax:
Loop
< Sequence of statements >
End loop;

Example:
DECLARE
i number := 0;
BEGIN
LOOP
dbms_output.put_line ('i = '||i);
i:=i+1;
EXIT WHEN i>=11;
END LOOP;

END;
/

DBMS 81
SRI CHANAKYA DEGREE COLLEGE

Run SQL Command Line


i=0
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i = 10
PL/SQL successfully completed.
WHILE loop
The while loop executes commands in its body as long as the condition remains true
Syntax :

WHILE < condition >


LOOP
< Action >
END LOOP

Example :
find reverse of given number using while loop
DECLARE
num Number(3) :=123;
ans Number(3) :=0;
i Number(3) :=0;
BEGIN
WHILE num != 0
LOOP
i:=mod(num,10);
ans:=(ans * 10 ) + i;
num:=floor(num/10);
END LOOP;
dbms_output.put_line('reverse of given number is: ' || ans);
END;
/

Output :
Run SQL Command Line
reverse of given number is: 321
PL/SQL successfully completed.

DBMS 82
SRI CHANAKYA DEGREE COLLEGE
The FOR Loop
The FOR loop can be used when the number of iterations to be executed are known.
Syntax :
FOR variable IN [REVERSE] start..end
LOOP
< Action >
END LOOP;
The variable in the For Loop need not be declared. Also the increment value cannot be specified.
The For Loop variable is always incremented by 1.
Example :
DECLARE
i number ;
BEGIN
FOR i IN 1 .. 10
LOOP
dbms_output.put_line ('i = '||i);
END LOOP;
END;
/

Output :
Run SQL Command Line
SQL>set serveroutput on

SQL>start d://it.sql
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i = 10
PL/SQL successfully completed.
Sequential Control :
The GOTO Statement
The GOTO statement changes the flow of control within a PL/SQL block. This statement allows
execution of a section of code, which is not in the normal flow of control. The entry point into
such a block of code is marked using the tags «userdefined name». The GOTO statement can
then make use of this user-defined name to jump into that block of code for execution.

DBMS 83
SRI CHANAKYA DEGREE COLLEGE

Syntax :
GOTO jump;
....
<<jump>>
Example :
DECLARE

BEGIN
dbms_output.put_line ('code starts');
dbms_output.put_line ('before GOTO statement');
GOTO down;
dbms_output.put_line ('statement will not get executed..');
<<down>>
dbms_output.put_line ('flow of execution jumped here.');
END;
/

Output :
code starts
before gotostatements
flow of execution jumped here.

PL/SQL successfully completed.

***Q7. Explain Steps to Create a PL/SQL Program?

SQL* Plus is an interactive and batch query tool that is installed with every Oracle installation.
Alternatively, you can also download it from the Oracle Technology Network (OTN). It has a
command line user interface, Windows GUI, and web-based user interface. It allows the user to
connect to the database and execute PL/SQL commands.

Connecting to Database
When we open SQL* Plus, it will prompt for the connection details as shown below.
Connection Details:
Username: <user name of the database>
Password: <password for that user>
Host String: <host details along with the port number and SID of the database>

DBMS 84
SRI CHANAKYA DEGREE COLLEGE

 After the successful connection, the SQL plus will appear as shown below
 We need to execute “set serveroutput on” if we need to see the output of the code.
 Now we are ready to work with the SQL* Plus tool.
 In this section, we are going to write a simple program for printing “Hello World” using
“Anonymous block”.

Code line 2: Prints the message “Hello World. . .”


Declaring and usage of variables in the program
Here we are going to print the “Hello World” using the variables.

Code Explanation:
Code line 2: Declaring a variable “text” of a VARCHAR2 type with size 25
Code line 4: Assigning the value “Hello World” to the variable “text”.
Code line 5: Printing the value of the variable “text”.

Comments in PL/SQL
Commenting code simply instructs the compiler to ignore that particular code from executing.
Comment can be used in the program to increase the readability of the program. In PL/SQL
codes can be commented in two ways.
Using ‘–‘ in the beginning of the line to comment that particular line.

DBMS 85
SRI CHANAKYA DEGREE COLLEGE
Using ‘/*…….*/’ we can use multiple lines. The symbol ‘/*’ marks the starting of the comment
and the symbol ‘*/’ marks the end of the comment.
The code between these two symbols will be treated as comments by the compiler.
Example: In this example, we are going to print ‘Hello World’ and we are also going to see how
the commented lines behave in the code

 Code line 2: Single line comment and compiler ignored this line from execution.
 Code line 3: Printing the value “Hello World.”
 Code line 4: Multiline commenting starts with ‘/*’
 Code line 5: Multiline commenting ends with ‘*/’

***Q8. Explain PL/SQL procedure?

A PL/SQL procedure is a reusable unit that encapsulates specific business logic of the
application. Technically speaking, a PL/SQL procedure is a named block stored as a schema
object in the Oracle Database.

The following illustrates the basic syntax of creating a procedure in PL/SQL:

CREATE [OR REPLACE] PROCEDURE procedure_name ( parameter list)


IS

[declaration statements]
BEGIN
[execution statements]
EXCEPTION
[exception handler]
END [procedure_name ];

PL/SQL procedure header

A procedure begins with a header that specifies its name and an optional parameter list. Each
parameter can be in either IN, OUT, or INOUT mode. The parameter mode specifies whether a
parameter can be read from or write to.

DBMS 86
SRI CHANAKYA DEGREE COLLEGE
IN : An IN parameter is read-only. You can reference an IN parameter inside a procedure, but
you cannot change its value.

OUT: An OUT parameter is writable. Typically, you set a returned value for The OUT
parameter and return it to the calling program.

INOUT : An INOUT parameter is both readable and writable. The procedure can read and
modify it.

PL/SQL procedure body

Similar to an anonymous block, the procedure body has three parts.


1) Declarative part
In this part, you can declare variables, constants, cursors, etc. Unlike an anonymous block, a
declaration part of a procedure does not start with the DECLARE keyword.
2) Executable part
This part contains one or more statements that implement specific business logic. It might
contain only a NULL statement.
3) Exception-handling part
This part contains the code that handles exceptions.
Creating a PL/SQL procedure example
The following procedure accepts a customer id and prints out the customer’s contact information
including first name, last name, and email:

CREATE OR REPLACE PROCEDURE print_contact(


in_customer_id NUMBER
)
IS
r_contact contacts%ROWTYPE;
BEGIN
-- get contact based on customer id
SELECT *
INTO r_contact
FROM contacts
WHERE customer_id = p_customer_id;

-- print out contact's information


dbms_output.put_line( r_contact.first_name || ' ' ||
r_contact.last_name || '<' || r_contact.email ||'>' );

EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( SQLERRM );
END;

DBMS 87
SRI CHANAKYA DEGREE COLLEGE

***Q9. Explain Functions in PL/SQL?


A PL/SQL function is same as a procedure and it is a reusable program unit stored as a
schema object in the Oracle Database except that it returns a value.

Creating a Function

A standalone function is created using the CREATE FUNCTION statement. The simplified
syntax for the CREATE OR REPLACE FUNCTION statement is as follows −
CREATE [OR REPLACE] FUNCTION function_name
[(parameter_name [IN | OUT | IN OUT] type [, ...])]
RETURN return_datatype
{IS | AS}
BEGIN
< function_body >
END [function_name];
Where,
 function-name specifies the name of the function.
 [OR REPLACE] option allows the modification of an existing function.
 The optional parameter list contains name, mode and types of the parameters. IN
represents the value that will be passed from outside and OUT represents the parameter
that will be used to return a value outside of the procedure.
 The function must contain a return statement.
 The RETURN clause specifies the data type you are going to return from the function.
 function-body contains the executable part.
 The AS keyword is used instead of the IS keyword for creating a standalone function.

Calling a Function

 A called function performs the defined task and when its return statement is executed or
when the last end statement is reached, it returns the program control back to the main
program.

DBMS 88
SRI CHANAKYA DEGREE COLLEGE

The following example illustrates how to create and call a standalone function. This function
returns the total number of CUSTOMERS in the customers table.
CREATE OR REPLACE FUNCTION totalCustomers
RETURN number IS
total number(2) := 0;
BEGIN
SELECT count(*) into total
FROM customers;

RETURN total;
END;
/

Following program calls the function totalCustomers from an anonymous block −


DECLARE
c number(2);
BEGIN
c := totalCustomers();
dbms_output.put_line('Total no. of Customers: ' || c);
END;
/

***Q10. Explain PL/SQL Triggers? Or Database triggers? And its types?

Triggers are stored programs, which are automatically executed or fired when some event
occurs. Trigger is stored into database and invoked repeatedly, when specific condition match.
Triggers are written to be executed in response to any of the following events.

 A database manipulation (DML) statement (DELETE, INSERT, or UPDATE).


 A database definition (DDL) statement (CREATE, ALTER, or DROP).
 A database operation (SERVERERROR, LOGON, LOGOFF, STARTUP, or
SHUTDOWN).

Advantages of Triggers

 Trigger generates some derived column values automatically


 Enforces referential integrity
 Event logging and storing information on table access
 Auditing
 Synchronous replication of tables
 Imposing security authorizations
 Preventing invalid transactions

DBMS 89
SRI CHANAKYA DEGREE COLLEGE
Syntax for creating trigger:

CREATE [OR REPLACE ] TRIGGER trigger_name


{BEFORE | AFTER | INSTEAD OF }
{INSERT [OR] | UPDATE [OR] | DELETE}
[OF col_name]
ON table_name
[REFERENCING OLD AS o NEW AS n]
[FOR EACH ROW]
WHEN (condition)
DECLARE
Declaration-statements
BEGIN
Executable-statements
EXCEPTION
Exception-handling-statements
END;

 CREATE [OR REPLACE] TRIGGER trigger_name: It creates or replaces an existing


trigger with the trigger_name.
 {BEFORE | AFTER | INSTEAD OF} : This specifies when the trigger would be
executed. The INSTEAD OF clause is used for creating trigger on a view.
 {INSERT [OR] | UPDATE [OR] | DELETE}: This specifies the DML operation.
 [OF col_name]: This specifies the column name that would be updated.
 [ON table_name]: This specifies the name of the table associated with the trigger.
 [REFERENCING OLD AS o NEW AS n]: This allows you to refer new and old values
for various DML statements, like INSERT, UPDATE, and DELETE.
 [FOR EACH ROW]: This specifies a row level trigger, i.e., the trigger would be executed
for each row being affected. Otherwise the trigger will execute just once when the SQL
statement is executed, which is called a table level trigger.
 WHEN (condition): This provides a condition for rows for which the trigger would fire.
This clause is valid only for row level triggers.
Example Program

CREATE OR REPLACE TRIGGER display_salary_changes


BEFORE DELETE OR INSERT OR UPDATE ON customers
FOR EACH ROW
WHEN (NEW.ID > 0)
DECLARE
sal_diff number;
BEGIN
sal_diff := :NEW.salary - :OLD.salary;
dbms_output.put_line('Old salary: ' || :OLD.salary);
dbms_output.put_line('New salary: ' || :NEW.salary);
dbms_output.put_line('Salary difference: ' || sal_diff);
END; /

DBMS 90
SRI CHANAKYA DEGREE COLLEGE
Type of Triggers

1. BEFORE Trigger: BEFORE trigger execute before the triggering DML statement
(INSERT, UPDATE, DELETE) execute. Triggering SQL statement is may or may not
execute, depending on the BEFORE trigger conditions block.
2. AFTER Trigger: AFTER trigger execute after the triggering DML statement (INSERT,
UPDATE, DELETE) executed. Triggering SQL statement is execute as soon as followed
by the code of trigger before performing Database operation.
3. ROW Trigger: ROW trigger fire for each and every record which are performing
INSERT, UPDATE, DELETE from the database table. If row deleting is define as trigger
event, when trigger file, deletes the five rows each times from the table.
4. Statement Trigger: Statement trigger fire only once for each statement. If row deleting
is define as trigger event, when trigger file, deletes the five rows at once from the table.
5. Combination Trigger: Combination trigger are combination of two trigger type,

a) Before Statement Trigger: Trigger fire only once for each statement before the
triggering DML statement.
b) Before Row Trigger : Trigger fire for each and every record before the triggering
DML statement.
c) After Statement Trigger: Trigger fire only once for each statement after the
triggering DML statement executing.
d) After Row Trigger: Trigger fire for each and every record after the triggering
DML statement executing.

DBMS 91
SRI CHANAKYA DEGREE COLLEGE

DATABASE MANAGEMENT SYSTEM


IMPORTANT QUESTIONS
UNIT –I TO UNIT -V

UNIT- I
1. Define Database system. write their away
2. write the difference between file band approach &Database approach

3. while the advantages & applications of DBMS

4. write the components of DBMS

5. Define data model. Explain different type of data model in DBMS


6. Explain about the Architecture of DBMS

UNIT-II
1. Explain about codd's Rules

2. write about constraints


3. write about keys concept

4. A Define Attribute & write their types

5. Explain about Relational Algebra


6. Explain about Relational calculus
7. Explain about Normalization

UNIT - III

1. Brite the basic building blocks of Relational Model.

2. Explain about Entiry & its types

3. Explain about Relationship degree

4. Explain about EER Model

DBMS 92
SRI CHANAKYA DEGREE COLLEGE

5. Write data types in SQL

6. Explain about DDL & DML operations

7. write about Aggregate functions in SQL

8. write about Selection & projection operations in SQL

9. write about clauses in SQL

UNIT - IV
1. Explain about Joins in SQL

2. Explain about Sub queries in SQL


3. Explain about views in SQL

4. write about DCL & TCL Commands


5. write about set operations

6. write about SQL functions

UNIT – V
1. write the structure of PL/SQL
2. write the control structures in PL/SQL

3. Explain about cursors in detail

4. Explain about procedures & functions

5. write about packages in PL/SQL

6. Write about Exception Handling


7. Explain about Triggers.

DBMS 93
SRI CHANAKYA DEGREE COLLEGE

OBJECT ORIENTED
SOFTWARE ENGINEERING

OBJECT ORIENTED SOFTWARE ENGINEERING 94


SRI CHANAKYA DEGREE COLLEGE

UNIT-I

Introduction to Object-Oriented Programming: Overview of software engineering,


Introduction to Object-Oriented Programming (OOP) concepts (classes, objects,
inheritance, polymorphism), Unified Modelling Language (UML) basics, Introduction to
software development process and software development life cycle (SDLC).

UNIT-II

Requirements Analysis and Design: Requirements analysis and specification, Use cases
and scenarios, Object-oriented analysis and design (OOAD), Design patterns, UML
modelling techniques (class diagrams, sequence diagrams, state machine diagrams, activity
diagrams)

UNIT-III

Software Construction and Testing: Software construction basics, Object- oriented design
principles, Object-oriented programming languages (Java, C++, Python), Software testing
basics (unit testing, integration testing, system testing), Test-driven development (TDD)

UNIT-IV

Software Maintenance and Evolution: Software maintenance basics, refactoring techniques


Software version control, Code review and inspection, Software evolution and reengineering

UNIT-V

Advanced Topics in Object-Oriented Software Engineering: Model-driven engineering


(MDE), Aspect-oriented programming (AOP), Component-based software engineering
(CBSE), Serviceoriented architecture (SOA), Agile software development and Scrum
methodologies.

OBJECT ORIENTED SOFTWARE ENGINEERING 95


SRI CHANAKYA DEGREE COLLEGE

UNIT - I
Q) Discuss about the overview of software engineering?

Software engineering is a systematic, disciplined, and quantifiable approach to the development,


operation, and maintenance of software. It involves applying engineering principles to software
development in order to produce reliable, efficient, and scalable software systems. Here’s an
overview of key aspects of software engineering:

1. Definition and Scope

Software engineering encompasses all the activities involved in software development, from
initial requirements gathering to the final deployment and maintenance of software systems. It
includes designing, coding, testing, and maintaining software.

2. Key Principles

Some foundational principles of software engineering include:

 Modularity: Breaking down a large system into smaller, manageable components.


 Abstraction: Hiding the complex implementation details and showing only the essential
features.
 Encapsulation: Keeping data and the methods that operate on the data bundled together,
which helps reduce complexity.
 Reusability: Writing code and components that can be used across different parts of the
system or in different projects.
 Maintainability: Ensuring that software can be easily updated, fixed, or expanded in the
future.
3. Software Development Life Cycle (SDLC)

The SDLC is a structured framework that guides the development process of software projects.
The main phases include:
 Requirement Analysis: Gathering and defining the needs of users and stakeholders.
 System Design: Planning the system architecture, choosing technologies, and designing
the system components.
 Implementation (Coding): Writing the actual code based on the system design.
 Testing: Ensuring that the software is free from defects and works as expected.
 Deployment: Installing and configuring the software for users.
 Maintenance: Updating and fixing the software after deployment.

OBJECT ORIENTED SOFTWARE ENGINEERING 96


SRI CHANAKYA DEGREE COLLEGE

4. Software Engineering Models


Different models provide frameworks for managing software projects. Some of the most
common ones include:
 Waterfall Model: A linear and sequential approach to software development.
 Agile Development: An iterative approach, where development is done in small, rapid
cycles called sprints, with a focus on flexibility and customer collaboration
 DevOps: A methodology that emphasizes collaboration between development and IT
operations teams, aiming for faster deployment cycles.
 V-Model: Focuses on validation and verification of each stage of development.
5. Software Engineering Practices

Good software engineering practices are critical for delivering high-quality software. These
include:

 Version Control: Tools like Git are used to manage changes to the software codebase.
 Code Reviews: Peer reviews help identify issues early and improve code quality.
 Continuous Integration/Continuous Deployment (CI/CD): Automating testing and
deployment to quickly and efficiently deliver updates.
 Test-Driven Development (TDD): Writing tests before the actual code to ensure the
software meets the desired requirements.
6. Types of Software Engineering

Software engineering can be specialized in various fields:


 System Software: Software designed to provide a platform for other software to run
(e.g., operating systems).
 Application Software: Software designed to perform specific tasks for users (e.g., word
processors, web browsers).
 Embedded Systems: Software built to control devices that aren't traditional computers,
like those in cars or medical devices.
 Web Development: Software engineering focused on creating applications that run on
the web.
 Mobile Development: Creating software for mobile devices like smartphones and
tablets.
7. Challenges in Software Engineering

The field is not without its challenges. Some common issues include:
 Complexity: Software systems can become very complex, making it hard to manage and
maintain.
 Quality Assurance: Ensuring that software is bug-free and meets users’ needs is an
ongoing challenge.

OBJECT ORIENTED SOFTWARE ENGINEERING 97


SRI CHANAKYA DEGREE COLLEGE

 Changing Requirements: As user needs change, software requirements often evolve


during the development process.
 Time and Budget Constraints: Managing the scope of a project to stay within time and
budget limits can be difficult.
8. Emerging Trends in Software Engineering

Software engineering is continually evolving with advancements in technology. Current trends


include:
 Artificial Intelligence (AI): AI and machine learning are being integrated into software
to provide smart features.
 Cloud Computing: Software is increasingly being developed for cloud platforms,
providing flexibility and scalability.
 Microservices: Architectures are moving away from monolithic designs to
microservices, where software is built as a collection of loosely coupled services.
 Blockchain: Some software systems are using blockchain technology to create
decentralized, secure applications.

Q) Explain the concept of classes and objects in Object Oriented Programming?

What are the basic concepts of Object Oriented Programming?

The general concepts of OOP which form the heart of Java language are

Objects and Classes

Classes and Objects.

1) Class: A group of Attributes with its relative behavior kept into a single unit with
permittedaccessibilities known as a CLASS. A class is a blueprintor Template that defines
the structure and behavior of objects.
class is a user defined data type in oops to define our own data types.

store specific
information.
is a logical Entity which allows to keep attributes with its related methods in a single unit with
authorized accessing, with security
2) Object: Object is a reference of its class blueprint. An object is an instance of a
class. Which stores a specific data to perform specificoperations. Object has a physical
reality. Members of an object are invoked with ‘.’ Operato
3)

OBJECT ORIENTED SOFTWARE ENGINEERING 98


SRI CHANAKYA DEGREE COLLEGE

Person Object

Name Data(Members)
Basic Pay

Salary ( )
Methods
Tax ( )
FIGURE 1: REPRESENTATION OF AN OBJECT
Benefits of using classes and objects:
Modularity,Reusability,Maintainability Data
Abstraction and Encapsulation
The wrapping up of data and methods into a single unit (called class) is known as
encapsulation. Data encapsulation is the most striking feature of a class. The data is not
accessible to the outside world and only these methods, which are wrapped in the class, can
access it. These methods provide the interface between the object’s data and the program. This
insulation of the data from direct access by the program is called data hiding. Encapsulation
makes it possible for objects to be treated like ‘black boxes’.

Data
Information “in” and Information “out”
Method

FIGURE 2: ENCAPSULATION – OBJECTS AS “BLACK BOXES”

Abstraction refers to the act of representing essential features without including the
background details or explanation.

Inheritance
Inheritance is the process by which objects of one class acquire the properties of objects
of another class. Inheritance supports the concept of hierarchical classification.

Bird
Attributes:
Flying Bird Non-Flying
Attributes: Bird

OBJECT ORIENTED SOFTWARE ENGINEERING 99


SRI CHANAKYA DEGREE COLLEGE

FIGURE 3: PROPERTY INHERITANCE


In OOP, the concept of inheritance provides the idea of reusability. This means that we
can add additional features to an existing class without modifying it. This is possible by deriving
a new class from the existing one. The new class will have the combined features of both the
classes. Types of inheritance 5
1)single Inheritance,2) Multiple Inheritance 3)Multilevel Inheritance4) hierarchical Inheritance
5) Hybrid Inheritance
Benefits : Code reusability,extensibility,Maintenance

Polymorphism
Polymorphism is another important OOP concept. Polymorphism means the ability to
take more than one form. For example, an operation may exhibit different behavior in different
instances.

The behavior depends upon the types of data used in the operation.

Polymorphism are 2 types


1. Static polymorphism(Method overloading) 2) Dynamic
Polymorphism(Method overriding)
Q) What is UML?

The UML stands for Unified modeling language, is a standardized general-purpose visual
modeling language in the field of Software Engineering. It is used for specifying, visualizing,
constructing, and documenting the primary artifacts of the software system. It helps in designing
and characterizing, especially those software systems that incorporate the concept of Object
orientation. It describes the working of both the software and hardware systems.

The UML was developed in 1994-95 by Grady Booch, Ivar Jacobson, and James Rumbaugh at
the Rational Software. In 1997, it got adopted as a standard by the Object Management Group
(OMG).

OBJECT ORIENTED SOFTWARE ENGINEERING 100


SRI CHANAKYA DEGREE COLLEGE

The Object Management Group (OMG) is an association of several companies that controls the
open standard UML. The OMG was established to build an open standard that mainly supports the
interoperability of object-oriented systems. It is not restricted within the boundaries, but it can also
be utilized for modeling the non-software systems. The OMG is best recognized for the Common
Object Request Broker Architecture (CORBA) standards.

Characteristics of UML
The UML has the following features:
o It is a generalized modeling language.
o It is distinct from other programming languages like C++, Python, etc.
o It is interrelated to object-oriented analysis and design.
o It is used to visualize the workflow of the system.

o It is a pictorial language, used to generate powerful modeling artifacts.


Q) Explain UML-Building Blocks
UML is composed of three main building blocks, i.e., things, relationships, and diagrams.
Building blocks generate one complete UML model diagram by rotating around several different
blocks. It plays an essential role in developing UML diagrams. The basic UML building blocks
are enlisted below:
1. Things
2. Relationships
3. Diagrams
Things
Anything that is a real world entity or object is termed as things. It can be divided into several
different categories:
o Structural things
o Behavioral things
o Grouping things

o Annotational things

Structural things
Nouns that depicts the static behavior of a model is termed as structural things. They display the
physical and conceptual components. They include class, object, interface, node, collaboration,
component, and a use case.
Class: A Class is a set of identical things that outlines the functionality and properties of an
object. It also represents the abstract class whose functionalities are not defined. Its
notation is as follows;

OBJECT ORIENTED SOFTWARE ENGINEERING 101


SRI CHANAKYA DEGREE COLLEGE

Interface: A set of operations that describes the functionality of a class, which is implemented
whenever an interface is implemented.

Collaboration: It represents the interaction between things that is done to meet the goal. It is
symbolized as a dotted ellipse with its name written inside it.

Use case: Use case is the core concept of object-oriented modeling. It portrays a set of actions
executed by a system to achieve the goal.

Actor: It comes under the use case diagrams. It is an object that interacts with the system, for
example, a user.

Component: It represents the physical part of the system.


OBJECT ORIENTED SOFTWARE ENGINEERING 102
SRI CHANAKYA DEGREE COLLEGE

Node: A physical element that exists at run time.

Behavioral Things
They are the verbs that encompass the dynamic parts of a model. It depicts the behavior of a
system. They involve state machine, activity diagram, interaction diagram, grouping things,
annotation things

State Machine: It defines a sequence of states that an entity goes through in the software
development lifecycle. It keeps a record of several distinct states of a system component.

OBJECT ORIENTED SOFTWARE ENGINEERING 103


SRI CHANAKYA DEGREE COLLEGE

Activity Diagram: It portrays all the activities accomplished by different entities of a system. It is
represented the same as that of a state machine diagram. It consists of an initial state, final state, a decision
box, and an action notation.

Interaction Diagram: It is used to envision the flow of messages between several components in a system.

OBJECT ORIENTED SOFTWARE ENGINEERING 104


SRI CHANAKYA DEGREE COLLEGE

Grouping Things
It is a method that together binds the elements of the UML model. In UML, the package is the only
thing, which is used for grouping.

Package: Package is the only thing that is available for grouping behavioral and structural things.

Advertisement

Annotation Things
It is a mechanism that captures the remarks, descriptions, and comments of UML model elements. In UML, a
note is the only Annotational thing.

Note: It is used to attach the constraints, comments, and rules to the elements of the model. It is a kind of
yellow sticky note.

Relationships

OBJECT ORIENTED SOFTWARE ENGINEERING 105


SRI CHANAKYA DEGREE COLLEGE

It illustrates the meaningful connections between things. It shows the association between the entities
and defines the functionality of an application. There are four types of relationships given below:

Dependency: Dependency is a kind of relationship in which a change in target element affects the source
element, or simply we can say the source element is dependent on the target element. It is one of the most
important notations in UML. It depicts the dependency from one entity to another.

It is denoted by a dotted line followed by an arrow at one side as shown below,

Association: A set of links that associates the entities to the UML model. It tells how many elements are
actually taking part in forming that relationship.

It is denoted by a dotted line with arrowheads on both sides to describe the relationship with the element on
both sides.

Generalization: It portrays the relationship between a general thing (a parent class or superclass) and a
specific kind of that thing (a child class or subclass). It is used to describe the concept of inheritance.

It is denoted by a straight line followed by an empty arrowhead at one side.

Realization: It is a semantic kind of relationship between two things, where one defines the behavior to be
carried out, and the other one implements the mentioned behavior. It exists in interfaces.

It is denoted by a dotted line with an empty arrowhead at one side.

Q) What are the various diagrams used in UML ?

Unified Modeling Language (UML) is a standardized visual language used to model and design
software systems. It provides various diagrams to represent the structure, behavior, and interactions
within a system. UML diagrams can be broadly categorized into two types: Structural Diagrams
Behavioral Diagrams. Below is a list of the most commonly used UML diagrams within these
categories
1. Structural Diagrams
These diagrams represent the static structure of a system, including the organization of its
components and their relationships.

OBJECT ORIENTED SOFTWARE ENGINEERING 106


SRI CHANAKYA DEGREE COLLEGE

a. Class Diagram
 Purpose: Represents the static structure of a system by showing the system’s classes, their
attributes, methods, and the relationships between them.
 Key Elements: Classes, attributes, methods, associations, inheritance, interfaces, etc.
 Example Use: Designing the object model of a system.
b. Object Diagram
 Purpose: Shows a snapshot of the instances of classes (objects) at a particular moment
in time, illustrating the system's state.
 Key Elements: Objects, links (associations) between them.
 Example Use: Showing examples of real objects at runtime, such as user accounts or
product items.
c. Component Diagram
 Purpose: Describes the components of a system, including their dependencies and
how they interact.
 Key Elements: Components, interfaces, dependencies, ports, and connectors.
 Example Use: Showing how different software components (libraries, modules) interact.
d. Deployment Diagram
 Purpose: Depicts the physical deployment of software components on hardware
nodes, showing how the system is distributed.
 Key Elements: Nodes (hardware), artifacts (software), communication paths, associations.
 Example Use: Illustrating how the system will be installed and run on physical machines.
e. Package Diagram
 Purpose: Organizes classes or components into packages, showing their dependencies.
 Key Elements: Packages, classes, dependencies between packages.
 Example Use: Grouping related classes or components in a system to improve organization.

f. Composite Structure Diagram


 Purpose: Describes the internal structure of a class or component and the interactions
between its parts.
 Key Elements: Parts, connectors, internal nodes, ports, and collaborations.
 Example Use: Modeling complex classes or components with detailed internal behavior.
g. Profile Diagram
 Purpose: Extends UML by allowing users to define custom stereotypes, tagged
values, and constraints for specific domains.
 Key Elements: Stereotypes, tagged values, profiles.
 Example Use: Defining custom UML elements for specific application domains like
business processes or hardware design.
2. Behavioral Diagrams
These diagrams represent the dynamic behavior of a system, including how objects interact and
the system’s processes over time.
a. Use Case Diagram

OBJECT ORIENTED SOFTWARE ENGINEERING 107


SRI CHANAKYA DEGREE COLLEGE

 Purpose: Illustrates the interactions between actors (users or external systems) and the
system to achieve a goal.
 Key Elements: Actors, use cases, relationships (associations, includes, extends).
 Example Use: Capturing user requirements and depicting system functionality.
b. Sequence Diagram
 Purpose: Shows how objects interact in a particular sequence over time. It represents
the flow of messages between objects.
 Key Elements: Objects, messages, activation bars, time axis.
 Example Use: Modeling the flow of control between objects, such as the process of
handling a user login.
c. Collaboration Diagram (also called Communication Diagram)
 Purpose: Depicts interactions between objects but focuses on the relationships
and the messages passed between them.
 Key Elements: Objects, messages, relationships, interaction labels.
 Example Use: Illustrating how objects communicate to fulfill a specific task,
focusing on the interaction structure.
d. State Diagram (also called State Machine Diagram)
 Purpose: Describes the states an object can be in and the transitions between these
states based on events or conditions.
 Key Elements: States, transitions, events, actions.
 Example Use: Modeling the life cycle of an object, such as a document moving from
draft to published.
e. Activity Diagram
 Purpose: Represents the workflow of activities and their flow, capturing business
processes and system workflows.
 Key Elements: Actions, decisions, control flows, initial and final nodes.
 Example Use: Modeling business processes, like the steps involved in processing an order.
f. Interaction Overview Diagram
 Purpose: Combines aspects of activity and sequence diagrams, showing the control flow
and the interactions within a system.
 Key Elements: Interaction frames, activities, object interactions.
 Example Use: Visualizing high-level behavior and interactions, like a sequence of
workflows.
g. Timing Diagram
 Purpose: Focuses on the timing constraints of interactions, showing the state changes of
objects over time.
 Key Elements: Time intervals, states, events, lifelines.
 Example Use: Modeling real-time systems where the timing of events is crucial.
3. Additional Diagram Types
 Communication Diagram: Another name for the Collaboration Diagram mentioned
earlier.
OBJECT ORIENTED SOFTWARE ENGINEERING 108
SRI CHANAKYA DEGREE COLLEGE

 Interaction Diagram: Can be used to refer to both sequence and communication diagrams.
 Behavioral State Machine Diagram: A detailed diagram for modeling the states of
an object with complex behaviors.
Q) EXPLAIN SDLC(SOFTWARE DEVELOPMENT LIFE CYCLE)

The Software Development Life Cycle (SDLC) is a structured process that outlines the phases
involved in developing software applications. It defines the steps taken to build software from
the initial concept all the way through to its deployment and maintenance. SDLC provides a
systematic approach to software development, ensuring quality, consistency, and predictability.
Here’s an explanation of the various stages involved in SDLC:
1. Requirement Analysis
 Purpose: Understand and document the requirements of the software from
stakeholders, including end users, business analysts, and clients.
 Activities:
o Gathering requirements through meetings, questionnaires, or research.
o Analyzing and prioritizing the requirements.
o Creating a Software Requirement Specification (SRS) document that
defines the system's functionalities and constraints.
 Outcome: A clear understanding of what the software is expected to do.
2. System Design
 Purpose: Plan the architecture and design of the software system, ensuring it
meets the functional and non-functional requirements.
 Activities:
o High-Level Design (HLD): Defines the overall system architecture,
including components, technologies, and their interactions.
o Low-Level Design (LLD): Focuses on detailed design, such as database
schema, individual components, and how each module functions.
 Outcome: System and software design documents that guide the development phase.
3. Implementation (Coding)
 Purpose: Write the actual code based on the system and software design.
 Activities:
o Developers start coding based on the design specifications.
o The code is written in appropriate programming languages, and
algorithms are implemented.
o It may involve collaboration among multiple developers working on different
modules or components of the system.
 Outcome: A working software application that implements the system’s functionality.
4. Testing
 Purpose: Ensure that the software functions as expected and is free of defects.
 Activities:

OBJECT ORIENTED SOFTWARE ENGINEERING 109


SRI CHANAKYA DEGREE COLLEGE

o Unit Testing: Testing individual components or modules of the system.


o Integration Testing: Ensuring that the various components of the system work
together as intended.
o System Testing: Verifying that the entire system functions correctly in the
environment it will be deployed.
o User Acceptance Testing (UAT): The final testing phase, where the end users
validate the software based on real-world scenarios.
o Regression Testing: Ensuring that new changes haven't broken existing functionality.
 Outcome: Identifying and fixing bugs, ensuring the software meets the requirements and
quality standards.
5. Deployment

 Purpose: Deploy the software for use by end users.


 Activities:
o Deploying the software in the production environment.
o Configuring the environment, installing necessary software or hardware, and
ensuring that the system is ready for use.
o Sometimes, a phased deployment or beta release is done to get feedback before
full- scale deployment.
 Outcome: The software is live and accessible by users.
6. Maintenance
 Purpose: Continuously monitor and improve the software after its deployment.
 Activities:
o Bug Fixes: Addressing defects or issues reported by users.
o Updates: Making changes to the software to improve its performance,
add new features, or adapt it to new hardware or software environments.
o Enhancements: Adding new features based on evolving business needs
or user feedback.
o Optimization: Improving the system's performance or efficiency.
 Outcome: Ongoing support for the software, ensuring that it remains functional and up-to-
date.
SDLC Models
There are various models that define how the phases of SDLC are executed. Here are some of the
most common SDLC models:
1. Waterfall Model:
o A linear and sequential approach where each phase must be completed before
moving on to the next one.
o Pros: Simple to understand and implement.
o Cons: Not flexible; difficult to go back and make changes after a phase is completed.

OBJECT ORIENTED SOFTWARE ENGINEERING 110


SRI CHANAKYA DEGREE COLLEGE

2. Agile Model:
o An iterative and incremental approach where the development process is
divided into small cycles (sprints), typically lasting 1-4 weeks.
o Pros: Flexibility, allows changes based on feedback, and provides frequent
releases of software.
o Cons: Can be hard to predict timelines and budgets, especially for larger projects.
3. V-Model (Verification and Validation):
o An extension of the waterfall model, where each phase corresponds to a testing phase.
o Pros: Emphasizes validation and testing early in the process.
o Cons: Rigid and less flexible when changes are required.
4. Iterative Model:
o Similar to Agile but with longer development cycles. Development is done in
iterative loops, and feedback is incorporated at the end of each iteration.
o Pros: Allows for better risk management and continuous improvement.
o Cons: Can lead to incomplete documentation.
5. Spiral Model:
o Combines elements of both design and prototyping. It focuses on iterative
development and risk management.
o Pros: Suitable for large, complex, and high-risk projects.
o Cons: Can be expensive and time-consuming.
6. DevOps Model:
o Emphasizes continuous integration, delivery, and feedback. Development and
operations teams work together to automate processes, improve deployment
speed, and ensure software quality.
o Pros: Faster delivery of software, improved collaboration between teams,
better feedback loops.
o Cons: Requires strong collaboration and automation tools.
Benefits of SDLC

 Predictability: It provides a clear structure and timeline, allowing for better


project management and resource allocation.
 Quality: SDLC ensures thorough testing, improving software quality and reducing bugs.
 Efficiency: A structured approach leads to more efficient use of resources and time.
 Risk Management: Each phase identifies potential issues early in the process,
reducing the likelihood of major failures.
 Customer Satisfaction: Through proper requirement gathering and validation, SDLC
ensures that the software meets user needs.

OBJECT ORIENTED SOFTWARE ENGINEERING 111


SRI CHANAKYA DEGREE COLLEGE

UNIT - II
Q) EXPLAIN ABOUT SOFTWARE REQUIREMENTS ANALYSIS AND
SPECIFICATION(SRS)?

oftware Requirements Analysis and Specification


Software Requirements Analysis and Specification is a critical phase in the software
development lifecycle (SDLC) that focuses on gathering, analyzing, and documenting the
requirements of a system. This phase ensures that the software being developed meets the
expectations of its stakeholders and provides a clear, well-understood blueprint for the
development team.
It is divided into two main parts:
1. Software Requirements Analysis: The process of identifying, analyzing, and
defining the system's requirements.
2. Software Requirements Specification (SRS): The formal document that outlines the
system’s requirements in detail.
1. Software Requirements Analysis
Software Requirements Analysis is the phase where the needs of the stakeholders are gathered,
understood, and documented. The primary goal of this phase is to ensure that all aspects of the
system, both functional and non-functional, are captured accurately and comprehensively.
Key Activities in Software Requirements Analysis:
1. Requirement Elicitation:
o The process of gathering requirements from various stakeholders, including
users, clients, business analysts, and other subject matter experts.
o Methods used:
 Interviews: Direct discussions with stakeholders to understand their
needs and expectations.
 Surveys/Questionnaires: Collecting feedback from users or a large
group of stakeholders.
 Workshops: Collaborative group discussions to extract requirements.
 Document Analysis: Reviewing existing system documentation or
business process documents.
 Prototyping: Developing a preliminary version of the system to gather
feedback.
2. Requirement Classification:
o Once gathered, the requirements are classified into two broad categories:
 Functional Requirements: Define the specific behaviors or
functions of the system (e.g., "The system should allow users to
register and log in").
 Non-Functional Requirements: Specify the qualities or attributes the
system must have (e.g., performance, security, reliability, scalability,
and usability).
OBJECT ORIENTED SOFTWARE ENGINEERING 112
SRI CHANAKYA DEGREE COLLEGE

3. Requirement Prioritization:
o This involves prioritizing the requirements to determine which ones are most
important and should be developed first. Prioritization techniques include:
 MoSCoW (Must have, Should have, Could have, Won't have).
 Kano Model (Basic, Performance, Excitement factors).
4. Requirement Validation:
o Ensuring that the requirements are realistic, feasible, and meet the needs of
the stakeholders.
o This step often involves reviewing the requirements with stakeholders to ensure
they are correctly understood and feasible within project constraints (e.g.,
budget, timeline, technology).
5. Feasibility Analysis:
o Assessing the feasibility of the requirements in terms of technical,
operational, and financial constraints.
o This involves analyzing whether the requirements can be implemented
with the available resources and technologies.
2. Software Requirements Specification (SRS)
The Software Requirements Specification (SRS) is a formal document that describes in detail
the software system to be developed. The SRS serves as a contract between the client and the
development team, ensuring that both parties have a clear understanding of the system's
functionality and expectations.

Key Components of an SRS:


1. Introduction:
o Purpose: The purpose of the software, its intended audience, and the scope
of the project.
o Scope: A high-level overview of the system, describing the boundaries of the
system and what will and will not be included.
o Definitions, Acronyms, and Abbreviations: Any terms, acronyms, or
abbreviations used in the document to ensure clarity.

2. System Overview:
o A general description of the system’s purpose, context, and high-level
features. This section typically provides background information on the
problem the software is solving.
3. Functional Requirements:
o Detailed descriptions of the functionalities the system must have. Each
functional requirement should define a specific behavior or interaction.
o For example:
 "The system shall allow the user to reset their password via email."
 "The system shall generate monthly reports for administrators."

OBJECT ORIENTED SOFTWARE ENGINEERING 113


SRI CHANAKYA DEGREE COLLEGE

4. Non-Functional Requirements:
o These are the quality attributes of the system that specify how the system
should perform.
o Key non-functional requirements include:
 Performance: E.g., "The system must process 1000 transactions per second."
 Security: E.g., "The system shall use AES-256 encryption for all sensitive
data."
 Usability: E.g., "The system shall have an intuitive user interface that
can be learned in 1 hour."
 Reliability: E.g., "The system shall be available 99.9% of the time."
5. External Interface Requirements:
o Describes how the system will interact with external systems, hardware, or
software components. This includes user interfaces, hardware interfaces, software
interfaces, and communication protocols.
o For example:
 User Interface: The layout and design of screens and inputs.
 Hardware Interface: Describing how the system will interface with
hardware (e.g., printers, sensors).
 Software Interface: Interfaces with other software applications or
systems (e.g., database systems, third-party APIs).
6. System Features:
o A detailed list of all the features that the system will provide, organized in a
structured manner, often with corresponding functional requirements.
o Each feature description typically includes the expected inputs, processing, and
outputs, as well as any specific behaviors or constraints.
7. Assumptions and Constraints:
o Any assumptions made during the requirements gathering process or constraints on
the
system’s design or implementation.
o For example:
 "The system will be developed in Java."
 "The system must be able to run on a Windows environment."
8. Acceptance Criteria:
o The specific conditions or tests that must be met for the system to be accepted by
the client. This section is crucial for validating the software's functionality and
performance during the testing phase.

9. Appendices:
o Additional information, such as diagrams, prototypes, or examples, that might be
useful for understanding the requirements.

OBJECT ORIENTED SOFTWARE ENGINEERING 114


SRI CHANAKYA DEGREE COLLEGE

Importance of Software Requirements Analysis and Specification

1. Clear Communication:
o By documenting the requirements clearly, the SRS helps ensure that all
stakeholders, including clients, developers, and testers, have a common
understanding of the project.
2. Foundation for Design and Development:
o The SRS serves as the blueprint for the system’s design and development. It
guides the software architects and developers in creating the software according
to the specified requirements.
3. Ensures Stakeholder Alignment:
o By validating and prioritizing requirements, software requirements analysis
ensures that the final product meets the needs of the stakeholders and solves the
correct problem.
4. Reduces Risk:
o A well-defined SRS reduces the risk of scope creep, misinterpretation, and
failure by providing clear documentation and ensuring all requirements are
thoroughly analyzed and agreed upon early in the process.
5. Improved Testing and Validation:
o The SRS serves as a reference point for testing, ensuring that all specified
requirements are validated during the quality assurance phase. This makes it
easier to identify discrepancies or defects in the developed system.
Challenges in Software Requirements Analysis and Specification
1. Incomplete or Ambiguous Requirements:
o Requirements that are unclear or missing important details can
lead to misunderstandings and errors during development.
2. Changing Requirements:
o As the project progresses, stakeholders may change their requirements, which
can be difficult to manage and may require going back and revisiting previous
stages.
3. Communication Gaps:
o Miscommunication between clients, users, and the development team can result
in the wrong requirements being captured or misunderstood.
4. Conflicting Requirements:
o Different stakeholders may have conflicting needs or expectations, making it
challenging to satisfy everyone.

Q) WHAT IS A USE-CASE DIAGRAM?

In the Unified Modeling Language (UML), a use case diagram can summarize the details of your

OBJECT ORIENTED SOFTWARE ENGINEERING 115


SRI CHANAKYA DEGREE COLLEGE

system's users (also known as actors) and their interactions with the system. To build one, you'll

use a set of specialized symbols and connectors. An effective use case diagram can help your
team discuss and represent:

 Scenarios in which your system or application interacts with people, organizations, or


external systems

 Goals that your system or application helps those entities (known as actors) achieve

 The scope of your system

When to apply use case diagrams

A use case diagram doesn't go into a lot of detail—for example, don't expect it to model the
order in which steps are performed. Instead, a proper use case diagram depicts a high-level
overview of the relationship between use cases, actors, and systems. Experts recommend that use
case diagrams be used to supplement a more descriptive textual use case.

UML is the modeling toolkit that you can use to build your diagrams. Use cases are represented
with a labeled oval shape. Stick figures represent actors in the process, and the actor's
participation in the system is modeled with a line between the actor and use case. To depict the
system boundary, draw a box around the use case itself.

UML use case diagrams are ideal for:

 Representing the goals of system-user interactions


 Defining and organizing functional requirements in a system

 Specifying the context and requirements of a system

 Modeling the basic flow of events in a use case

OBJECT ORIENTED SOFTWARE ENGINEERING 116


SRI CHANAKYA DEGREE COLLEGE

Benefits of Use Case Diagrams:

1. Simplifies Complex Systems: Use case diagrams help simplify complex systems by
focusing on the high-level functionality without getting into implementation details.
2. Clarifies User Requirements: They are helpful in capturing and
communicating user requirements to both developers and stakeholders.
3. Identifies System Interactions: They help identify which actors interact with which
parts of the system, which is useful for defining roles and responsibilities.
4. Facilitates Communication: Use case diagrams provide a clear and easy-to-understand
way of representing system interactions, making it easier for non-technical stakeholders
to participate in the development process.

Q) WHAT ARE THE BENEFITS OF OBJECT-ORIENTED ANALYSIS AND DESIGN?


Benefits of Object-Oriented Analysis and Design (OOAD)
Object-Oriented Analysis and Design (OOAD) is an approach to software development that
focuses on identifying the key objects in a system and modeling their interactions. OOAD
emphasizes breaking down a system into smaller, reusable components, often called objects, and
organizing the design around those objects. This methodology is based on Object-Oriented
Programming (OOP) principles such as inheritance, encapsulation, polymorphism, and
abstraction.

OBJECT ORIENTED SOFTWARE ENGINEERING 117


SRI CHANAKYA DEGREE COLLEGE

Here are the key benefits of using Object-Oriented Analysis and Design:
1. Modularity and Reusability
 Modularity: OOAD promotes breaking down the system into smaller, manageable
objects. Each object typically represents a real-world entity or concept (e.g., a customer,
a product), and it encapsulates both data and behavior related to that entity. This
modular approach makes it easier to manage complex systems by focusing on individual
components.
 Reusability: Once an object or class is designed, it can be reused across different parts
of the system or even in other projects. This reduces the need to duplicate code,
making the system more efficient and maintainable. For example, a "Customer" class
could be reused in different applications or scenarios where customer data is needed.
2. Easier Maintenance and Modification
 Encapsulation: Objects encapsulate data and behavior together, which means that
internal object details can be hidden from other parts of the system. This makes it easier
to modify or update an object without affecting other parts of the system, reducing the
risk of breaking other parts of the codebase.
 Extensibility: OOAD makes it easier to extend the system with new features or
objects. For instance, if new functionality is required, you can add new objects or
extend existing ones through inheritance, rather than rewriting large sections of
code.
3. Real-World Modeling
 Natural Mapping to the Real World: OOAD focuses on modeling real-world entities
and processes as objects. Each object typically represents a concept or entity that can be
found in the real world (e.g., a "BankAccount" or "Customer"). This makes the design
more intuitive and easier to understand for both technical and non-technical
stakeholders.
 Rich Modeling: OOAD allows you to capture complex relationships and behaviors
between objects. Features like inheritance and polymorphism help in expressing
hierarchical relationships and dynamic behaviors that would be difficult to represent with
other methodologies.
4. Improved Communication and Collaboration
 Clearer Documentation: The use of UML (Unified Modeling Language) diagrams,
which are often used in OOAD, provides clear and visual documentation of the system.
Diagrams like class diagrams, use case diagrams, and sequence diagrams can help
stakeholders understand system behavior, object interactions, and structure in a simple
and organized way.
 Better Stakeholder Communication: Because the objects in OOAD correspond to
real-world entities, the design is easier to discuss with non-technical stakeholders,
making it easier for them to understand how the system works and what it does. This
improves communication between business users, designers, and developers.

OBJECT ORIENTED SOFTWARE ENGINEERING 118


SRI CHANAKYA DEGREE COLLEGE

5. Scalability
 Scalable Design: Object-oriented systems can more easily scale as new requirements are
added. For example, new types of objects can be created without needing to overhaul the
existing system. This is due to the principles of inheritance and polymorphism, which
allow objects to be extended and modified without changing the entire system.
 Flexibility: OOAD supports the gradual expansion of a system by allowing new
functionality to be added through subclassing (via inheritance) or by adding new
objects to the system. This makes it easier to add features over time, especially in
complex systems that are constantly evolving.
6. Reduced Complexity
 Abstraction: OOAD helps reduce complexity by allowing designers to focus on high-
level abstractions rather than low-level details. The abstraction allows users to interact
with objects at a higher level, while the internal complexities are hidden from them.
This makes the design and development process simpler and easier to understand.
 Clear Structure: The object-oriented approach provides a well-defined structure for
the software system, making it easier to understand relationships between different
parts of the system, which helps reduce overall complexity.
7. Better Code Organization
 Separation of Concerns: In OOAD, each object typically encapsulates a specific
responsibility or function, which means that different concerns (e.g., data management,
user interface, business logic) are well-separated. This leads to clearer code organization
and better alignment with the Single Responsibility Principle (SRP), one of the SOLID
principles in OOP.
 Simpler Debugging: Since objects are modular and independent, it is easier to locate
and debug problems. Issues related to a particular object can be isolated to that object
without affecting other parts of the system.
8. Supports the Use of Design Patterns
 Design Patterns: OOAD encourages the use of well-established design patterns,
which are proven, reusable solutions to common design problems. Some common
patterns include:
o Singleton Pattern: Ensures that a class has only one instance and provides a
global point of access.
o Observer Pattern: Allows one object to notify others about changes in its state.
o Factory Pattern: Simplifies object creation by providing an interface for creating
objects in a super class but allowing subclasses to alter the type of created
objects.

By using design patterns, developers can apply best practices and improve the reliability and
maintainability of the system.

OBJECT ORIENTED SOFTWARE ENGINEERING 119


SRI CHANAKYA DEGREE COLLEGE

9. Facilitates Testing and Debugging


 Unit Testing: Objects can be tested independently, making it easier to perform unit
testing. Since the behavior and data for an object are encapsulated, it can be tested in
isolation from other components. This leads to easier identification of defects and
more reliable tests.
 Integration Testing: OOAD's well-defined structure allows for easier integration
testing, as objects can be combined to test interactions between them in a controlled
manner.
10. Better System Reliability and Quality
 Modular Testing and Debugging: Since objects are self-contained and have well-
defined behaviors, it is easier to test and debug individual objects, which improves the
overall reliability of the system.
 Consistent and Predictable Behavior: Object-oriented systems exhibit more
predictable behavior as changes to one object generally do not affect others, leading to
a more stable and reliable system.
Q) WHAT ARE VARIOUS TYPES OF DESIGN PATTERNS?

Design patterns are well-established solutions to common problems encountered in software


design. They provide reusable templates for solving specific design issues in object-oriented
systems. The Gang of Four (GoF) book, Design Patterns: Elements of Reusable Object-
Oriented Software, is the seminal work that categorized design patterns into three main types
based on their purpose:
1. Creational Design Patterns
2. Structural Design Patterns
3. Behavioral Design Patterns
Below is a detailed explanation of each category and the key patterns within them.
1. Creational Design Patterns
Creational design patterns deal with the process of object creation. These patterns help in object
creation mechanisms, trying to create objects in a manner suitable to the situation. The goal is to
avoid creating objects directly using newoperators and instead provide more flexible ways to
instantiate objects.

Key Creational Patterns:


 Singleton Pattern:
o Ensures that a class has only one instance and provides a global point of access
to that instance.
o Example: Database connection or logging class, where only one instance is
needed throughout the application.
 Factory Method Pattern:
o Defines an interface for creating objects, but allows subclasses to alter the
type of objects that will be created.
OBJECT ORIENTED SOFTWARE ENGINEERING 120
SRI CHANAKYA DEGREE COLLEGE

o Example: A vehicle factory that can produce different types of vehicles (car,
truck, bike) based on user input.
 Abstract Factory Pattern:
o Provides an interface for creating families of related or dependent objects
without specifying their concrete classes.
o Example: GUI toolkit that creates buttons, windows, and other components
depending on whether the platform is Windows or MacOS.
 Builder Pattern:
o Separates the construction of a complex object from its representation,
allowing the same construction process to create different representations.
o Example: Building a complex document, where the parts (sections, paragraphs,
images) are added in a step-by-step manner.
 Prototype Pattern:
o Creates new objects by copying an existing object (a prototype). This is
useful when creating a new object is costly or time-consuming.
o Example: A game where enemies can be cloned from a prototype enemy object,
varying only in specific attributes.
2. Structural Design Patterns
Structural design patterns focus on the composition of classes or objects. These patterns help
ensure that objects and classes can be combined into larger structures while keeping the system
flexible and easy to extend.
Key Structural Patterns:
 Adapter Pattern:
o Converts one interface to another expected by the client. It acts as a bridge
between two incompatible interfaces.
o Example: A system that needs to communicate with legacy code which uses a
different interface from the current system.
 Bridge Pattern:
o Decouples an abstraction from its implementation so that both can
evolve independently.
o Example: A remote control with different types of devices (TV, air
conditioner) where the interface for the remote can be adapted to any device.
 Composite Pattern:
o Allows individual objects and composite objects (groups of objects) to be
treated uniformly. This pattern is often used for tree-like structures.
o Example: A file system where both individual files and directories (which
contain files) are treated uniformly.
 Decorator Pattern:
o Allows you to dynamically add behavior or responsibilities to an object
without modifying its code. It's a way to extend the functionality of a
class.

OBJECT ORIENTED SOFTWARE ENGINEERING 121


SRI CHANAKYA DEGREE COLLEGE

o Example: A window that can have various features (scroll bar, border, etc.)
added dynamically.
 Facade Pattern:
o Provides a simplified interface to a complex subsystem. It helps make the
subsystem easier to use.
o Example: A home theater system with multiple components (DVD player,
speakers, projector) can be controlled via a single facade object.
 Flyweight Pattern:
o Reduces memory usage by sharing common parts of state between multiple
objects, rather than creating duplicates.
o Example: In a game, characters that have the same appearance and behavior can
share common attributes like color or size.
 Proxy Pattern:
o Provides a surrogate or placeholder for another object. It can be used to control
access, enhance functionality, or lazy-load resources.
o Example: A virtual proxy for an image that only loads the image when it is needed.
3. Behavioral Design Patterns
Behavioral design patterns are concerned with the interaction between objects and how they
communicate with each other. These patterns focus on the delegation of responsibilities, how the
system behaves, and how the objects communicate.
Key Behavioral Patterns:
 Chain of Responsibility Pattern:
o Allows passing of requests along a chain of handlers. Each handler processes the
request or passes it on to the next handler in the chain.
o Example: A helpdesk system where multiple support levels (level 1, level 2, etc.)
handle customer queries.
 Command Pattern:
o Encapsulates a request as an object, thereby allowing for parameterization of
clients with queues, requests, and operations.

o Example: A GUI with buttons where each button press triggers a command that
can be undone or redone.
 Interpreter Pattern:
o Provides a way to evaluate language grammar or expressions. It is used in
situations where a language's grammar needs to be parsed.
o Example: A program that interprets and executes mathematical expressions in
string format.
 Iterator Pattern:
o Provides a way to access elements of a collection object sequentially without
exposing its underlying representation.
o Example: Traversing through a list of employees in a company one by one.

OBJECT ORIENTED SOFTWARE ENGINEERING 122


SRI CHANAKYA DEGREE COLLEGE

 Mediator Pattern:
o Defines an object that controls the communication between a set of objects,
preventing them from referring to each other explicitly, and reducing coupling.
o Example: A chat room where users do not interact with each other directly, but
through a central mediator that manages the communication.
 Memento Pattern:
o Allows the state of an object to be captured and restored without exposing its
internal structure.
o Example: A text editor that saves the history of user inputs to allow undo
and redo functionality.
 Observer Pattern:
o Defines a one-to-many dependency relationship so that when one object changes
state, all its dependents are notified and updated automatically.
o Example: A news agency where multiple subscribers (observers) are notified
when a new story is published.
 State Pattern:
o Allows an object to alter its behavior when its internal state changes. The object
appears to change its class.
o Example: A vending machine that behaves differently depending on whether it is
waiting for money or dispensing a product.
 Strategy Pattern:
o Defines a family of algorithms, encapsulates each one, and makes them
interchangeable. The strategy allows the algorithm to be selected at
runtime.
o Example: A payment system where different payment methods (credit card,
PayPal, etc.) can be selected by the user.
 Template Method Pattern:
o Defines the structure of an algorithm in a base class, allowing subclasses to provide
specific implementations of certain steps without changing the algorithm’s structure.
o Example: A file parsing process where the overall process is the same, but the
steps for parsing different file types vary.
 Visitor Pattern:
o Allows you to add further operations to objects without having to modify
them. It separates an algorithm from the objects on which it operates.
o Example: An operation on different shapes (circle, square, etc.) where a
visitor can perform actions like area calculation or drawing, without changing
the shape classes

OBJECT ORIENTED SOFTWARE ENGINEERING 123


SRI CHANAKYA DEGREE COLLEGE

Q) SEQUENCE DIAGRAM WITH EXAMPLE IN UML ?

Sequence Diagram in UML


A Sequence Diagram is one of the interaction diagrams in Unified Modeling Language (UML)
that shows how objects interact in a particular scenario of a system. It illustrates the order of
messages exchanged between objects over time.
Key Components of a Sequence Diagram
1. Actors:
o External entities that interact with the system. Represented by stick figures.
2. Objects/Participants:
o Entities that participate in the interaction, such as classes or other objects.
Represented by rectangles with the object/class name.
3. Lifelines:
o A vertical dashed line below each participant, representing the existence of the
object over time.
4. Messages:
o Communication between objects (method calls, responses, etc.).
o Solid arrow: Indicates a synchronous message (e.g., a method call).
o Dashed arrow: Indicates a return or response message.
5. Activation Bar:
o A rectangle on a lifeline showing when an object is active (e.g., processing a request).
6. Loops and Conditions:
o Represent repetitive or conditional behaviors using loops (e.g., loop) or
optional fragments (e.g., opt).
Example: Online Shopping System

Scenario:
A customer searches for a product, adds it to the cart, and proceeds to checkout.
Steps:

1. The Customer searches for a product.


2. The Search System retrieves the product details from the Database.
3. The Customer adds the product to the cart.
4. The Cart System updates the cart and confirms the addition.
5. The Customer proceeds to checkout.

OBJECT ORIENTED SOFTWARE ENGINEERING 124


SRI CHANAKYA DEGREE COLLEGE

6. The Payment System processes the payment.


Sequence Diagram Representation:
Actor: Customer
Participants: Search System, Database, Cart System, Payment System
Diagram Description

1. Customer sends a Search Productmessage to the Search System.


2. The Search System sends a query (Retrieve Product Details) to the Database and waits
for a response.
3. Database returns the product details to the Search System.
4. The Search System displays the product to the Customer.
5. Customer sends an Add to Cartmessage to the Cart System.
6. The Cart System updates the cart and confirms the action to the Customer.
7. Customer sends a Proceed to Checkoutmessage to the Payment System.
8. The Payment System processes the payment and confirms success.

UML Sequence Diagram

Here’s a visual representation:

OBJECT ORIENTED SOFTWARE ENGINEERING 125


SRI CHANAKYA DEGREE COLLEGE

Here is the UML sequence diagram illustrating the online shopping system. It visually represents
the interaction between the Customer, Search System, Database, Cart System, and Payment
System during a typical purchase flow.
Q) What are the components of an activity diagram with example?

UML Activity Diagram


In UML, the activity diagram is used to demonstrate the flow of control within the system rather
than the implementation. It models the concurrent and sequential activities.

The activity diagram helps in envisioning the workflow from one activity to another. It put
emphasis on the condition of flow and the order in which it occurs. The flow can be sequential,
branched, or concurrent, and to deal with such kinds of flows, the activity diagram has come up
with a fork, join, etc.

It is also termed as an object-oriented flowchart. It encompasses activities composed of a set of


actions or operations that are applied to model the behavioral diagram.

Components of an Activity Diagram


Following are the component of an activity diagram:

Activities

The categorization of behavior into one or more actions is termed as an activity. In other words,
it can be said that an activity is a network of nodes that are connected by edges. The edges depict
the flow of execution. It may contain action nodes, control nodes, or object nodes.

The control flow of activity is represented by control nodes and object nodes that illustrates the
objects used within an activity. The activities are initiated at the initial node and are terminated at
the final node.

Activity partition /swimlane


The swimlane is used to cluster all the related activities in one column or one row. It can be
either vertical or horizontal. It used to add modularity to the activity diagram. It is not necessary
to incorporate swimlane in the activity diagram. But it is used to add more transparency to the
activity diagram.

OBJECT ORIENTED SOFTWARE ENGINEERING 126


SRI CHANAKYA DEGREE COLLEGE

Forks

Forks and join nodes generate the concurrent flow inside the activity. A fork node consists of
one inward edge and several outward edges. It is the same as that of various decision parameters.
Whenever a data is received at an inward edge, it gets copied and split crossways various
outward edges. It split a single inward flow into multiple parallel flows.

Join Nodes

Join nodes are the opposite of fork nodes. A Logical AND operation is performed on all of the
inward edges as it synchronizes the flow of input across one single output (outward) edge.

Pins

It is a small rectangle, which is attached to the action rectangle. It clears out all the messy and
complicated thing to manage the execution flow of activities. It is an object node that precisely
represents one input to or output from the action.
Notation of an Activity diagram
Activity diagram constitutes following notations:
Initial State: It depicts the initial stage or beginning of the set of actions.

OBJECT ORIENTED SOFTWARE ENGINEERING 127


SRI CHANAKYA DEGREE COLLEGE

Final State: It is the stage where all the control flows and object flows end.
Decision Box: It makes sure that the control flow or object flow will follow only one path.

Action Box: It represents the set of actions that are to be performed.

Why use Activity Diagram?


An event is created as an activity diagram encompassing a group of nodes associated with edges.
To model the behavior of activities, they can be attached to any modeling element. It can model
use cases, classes, interfaces, components, and collaborations.

It mainly models processes and workflows. It envisions the dynamic behavior of the system as
well as constructs a runnable system that incorporates forward and reverse engineering. It does
not include the message part, which means message flow is not represented in an activity
diagram.

It is the same as that of a flowchart but not exactly a flowchart itself. It is used to depict the flow
between several activities.
How to draw an Activity Diagram?
An activity diagram is a flowchart of activities, as it represents the workflow among various
activities. They are identical to the flowcharts, but they themself are not exactly the flowchart. In
other words, it can be said that an activity diagram is an enhancement of the flowchart, which
encompasses several unique skills.
Since it incorporates swimlanes, branching, parallel flows, join nodes, control nodes, and forks,
it supports exception handling. A system must be explored as a whole before drawing an activity
diagram to provide a clearer view of the user. All of the activities are explored after they are
properly analyzed for finding out the constraints applied to the activities. Each and every
activity, condition, and association must be recognized.
After gathering all the essential information, an abstract or a prototype is built, which is then
transformed into the actual diagram.

OBJECT ORIENTED SOFTWARE ENGINEERING 128


SRI CHANAKYA DEGREE COLLEGE

Following are the rules that are to be followed for drawing an activity diagram:

1. A meaningful name should be given to each and every activity.


2. Identify all of the constraints.
3. Acknowledge the activity associations.

Example of an Activity Diagram


An example of an activity diagram showing the business flow activity of order processing is
given below.

Here the input parameter is the Requested order, and once the order is accepted, all of the
required information is then filled, payment is also accepted, and then the order is shipped. It
permits order shipment before an invoice is sent or payment is completed.

When to use an Activity Diagram?


An activity diagram can be used to portray business processes and workflows. Also, it used for
modeling business as well as the software. An activity diagram is utilized for the followings:
1. To graphically model the workflow in an easier and understandable way.
2. To model the execution flow among several activities.
3. To model comprehensive information of a function or an algorithm employed within the
system.
4. To model the business process and its workflow.
5. To envision the dynamic aspect of a system.
6. To generate the top-level flowcharts for representing the workflow of an application.
7. To represent a high-level view of a distributed or an object-oriented system.

OBJECT ORIENTED SOFTWARE ENGINEERING 129


SRI CHANAKYA DEGREE COLLEGE

Q) What is a state machine diagram , types of statediagram and explain with


example?

UML State Machine Diagram


The state machine diagram is also called the Statechart or State Transition diagram, which shows
the order of states underwent by an object within the system. It captures the software system's
behavior. It models the behavior of a class, a subsystem, a package, and a complete system.

It tends out to be an efficient way of modeling the interactions and collaborations in the external
entities and the system. It models event-based systems to handle the state of an object. It also
defines several distinct states of a component within the system. Each object/component has a
specific state.

Following are the types of a state machine diagram that are given below:

1. Behavioralstatemachine
The behavioral state machine diagram records the behavior of an object within the
system. It depicts an implementation of a particular entity. It models the behavior of the
system.
2. Protocolstatemachine
It captures the behavior of the protocol. The protocol state machine depicts the change in
the state of the protocol and parallel changes within the system. But it does not portray
the implementation of a particular component.

Why State Machine Diagram?


Since it records the dynamic view of a system, it portrays the behavior of a software application.
During a lifespan, an object underwent several states, such that the lifespan exist until the
program is executing. Each state depicts some useful information about the object.

It blueprints an interactive system that response back to either the internal events or the external
ones. The execution flow from one state to another is represented by a state machine diagram. It
visualizes an object state from its creation to its termination.

The main purpose is to depict each state of an individual object. It represents an interactive
system and the entities inside the system. It records the dynamic behavior of the system.

Notation of a State Machine Diagram


Following are the notations of a state machine diagram enlisted below:

OBJECT ORIENTED SOFTWARE ENGINEERING 130


SRI CHANAKYA DEGREE COLLEGE

1. Initial state: It defines the initial state (beginning) of a system, and it is represented by a
black filled circle.
2. Final state: It represents the final state (end) of a system. It is denoted by a filled circle
present within a circle.
3. Decision box: It is of diamond shape that represents the decisions to be made on the
basis of an evaluated guard.
4. Transition: A change of control from one state to another due to the occurrence of some
event is termed as a transition. It is represented by an arrow labeled with an event due to
which the change has ensued.
5. State box: It depicts the conditions or circumstances of a particular object of a class at a
specific point of time. A rectangle with round corners is used to represent the state box.
Types of State
The UML consist of three states:
1. Simple state: It does not constitute any substructure.
2. Composite state: It consists of nested states (substates), such that it does not contain
more than one initial state and one final state. It can be nested to any level.
3. Submachine state: The submachine state is semantically identical to the composite state,
but it can be reused.
How to Draw a State Machine Diagram?
The state machine diagram is used to portray various states underwent by an object. The change
in one state to another is due to the occurrence of some event. All of the possible states of a
particular component must be identified before drawing a state machine diagram.

The primary focus of the state machine diagram is to depict the states of a system. These states
are essential while drawing a state transition diagram. The objects, states, and events due to
which the state transition occurs must be acknowledged before the implementation of a state
machine diagram.
Following are the steps that are to be incorporated while drawing a state machine diagram:

OBJECT ORIENTED SOFTWARE ENGINEERING 131


SRI CHANAKYA DEGREE COLLEGE

1. A unique and understandable name should be assigned to the state transition that
describes the behavior of the system.
2. Out of multiple objects, only the essential objects are implemented.
3. A proper name should be given to the events and the transitions.

When to use a State Machine Diagram?


The state machine diagram implements the real-world models as well as the object-oriented
systems. It records the dynamic behavior of the system, which is used to differentiate between
the dynamic and static behavior of a system.

It portrays the changes underwent by an object from the start to the end. It basically envisions
how triggering an event can cause a change within the system.

State machine diagram is used for:

1. For modeling the object states of a system.


2. For modeling the reactive system as it consists of reactive objects.
3. For pinpointing the events responsible for state transitions.
4. For implementing forward and reverse engineering.

Example of a State Machine Diagram


An example of a top-level state machine diagram showing Bank Automated Teller Machine
(ATM) is given below.

Initially, the ATM is turned off. After the power supply is turned on, the ATM starts performing
the startup action and enters into the Self Test state. If the test fails, the ATM will enter into
the Out Of Service state, or it will undergo a triggerless transition to the Idle state. This
is the state where the customer waits for the interaction.

Whenever the customer inserts the bank or credit card in the ATM's card reader, the ATM state
changes from Idle to Serving Customer, the entry action readCard is performed after entering
into Serving Customer state. Since the customer can cancel the transaction at any instant, so the
transition from Serving Customer state back to the Idle state could be triggered by cancel
event.

OBJECT ORIENTED SOFTWARE ENGINEERING 132


SRI CHANAKYA DEGREE COLLEGE

Here the Serving Customer is a composite state with sequential substates that are
Customer Authentication, Selecting Transaction, and Transaction.

Customer Authentication and Transaction are the composite states itself is displayed by a
hidden decomposition indication icon. After the transaction is finished, the Serving Customer
encompasses a triggerless transition back to the Idle state. On leaving the state, it undergoes the
exit action ejectCard that discharges the customer card.

OBJECT ORIENTED SOFTWARE ENGINEERING 133


SRI CHANAKYA DEGREE COLLEGE

UNIT-III
Q) WHAT ARE SOFTWARE CONSTRUCTION FUNDAMENTALS

 Minimizing complexity: emphasizing code creation that is simple and readable rather
than clever
 Anticipating change: enhance a software product without disrupting the
underlying structure
 Constructing for verification: faults can be readily found by the software engineers
writing the software as well as by the testers and users
 Reuse: using existing assets in solving different problems
 Standards in construction: helps achieve a project's objectives for efficiency, quality,
and cost.

Q) WHAT ARE THE MAIN OBJECTIVES OF SOFTWARE CONSTRUCTION AND TESTING?

Main Objectives of Software Construction and Testing

Software construction and testing are critical phases of the Software Development Life Cycle
(SDLC). These phases ensure that the software is built according to design specifications and
meets the required functionality, performance, and quality standards. Below are the primary
objectives of each phase:

1. Objectives of Software Construction

Software construction involves writing code, integrating modules, and building the software
system based on the design. Its objectives are:

1.1 Ensure Correct Implementation

 Implement design specifications accurately in code.


 Follow best practices, coding standards, and guidelines.

1.2 Achieve Modularity and Reusability

 Develop modular components that can be reused in other parts of the system or future
projects.
 Use design patterns and principles like DRY (Don't Repeat Yourself).

OBJECT ORIENTED SOFTWARE ENGINEERING 134


SRI CHANAKYA DEGREE COLLEGE

1.3 Optimize Performance


 Write efficient, maintainable, and scalable code.
 Use algorithms and data structures that optimize performance based on the application’s
requirements.
1.4 Maintain Code Quality
 Follow consistent coding standards and documentation practices.
 Use code review processes to identify and rectify issues early.
1.5 Minimize Defects
 Focus on creating defect-free code during development by employing unit testing,
static code analysis, and debugging techniques.
1.6 Enable Smooth Integration
 Ensure individual modules integrate seamlessly with one another.
 Use continuous integration tools and automated builds to catch integration issues early.
1.7 Use Automation Tools
 Leverage tools for code generation, refactoring, version control, and deployment to
improve productivity and reduce errors.
2. Objectives of Software Testing
Software testing is the process of evaluating the software to ensure it meets the specified
requirements and functions correctly. Its objectives are:
2.1 Verify and Validate Functionality
 Ensure the software performs as intended (verification).
 Confirm that the software meets the needs and expectations of the user (validation).
2.2 Identify and Eliminate Defects
 Detect bugs, errors, or inconsistencies in the software.
 Correct defects to ensure the system works without failures.

2.3 Improve Software Quality


 Validate the software against quality standards like performance, usability,
reliability, and security.
 Ensure the software is robust and ready for deployment.
2.4 Ensure Compatibility
 Test software across different devices, operating systems, browsers, and hardware to
ensure compatibility.
2.5 Test Performance and Scalability
 Verify that the system performs efficiently under expected and extreme load conditions.
 Ensure the software can scale as per user demands and resource availability.
2.6 Validate Security
 Identify and fix vulnerabilities to protect against unauthorized access, data
breaches, or malicious attacks.

OBJECT ORIENTED SOFTWARE ENGINEERING 135


SRI CHANAKYA DEGREE COLLEGE

2.7 Support Continuous Integration


 Ensure that changes made during development do not break existing functionality.
 Use automated regression testing tools to maintain system stability.
2.8 Provide Feedback
 Give developers detailed feedback on issues discovered during testing to facilitate
quicker resolution.
3. Combined Objectives: Construction and Testing
When combined, software construction and testing aim to:
 Deliver High-Quality Software: Ensure the final product is robust, reliable, and
meets user expectations.
 Enhance Development Efficiency: Reduce time and cost by identifying issues
early and preventing cascading failures.
 Ensure Maintainability: Create a codebase that is easy to update, extend, and debug.
 Facilitate Smooth Deployment: Ensure the software is production-ready with minimal
issues.
 Improve User Satisfaction: Deliver a product that is functional, efficient, and free
from critical defects.

Q) WHAT ARE THE PRICIPLES OF SOFTWARE CONSTRUCTION

Principles of Software Construction

Software construction involves coding, testing, debugging, and integrating software components
to create a functional system. Adhering to fundamental principles during software construction
ensures that the software is reliable, maintainable, and scalable. Below are the key principles of
software construction:
1. Modularity
 Definition: Divide the software into smaller, self-contained units or modules.
 Purpose: Makes the code easier to understand, test, debug, and maintain.
 Best Practices:
o Use cohesive modules with single responsibilities (Single Responsibility Principle).
o Minimize dependencies between modules (Low Coupling).
2. Abstraction
 Definition: Simplify complex systems by hiding unnecessary details and exposing
only the essential features.
 Purpose: Reduces complexity and improves readability and maintainability.
 Best Practices:
o Use interfaces and abstract classes.
o Encapsulate implementation details and expose high-level functionality.

OBJECT ORIENTED SOFTWARE ENGINEERING 136


SRI CHANAKYA DEGREE COLLEGE

3. Encapsulation
 Definition: Restrict access to certain parts of the software to prevent unintended
interference and maintain control over the internal state.
 Purpose: Protects the integrity of objects and modules, ensuring stability.
 Best Practices:
o Use private and protected access modifiers.
o Expose data through well-defined methods (getters and setters).
4. Separation of Concerns
 Definition: Separate a program into distinct sections, each addressing a specific
aspect of functionality.
 Purpose: Reduces overlap and interdependency, making it easier to modify one part of
the code without affecting others.
 Best Practices:
o Apply the MVC (Model-View-Controller) architecture.
o Separate business logic from user interface code.
5. Reusability
 Definition: Design components so they can be reused in multiple parts of the software
or other projects.
 Purpose: Saves time and effort by avoiding redundant code.
 Best Practices:
o Write generic methods or classes.
o Use design patterns, such as Factory or Singleton.
6. Testability
 Definition: Write code that is easy to test, ensuring each component can be
validated individually.
 Purpose: Facilitates debugging and helps detect errors early.
 Best Practices:
o Write unit tests for individual components.
o Ensure loose coupling to allow mocking during tests.
7. Maintainability

 Definition: Ensure the software is easy to update, debug, and enhance over time.
 Purpose: Reduces the cost and effort required to make changes in the future.
 Best Practices:
o Use clear and consistent naming conventions.
o Write meaningful comments and documentation.
8. Simplicity
 Definition: Keep the design and code as simple as possible.
 Purpose: Makes the software easier to understand and maintain, reducing the
likelihood of errors.

OBJECT ORIENTED SOFTWARE ENGINEERING 137


SRI CHANAKYA DEGREE COLLEGE

 Best Practices:
o Avoid over-engineering.
o Use straightforward algorithms and data structures.
9. Performance Optimization

 Definition: Design and write code that performs efficiently under expected workloads.
 Purpose: Ensures the software runs smoothly and meets performance requirements.
 Best Practices:
o Optimize algorithms and memory usage.
o Avoid premature optimization; focus on bottlenecks.
10. Adherence to Standards
 Definition: Follow established coding standards, guidelines, and industry best practices.
 Purpose: Ensures consistency across the codebase and facilitates collaboration
among team members.
 Best Practices:
o Use standardized frameworks and libraries.
o Enforce code reviews to maintain quality.
11. Error Handling and Robustness

 Definition: Anticipate and handle errors gracefully to ensure system stability.


 Purpose: Prevents unexpected crashes and improves user experience.
 Best Practices:
o Implement proper exception handling.
o Validate user inputs and system outputs.
12. Incremental and Iterative Development

 Definition: Build the software in small, manageable increments and refine it through
iterations.
 Purpose: Allows for continuous feedback and minimizes risk.
 Best Practices:
o Use Agile methodologies.
o Continuously test and integrate changes.

13. Scalability

 Definition: Design the software to handle increasing loads without significant


performance degradation.
 Purpose: Ensures the system can grow to meet future demands.
 Best Practices:
o Use distributed architectures where needed.
o Optimize database queries and caching mechanisms.

OBJECT ORIENTED SOFTWARE ENGINEERING 138


SRI CHANAKYA DEGREE COLLEGE

14. Security
 Definition: Design and code software with security considerations to protect
against vulnerabilities.
 Purpose: Ensures data integrity, confidentiality, and availability.
 Best Practices:
o Use secure coding practices.
o Regularly update dependencies to patch vulnerabilities.

15. Continuous Improvement


 Definition: Always look for ways to improve the code and the development process.
 Purpose: Ensures long-term efficiency and quality.
 Best Practices:
o Refactor code periodically.
o Gather feedback from users and team members.
Q) WHAT ARE THE BENEFITS OF USING JAVA IN SOFTWARE DEVELOPMENT?

Benefits of Using Java in Software Development

Java is one of the most popular programming languages in the world due to its versatility,
reliability, and rich ecosystem. Here are the key benefits of using Java for software development:
1. Platform Independence
 Write Once, Run Anywhere (WORA): Java programs are compiled into bytecode,
which runs on any device equipped with a Java Virtual Machine (JVM). This eliminates
the need to rewrite code for different platforms.
 Cross-platform compatibility makes Java ideal for distributed systems and applications
requiring deployment on various environments.
2. Object-Oriented Programming (OOP)
 Java is an object-oriented language, which promotes:
o Modularity: Breaking down applications into smaller, reusable objects.
o Maintainability: Code is easier to understand, update, and extend.
o Reusability: Inherits and reuses existing components, reducing development time.
3. Rich Standard Library
 Java provides a comprehensive Java Standard Library (JDK) with pre-built classes
and methods for:
o Data structures (e.g., lists, maps).
o Networking (e.g., sockets, HTTP handling).
o Database access (JDBC).
o File I/O operations.
o Multithreading and concurrency.

OBJECT ORIENTED SOFTWARE ENGINEERING 139


SRI CHANAKYA DEGREE COLLEGE

4. Robustness
 Java emphasizes error detection during both compile-time and runtime, reducing the
chances of system crashes.
 Features like:
o Automatic Garbage Collection: Manages memory efficiently.
o Strong Typing System: Reduces type-related errors.
o Exception Handling: Provides structured error management.
5. Security
 Java has built-in security features such as:
o Sandboxing: Restricts untrusted code from performing harmful actions.
o Security APIs: For cryptography, secure communication, and authentication.
o Bytecode Verifier: Prevents malicious bytecode execution.
o No Direct Memory Access: Eliminates vulnerabilities like buffer overflows.

6. Scalability
 Java's architecture makes it suitable for developing scalable applications:
o It supports multithreading and asynchronous processing for high-
performance applications.
o Java frameworks (e.g., Spring, Hibernate) simplify scaling large systems.
7. Extensive Framework and Tools Ecosystem
 Java has a vast range of frameworks and tools for different development needs:
o Spring, Hibernate: For enterprise applications.
o Apache Struts: For web applications.
o JUnit, TestNG: For unit testing.
o Apache Maven, Gradle: For build automation.
o Android SDK: For mobile app development.
8. Community Support
 Java has a large, active global community, which offers:
o Extensive documentation and tutorials.
o Libraries and plugins for almost any use case.
o Quick support for troubleshooting and development challenges.
9. Versatility
 Java can be used to build:
o Web applications: Using frameworks like Spring and JSP.
o Enterprise applications: For business-critical systems.
o Mobile applications: Android development relies heavily on Java.
o Embedded systems: Java's lightweight nature is suitable for IoT devices.
o Big Data applications: Tools like Hadoop and Apache Spark are written in Java.
o Cloud-based applications: Java integrates seamlessly with cloud platforms.

OBJECT ORIENTED SOFTWARE ENGINEERING 140


SRI CHANAKYA DEGREE COLLEGE

10. Performance

 Java is not as fast as low-level languages like C++, but Just-In-Time (JIT)
compilation improves runtime performance.
 Efficient memory management through garbage collection enhances
application responsiveness.
11. Backward Compatibility
 Java maintains backward compatibility between versions, allowing older applications to
run on newer JVMs with minimal changes.
12. Strong Ecosystem for Enterprise Development
 Java's features align with enterprise requirements:
o High reliability and scalability.
o Support for distributed computing via tools like Java RMI and CORBA.
o Compatibility with enterprise standards (e.g., JEE).
13. Integration Capabilities
 Java integrates seamlessly with:
o Databases: JDBC API.
o Messaging Systems: JMS for communication.
o Third-party libraries and APIs.

14. Future-Proof Language


 Regular updates and enhancements by Oracle and the Java community ensure Java
remains relevant.
 It adapts to modern development trends, such as modular programming and reactive
streams (introduced in recent Java versions).

15. Cost-Effectiveness
 Open-source nature of the Java Development Kit (JDK) reduces licensing costs.
 Free tools, frameworks, and libraries make it accessible for organizations and developers.

Q) WHAT ARE THE BENEFITS OF USING PYTHON IN SOFTWARE DEVELOPMENT

Benefits of Using Python in Software Development

Python is one of the most versatile and widely-used programming languages in software
development. Its simplicity, readability, and extensive library ecosystem make it a preferred

choice for developers across various domains. Here are the key benefits of using Python in
software development:

OBJECT ORIENTED SOFTWARE ENGINEERING 141


SRI CHANAKYA DEGREE COLLEGE

1. Simplicity and Readability


 Ease of Learning: Python has a simple syntax that resembles natural language, making it
easy for beginners to learn and understand.
 Code Readability: Python's clear and concise code style improves maintainability and
reduces the learning curve for teams.

2. Versatility and Flexibility

 Multipurpose Language: Python can be used for web development, data analysis,
machine learning, artificial intelligence, automation, and more.

 Cross-Platform: Python applications run on various platforms, including Windows,


macOS, Linux, and more, without modification.

3. Rich Standard Library

 Python comes with a vast standard library that includes modules and packages for:
o File I/O operations.
o String manipulation.
o Internet protocols (HTTP, FTP).
o Data serialization (JSON, XML).
o Database access.

4. Extensive Ecosystem of Libraries and Frameworks


 Python's ecosystem offers a wide range of libraries and frameworks that speed up
development:
o Web Development: Django, Flask, FastAPI.
o Data Analysis and Visualization: NumPy, pandas, Matplotlib, Seaborn.
o Machine Learning and AI: TensorFlow, PyTorch, Scikit-learn.
o Automation and Scripting: Selenium, PyAutoGUI.
o Game Development: Pygame.
o Scientific Computing: SciPy, SymPy.

5. Strong Community Support

 Active Global Community: Python has a vast and active developer community that
provides:
o Extensive documentation.
o Tutorials, guides, and examples.
o Fast support for troubleshooting.

OBJECT ORIENTED SOFTWARE ENGINEERING 142


SRI CHANAKYA DEGREE COLLEGE

6. Portability

 Python's interpreted nature allows it to run seamlessly on multiple platforms without the
need for recompilation, enhancing its portability.

7. Rapid Development
 Python enables faster prototyping and development due to:
o Simplified syntax.
o Pre-built libraries.
o Readily available frameworks.

8. Integration Capabilities
 Python integrates well with other technologies and languages:
o Database Integration: Libraries like SQLAlchemy and Django ORM.
o Language Interoperability: Jython (Java), IronPython (.NET), Cython (C/C++).
o API Development: Easy RESTful API creation with Flask and FastAPI.
o

9. Scalability
 Python supports scalable solutions for small scripts to large enterprise applications:
o Can handle increasing loads using frameworks like Django and Flask.
o Suitable for microservices and serverless architecture.

10. Support for Advanced Technologies

 Python is widely used in cutting-edge technologies:


o Artificial Intelligence and Machine Learning: Frameworks like TensorFlow
and Scikit- learn are optimized for Python.

o Data Science and Big Data: Libraries like pandas and Dask make handling large
datasets easier.
o IoT Development: Works with Raspberry Pi and microcontrollers for IoT projects.

11. Automation and Scripting


 Python excels in automating repetitive tasks, such as:
o Web scraping (Beautiful Soup, Scrapy).
o Task scheduling and system monitoring.
o Automating testing (Selenium, Robot Framework).

OBJECT ORIENTED SOFTWARE ENGINEERING 143


SRI CHANAKYA DEGREE COLLEGE

12. Open-Source and Free


 Python is free to use, even for commercial applications.
 The open-source community continuously improves and expands its capabilities.

13. Strong Support for Testing


 Python has built-in and third-party testing tools, such as:
o Unit Testing: unittest, pytest.
o Behavior-Driven Development: Behave.
o Continuous Integration Tools: Integrated with Jenkins, Travis CI, etc.
14. Ideal for Prototyping
 Python's flexibility and rapid development capabilities make it excellent for creating
prototypes and proof-of-concept applications.

15. Support for Asynchronous Programming


 Python provides robust support for asynchronous programming:
o Libraries like asyncio help build high-performance, asynchronous applications.

16. High Demand in the Job Market


 Python developers are in high demand due to its extensive use in industries such as
finance, healthcare, tech, and education.

17. Backward Compatibility


 While Python continues to evolve, it maintains backward compatibility, ensuring
minimal disruption when upgrading versions.

Q) WHAT ARE THE 7 PRINCIPLES OF SOFTWARE TESTING

The 7 Principles of Software Testing are a set of foundational guidelines that help testers
perform effective and efficient testing, ensuring software quality. These principles emphasize the
importance of structured testing practices and realistic expectations. Here's a detailed
explanation:

1. Testing Shows Presence of Defects, Not Their Absence


 Meaning: Testing can identify defects in the software but cannot prove that the
software is completely defect-free.

 Implication:
o Even after extensive testing, some defects may still exist.
o The goal of testing is to minimize the number of undiscovered issues.
 Key Practice: Focus on uncovering critical bugs rather than achieving "zero defects."

OBJECT ORIENTED SOFTWARE ENGINEERING 144


SRI CHANAKYA DEGREE COLLEGE

2. Exhaustive Testing is Impossible


 Meaning: Testing every possible input combination and execution path is impractical,
especially in complex systems.
 Implication:
o It is infeasible to test all scenarios due to time and resource constraints.
 Key Practice:
o Use risk-based testing to prioritize the most critical functionalities.
o Focus on high-impact areas and areas prone to failure.

3. Early Testing Saves Time and Money

 Meaning: Detecting defects early in the Software Development Life Cycle (SDLC)
reduces the cost and effort required to fix them.
 Implication:
o Late detection of bugs, especially during production, leads to higher repair
costs and customer dissatisfaction.
 Key Practice:
o Start testing activities during the requirements and design phases (e.g., through
reviews and static testing).

4. Defect Clustering

 Meaning: A small number of modules or components often contain the majority of the
defects.
 Implication:
o Focus on areas of the application with a history of bugs or complexity.
 Key Practice:
o Apply Pareto Principle (80/20 rule): 80% of defects are found in 20% of the code.
o Use test coverage reports and bug trends to identify risky modules.
5. The Pesticide Paradox

 Meaning: Repeating the same set of tests over time may no longer uncover new defects.
 Implication:
o Test cases must be periodically reviewed and updated to remain effective.
 Key Practice:
o Regularly create new test cases to target uncovered areas or new functionality.
o Introduce exploratory testing to uncover unexpected issues.

OBJECT ORIENTED SOFTWARE ENGINEERING 145


SRI CHANAKYA DEGREE COLLEGE

6. Testing is Context-Dependent
 Meaning: The testing approach and effort should vary depending on the type of software
and its intended purpose.
 Implication:
o Different applications (e.g., e-commerce vs. safety-critical systems) require
distinct testing strategies and focus areas.
 Key Practice:
o Tailor the testing strategy to match the application’s requirements, domain, and user
expectations.

7. Absence of Errors is a Fallacy

 Meaning: Even if no defects are found, it does not mean the software is useful or
meets user requirements.
 Implication:
o Software can pass tests but still fail if it does not fulfill business needs or is
not user- friendly.
 Key Practice:
o Align testing objectives with business requirements and user expectations.
o Perform validation testing to ensure the software delivers value.

Q) WHAT IS UNIT TESTING AND HOW TO PROCESS OF UNIT TESTING

What is Unit Testing?


Unit testing is a type of software testing that focuses on verifying the correctness of individual
components or units of code. A "unit" in this context is the smallest testable part of an
application, such as a function, method, or class.

Purpose:

To ensure that each unit of code works as expected in isolation.


 To identify and fix bugs at an early stage, reducing downstream costs.
Characteristics of Unit Testing
1. Isolation: Tests only the specific functionality of a single unit, independent of other units.
2. Automation: Often automated using testing frameworks like JUnit (Java), pytest
(Python), or NUnit (.NET).

3. Fast Feedback: Provides quick feedback on code changes, especially in agile and
continuous integration workflows.
4. Repeatable: Can be run multiple times to verify the unit's consistency across different
scenarios.
OBJECT ORIENTED SOFTWARE ENGINEERING 146
SRI CHANAKYA DEGREE COLLEGE

Process of Unit Testing

1. Understand the Requirements and Code

 Review the requirements and technical specifications.


 Understand the logic of the unit (e.g., function, method, or class) to determine
expected behavior.

2. Write Test Cases

 Define test cases for different scenarios, including:


o Positive tests: Valid inputs producing expected results.
o Negative tests: Invalid inputs or edge cases to ensure proper error handling.
o Boundary tests: Inputs at the edge of acceptable ranges.

3. Use Unit Testing Frameworks

 Select an appropriate testing framework for the language, such as:


o Python: unittest, pytest
o Java: JUnit, TestNG
o C#: NUnit, MSTest
o JavaScript: Jest, Mocha

4. Mock Dependencies

 Isolate the unit by mocking external dependencies like databases, APIs, or files.
 Use mocking libraries (e.g., Mockito for Java, unittest.mock for Python) to
simulate these dependencies.

5. Execute Test Cases

 Run the unit tests using the chosen framework.


 Observe whether the unit behaves as expected under all test scenarios.
6. Debug and Fix Issues
 If a test case fails, identify the root cause by debugging the unit.
 Update the code and rerun the test cases to ensure issues are resolved

OBJECT ORIENTED SOFTWARE ENGINEERING 147


SRI CHANAKYA DEGREE COLLEGE

7. Validate Code Coverage


 Use tools to measure test coverage to ensure all critical code paths are tested.
o Examples: coverage.py(Python), Jacoco(Java).

8. Maintain and Update Tests


 Update test cases as the code evolves due to feature additions or changes.
 Refactor both the code and tests as needed to maintain clarity and efficiency.

# Code to be tested
def add(a, b):
return a + b

# Unit Test
import pytest
def test_add():

assert add(2, 3) == 5 # Positive test


assert add(-1, 1) == 0 # Boundary test
assert add(0, 0) == 0 # Edge case
Advantages of Unit Testing

1. Early Bug Detection: Catches bugs in the initial stages of development.


2. Improved Code Quality: Encourages modular and well-structured code.
3. Faster Debugging: Helps identify which unit caused a failure.
4. Facilitates Changes: Acts as a safety net when refactoring or adding new features.

Challenges in Unit Testing

1. Mocking Dependencies: Isolating a unit from external systems can be complex.


2. Time-Consuming: Writing comprehensive test cases can be time-intensive.
3. False Confidence: Poorly written tests might not cover all critical scenarios

Q) WHAT IS INTEGRATION TESTING?AND EXPLAIN TYPES OF INTEGRATION


TESTING?
What is Integration Testing?
Integration Testing is a type of software testing where individual modules or components of a
system are combined and tested as a group. The primary goal is to ensure that these modules
work together as expected and that the interfaces between them are functioning correctly.

OBJECT ORIENTED SOFTWARE ENGINEERING 148


SRI CHANAKYA DEGREE COLLEGE

Purpose of Integration Testing


 To identify defects in the interaction between integrated units.
 To verify data flow and communication between components.
 To detect interface mismatches or incorrect assumptions between modules.

Types of Integration Testing


Integration testing can be categorized into various types based on the approach used to integrate
and test the modules:

1. Big Bang Integration Testing


 Description: In this approach, all modules are integrated simultaneously after unit
testing, and the entire system is tested as a whole.
 Advantages:
o Simple and straightforward.
o Suitable for smaller systems.
 Disadvantages:
o Defects are harder to isolate and debug due to late integration.
o Risk of critical issues arising at a late stage.
 Use Case: Rarely used in large or complex systems due to its high risk.

2. Incremental Integration Testing


In this method, modules are integrated and tested incrementally, allowing early defect detection.
It has the following subtypes:

a. Top-Down Integration Testing

 Description: Starts from the top-level modules (main control) and integrates
progressively with lower-level modules.
 Key Features:
o Requires stubs to simulate lower-level modules.
o Begins testing early in the development cycle.
 Advantages:
o High-level modules are tested first, ensuring the core functionality works.
o Logical control flow is tested early.
 Disadvantages:
o Lower-level modules are not fully tested initially.
o Stubs can be complex to develop.
 Use Case: Suitable for systems where high-level modules are critical.

OBJECT ORIENTED SOFTWARE ENGINEERING 149


SRI CHANAKYA DEGREE COLLEGE

b. Bottom-Up Integration Testing

 Description: Starts testing from the lower-level modules and progressively integrates
higher- level modules.
 Key Features:
o Requires drivers to simulate higher-level modules.
o Tests utility and low-level functionalities first.
 Advantages:
o Detects issues in low-level modules early.
o No need for stubs; only drivers are required.
 Disadvantages:
o High-level functionalities are tested late.
o Drivers can be complex to develop.
 Use Case: Suitable when the system relies heavily on lower-level utilities or services.
c. Sandwich Integration Testing (Hybrid Testing)

 Description: Combines both top-down and bottom-up approaches. Testing is


performed simultaneously on higher and lower modules, meeting in the middle.
 Advantages:
o Both high-level and low-level modules are tested in parallel.
o Provides a balanced approach.
 Disadvantages:
o Requires both stubs and drivers, increasing complexity.
 Use Case: Useful in large systems where both top-down and bottom-up testing are needed.
3. System Integration Testing (SIT)
 Description: Focuses on testing interactions between different subsystems or systems,
ensuring they work together correctly.
 Advantages:
o Verifies end-to-end workflows.
o Useful for enterprise applications involving multiple subsystems.
 Use Case: Large-scale systems with diverse subsystems like CRM, ERP, and databases.
4. Incremental Mixed Testing
 Description: Combines Big Bang and Incremental approaches by integrating some
modules at once and testing incrementally.
 Advantages:
o Balanced integration and defect isolation.
o Reduces risk compared to Big Bang.

OBJECT ORIENTED SOFTWARE ENGINEERING 150


SRI CHANAKYA DEGREE COLLEGE

 Disadvantages:
o Moderately complex.
 Use Case: Medium-sized systems requiring partial parallel integration.
5. Interface Testing
 Description: Verifies the communication between modules through interfaces, including
APIs, protocols, and data formats.
 Advantages:
o Focused testing on how modules interact.
o Detects interface mismatches early.
 Use Case: Applications involving multiple APIs or external systems.
Steps in Integration Testing
1. Prepare the Test Plan: Define the integration strategy and test cases.
2. Set Up the Test Environment: Ensure all necessary tools, data, and systems are in place.
3. Develop Stubs and Drivers (if needed): Simulate missing components.
4. Execute Test Cases: Perform integration testing as per the chosen approach.
5. Log and Fix Defects: Record and address any issues found.
6. Re-test and Validate: Ensure the resolved defects no longer affect functionality.
7. Document Results: Maintain a record of test results for future reference.
Benefits of Integration Testing
 Detects defects in the interaction between integrated components.
 Helps identify issues like data inconsistencies and interface mismatches.
 Facilitates early defect detection in the development lifecycle.
 Ensures a seamless user experience in multi-module systems.
Q) WHAT IS SYSTEM TESTING ?

What is System Testing?


System Testing is a type of software testing where the entire system is tested as a whole to verify that
it meets the specified requirements. It is performed after integration testing and before acceptance
testing. The primary focus is to validate the system's compliance with functional and non-functional
requirements.
Purpose of System Testing
 To ensure that the system works as intended in a complete, integrated environment.
 To validate the end-to-end functionality of the application.
 To identify defects related to the system’s interaction with external systems, hardware, and
other components.
Key Features of System Testing
1. End-to-End Testing: Tests the application from start to finish, mimicking real-world scenarios.
2. Requirement-Based Testing: Ensures the application meets functional and non-
functional requirements.
3. Environment Testing: Tests the application in a production-like environment.

OBJECT ORIENTED SOFTWARE ENGINEERING 151


SRI CHANAKYA DEGREE COLLEGE

4. Independent Testing Team: Often conducted by a team that was not involved in
development to ensure objectivity.
Types of System Testing

1. Functional Testing
 Description: Focuses on verifying that the system’s functions work as specified.
 Examples:
o Validating user login.
o Ensuring that data is saved to the database correctly.
2. Non-Functional Testing
 Description: Focuses on aspects like performance, security, usability, and reliability.
 Subtypes:
o Performance Testing: Checks the system’s response time and behavior under load.
o Security Testing: Ensures the system is protected against unauthorized access and
vulnerabilities.
o Usability Testing: Verifies that the system is user-friendly and intuitive.
o Scalability Testing: Ensures the system can scale up to handle increased load.
o Reliability Testing: Confirms the system can perform consistently over time.

3. Regression Testing
 Description: Ensures that recent changes to the system do not adversely affect existing
functionality.
4. Recovery Testing
 Description: Tests the system’s ability to recover from crashes, hardware failures, or other
unexpected events.
5. Compatibility Testing
 Description: Verifies that the system works correctly across various environments, including:
o Operating systems.
o Browsers.
o Devices (e.g., mobile, tablet).
6. Smoke Testing
 Description: A quick set of tests to verify that the major functions of the system work and
the build is stable enough for further testing.
7. End-to-End Testing
 Description: Tests the complete workflow of the application, simulating real-world
usage scenarios.
Process of System Testing
1. Requirement Analysis
o Understand the functional and non-functional requirements.
o Create a traceability matrix to map requirements to test cases.
2. Test Planning
o Define the scope, objectives, and approach for system testing.

OBJECT ORIENTED SOFTWARE ENGINEERING 152


SRI CHANAKYA DEGREE COLLEGE

o Identify tools, resources, and test environments.


3. Test Case Design
o Write test cases based on requirements.
o Cover both functional and non-functional aspects.
4. Set Up Test Environment
o Prepare the environment to mimic production conditions.
o Include hardware, software, and network configurations.
5. Test Execution
o Execute the test cases and log results.
o Document any defects and communicate them to the development team.
6. Defect Reporting and Retesting
o Fix and re-test reported defects to ensure they are resolved.
7. Test Closure
o Summarize the results in a test closure report.
o Assess if the system meets the exit criteria.
Advantages of System Testing
 Validates the software as a whole in a production-like environment.
 Ensures the application meets user and business requirements.
 Detects defects in the integrated system early.
 Provides confidence that the system works as expected.
Challenges in System Testing
 Requires a stable and production-like environment.
 Time-consuming due to the large scope.
 Requires extensive documentation and traceability.

Q)WHAT ARE THE VARIOUS PHSES IN TEST DRIVEN DEVELOPMENT(TDD)?

Phases in Test-Driven Development (TDD)


Test-Driven Development (TDD) is a software development methodology where tests are written
before the actual code. The process emphasizes creating small, incremental tests that guide the
development of functionality. TDD follows a structured cycle known as Red-Green- Refactor.
1. The TDD Cycle
The TDD process is iterative and consists of three main phases:
a. Red Phase
 Objective: Write a test that defines a new functionality or behavior the code should have.
 Details:
o The test should fail initially because the functionality does not exist yet.
o Failing tests indicate that the feature is not implemented or is incorrect.
 Key Principle: "Write a failing test first."

OBJECT ORIENTED SOFTWARE ENGINEERING 153


SRI CHANAKYA DEGREE COLLEGE

def test_addition():

assert add(2, 3) == 5 # This will fail because the `add` function is not implemented.

b. Green Phase
 Objective: Write the minimum code necessary to make the failing test pass.
 Details:
o Write just enough code to meet the test requirements without worrying about
optimization or clean design.
o Avoid writing extra code unrelated to the test.
 Key Principle: "Make the test pass."
 Example:
def add(a, b): return a + b
c. Refactor Phase
 Objective: Improve the code by refactoring it while ensuring the tests continue to pass.
 Details:
o Optimize the code for readability, maintainability, and efficiency without changing its
functionality.
o Use techniques like eliminating duplication, improving naming, or simplifying logic.
 Key Principle: "Keep it clean."
 Example (refactored addfunction for additional clarity):
def add(a: int, b: int) -> int: """Adds two
integers.""" return a + b
2. Supporting Phases in TDD

a. Test Creation
 Define the scope of functionality to be tested.
 Break down the feature into small, testable components.
 Write unit tests using a framework like JUnit(Java), pytest(Python), or NUnit(C#).
b. Continuous Testing
 Run the tests frequently to ensure they pass at every stage.
 Automation tools and test runners are often used to streamline this process.
c. Feedback and Iteration
 Analyze test results and debug as necessary.
 Iterate through the cycle (Red-Green-Refactor) until the feature is fully implemented and all
tests pass.
Benefits of TDD Phases
 Ensures high test coverage from the beginning.
 Encourages modular, maintainable, and bug-free code.
 Provides immediate feedback during development.
 Simplifies debugging by identifying issues in smaller units.

OBJECT ORIENTED SOFTWARE ENGINEERING 154


SRI CHANAKYA DEGREE COLLEGE

UNIT-IV
Q) WHAT ARE THE OBJECTIVES OF SOFTWAREMAINTENANCE AND EVOLUTION?

The objectives of software maintenance and evolution are essential for ensuring the long-term
effectiveness, reliability, and relevance of software systems. Here are the key objectives:

1. Bug Fixing and Error Correction


Objective: Identify and resolve software defects or bugs that were not detected during the
initial development.
 Goal: Improve system stability, performance, and usability by correcting errors that affect the
system's operation.
2. Adapting to New Requirements
 Objective: Modify and enhance the software to meet evolving user needs, market demands, or
organizational changes.
 Goal: Ensure the software remains aligned with business goals, industry trends, and user
expectations over time.

3. Improving System Performance


 Objective: Enhance the efficiency, speed, and resource usage of the software.
 Goal: Achieve better system performance, reduce processing time, and optimize resource
consumption.

4. Updating to New Technologies


 Objective: Keep the software compatible with new technologies, frameworks, operating
systems, or hardware.
 Goal: Ensure the system remains functional and up-to-date with current technical
advancements, preventing obsolescence.
5. Enhancing Security
 Objective: Identify and fix security vulnerabilities to protect against potential threats.
 Goal: Maintain a secure environment by addressing security risks, patching vulnerabilities,
and updating security protocols to safeguard data and user privacy.
6. Maintaining Documentation
 Objective: Keep system documentation up to date to reflect modifications and enhancements.
 Goal: Ensure that users, developers, and administrators can easily understand and manage the
system.
7. Refactoring and Re-structuring
 Objective: Improve the internal design and code structure without changing the system's
external behavior.

OBJECT ORIENTED SOFTWARE ENGINEERING 155


SRI CHANAKYA DEGREE COLLEGE

 Goal: Enhance the maintainability and scalability of the software, making it easier to
implement future changes or expansions.
8. Ensuring Compliance with Standards
 Objective: Ensure that the software complies with legal, regulatory, and industry standards.
 Goal: Maintain compliance to avoid legal issues, ensure quality, and stay aligned with
industry best practices.
9. User Interface and Experience (UI/UX) Updates
 Objective: Modify and improve the user interface to provide a more user-friendly experience.
 Goal: Ensure the software remains intuitive, modern, and easy to use, which helps improve user
satisfaction and engagement.
10. Maintaining Compatibility
 Objective: Ensure the software continues to operate across different platforms, versions, or
environments.
 Goal: Achieve cross-platform compatibility to meet the diverse needs of users and
environments.
11. Software Evolution
 Objective: Continuously evolve the software based on feedback, market demands, and
technological advancements.
 Goal: Drive the software's evolution to adapt to long-term business goals and maintain
competitive advantage.
12. Cost-Effectiveness
 Objective: Perform maintenance and evolution in a cost-effective manner.
 Goal: Ensure that the long-term maintenance costs are manageable, while providing continuous
value from the software.
These objectives work together to ensure that software remains functional, relevant, and high- performing
over time.

Q)WHAT IS REFACTORING ? WHAT ARE THE TECHNIQUES USED FOR IT?

Refactoring:
Refactoring is the process of improving the internal structure of existing code without altering its
external behavior. The goal of refactoring is to make the code more readable, maintainable, and
scalable while preserving its functionality. It helps in improving the design, making the system easier to
understand, and reducing the complexity of the codebase.

Objectives of Refactoring:
1. Improve Readability: Refactor code to make it easier to understand for current and future
developers.
2. Enhance Maintainability: Make the system easier to modify and extend over time.
3. Simplify Complexity: Reduce code duplication, long methods, and large classes.

OBJECT ORIENTED SOFTWARE ENGINEERING 156


SRI CHANAKYA DEGREE COLLEGE

4. Improve Performance (in some cases): Refactor inefficient code for better performance
without altering the system's external behavior.
5. Increase Testability: Create cleaner code that is easier to test and debug.
Techniques Used in Refactoring:
1. Extract Method:
o Description: Break down large, complex methods into smaller, more manageable
methods.
o When to use: When a method is doing more than one thing or is too long to understand
easily.
o Example:
def calculate_salary(employee): base_salary =
employee.base_salary bonus = employee.bonus
tax = employee.tax
return base_salary + bonus - tax
Can be refactored to:
def calculate_salary(employee): base_salary =
employee.base_salary bonus =
calculate_bonus(employee) tax =
calculate_tax(employee) return base_salary +
bonus - tax
def calculate_bonus(employee): return
employee.bonus
def calculate_tax(employee): return
employee.tax
2. Rename Variable/Method/Class:
o Description: Rename variables, methods, or classes to reflect their purpose more
clearly.
o When to use: When names are unclear, ambiguous, or misleading.
o Example:
Rename tempto temporaryFile.
3. Replace Magic Numbers with Named Constants:
o Description: Replace hard-coded numbers or strings (magic numbers) with named
constants for clarity and maintainability.
o When to use: When a number appears in code that isn't self-explanatory.
o Example:

if age > 21:


print("Eligible")
Can be refactored to:

OBJECT ORIENTED SOFTWARE ENGINEERING 157


SRI CHANAKYA DEGREE COLLEGE

MINIMUM_AGE = 21
if age > MINIMUM_AGE:
print("Eligible")

4. Consolidate Duplicate Conditional Fragments:


o Description: If the same code appears in multiple places within conditional statements,
consolidate it into a single method or location.
o When to use: When the same code block appears in multiple places under different
conditions.
o Example:
if user.is_admin(): send_notification()
if user.is_moderator(): send_notification()
Can be refactored to:
python Copy code
if user.is_admin() or user.is_moderator(): send_notification()

5. Inline Method:
o Description: Replace a method call with the method's body when the method is not
adding much value.
o When to use: When the method is too simple or redundant.
o Example:

def calculate_tax(amount): return amount


* 0.05

def total_price(amount):
return calculate_tax(amount) + amount

Can be refactored to:

def total_price(amount):
return amount * 0.05 + amount

6. Move Method/Field:
o Description: Move a method or field to a more appropriate class if it's being used more
frequently in that class than the current one.
o When to use: When methods or fields are located in the wrong class.
o Example:
If a method is more relevant to a different class, move it to that class to improve
cohesion.

OBJECT ORIENTED SOFTWARE ENGINEERING 158


SRI CHANAKYA DEGREE COLLEGE

7. Introduce Assertion:
o Description: Add assertions in the code to make assumptions about the program's state
explicit.
o When to use: When you want to make certain conditions in the code more explicit and
check for errors early.
o Example:

assert user is not None, "User object should not be None"

8. Encapsulate Field:
o Description: Make a class field private and provide getter and setter methods to control
access to it.
o When to use: When direct access to a class field could lead to misuse or when you want
to protect its value.
o Example:
class Employee:
def init (self, salary): self.salary = salary

def set_salary(self, salary): self.salary = salary


def get_salary(self): return
self.salary

9. Decompose Conditional:
o Description: Replace complex conditional logic with a simpler one or move logic into
a separate method for clarity.
o When to use: When conditionals become too complicated or difficult to follow.
o Example:

if (age > 18 and age < 65):


print("Eligible")

Can be refactored to:

if is_eligible_age(age): print("Eligible")

def is_eligible_age(age): return 18 < age


< 65

OBJECT ORIENTED SOFTWARE ENGINEERING 159


SRI CHANAKYA DEGREE COLLEGE

10. Replace Inheritance with Delegation:


o Description: When inheritance creates complexity or tight coupling, replace it with
delegation by having one object use another object's functionality.
o When to use: When a class is inheriting behavior that could be more simply delegated
to another object.
o Example:
Instead of inheriting functionality from a parent class, delegate specific tasks to an
object that fulfills that functionality.
Tools for Refactoring:
 IDE Support: Many integrated development environments (IDEs) like IntelliJ IDEA, Eclipse,
and Visual Studio have built-in refactoring tools for automated refactorings such as renaming
variables, extracting methods, etc.
 Code Analyzers: Tools like SonarQube, CodeClimate, and ESLint can identify areas of the
code that need refactoring, such as code smells or complexity hotspots.
 Automated Refactoring Tools: Tools like JRefactory or Refactoring.Guru provide
additional support for identifying refactoring opportunities.

Benefits of Refactoring:
 Increased code readability and maintainability.
 Simplified code structure and reduced duplication.
 Better performance (sometimes).
 Enhanced scalability and flexibility.
 Easier integration and testing.
Refactoring is an ongoing process, usually done in small steps to ensure that the code remains functional
while improving its internal structure over time.
Q) WHAT IS SOFTWARE VERSION?WHAT IS SOFTWARE VERSION CONTROL?

What is Software Version?


A software version refers to the specific state or release of a software application or system at a given
point in time. It is used to track changes, improvements, or bug fixes that are made to the software
throughout its lifecycle. Each version of a software system is typically given a unique identifier, usually
consisting of numbers or codes, that signify the sequence and nature of the changes.

Components of a Software Version:

 Major version: Indicates significant changes or overhauls in the software, often


introducing new features or breaking backward compatibility.
o Example: Version 2.0 → major update, new features, and/or breaking changes.
 Minor version: Refers to incremental improvements or new features that are compatible with
previous versions.
o Example: Version 1.1 → minor update, new functionality without breaking compatibility.

OBJECT ORIENTED SOFTWARE ENGINEERING 160


SRI CHANAKYA DEGREE COLLEGE

 Patch version: Involves bug fixes or small improvements that don’t affect the overall
functionality or compatibility.
o Example: Version 1.0.1 → a patch to fix bugs in version 1.0.
 Build version: Represents internal releases or builds of the software, often used during the
development cycle.
o Example: Version 1.0.0.123 → build 123 of version 1.0.

 Pre-release versions: Versions that are under development or are being tested before the
official release. These might include:
o Alpha: Early, unfinished versions for internal testing.
o Beta: A more complete version for external testing with potential bugs.
o Release candidate (RC): A final pre-release version that is almost ready for the
stable release.
Software Version Control (SVC):
Software Version Control, also known as Source Code Management (SCM), is the process of
tracking and managing changes to software code over time. It allows developers to store multiple
versions of code, track modifications, collaborate with team members, and ensure that the software is
developed efficiently without losing any historical changes.

Key Features of Version Control:


1. Tracking Changes: Version control systems keep track of every change made to the code,
who made the change, and when it was made. This allows for a historical record of the
software's development.

2. Collaboration: Multiple developers can work on the same project simultaneously


without overwriting each other's work. The system merges changes from different
contributors and resolves conflicts.
3. Branching and Merging: Developers can create separate "branches" for developing new
features or fixing bugs without affecting the main codebase (often referred to as the "master" or
"main" branch). Once the work on the branch is complete, it can be "merged" back into the
main codebase.
4. Backup and Recovery: If something goes wrong, version control allows you to revert to a
previous stable version of the code, ensuring that no work is lost.
5. Code Auditing: Version control provides visibility into the history of the code, allowing
developers and team leads to review changes and see why certain decisions were made.
6. Release Management: It helps in maintaining different versions of software for production,
testing, and development environments, and can assist in deploying different versions of
software to end users
Types of Version Control Systems (VCS):

OBJECT ORIENTED SOFTWARE ENGINEERING 161


SRI CHANAKYA DEGREE COLLEGE

1. Local Version Control:


o A local version control system tracks changes in a single directory or project on the
developer’s machine. It's very basic and doesn't allow for collaboration.
o Example: Simple file management systems that store changes locally, such as
RCS (Revision Control System).
2. Centralized Version Control:
o In this model, there is a central repository where the codebase is stored, and developers
commit their changes to the central server. Each developer checks out the latest version
of the code, makes changes, and commits back to the central server.
o Example: CVS (Concurrent Versions System), Subversion (SVN).
3. Distributed Version Control:
o This is a more advanced and flexible system where every developer has a local copy of

o the entire repository, including its history. Changes are made locally and can be pushed
to a central server or shared with other developers. Developers can work offline and
merge their changes later.
o Example: Git, Mercurial, Bazaar.
Popular Version Control Systems:
 Git: A distributed version control system, widely used in open-source projects and by
developers worldwide. It is known for its speed, flexibility, and powerful branching and
merging capabilities. GitHub, GitLab, and Bitbucket are platforms that host Git repositories.
 Subversion (SVN): A centralized version control system, commonly used in enterprise
environments. It allows for fine-grained control over the repository but does not offer the
offline capabilities of distributed systems like Git.
 Mercurial: Another distributed version control system similar to Git, known for its
simplicity and ease of use.
 Perforce (Helix Core): A centralized version control system typically used in large
enterprises and for handling large-scale projects with large binary files.

Benefits of Software Version Control:

1. Collaboration: Allows multiple developers to work on the same project without conflicts.
2. History Tracking: Provides a detailed history of changes, which can help in debugging
or understanding the rationale behind certain decisions.
3. Branching and Merging: Facilitates feature development in isolated branches and the ability
to merge changes when they are complete.
4. Disaster Recovery: Helps recover the code from accidental deletions or mistakes by reverting
to previous versions.
5. Efficiency: Improves workflow efficiency and reduces the risk of errors or conflicts
when managing complex codebases.

OBJECT ORIENTED SOFTWARE ENGINEERING 162


SRI CHANAKYA DEGREE COLLEGE

6. Audit and Compliance: Supports code auditing by keeping a log of who made which
changes and when.

Q) WHAT IS CODE INSPECTION?

Code inspection is a formal, systematic, and structured process in which a group of developers or
experts review the source code of a software project to identify potential issues, improve code quality,
and ensure that it adheres to coding standards and best practices. It is one of the key practices in static
code analysis and focuses on finding defects early in the development process, which helps prevent
costly fixes later in the software lifecycle.
The primary goal of code inspection is to improve the quality of the software by identifying and
addressing issues related to correctness, performance, security, readability, maintainability, and
adherence to coding standards.
Key Objectives of Code Inspection:
1. Identify Defects: Spot logical errors, bugs, and inconsistencies in the code that might not be
caught by automated tests.
2. Improve Code Quality: Enhance the quality of the code by ensuring it is well-
structured, readable, and follows best practices.

3. Ensure Compliance with Standards: Verify that the code adheres to coding standards
and guidelines for the organization or project.
4. Improve Maintainability: Ensure the code is modular, well-documented, and easy to
maintain over time.
5. Facilitate Knowledge Sharing: Promote knowledge sharing within the team by having
multiple people review and discuss the code, which helps developers learn from each other.
Steps Involved in Code Inspection:
1. Preparation:
o The author of the code (developer) prepares the code for inspection by cleaning it up
and ensuring it is complete.
o The code is typically reviewed in a small chunk, such as a module, function, or class,
to keep the inspection focused and manageable.
o The inspection team is formed, which may include the developer, lead developers,
subject matter experts, testers, and sometimes even non-technical stakeholders.
2. Inspection Meeting:
o The actual inspection is conducted during a meeting where each member of the team
reviews the code in detail.
o The reviewer checks the code for various concerns such as design flaws, coding
standards violations, potential bugs, performance issues, and security vulnerabilities.
o The discussion is typically led by an inspection facilitator or moderator, who ensures
that the process stays on track and that all issues are discussed and noted.

OBJECT ORIENTED SOFTWARE ENGINEERING 163


SRI CHANAKYA DEGREE COLLEGE

3. Issue Identification:
o Reviewers identify and document any defects, issues, or areas for improvement.
o Issues can be categorized into:
 Minor issues: Coding style violations, naming conventions.
 Major issues: Logic flaws, architectural problems, security vulnerabilities.
 Critical issues: Bugs that will cause the application to fail or behave
unexpectedly.
o The team also looks for missing or unclear documentation, lack of tests, and code
duplication.
4. Discussion and Feedback:
o The inspection team discusses the identified issues, their severity, and possible
solutions.
o Feedback is provided to the author of the code, who is responsible for addressing the
issues raised.
o The review team may offer suggestions for improving the code, but it’s up to the author
to implement the changes.
5. Follow-Up:
o After the code inspection meeting, the author works on fixing the identified issues and
updating the code accordingly.
o The code may go through multiple iterations of inspection if necessary, especially if
major flaws were found.
6. Closure:
o Once the code has been fixed and the issues addressed, the code inspection process is
closed.
o A final review is done to ensure all issues have been resolved, and the code is ready for
further testing or integration.
Types of Code Inspection:
1. Formal Inspection:
o A very structured, formal process that involves detailed documentation of defects,
comments, and suggestions.
o It typically involves a group of individuals, including the author, reviewers, and
sometimes an external moderator.
o Formal inspections are more rigorous and often used in critical software projects where
high quality is essential.
2. Informal Inspection:
o A more relaxed, less structured review where the code is reviewed by a team in an ad-
hoc manner.
o It may not follow the strict formal processes and is usually quicker but still provides
valuable feedback.
o Informal inspections may involve peer reviews or pair programming.

OBJECT ORIENTED SOFTWARE ENGINEERING 164


SRI CHANAKYA DEGREE COLLEGE

3. Walkthrough:
o In a walkthrough, the developer presents their code to the team and walks them
through its logic, explaining decisions made during development.
o The team provides feedback, but it is generally less critical and more focused on
understanding the code rather than identifying defects.
Benefits of Code Inspection:
1. Early Detection of Defects: Catching bugs and issues in the design or logic of the code
early reduces the cost and time required for later-stage fixes.
2. Improved Code Quality: Regular code inspections help to ensure that the code adheres to
high standards, is well-documented, and is easy to understand and maintain.
3. Knowledge Sharing: Developers can learn from each other’s code and techniques, promoting best
practices across the team.
4. Better Collaboration: Code inspection fosters collaboration and communication between team
members, leading to a more cohesive development process.
5. Reduced Development Time: By identifying and fixing defects early, the overall
development cycle is more efficient, and fewer issues arise during later stages like
integration or testing.
Challenges of Code Inspection:
1. Time-Consuming: Code inspections, especially formal ones, can be time-consuming and
may slow down the development process if not managed well.
2. Resistance from Developers: Some developers may feel defensive or resistant to criticism
of their code, which can affect the effectiveness of the inspection process.
3. Inconsistent Results: If inspections are not done thoroughly, or if the reviewers are not
sufficiently skilled, they may miss important issues.

4. Overhead: Formal inspections require dedicated resources, including trained moderators,


inspectors, and time for feedback, which can be seen as overhead.
Best Practices for Code Inspection:

1. Set Clear Goals: Define the scope and objectives of the inspection (e.g., focus on
bugs, performance, security, or readability).
2. Keep Inspections Small: Avoid reviewing too much code at once. Smaller, more
manageable code chunks are easier to inspect.
3. Use Checklists: Provide reviewers with checklists or guidelines to help them focus on
common problem areas like design flaws, code smells, and performance issues.
4. Involve Multiple Perspectives: Engage multiple team members with different expertise
to identify a wider range of issues.
5. Encourage Constructive Feedback: Focus on providing helpful, constructive feedback
rather than criticism, to promote learning and improvement.

OBJECT ORIENTED SOFTWARE ENGINEERING 165


SRI CHANAKYA DEGREE COLLEGE

Q) What is Software Evolution?

Software evolution refers to the process of continuously developing, updating, and modifying
software systems over time to adapt to new requirements, fix defects, improve functionality, and

keep up with technological advancements. It is the ongoing process of refining, enhancing, and
maintaining software after its initial release. Software evolution involves activities such as adding new
features, correcting bugs, optimizing performance, and ensuring compatibility with other systems or
platforms.

Software evolution is critical because software systems rarely remain static. The needs of users,
technology, and business environments are constantly changing, and software must evolve to meet
these demands.
Key Aspects of Software Evolution:
1. Bug Fixes and Maintenance: Over time, software systems may encounter defects, security
vulnerabilities, or performance bottlenecks. Fixing these issues and ensuring the system
remains stable is a major part of software evolution.
2. Feature Enhancement: Software often evolves to include new features or improve
existing ones. This may result from user feedback, competitive pressures, or technological
advancements.
3. Performance Improvement: Software may require optimizations to handle larger data sets,
increase processing speeds, or reduce resource consumption as usage grows or technology
changes.
4. Adaptation to New Environments: As new platforms, devices, or operating systems emerge,
software may need to be adapted or refactored to ensure compatibility with these changes.
5. Refactoring and Code Improvement: Over time, the software's codebase may become hard to
maintain or inefficient. Refactoring involves cleaning up and reorganizing the code without
changing its external behavior to improve its maintainability and flexibility.
6. Security Updates: Software may evolve to address security vulnerabilities as they are
discovered. Regular security patches are part of keeping software secure and reliable.
7. User Interface (UI) and User Experience (UX) Updates: As user expectations evolve and
new design trends emerge, software may need updates to its UI/UX to remain relevant and
user-friendly.
8. Adaptation to Regulatory Changes: Software might need to evolve to comply with new
regulations, standards, or laws in various industries (e.g., GDPR for data privacy).
Challenges of Software Evolution:
1. Legacy Code: As software evolves over time, older portions of the code may become outdated
or hard to maintain, especially if the original developers are no longer available or the code was
written without best practices.

OBJECT ORIENTED SOFTWARE ENGINEERING 166


SRI CHANAKYA DEGREE COLLEGE

2. Changing Requirements: Requirements often evolve as users' needs change or as


business priorities shift. This can lead to scope creep and challenges in keeping the
software aligned with user expectations.
3. Complexity: Over time, the software system may become more complex due to added
features, integrations with other systems, or increasing data volume. This can make further
evolution harder and more error-prone.
4. Resource Constraints: The need for continuous evolution may be constrained by limited
resources, such as time, budget, or personnel. This could affect the ability to fix bugs, add
features, or address performance issues in a timely manner.
5. Quality Assurance: As software evolves, maintaining consistent quality through testing and
validation becomes more challenging, especially as the system grows in size and complexity.
6. Technology Changes: Rapid advancements in technology may render some parts of the
software obsolete or incompatible with newer systems, requiring major changes to the
codebase.
Types of Software Evolution:
1. Corrective Evolution: Involves fixing errors or bugs discovered after the software's
release. This is often a reactive process and addresses defects that were not identified during
the initial development or testing.
2. Adaptive Evolution: Involves modifying the software to adapt to changes in the environment,
such as new operating systems, hardware, or other software dependencies. Adaptive evolution
ensures that the software remains functional and compatible with changing technological
conditions.
3. Perfective Evolution: Refers to enhancing the software by adding new features or improving
existing ones. Perfective evolution often results from feedback from users or stakeholders.
4. Preventive Evolution: Involves making changes to anticipate future problems or improve
the software's maintainability, even if no immediate issues exist. This could involve
refactoring code, improving documentation, or improving the software's architect
Benefits of Software Evolution:
1. Improved Software Quality: Over time, software evolves to become more stable, secure,
and user-friendly as issues are identified and corrected, and features are refined.
2. Adapting to New Technologies: By evolving software, organizations can ensure that their
systems remain compatible with new technologies, platforms, and standards.
3. Satisfying Changing User Needs: Regular updates and feature additions keep the
software aligned with user demands and business goals.
4. Enhanced Efficiency: Over time, software can become more efficient, faster, and more
scalable as performance issues are addressed and new optimization techniques are applied.
5. Long-Term Sustainability: Well-executed software evolution practices ensure that the
software remains useful and relevant over a long period, even as technology and business
requirements change.

OBJECT ORIENTED SOFTWARE ENGINEERING 167


SRI CHANAKYA DEGREE COLLEGE

Q) WHAT ARE SOFTWARE REENGINEERING ACTIVITIES AND


ADVANTAGES AND DISADVANTAGES OF REENGINEERING

What are Software Reengineering Activities?


Software reengineering is the process of improving or restructuring existing software to enhance its
performance, maintainability, or functionality without altering its core functionality. It involves
analyzing, modifying, and updating a legacy software system to meet new requirements or adapt to a
new environment. The goal of reengineering is to reduce the cost and effort of maintaining outdated
software while enhancing its ability to support new business needs.
The main focus of software reengineering is on improving the quality and efficiency of the
software without needing to completely rebuild the system from scratch.
Key Activities of Software Reengineering:
1. Reverse Engineering:
o Purpose: To understand the existing system's structure, behavior, and functionality. This
involves deconstructing the software code and documentation (if available) to gain
insights into its current state.
o Methods: Code analysis, system documentation reviews, and data flow analysis.
o Outcome: A clear understanding of the software’s internal workings and design, which is
crucial for making improvements or restructuring.
2. Restructuring:
o Purpose: To reorganize and clean up the existing code, remove redundancy, improve
readability, and ensure it is aligned with modern coding standards.
o Methods: Refactoring code, optimizing algorithms, and improving modularity.
o Outcome: Improved maintainability and reduced complexity, which makes the software
easier to modify and extend in the future.
3. Forward Engineering:
o Purpose: To modify or enhance the software by adding new functionality or integrating
it with modern systems and platforms.
o Methods: Implementing new features, adapting the software to newer operating
systems, or improving its user interface (UI).
o Outcome: A system that can meet contemporary business needs and technological
standards.
4. Data Reengineering:
o Purpose: To migrate data from outdated or incompatible formats to modern databases
or systems.
o Methods: Data conversion, normalization, and database restructuring.
o Outcome: Data that is more accessible, easier to analyze, and compatible with modern
software tools.
5. System Migration:
o Purpose: To move software applications from one platform, architecture, or technology
to another.

OBJECT ORIENTED SOFTWARE ENGINEERING 168


SRI CHANAKYA DEGREE COLLEGE

o Methods: Porting software to a new hardware platform, transitioning from mainframe


to client-server systems, or moving from proprietary databases to open-source systems.
o Outcome: Improved performance, better scalability, and reduced dependency on
outdated technology.
6. Reengineering Documentation:
o Purpose: To create or update the documentation that describes the software system, its
components, and its operations.
o Methods: Documenting system architecture, data flow, user manuals, and maintenance
guides.
o Outcome: Comprehensive and up-to-date documentation that can be used for future
development or by new team members.
Advantages of Software Reengineering:
1. Cost Savings:
o Reengineering an existing system is often more cost-effective than developing a new
one from scratch. By leveraging the existing system's architecture, data, and logic,
organizations can save on development and infrastructure costs.
2. Improved Maintainability:
o Legacy software systems are often difficult to maintain due to outdated technologies or
poorly organized code. Reengineering improves the structure and readability of the
code, making it easier to maintain and extend over time.
3. Extending the Life of Legacy Systems:
o Reengineering can breathe new life into legacy software, allowing it to continue serving
the business needs without the need for a complete replacement.
4. Adaptation to Modern Technologies:
o Reengineering helps legacy systems integrate with modern technologies, platforms, and
tools, ensuring they remain compatible with current standards and can support new
business requirements.
5. Risk Mitigation:
o Reengineering is often seen as a lower-risk option than complete system replacement
because the existing system is already in use and has a known performance track
record. It minimizes the chance of introducing major failures or disruptions.
6. Better Performance and Scalability:
o Through optimization and restructuring, reengineering can improve the software’s
performance, scalability, and efficiency, making it better suited to handle increased
loads and more complex operations.
7. Improved Security:
o Older systems may lack adequate security features or be vulnerable to modern security
threats. Reengineering allows the software to be updated with better security protocols,
compliance standards, and protections.

OBJECT ORIENTED SOFTWARE ENGINEERING 169


SRI CHANAKYA DEGREE COLLEGE

8. Better User Experience:


o Reengineering can involve upgrading the user interface (UI) or enhancing user
experience (UX), making the system easier to use and more visually appealing to end-
users.

Disadvantages of Software Reengineering:


1. Time-Consuming:
o Reengineering an existing system can take significant time, especially if the system is
large, complex, or poorly documented. The reverse engineering process alone can be a
lengthy effort to understand the software’s functionality and behavior.
2. High Initial Cost:
o While reengineering can be cheaper than building a new system, the initial costs can still
be high due to the need for skilled personnel, specialized tools, and extensive analysis.
Additionally, there might be costs involved in upgrading hardware or platforms.
3. Risk of Introducing New Problems:
o While reengineering aims to improve the software, there is a risk of introducing new
defects, bugs, or issues due to the complexity of modifying existing systems. A lack
of understanding of the original code or inadequate testing could result in system
instability.
4. Requires Expertise:
o Reengineering requires a deep understanding of the legacy system, as well as expertise
in modern technologies and software engineering practices. Finding qualified personnel
with both sets of skills can be challenging.
5. Possible Loss of Business Logic:
o During the reengineering process, there is a risk of losing critical business logic or
features that were embedded in the old system, especially if the legacy software was
poorly documented or not fully understood.
6. Disruption to Operations:
o Reengineering can disrupt ongoing operations, particularly if the system needs to be
taken offline for significant periods during the process. Businesses may experience
delays, decreased productivity, or downtime while reengineering is being carried out.
7. Resistance to Change:
o There may be resistance from users or internal stakeholders who are accustomed to the
old system. Changing familiar workflows or interfaces can be met with reluctance,
potentially leading to poor adoption of the reengineered system.
8. Limited Return on Investment (ROI):
o In some cases, the benefits of reengineering may not justify the time and resources
invested, especially if the system is nearing the end of its useful life or if the software is
highly outdated and cannot be easily brought up to current standards.

OBJECT ORIENTED SOFTWARE ENGINEERING 170


SRI CHANAKYA DEGREE COLLEGE

UNIT -V
Q) What is Model-Driven Engineering (MDE) in Software Development?
Model-Driven Engineering (MDE) is a software development approach that focuses on creating and
utilizing models at various stages of the software development lifecycle. In MDE, models are used as
primary artifacts for design, development, and implementation, with code generation and other
activities being automated from these models. The goal is to increase abstraction, reduce manual
coding, improve productivity, and ensure consistency throughout the development process.

MDE uses modeling languages (such as UML, SysML, or domain-specific languages) to represent
system components, behaviors, and architecture. The key idea is that models become first-class
artifacts in the development process, rather than just intermediate steps or documentation.

Key Components of Model-Driven Engineering:


1. Models:
o Represent the essential aspects of the software system, such as its structure, behavior,
interactions, and state.
o These models can be at various abstraction levels (e.g., platform-independent models or
platform-specific models).
2. Model Transformations:
o Involve converting models from one form to another (e.g., from a high-level abstract
model to a platform-specific model or from a model to executable code).
o Common transformation techniques include code generation, model refinement, and
model optimization.
3. Model-Driven Development (MDD):
o A specific form of MDE focused on automating the creation of software artifacts
(like code or configuration files) from the models.
o Tools like Eclipse Modeling Framework (EMF) or AndroMDA can be used to
generate code directly from high-level models.
4. Meta-Modeling:
o Meta-modeling refers to creating models that describe other models. A meta-model
defines the abstract syntax and semantics for a specific modeling language.
o For example, UML can be viewed as a modeling language with its own meta-model that
specifies how UML diagrams are constructed and what they represent.
5. Platform Independence:
o MDE emphasizes the creation of platform-independent models (PIMs) that can later be
transformed into platform-specific models (PSMs) and eventually executable code.
o This separation enables easier adaptation of the system to different platforms without
modifying the core design.

OBJECT ORIENTED SOFTWARE ENGINEERING 171


SRI CHANAKYA DEGREE COLLEGE

Role of MDE in Software Development:


1. Abstraction and Automation:
o MDE allows developers to work at a higher level of abstraction, focusing on the
structure and behavior of the software rather than dealing with low-level code. This
improves the focus on business logic, user needs, and system architecture.
o By automating repetitive tasks, such as code generation from models, MDE reduces
manual coding, speeding up development and reducing errors.
2. Improved Productivity:
o Since MDE allows for automated transformations from high-level models to low-level
implementations (e.g., code), the overall productivity increases as developers spend less
time writing boilerplate code.
o Changes to the software can be made quickly at the model level, which can
automatically propagate through to the generated code.
3. Consistency and Traceability:
o MDE ensures consistency across different levels of abstraction, as all system
components are derived from the same model.
o Traceability is improved because developers can trace from high-level design models
down to the implementation, making it easier to understand why certain decisions were
made.
4. Separation of Concerns:
o With MDE, developers can separate concerns related to different aspects of software
design. For instance, a model might describe the business logic independently from how
it is executed on a specific platform or hardware. This separation allows for easier
maintenance and evolution of the system.
o Different teams can focus on different levels of the model, such as architecture, design,
or platform-specific details, and can work concurrently on separate parts of the project.
5. Reusability:
o Once a model is created, it can be reused across different projects or parts of a project.
For example, the same model can be adapted for different platforms, configurations, or
customer needs with minimal changes.
o Model-based components or services can be shared, making software development
more modular and reducing duplication.
6. Facilitates Collaboration:
o Models serve as a common language for developers, designers, and other stakeholders,
making it easier to communicate requirements and design decisions across teams.
o Since models can be visual (e.g., UML diagrams) or executable, they provide a rich
representation that stakeholders can easily understand, enabling better collaboration.
7. Early Validation and Verification:
o Since models capture the system at an early stage, MDE enables early validation of
design decisions before they are implemented in code. This reduces the likelihood of
significant errors later in the development lifecycle.

OBJECT ORIENTED SOFTWARE ENGINEERING 172


SRI CHANAKYA DEGREE COLLEGE

o Formal techniques and automated validation tools can be used on models to detect
inconsistencies, errors, or gaps in functionality early in the process.

8. Better Maintenance and Evolution:


o In MDE, the system's architecture and behavior are captured in high-level models,
making it easier to understand and modify the software as it evolves over time.
o With a model-driven approach, modifications to the software can be made at the model
level and propagated automatically, making it easier to adapt the system to changing
requirements or new platforms.
9. Support for Complex Systems:
o MDE is particularly useful for developing large-scale, complex systems (such as
embedded systems, enterprise applications, or distributed systems) because it allows
for a clear, organized representation of the system at different levels of abstraction.
o It helps in managing system complexity by breaking it down into more manageable
models, each focusing on a different aspect of the system.
10. Integration with DevOps and Continuous Delivery:
o MDE can be integrated into modern DevOps pipelines, where model transformations
and code generation can be part of the continuous integration (CI) and continuous
deployment (CD) process.
o This ensures that new features, changes, and fixes are quickly reflected in the system
and deployed to production.
Advantages of Model-Driven Engineering:
1. Increased Abstraction:
o Developers can focus on high-level concepts, system architecture, and design, rather
than low-level coding.
2. Faster Development:
o Automated code generation reduces the amount of manual coding required, speeding
up development.
3. Improved Quality and Consistency:
o As models are the central artifacts, they ensure that the design and implementation are
aligned and consistent, improving software quality.
4. Easier Maintenance and Evolution:
o High-level models enable easier understanding and modification of systems, simplifying
ongoing maintenance and future enhancements.
5. Reusable Components:
o Models can be reused across multiple projects, reducing development time and cost.

6. Better Communication:
o Models act as a common language between stakeholders, including developers,
business analysts, and end-users.

OBJECT ORIENTED SOFTWARE ENGINEERING 173


SRI CHANAKYA DEGREE COLLEGE

7. Early Validation:
o Since models can be validated and verified early in the development process, many
design errors can be identified and corrected early, reducing risks in later stages.

Disadvantages of Model-Driven Engineering:


1. Complexity of Tools and Frameworks:
o MDE requires sophisticated tools for model creation, transformation, and code
generation. These tools can be complex to set up and use effectively, requiring
specialized knowledge and training.
2. Learning Curve:
o Developers and stakeholders may face a steep learning curve when transitioning from
traditional coding practices to a model-driven approach.
3. Overhead in Model Management:
o Managing and maintaining models (especially in large systems) can be cumbersome, as
models themselves can become complex and difficult to keep updated.
4. Potential for Model Incompleteness:
o Models may not always capture every detail of the system's behavior, leading to
potential gaps or misunderstandings that could cause issues during implementation.
5. High Initial Investment:
o The initial setup of MDE tools, training, and model development may require
significant investment in terms of time, money, and effort.
6. Difficulty in Adapting to Rapid Changes:
o MDE is highly structured, and while it is excellent for systems with stable, long-term
requirements, it may struggle to keep up with fast-paced development environments
that require frequent changes.

Q) HOW DOES ASPECT-ORIENTED PROGRAMMING IN SOFTWARE


DEVELOPMENT?
What is Aspect-Oriented Programming (AOP)?
Aspect-Oriented Programming (AOP) is a programming paradigm that aims to increase modularity
by separating cross-cutting concerns from the main business logic. In AOP, a cross- cutting concern is
a functionality that affects multiple parts of a program but is not central to the business logic itself.
Examples of cross-cutting concerns include logging, security, error handling, transaction management,
and performance monitoring.

AOP works by allowing these cross-cutting concerns to be defined separately (as "aspects") and then
injected into the core business logic at specified points in the program’s execution. This results in
cleaner, more modular code where the cross-cutting concerns are managed independently of the main
application logic.

OBJECT ORIENTED SOFTWARE ENGINEERING 174


SRI CHANAKYA DEGREE COLLEGE

Key Concepts in Aspect-Oriented Programming:


1. Aspect:
o An aspect is a module that encapsulates a cross-cutting concern (e.g., logging, security
checks). It contains the logic that is applied to multiple parts of the program without
modifying the business logic.
2. Join Point:
o A join point is a point in the execution of the program where an aspect can be applied.
These points could be method calls, method executions, object instantiations, or field
accesses.
3. Pointcut:
o A pointcut is an expression that specifies where an aspect should be applied. It defines
the set of join points where the aspect should be woven into the code (i.e., which
methods or classes the aspect should affect).
4. Advice:
o Advice is the action taken at a particular join point. It defines what the aspect does
when it is triggered. There are different types of advice:
 Before advice: Executes before the target method is called.
 After advice: Executes after the target method finishes, whether it finishes
normally or throws an exception.
 Around advice: Wraps the target method, allowing it to modify or even replace
the method call.
5. Weaving:
o Weaving is the process of integrating the aspect code into the main business logic. This
can happen at compile time, load time, or runtime, depending on the AOP framework
used.
6. Target Object:
o The target object is the object that the aspect applies to. It is the class or method that
the cross-cutting concern interacts with.

How AOP Works in Software Development:


In traditional object-oriented programming (OOP), cross-cutting concerns like logging, security, or
transaction management are often scattered across multiple parts of the program. This leads to code
duplication and makes the system harder to maintain. AOP solves this problem by separating these
concerns from the core logic and applying them centrally.
Here's how AOP works in a typical software development workflow:
1. Define Aspects:
o You define aspects that represent the cross-cutting concerns. For example, an aspect for
logging may capture method calls and log relevant details.

OBJECT ORIENTED SOFTWARE ENGINEERING 175


SRI CHANAKYA DEGREE COLLEGE

2. Identify Join Points and Pointcuts:


o You define pointcuts that specify where the aspects should be applied. For instance, you
may want logging to occur every time a method in a particular class is executed.

3. Apply Advice:
o You implement advice that specifies what action to take at the join points. For instance,
the logging aspect might record the method's entry and exit times, log arguments, or
handle exceptions.
4. Weaving:
o During the weaving process, the AOP framework automatically inserts the aspect code
at the appropriate join points. The core business logic remains unchanged, and the
cross-cutting concerns are applied wherever they are needed.
Types of AOP Weaving:
 Compile-time weaving: The aspect code is woven into the classes during the
compilation process. This is typically done using an AOP compiler or by using an
AspectJ compiler.

 Load-time weaving: The aspects are woven into the code when the classes are loaded into
the Java Virtual Machine (JVM). This is done using a special classloader that can modify the
bytecode as it loads classes.

 Runtime weaving: Aspects are applied dynamically at runtime using a proxy mechanism.
Frameworks like Spring AOP use this method, where the aspects are applied to objects through
proxies.
Advantages of AOP in Software Development:
1. Separation of Concerns:
o AOP allows you to keep cross-cutting concerns (e.g., logging, security) separate from
the core business logic, leading to cleaner and more maintainable code.
2. Code Reusability:
o Since aspects are modular and reusable, you can apply the same logic (e.g., logging or
error handling) across multiple parts of your application without duplicating code
3. Increased Maintainability:
o Changes to a cross-cutting concern (like modifying the logging format) can be made in
one place (the aspect) without needing to modify the business logic in multiple classes.
4. Cleaner Business Logic:
o With AOP, the core business logic becomes cleaner and more focused, as it is not
cluttered with concerns like logging, security checks, or transaction management.
5. Easier Testing:
o Since aspects are separated from business logic, they can be tested independently, and
you can easily mock aspects during unit tests of the core application logic.

OBJECT ORIENTED SOFTWARE ENGINEERING 176


SRI CHANAKYA DEGREE COLLEGE

Disadvantages of AOP:
1. Complexity:
o AOP introduces additional layers of abstraction, which can make the system more
difficult to understand and debug, especially for developers unfamiliar with AOP.
2. Performance Overhead:
o Aspect weaving introduces a small performance overhead, especially when using
runtime weaving or proxy-based AOP frameworks like Spring AOP, because it
creates additional method calls and layers.
3. Hidden Logic:
o Since aspects can modify the flow of execution at runtime, it can be harder to trace and
understand the program's behavior, making debugging and troubleshooting more
challenging.
4. Steep Learning Curve:
o AOP can have a steep learning curve, particularly for developers accustomed to more
traditional OOP approaches. Understanding how to properly define pointcuts and advice
takes time.
5. Tooling and Framework Limitations:
o Some tools or frameworks may not fully support AOP, which could limit its usage
in certain environments or applications.
Q) WHAT ARE THE KEY BENITS OF COMPONENT BASED SOFTWARE
ENGINEERING?

Component-Based Software Engineering (CBSE) is an approach to software development where


software systems are built by assembling pre-existing, reusable components rather than developing
everything from scratch. These components can be either commercially available or developed in-
house and are designed to be independent, modular, and easily integrated into various applications.
Key Benefits of Component-Based Software Engineering (CBSE):
1. Reusability:
o High Reusability of Components: CBSE promotes the reuse of software components
across different projects. Components are designed to be modular, self-contained, and
independent, making them easy to reuse in multiple applications, reducing
development time and costs.
o This reusability helps to avoid reinventing the wheel for common functionalities (e.g.,
authentication, database connections, file handling).
2. Faster Development:
o Reduced Development Time: Since many components are pre-built, the time spent
developing software from scratch is significantly reduced. Developers can focus on
integrating and customizing components to meet specific project requirements.
o This allows teams to deliver software faster and respond to market or customer
demands more promptly.

OBJECT ORIENTED SOFTWARE ENGINEERING 177


SRI CHANAKYA DEGREE COLLEGE

3. Cost Efficiency:
o Lower Development Costs: Reusing pre-existing components reduces the need to
develop everything from scratch. As a result, development costs are reduced, and
companies can leverage already-tested components instead of spending resources on
testing and debugging.
o Moreover, CBSE enables the use of third-party commercial components, which can be
more cost-effective than building custom solutions.
4. Improved Quality and Reliability:
o Well-tested Components: Many components in CBSE are commercially available
or have been tested in other applications, which enhances their reliability and
quality. Using these tested and proven components reduces the risk of defects in the
final system.
o Components that are widely used in the industry often have robust documentation and
community support, contributing to their quality.
5. Maintainability:
o Easier Maintenance: Since components are modular and self-contained, it is easier to
maintain and update specific parts of a software system without affecting the entire
application. If a component needs to be updated, developers can replace or upgrade it
without significant system-wide disruptions.
o This reduces long-term maintenance efforts and allows for quicker adaptations to
evolving business needs or technologies.
6. Scalability and Flexibility:
o Scalable Architecture: CBSE supports scalable software architectures since new
components can be added to the system as needed. You can also swap out components
to optimize performance or scalability, depending on the specific use case or
infrastructure changes.
o The modularity of components enables flexibility in customizing and adapting the
software for different environments and user requirements.
7. Separation of Concerns:
o Clear Separation of Concerns: Each component focuses on a specific piece of
functionality, which makes the system easier to understand, modify, and extend.
Developers can work on individual components without needing to understand the
entire system's intricacies.
o This also makes it easier to organize development efforts and assign specialized teams
to different components, improving efficiency.
8. Interoperability:
o Integration with Heterogeneous Systems: CBSE encourages the development of
components with well-defined interfaces, making it easier to integrate different
components and third-party systems. This improves the ability to create software that
interoperates with other systems, platforms, or services.
o Through well-defined APIs, components from different sources (e.g., open-source,

OBJECT ORIENTED SOFTWARE ENGINEERING 178


SRI CHANAKYA DEGREE COLLEGE

proprietary) can be integrated seamlessly into the software.


9. Parallel Development:
o Parallel and Distributed Development: Different teams can develop and test
components simultaneously, making it easier to divide labor in large projects. Each team
can work independently on separate components, increasing overall productivity and
reducing bottlenecks.
o This parallelism also facilitates more efficient use of resources and quicker delivery.
10. Enhanced Flexibility in Upgrades:
o Easier Upgrades and Extensions: Since components are modular, replacing or
upgrading a component (such as a database system or user authentication module) is
straightforward without affecting the rest of the system. This reduces the risk of system-
wide disruptions when upgrading or adding new features.
o Furthermore, systems can evolve over time by adding new components to handle
additional functionality or requirements.
11. Reduced Risk:
o Lower Development Risk: By using pre-tested and widely accepted components, the
risk of introducing bugs or errors into the system is reduced. If a component has been
used and validated in other applications, the likelihood of it causing issues is smaller.
o In addition, if a component has a strong community or vendor support, any issues
encountered during integration can be resolved more efficiently.
12. Support for Legacy Systems:
o Legacy System Integration: CBSE facilitates the integration of legacy systems
with newer technologies. By using well-defined interfaces, new components can
be integrated into existing systems, making it easier to modernize software without
replacing the entire legacy system.
o This helps organizations extend the lifespan of their legacy systems while adding new
features or capabilities.

Q) HOW DOES SERVICE-ORIENTED ARCHITECTURE ?


What is Service-Oriented Architecture (SOA)?
Service-Oriented Architecture (SOA) is an architectural pattern in software design where software
components (known as "services") are designed to be reusable, loosely coupled, and interoperable.
These services can be accessed over a network, typically using standardized communication protocols
such as HTTP, SOAP, or REST. SOA is aimed at improving the modularity, flexibility, and scalability
of software systems, especially in large and distributed applications.
In SOA, each service is designed to perform a specific business function and can communicate with
other services, either within the same system or across different systems. Services are designed to be
independent, reusable, and able to interact with each other through well-defined interfaces.

OBJECT ORIENTED SOFTWARE ENGINEERING 179


SRI CHANAKYA DEGREE COLLEGE

Key Characteristics of SOA:


1. Loose Coupling:
o Services in SOA are loosely coupled, meaning that changes to one service generally do
not affect other services. This decoupling allows services to evolve independently,
improving system flexibility and maintainability.
2. Interoperability:
o SOA supports communication across different platforms and technologies. Services can
be built in different programming languages, use different operating systems, and
communicate over different protocols but still interact seamlessly through standardized
interfaces.
3. Discoverability:
o Services in SOA can be published to service registries, making it easier for other
services or applications to discover and use them.
4. Abstraction:
o SOA services abstract their internal logic and expose only necessary functionality
via well-defined interfaces (e.g., APIs). Clients do not need to know how a service
works internally, only how to invoke its functionality.
5. Reusability:
o Services are designed to be reusable across different systems and applications. Once a
service is developed, it can be accessed and utilized by any application that requires that
functionality.
6. Scalability:
o Since services are modular and independent, it is easier to scale individual services to
meet demand. This modularity also allows the system to handle changes in load or
usage more efficiently.
How Service-Oriented Architecture Works:
1. Service Definition:
o A service in SOA is typically a software module or function that performs a specific
business task (e.g., processing payments, fetching customer details, etc.). Each service
exposes an interface (typically a web service) that defines how it can be accessed by
other services or applications.
2. Service Communication:
o Services communicate with each other via standard protocols such as HTTP,
SOAP (Simple Object Access Protocol), or REST (Representational State
Transfer). They exchange data in commonly used formats such as XML or JSON.
o A service may call another service, passing necessary data to execute a task. For
instance, an order processing service might call a payment service to process payment
after receiving an order request.
3. Service Registry:
o A service registry (or repository) is used to store metadata about available services, such
as their functionality, location, and how to call them. This registry helps clients find and

OBJECT ORIENTED SOFTWARE ENGINEERING 180


SRI CHANAKYA DEGREE COLLEGE

interact with services at runtime.


o Clients can discover services based on the registry information, allowing dynamic
service binding and decoupling of service providers from consumers.
4. Service Composition:
o In SOA, complex workflows or business processes can be created by composing
multiple services together. This process is known as Orchestration. An orchestration
service may call multiple services in a specific sequence to complete a business process,
such as order fulfillment.
o Services can also be loosely grouped into Service Choreography, where each
service independently decides when to interact with other services.
5. Service Consumers:
o A service consumer (or client) is an application or another service that makes use of a
service. The consumer invokes the service's interface, typically through web service
protocols. The consumer is unaware of how the service performs its task internally, but
relies on its defined functionality.
6. Middleware:
o SOA often uses middleware solutions, such as Enterprise Service Buses (ESB), which
help manage communication between services. ESB provides routing, message
transformation, and service orchestration capabilities to ensure smooth communication
between services.
Benefits of Service-Oriented Architecture (SOA):
1. Modularity and Reusability:
o Since services are designed to perform specific tasks and are loosely coupled, they can
be reused across different systems, reducing development time and cost. New
applications can use existing services without having to build new functionality.
2. Scalability and Flexibility:
o SOA allows organizations to scale services independently, enabling the system to grow
according to demand. Services can also be replaced or upgraded independently without
affecting the overall system, ensuring flexibility as business needs evolve.
3. Loose Coupling:
o Services are independent and can evolve separately from one another. This decoupling
reduces the impact of changes in one service on others, making maintenance and
upgrades simpler.
4. Interoperability:
o SOA allows applications and services built on different technologies, platforms, or
programming languages to interact seamlessly. This is crucial for integrating legacy
systems with newer technologies.
5. Improved Agility:
o Businesses can react more quickly to market demands because they can change, add, or
remove services without disrupting other parts of the system. This allows organizations
to adapt more quickly to changes in business needs.

OBJECT ORIENTED SOFTWARE ENGINEERING 181


SRI CHANAKYA DEGREE COLLEGE

6. Ease of Integration:
o SOA provides a framework for integrating disparate systems within an enterprise. This
can include legacy systems, third-party applications, or services that need to interact
with each other.
7. Cost-Effectiveness:
o By reusing existing services and infrastructure, organizations can reduce duplication of
effort and resources. Also, service consumers can pay for only the services they need,
leading to more efficient resource allocation.
8. Centralized Management and Monitoring:
o SOA allows centralized management and monitoring of services. This means you can
track the performance of individual services, detect issues, and optimize them for better
performance and reliability.
Challenges and Drawbacks of Service-Oriented Architecture (SOA):
1. Complexity in Design and Maintenance:
o Designing, implementing, and managing a service-oriented architecture can be complex,
especially as the number of services increases. Ensuring that all services communicate
correctly and efficiently requires careful planning and management.
2. Performance Overhead:
o Communication between services over a network (especially using protocols like
SOAP or REST) can introduce performance overhead compared to internal function
calls. This can impact system performance if not managed properly.
3. Security:
o With services being exposed over the network, there are security concerns such as data
interception, unauthorized access, and attacks. Proper security mechanisms, such as
encryption, authentication, and authorization, need to be implemented.
4. Governance and Standardization:
o Ensuring proper governance of services is crucial in large-scale systems. This
includes ensuring that services are properly defined, documented, and conform to
industry standards. Lack of proper governance can lead to inconsistencies,
inefficiencies, and difficulties in scaling the system.
5. Service Communication Failures:
o Since services are distributed, network failures or communication issues can disrupt the
functionality of the system. This requires robust fault tolerance, error handling, and
retry mechanisms.
6. Integration Complexity:
o Although SOA facilitates integration between different systems, integrating with legacy
systems or third-party services can still be challenging. Adapting old systems to work
with new service-oriented architectures often requires significant refactoring.
Examples of SOA in Action:
 Amazon Web Services (AWS): Amazon's suite of cloud services is built on a service-

OBJECT ORIENTED SOFTWARE ENGINEERING 182


SRI CHANAKYA DEGREE COLLEGE

 oriented architecture. Services such as computing (EC2), storage (S3), and database (RDS)
are exposed as independent, reusable services that can be used to build complex applications.
 Banking Systems: Many large banks use SOA to integrate different internal systems like loan
processing, customer management, and transaction handling. These systems can interact with
each other through well-defined service interfaces.
 E-Commerce Platforms: E-commerce platforms use SOA to integrate various services such as
payment gateways, inventory management, and shipping logistics, allowing them to function as
a unified system while maintaining modularity.
Q) WHAT ARE THE CORE PRICIPLES OF AGILE SOFTWARE
DEVELOPMENT?

The Agile Software Development methodology is based on a set of core principles that prioritize
flexibility, collaboration, and customer satisfaction. Agile development is characterized by iterative
progress, continuous feedback, and adaptive planning. Below are the key principles that guide Agile
practices:
1. Customer Satisfaction Through Continuous Delivery of Valuable Software
 Primary Focus: Deliver functional software that provides value to the customer.
 Core Idea: The highest priority is satisfying the customer through the continuous delivery of
working software. Frequent releases of small, incremental updates provide constant value and
enable quicker adjustments to customer needs.
2. Welcome Changing Requirements, Even Late in Development
 Embracing Change: Agile welcomes changing requirements, even in late stages of development.
 Core Idea: Agile methods are designed to accommodate changes in requirements, as they are
expected to emerge during development. This flexibility allows teams to better meet customer
needs as they evolve, rather than rigidly adhering to initial plans.
3. Deliver Working Software Frequently
 Frequent Delivery: Agile teams deliver working software at regular intervals, usually every
few weeks or months.
 Core Idea: By delivering working increments of the product regularly, teams ensure that the
software is continuously refined and tested. It also allows customers to provide feedback earlier,
improving the final product.
4. Collaboration Between Business Stakeholders and Developers
 Close Collaboration: Developers, business stakeholders, and end-users should work
together throughout the development process.
 Core Idea: Constant communication ensures that the team understands the business
requirements and the customers’ needs. This collaboration fosters alignment between what is
being built and what is needed in the marketplace.
5. Build Projects Around Motivated Individuals
 Empowering Teams: Teams should consist of motivated and skilled individuals who are
trusted to make decisions.

OBJECT ORIENTED SOFTWARE ENGINEERING 183


SRI CHANAKYA DEGREE COLLEGE

 Core Idea: Agile encourages autonomy and accountability, as empowered teams are more
likely to succeed. Providing the team with the necessary environment and support enables them
to perform at their best.
6. Face-to-Face Communication Is the Most Efficient
 Effective Communication: Face-to-face conversation is the most efficient and effective
method of communication within an Agile team.
 Core Idea: Direct communication between team members, stakeholders, and customers
minimizes misunderstandings and ensures faster problem-solving. This principle encourages
collaboration through daily meetings (e.g., stand-ups) and co-located teams when possible.
7. Working Software Is the Primary Measure of Progress
 Measuring Progress: The ultimate measure of progress is the functionality and quality of
the software that has been delivered.
 Core Idea: Unlike traditional methods where progress is measured by documentation or
planning milestones, Agile focuses on the delivery of actual working software. This ensures
that the project is always moving toward creating something valuable.
8. Sustainable Development Pace
 Maintainable Pace: Agile promotes a sustainable development pace that can be maintained
indefinitely.
 Core Idea: Teams should work at a steady pace that avoids burnout and ensures long-term
productivity. This principle encourages a balance between speed and quality, ensuring that work
is maintainable over time.
9. Continuous Attention to Technical Excellence and Good Design
 Focus on Quality: Agile emphasizes technical excellence and good design, which enhances
the agility of the development process.
 Core Idea: Regular attention to improving technical skills and design principles leads to
simpler, more flexible code that is easier to modify and extend. This also ensures long-term
maintainability and scalability.
10. Simplicity – The Art of Maximizing the Amount of Work Not Done
 Simplicity and Focus: Agile teams focus on simplicity and only work on what’s necessary to meet
customer needs.
 Core Idea: Simplicity in design and functionality reduces complexity and makes the system
easier to maintain. By not over-engineering or adding unnecessary features, the team can focus
on delivering value.
11. Self-Organizing Teams
 Empowerment and Autonomy: Agile encourages teams to be self-organizing, making
decisions collectively.
 Core Idea: Teams that organize themselves tend to be more creative and efficient, as they take
ownership of their work and are more adaptable. Agile teams rely on trust and collaboration to
achieve the best outcomes.

OBJECT ORIENTED SOFTWARE ENGINEERING 184


SRI CHANAKYA DEGREE COLLEGE

12. Regular Reflection and Adjustment


 Continuous Improvement: Teams regularly reflect on how to improve their processes
and adjust accordingly.
 Core Idea: Agile emphasizes retrospectives (e.g., sprint reviews) where teams look back on
their work and discuss what went well and what can be improved. This promotes continuous
learning and adaptation to enhance future performance.
Q) EXPLAIN SCRUM METHODOLOGIES?
Scrum is one of the most popular Agile methodologies for managing and executing complex projects,
particularly in software development. It is designed to help teams work together in an organized and
efficient way to deliver high-quality products in iterative cycles called Sprints.
Scrum is centered around a set of roles, events, and artifacts that work together to support continuous
improvement, collaboration, and flexibility. It promotes transparency, inspection, and adaptation
throughout the development process.
Core Elements of Scrum

1. Scrum Roles
There are three primary roles in Scrum:
1. Product Owner:
o Responsibilities: The Product Owner is responsible for defining and prioritizing the
product backlog, ensuring that the team is working on the most valuable features first.
They represent the voice of the customer or stakeholders and ensure that the
development aligns with the business goals.
o Key Tasks:
 Manage and prioritize the product backlog.
 Communicate requirements and feedback.
 Accept or reject work items based on whether they meet the acceptance
criteria.
2. Scrum Master:
o Responsibilities: The Scrum Master serves as a facilitator and coach, helping the
Scrum team follow Scrum practices and principles. They remove any obstacles or
blockers the team faces and ensure that the Scrum process is being adhered to.
o Key Tasks:
 Facilitate Scrum events (meetings).
 Support the team in overcoming obstacles.
 Coach the team on self-organization and continuous improvement.
 Ensure that Scrum principles are understood and followed.
3. Development Team:
o Responsibilities: The development team is a cross-functional group of professionals
who are responsible for delivering the product increment. The team members possess
all the necessary skills to complete tasks (designers, developers, testers, etc.).

OBJECT ORIENTED SOFTWARE ENGINEERING 185


SRI CHANAKYA DEGREE COLLEGE

o Key Tasks:
 Execute the work needed to deliver the product increment.
 Self-organize and collaborate to achieve the sprint goal.
 Ensure high-quality work through testing and continuous improvement.
2. Scrum Events (Ceremonies)
Scrum consists of a set of time-boxed events that are designed to help the team plan, track
progress, and improve. These events include:
1. Sprint:
o Definition: A Sprint is a time-boxed iteration (usually 1 to 4 weeks) during which a
specific set of work (a product increment) is completed and made ready for review.
o Key Elements:
 Sprints are of fixed duration and repeat until the product is finished.
 No changes are made to the Sprint goal once the Sprint begins.
2. Sprint Planning:
o Purpose: Sprint Planning is held at the beginning of each Sprint to define the work that
needs to be done. The team decides what they will work on and how they will achieve
the Sprint goal.
o Key Elements:
 The Product Owner presents the prioritized items from the product backlog.
 The Development Team discusses and decides on which items to commit to for
the Sprint.
 The team collaboratively defines the tasks and creates a plan for completing the
work.
3. Daily Scrum (Stand-up):
o Purpose: The Daily Scrum is a brief, 15-minute meeting held every day of the Sprint.
It allows the team to synchronize, discuss progress, and address any roadblocks.
o Key Elements:
 Team members answer three key questions:
1. What did I do yesterday to help the team meet the Sprint goal?
2. What will I do today to help the team meet the Sprint goal?
3. Are there any obstacles blocking my progress?
 The goal is to keep the team aligned and focused, with any impediments raised
so they can be addressed.
4. Sprint Review:
o Purpose: The Sprint Review is held at the end of each Sprint to inspect the increment
(the completed work) and get feedback from the Product Owner and other
stakeholders.
o Key Elements:
 The team demonstrates the work they’ve completed during the Sprint.
 The Product Owner reviews whether the increment meets the acceptance
criteria.

OBJECT ORIENTED SOFTWARE ENGINEERING 186


SRI CHANAKYA DEGREE COLLEGE

 Stakeholders provide feedback that might lead to updates in the product


backlog.
5. Sprint Retrospective:
o Purpose: The Sprint Retrospective is a meeting for the Scrum team to reflect on the
Sprint and discuss what went well, what didn’t, and how to improve in the next Sprint.
o Key Elements:
 The team discusses successes, challenges, and any issues that occurred during
the Sprint.
 The Scrum Master leads a discussion on potential improvements for the next
Sprint.
 Action items are created to improve processes, team dynamics, or product
quality.
3. Scrum Artifacts
Scrum includes three key artifacts (documents) that help manage and communicate the work during the
project:
1. Product Backlog:
o Definition: The Product Backlog is a prioritized list of work items (features, bug
fixes, improvements, etc.) that need to be completed to build the product.
o Key Elements:
 Managed by the Product Owner.
 Items in the backlog are often written as user stories, detailing the functionality
from the user’s perspective.
 It is continuously updated as new requirements emerge or priorities change.
2. Sprint Backlog:
o Definition: The Sprint Backlog is a list of tasks the team has committed to complete
during the current Sprint. It is a subset of the Product Backlog that the team plans to
work on in the upcoming Sprint.
o Key Elements:
 Created during Sprint Planning.
 The team breaks down Product Backlog items into smaller, actionable tasks.
 The Sprint Backlog is updated daily as tasks are completed or modified.
3. Increment:
o Definition: The Increment is the sum of all the Product Backlog items completed
during the Sprint, combined with all previous Sprints. It represents the current state of
the product and should be in a "done" state, meaning it is potentially releasable.
o Key Elements:
 The Increment must be in a working state and meet the Definition of Done (a
shared understanding of what "done" means for the team).

OBJECT ORIENTED SOFTWARE ENGINEERING 187


SRI CHANAKYA DEGREE COLLEGE

Benefits of Scrum Methodology


 Flexibility and Adaptability: Scrum allows teams to adapt to changing requirements
and feedback from stakeholders throughout the development cycle.
 Faster Delivery: With regular, time-boxed Sprints, Scrum delivers working software quickly
and frequently, allowing teams to provide value faster.
 Continuous Improvement: Scrum's emphasis on retrospectives ensures that the team
continually improves processes and productivity.
 Transparency and Collaboration: Scrum fosters open communication, allowing all team
members and stakeholders to be aligned with the project’s goals and progress.
 Focus on Quality: Scrum encourages teams to consistently improve the quality of the product
through regular reviews, testing, and adjustments.

Challenges of Scrum
 Requires Commitment: Scrum requires full commitment from all team members, including
the Product Owner and stakeholders, to be effective.
 Discipline: Scrum requires discipline in following its roles, events, and artifacts, and teams
may face challenges if not properly trained or supported.
 Scope Creep: Without a clear focus, there is a risk of scope creep (adding additional features
or changes without proper review), which could affect project timelines and objectives.

OBJECT ORIENTED SOFTWARE ENGINEERING 188


SRI CHANAKYA DEGREE COLLEGE

UNIT-I

DATA COMMUNICATIONS AND NETWORKS


Q1. Computer Network

Computer network is a interconnected computers (or) A collection of computers


interconnected by a single technology. These computers are interconnected by
exchanging the information

Applications of computer Networks

1) Business applications:

Many companies have a number of computers. These are connected and able to extract
the information about the entire company. The client and server machines are connected
by a network.

2) Home applications:

The popular for home users are as follows uses of the internet

ⅰ) Access remote information: It can be surfing the Www for information

ii) Peer-Peer in Communication: In this system there are no fixed clients and servers

iii) Entertainment: We can download various types of Songs, movies, games i your
screen. in any country and displayed in

iv) E-commerce: Many people pay their bills, manage their bank accounts and handle,
their investments digitally (or) electronically and also many users purchase the products
through online shopping.

DATA COMMUNICATION AND NETWORK 189


SRI CHANAKYA DEGREE COLLEGE

3) Mobile users:

Mobile computers such as notebooks, laptops, tablets, and notepad are one of the fast
growing segments of Computer industry and also wireless networking and mobile
computing for often related

4) Social Issues:

The wide spread of networking problem to new social and ethical problems.

Q2. Network Hardware:

Network Hardware refers to the physical equipment needed for communication and
Interaction between devices on a computer network. These components are the basic
building blocks of network hardware devices plays a crucial role in the functioning of
any network.

Types of Network Hardware:

1. Routers:

These devices that can connect multiple networks together and direct data packets
between them. These are mainly used in both home and enterprise networks.

2. Switches:

These devices that connect the multiple Computers / systems/ devices on a LAN. They
use MAC address to forward data to the correct destination within the LAN. These are
important for managing data traffic effectively

3. Modems:

Devices convert digital data from a computer, into a analog communication such as
telephone lines. They are less common now-a-days

4. Hubs:

These are basic networking devices that can connect multiple LAN's together, they
broadcast data to all connected. Devices....

5. Bridges:

These are used to connect two separate LAN'S (or) divide a large LAN into smaller
segments. they filter traffic and reduce network issues by preventing unnecessary data.

DATA COMMUNICATION AND NETWORK 190


SRI CHANAKYA DEGREE COLLEGE

Q3. Network Software:

It’s a fundamental element for any networking System. It helps to reduce network
complexities and manage network traffic. It plays a crucial rote, in managing a network
infrastructure le, Security. Content and data sharing.

Functions of Network Software:

1. User Management:

It allows administrators to add & remove users from the network

2. File Management:

It allows administrators decide the location of data storage and control user access to
the data

3. Access: It enables users to, access, uninterrupted network resources

4. Network Security Systems: Network administrators provides security and


preventing data breaches

DATA COMMUNICATION AND NETWORK 191


SRI CHANAKYA DEGREE COLLEGE

Network Software

Components of network software

1. Application layer:-

The first component is the Application layer which refers to the applications and
Services running on the network. This layer also consist of Application logic and one or
more API Drivers

2. Control layer:-

This layer lies at the Center Of the Architecture and is one of the Most Important
component of the three layers it is called the Controller. It is the intermediately between
the top and bottom layers through Ap1 Interface's

3. Infrastructure layer:

It is also called the data plane consist of actual network devices so they are primary
responsible for Moving of avoiding the data packets, this Components handle. User
traffic based on Commands

Q4. Reference models

Reference model, describe how data is transmitted and received between devices. There
are two popular reference models

ⅰ) OSI model (open System Interconnection)

ii) TCP/IP model

1) OSI model: (Open System Interconnection)

This model was developed by International Standard organization (ISO). It has seven
Interconnected layers.

The seven layers of the OSI model are

i) Physical Layer,
ii) Data Link layer
iii) Network layer
iv) Transport layer
v) Session Layer
vi) Presentation layer
vii) Application layer

DATA COMMUNICATION AND NETWORK 192


SRI CHANAKYA DEGREE COLLEGE

i) Physical layer:
This is the lowest layer of the OSI model. It is responsible for the actual physical
connection between the devices. This layer contains information to the form of for
transmitting the bits. So, it is responsible individual bits from one node to the next.
After receiving, the data it converts it into O’S and 1's and send them to data link
layer.
Functions of physical layer:

1. Line Configuration: At defines the way how two or more devices can be
connected Physically.
2. Data transmission: At defines the transmission mode whether It is simplex, half
Duplex, duplex, mode between the two devices on the network.
3. Function Topology: It defines the way. How network devices are arranged.

DATA COMMUNICATION AND NETWORK 193


SRI CHANAKYA DEGREE COLLEGE

4. Signals: It determines the type of signal used for transmitting the information

ii) Data link layer:


This layer is responsible for the error free transfer of data" frames. It provides a
reliable and efficient communication between two or more devices. It contains two
sub layers
a) Logical link control layer

b) Media, access control layer

a) Logical link control layers: It, identifies the address of the network layer protocol
from the header. It also provides flow control.

b) Media access control layer: It is used for transfer. ring packets over the network.

Functions:

1. Framing: The data link layer translates the bit streams into packets known as
"frames"
This layer adds the header and trailer to the frame

2. Physical Addressing: This layers adds a header to the frame that contains a
destination address. The flame is transmitted to that address.

3. Flow Control: it is the main functionality of this layer. It is a technique through


which the constant that no data rate is maintained the get both the sides so that no data
get corrupted

4. Error Control: Error Control is achieved by adding a calculated values by CRC


(cyclic Redundancy Check) if any error occurs then the receiver sends the
acknowledgement for the retransmission of the corrupted frames.

5. Access Control: when two of mole devices are Connected to the same
communication channel. It is used to determine which device has control over the link
at a given time.

iii) Network layer:

This layer manages the device addressing. It is responsible for routing and forwarding
the packets. The protocols which are used in this layer are, IPV4 and IPV6.

Functions:

1. Internet Working: It provides a logical connection between different devices.

DATA COMMUNICATION AND NETWORK 194


SRI CHANAKYA DEGREE COLLEGE

2. Addressing: It adds the source and destination address to the header of the frame.

3. Routing: It determines the best optimal path from source to destination

4. Packetizing: This layer receives the packets from the upper layer and converts them
into packets.

iv) Transport layers:

The main responsibility of this layer is to transfer the data completely. It receives the
data from the upper layer and converts them into Segments. It provides a point to point
connection between source and destination to deliver the data The two protocols used in
this layer are TCP and UDP

Functions:

1. Service point addressing: This layer adds the header that contains the address is
known as service point address or port address."

2. Segmentation: This layer receives the message from upper layer. It divides the.
Message into multiple Segments

3. Connection Control: At provides two services connection oriented service and


connection less service.

4. Flow Control: This layer is responsible for flow Control but it is performed end to
end raver than across the Single link.

5. Error that Control: The sender transport layer ensures that message reach at the
destination without any error

v) Session layer:

It is used to establish, maintain and synchronizes the interaction between communicated


devices.

Functions:

1. Dialog Control: It allows the communication between two processors either half
duplex or full duplex.

2. Synchronization: This layer adds some check points when transferring data in a
sequence.

DATA COMMUNICATION AND NETWORK 195


SRI CHANAKYA DEGREE COLLEGE

vi) Presentation layers:

This layer is mainly deals with syntax and semantics of the information exchanged
between two systems. It acts as a data translator for a network.
Functions:
1. Translation: It converts the data from one format into another format and again
change in receiver Side
2. Encryption: It's a process converting the sender information into another form and
sends the message .Over the network.

3. Compression: It's a process of compressing the data.

vii) Application layer:

This layer serves as a window for users. It handles –network Issues and provides
network services to the Users

Functions

1. FTAM (File Transfer and access management):- It allows the user to access the
files in a remote computer and to manage the files.

2. Mail Services: It provides the facility for e-mail forwarding and storage

TCP/IP Model (Transmission)

It is a fundamental framework for computer networking. These are the core protocols of
the internet. It consists of four layers

1. The Link layer.

2. The internet layer

3 The transport layer

4. Application layer

It was designed and developed by the departments of defence in 1960's. The main work
of TCP/IP is to transfer the data of a computer from one device to another

DATA COMMUNICATION AND NETWORK 196


SRI CHANAKYA DEGREE COLLEGE

Application layer TELNET, DNS, HTTP, FTP, SMTP

Transport layer TCP, UDP, SCTP

Internet layer
ICMP RARP
IP,
IGMP ARP

Hast-To-Network Layer (link layer) Ethernet, Frame Relay, Token Ring, ATM

1) Link layer: This layer deals with physical -addressing and network, access.

 key protocols:

→Ethernet: It's a protocol for Local Area Networks.

→Frame Relays: This protocol is used for Wide Area Networks.

→ATM (Asynchronous Transfer Mode): This protocol is wed for WAN's.

→Token Ring: It is used for direct communication. between two nodes

2. Internet layer:

It is also known as Network layer. This layer is responsible for logical addressing,
routing and packet forwarding. This layer ensures that data packets travel across
multiple networks.

*key protocols:

→IP (Internet Protocol): It handles addressing and routing packets. It includes IPV4
and IPV6

→ICMP (Internet Control message protocol):

It is used for identifying network issues of problems

→ARP (Address Resolution protocol):

It identify the host address (or) It map's IP addresses to physical address machine within
a LAN

3. Transport layer: This layer provides end to end. Communication services for
applications. It ensures. Complete data transfer and Integrity.

DATA COMMUNICATION AND NETWORK 197


SRI CHANAKYA DEGREE COLLEGE

* Key protocols:

→TCP (Transmission Control Protocol):

It ensures reliable ordered and error free delivery of data. It establishes a connection
between sender and receiver

→UDP (User Datagram protocol):

It provides a faster service. It sends data without establishing a connection. It is a


connection less service

4. Application layer: This layer provides network services directly to the users
applications. It handles high level protocols encoding and dialog control.

* Key protocols:

→HTTP (Hyper Text Transfer Protocol):

It is used for transferring webpages on the internet.

→FTP (File Transfer Protocol):

It is used for transferring of files between computers.

→ SMTP (Simple mail transfer protocol):It is used for sending e-mails.

DNS (Domain Name System):It translates domain names to IP address.

→TELNET (Terminal Network): It is used for login to servers

Q5. CONNECTION ORIENTED NETWORKS

Connection oriented networks are

 X.25 network’s
 Frame relay
X.25 NETWORKS

 Our first example of a connection-oriented network is X.25, which was the


first public data network. It was deployed in the 1970s.
 To use X.25, a computer first established a connection to the remote
computer, that is, placed a telephone call.

DATA COMMUNICATION AND NETWORK 198


SRI CHANAKYA DEGREE COLLEGE

 This connection was given a connection number to be used in data transfer


packets (because multiple connections could be open at the same time).
 Data packets were very simple, consisting of a 3-byte header and up to 128
bytes of data.
 The header consisted of a 12-bit connection number, a packet sequence
number, an acknowledgement number.

FRAME RELAY:

 In the 1980s, the X.25 networks were largely replaced by a new kind of
network called frame relay.
 The essence of frame relay is that it is a connection-oriented network with
no error control and no flow control.
 Because it was connection-oriented, packets were delivered in order (if they
were delivered at all).
PHYSICAL LAYER
• The purpose of the physical layer is to transport a raw bit stream from one
machine to another.
• Various physical media can be used for the actual transmission.
Q6. TRANSMISSION MEDIA

Different types of data transmission media are as follows:

1. Wired/Guided Transmission Media

(a)Twisted Pair Cable

i. Unshielded Twisted Pair Cable

ii. Shielded Twisted Pair Cable

(b) Coaxial Cable

(c) Optical Fiber

DATA COMMUNICATION AND NETWORK 199


SRI CHANAKYA DEGREE COLLEGE

2. Unwired/Unguided Transmission Media

(a) Radio Waves

(b)Micro Waves

(c)Infrared Waves.

Wired/Guided Transmission Media

Guided media is a wired transmission media. It is a type of media in which data signals
are guided along a physical path i.e., within a wire. It is also known as Bounded or
Wired Media.

1. Twisted Pair Cable:

In Twisted Pair Cable, the wires are twisted to reduce cross talk and electrical
interference. It was invented by Alexander Graham Bell in 1881. Twisted- Pair cable
accepts and transports signals in the form of electric current. It consists of two copper
conductors, each with its own plastic insulation, twisted together.

One of the wires is used to carry signals to the receiver, and the other is
used only as a ground reference.

Advantages o. twisted Pair Cable

 Easier to install.
 The wire pairs are quite useful, and inexpensive
 The wire can be used for analog or digital transmission.
 Crosstalk is less, since the wires are twisted.
Disadvantages of Twisted Pair Cable

 These wires easily pick noise signal.


 Noise leads to high error rate.
Types of Twisted Pair Cable

DATA COMMUNICATION AND NETWORK 200


SRI CHANAKYA DEGREE COLLEGE

(a) Unshielded Twisted Pair Cable:

The unshielded twisted pair cable is a Guided Transmission Media, which is used for
transmitting both data and voice. UTP is also useful for LAN technologies, such as
Ethernet, security cameras, telephony system etc.

The cable has two insulating copper wires. The size of these wires is 1 mm thick. Each
of these has its own-colored plastic insulation. Colors are different to identify it from
particular conductors. They are twisted in a helical form, so that it helps in reducing
electrical interference or crosstalk.

There are five levels of data cabling for UTP cabling:

Category 1: These are used in telephone lines and low-speed data systems.

Category 2: These cables can support up to 4 MPS implementation.

Category 3: These cables support up to 16 MPS and are mostly used in 10 MP


environments.

Category 4: These are used for larger distances and high speeds. It can support 20
MPS.

Category 5: This is the highest rating for UTP cable and can support up to 100 MPS.

UTP cables consist of two or four pairs of tv.isted cable. Cable with two pairs uses RJ-
11 connectors and four-pair cables use an RJ-45 connector.

Advantages of UTP

 Low cost
 Easy to install
 High-speed cap
 High attenuation

DATA COMMUNICATION AND NETWORK 201


SRI CHANAKYA DEGREE COLLEGE

Disadvantage of UTP

Short-range capability due to attenuation

(b) Shielded Twisted Pair Cable

The shielded twisted pair cable is a Guided Transmission Media, which is quite
expensive than unshielded twisted pair cable. Shielded cable is less prone to noise.

STP encases each pair of insulated conductors with a metal foil. To prevent the
electromagnetic noise, and eliminate cross talk.

Shielded Twisted Pair Cable are more expensive than Unshielded Twisted Pair Cable.

Characteristics of STP:

 medium cost
 easy to install
 higher capacity than UTP
 higher attenuation, but same as UTP
 shielded
 faster than UTP and coaxial
Disadvantages of STP

 more expensive than UTP and coaxial


 more difficult installation
 high attenuation rate
2. Coaxial Cable: Coaxial cable, often referred to as coax cable, is a type of electrical
cable that is widely used for transmitting high-frequency signals and data. It consists of
a central conductor, which is surrounded by insulation, a metallic shield, and an outer
protective covering The coaxial design provides several advantages. Including
television distribution, broadband internet, telecommunications, and networking.

DATA COMMUNICATION AND NETWORK 202


SRI CHANAKYA DEGREE COLLEGE

Advantages of Coaxial Cable

 Coaxial cable is used in cable television.


 It offers much higher bandwidth.
 It is preferred for long distance telephone lines as well.
 Provides better shield when compared with Twisted Pair cable.
 It offers data transmission without any distortion.
 Expect quite higher noise immunity from coaxial cable.
Disadvantages of Coaxial Cable

 Single cable failure, also known as a single point of failure, can take down an
entire network.
3. Optic Fibre: Fibre-optic lines are strands of optically pure glass as thin as a human
hair that carry digital information over long distances. They are also used in medical
imaging and mechanical engineering inspection.

Advantages

 High bandwidth capacity (many gigabits per second).


 Longer distances between devices (from 2 to over 60 kilometres)
 Less signal attenuation
 Light weight
Disadvantages

 Difficulty in Installation and maintenance.


 Expensive
UNGUIDED TRANSMISSION MEDIA

Unguided media transport data without using a physical conductor. This type of
communication is often referred to as wireless communication. It uses wireless
electromagnetic signals to send data. There are three types of Unguided Media:

DATA COMMUNICATION AND NETWORK 203


SRI CHANAKYA DEGREE COLLEGE

 Radio waves
 Micro waves
 Infrared

1. Radio waves:

Radio waves are electromagnetic waves ranging in frequencies between 3 KHz and
1GHz. These are Omni-directional; when an antenna transmits radio waves they are
propagated in all directions. This means that sending and receiving antenna do not
have to be aligned. A sending antenna can send waves that can be received by any
receiving antenna. Radio waves are of low and medium frequencies

Applications

 The unidirectional characteristics of Radio waves make them useful for


multicasting, in which there is one sender but many receivers.
 AM and FM Radio, television, cordless phone, and paging are examples of
multicasting.
2. Microwaves:
Electromagnetic waves having frequencies between 1 and 300 GHz are called
microwaves. Microwaves are unidirectional This means that the sending and
receiving antennas need to be
Applications

 Microwaves due to their unidirectional properties are very useful when unicast
(one to one) communication is needed between the sender and the receiver.
 They are used in cellular phones.
 They are used in satellite networks.
 They are used in wireless LANS

DATA COMMUNICATION AND NETWORK 204


SRI CHANAKYA DEGREE COLLEGE

3. Infrared:
Infrared signals with frequencies ranges from 300 GHz to 400 GHz can be used
for short range communication. Infrared signals, having high frequencies. This
helps to prevent interference between one system and another Transfer digital
data is possible with a high speed with a very high frequency.
Applications

 The infrared band almost 400 THz has an excellent potential for data transmission.
 Such a wide bandwidth can be used to transmit digital data with a very high data
rate.
 Infrared waves are used in communication between devices such as keyboard,
PCs and printers.
Q7. Public Switched Telephone Network (PSTN)

Public Switched Telephone Network (PSTN) is an agglomeration of interconnected


network of telephone lines owned by both governments as well commercial
organizations.

Properties of PSTN

 It is also known as Plain Old Telephone Service (POTS)


 It has evolved from the invention of telephone by Alexander Graham Bell
 The individual networks can be owned by national government, region government
or private telephone operators.
 Its main objective is to transmit human voice in a recognizable form.
 It is an aggregation of circuit-switched networks of the world.
 Originally, it was an entirely analog network laid with copper cables and switches
 Presently, most part of PSTN networks is digitized and comprises of a wide variety
communicating devices.
 The present PSTNs comprises of copper telephone lines, fibre optic cable
communication satellites, microwave transmission links and undersea telephone
lines. It is also linked to the cellular networks.
 The interconnection between the different parts of the telephone system is done by
switching centres. This allows multiple telephone and cellular networks to
communicate with each other.

DATA COMMUNICATION AND NETWORK 205


SRI CHANAKYA DEGREE COLLEGE

 Present telephone systems are tightly coupled with WANs (wide area networks and
are used for both data and voice communications.
 The operation of PSTN networks follows the ITU-T standards.

Q8. The Mobile Telephone System

Mobile telephone service (MTS) connects mobile radio telephones with other networks
like public switched telephone networks (PSTN), other mobile telephones and
communication systems like Internet.

Basic Mobile Communications System

Mobile phones and other mobile devices, called mobile stations are connected to base
stations. Communication between the mobile stations and the base stations are done by
wireless radio signals, which may be both data signals and voice signals. Each base
station has a coverage area around it, such that mobile stations within this area can
connect provided they have access permissions. Base stations contain transmitters and
receivers to convert radio signals to electrical signals and vice versa. Base stations
transmit the message in form of electrical signals to the mobile switching center (MSC).
MSCs are connected to other MSCs and public networks like PSTNs.

Generations of Mobile Phone Systems

 1G (First Generation) - They were standards for analog voice mobile phone
communications.
 2G(Second Generation) They were standards for digital voice mobile phone
communications.
 3G(Third Generation) - These standards were for communications in form of both
digital voice as well as digital data.
 4G(Fourth Generation) - 4G standards provide mobile broadband internet access in
addition to digital voice and data.
 5G(Fifth Generation) - It is the next step of mobile communication standards
beyond 4G which currently under development.

DATA COMMUNICATION AND NETWORK 206


SRI CHANAKYA DEGREE COLLEGE

UNIT-I
1.1 ELECTRIC FIELD and ELECTRIC POTENTIAL

ELECTRIC FLUX
The electric flux through a surface placed inside electric field represents the total number of electric lines
of force crossing the surface in a direction normal to the surface.
Let the surface be divided into a number of elementary squares. Each square on the surface may be
represented by a vector dS whose magnitude is equal to its area and the direction taken as the outward
normal drawn on this surface. Let E be the electric field vector acting on the surface.

The scalar product, i.e., E. dS is defined as the electric flux for the surface. The total flux ΦE through the
entire surface is given by·

ΦE = ∮ �. �� = �. �

If θ is the angle between E and dS, then the scalar product is given by
E. dS = EdS cos θ
Now the electric flux ΦE = ∮ ��� cos

θ ΦE = �cos θ

∮ ��

ΦE = �� cos θ
For any closed surface, flux is taken as positive if they are outwards and taken as negative if
inwards.
Example 1: From the figure, for the surfaces S1and S2 the electric flux
are outwards and inwards so conveniently it is taken as positive for S1 and
negative for S2. But for surface S3, it is zero because the amount of flux
entering is equal to leaving the closed surface area S3.
Example 2: Consider a cylinder of radius R immersed in a uniform
electric field E parallel to its surface. The flux ΦE for the entire cylinder
is the sum of the fluxes through (a) left face (left cylinder cap) (b) right
face (right cylinder cap) and (c) the cylindrical surface.
Thus,
For the left cap of the cylinder, the angle between E and dS is 180°

 E.dS   EdS cos 180  E dS  ES


ELECTRICITY, MAGNETISM & ELECTRONICS 207
SRI CHANAKYA DEGREE COLLEGE
Similarly, for the right cap of the cylinder, the angle between E and dS is zero

 E.dS   EdS cos 0  E dS  ES


For the curved surface of the cylinder, the angle between E and dS is 90°

 E.dS   EdS cos 90   EdS(0)  0


So, the total flux through the entire cylinder
E  ES  ES  0  0
GAUSS'S LAW
Statement:
Gauss law states that total normal electric flux ϕE over a closed surface in an electric field is (1/ε0) times
the total charge Q enclosed within the surface.
Mathematically, it can be expressed as
1
ΦE   E.dS   EdS cos θ   εQ
0 

where ε0 is the permittivity of the free space.


Proof:
(i) When the charge is within the surface
Let a charge +Q be placed at O within a closed surface of irregular shape.
Consider a point P on the surface at a distance r from O. Now take a small area
dS around P. The normal to the surface dS is represented by a vector dS which
makes an angle θ with the direction of electric field E along OP. The electric
flux dΦE outwards through the area dS is given by
�ΦE = � ∙ �� = � �� cos θ (1)
where θ is angle between E and dS.
From Coulomb's law, the electric intensity E at a point P of distance r from a point charge Q is given by
1 Q
E   (2)
4 0  r 2 
From eqs. (1) and (2), we get

�ΦE = . �� cos θ
4�� �2
� �� cos θ
�ΦE = )
But �� cosθ 4�� �2
(
( �2 ) is the solid angle d� subtended by dS at O.
Hence, dΦE  Q d (3)
4
The total flux ΦE over the entire whole surface is given by

ΦE = ∮ ��
4��
where ∮ �� is the solid angle subtended by the whole surface at O. This is equal to 4 π. Hence,

ELECTRICITY, MAGNETISM & ELECTRONICS 208


SRI CHANAKYA DEGREE COLLEGE

ΦE = x 4�
4��
Q
 Φ  (4)
E
ε0
Let the closed surface enclose several charges +Q1, +Q2, +Q3, +,…, -Q1' – Q2', -Q3', …
Now each charge will contribute to the total electric flux. Thus, the total flux is given by
1
Φ  Q  Q  Q  Q '  Q '  Q '
E 1 2 3 1 2 3
ε0
1
Φ 
ε0 
Q (5)
E

where Q is algebraic sum of all the charges.


So the total normal electric flux over the closed surface is equal to (1/ε0) times the total charge
enclosed within the surface. Hence Gauss law is proved.
(ii) When the charge is outside the surface.
Let a point charge +Q be situated at point O outside the closed surface. Now cone of solid angle dω
from O cuts the surface areas dS1, dS2, dS3, dS4 at points P, Q, R and S respectively. The electric flux for
an outward normal is positive while the inward drawn normal is negative. Therefore, the flux through areas,
dS2 and dS4 are positive while for dS1 and dS3 are negative. Therefore,
 Q 
the electric flux at P through area dS  d
  
 40 
1

the electric flux at Q through area dS   Q  d


 
 40 
2

the electric flux at R through area dS   Q  d


 
 40 
3

the electric flux at S through area dS   Q  d


 
 40 
4

∴ Total electric flux =  Q  d   Q  d   Q  d   Q  d  0


           
 4 0   4 0   4 0   4 0 

So the total electric flux over the whole surface due to an external charge is zero. This verifies Gauss's
law.
ELECTRIC FIELD
The region surrounding an electric charge on a group of charges, in which another charge
experiences a force is called electric field.
The force between two charges can be considered in terms of electrical fields as follows:
(i) A charge �1 sets up an electric field in space itself.

ELECTRICITY, MAGNETISM & ELECTRONICS 209


SRI CHANAKYA DEGREE COLLEGE
(ii) The field of �1 acts on �2, now, �2 experiences a force due to �1.
(iii) Similarly �2 sets up the field and this fields acts on �1 thus, produces a force on �1
INTENSITY OF ELECTRIC FIELD E.
The intensity of electric field at a point in the field is defined as the force experienced by a unit
positive charge placed at that point.
Let F be the force experienced by a test charge �0 placed at a point in the electric field, then the
intensity of electric field E at that point is given by

The intensity of electric field is vector quantity. The unit of electric field is newton per coulomb.
APPLICATIONS OF GAUSS LAW
(1) Electric field intensity due to uniformly charged sphere
Consider a sphere of radius R with center O. Let the charge q be uniformly distributed over it. Now the
electric field at point P can be calculated as
Case I: If the point P lies outside the sphere:
Consider a point P outside the sphere at a distance r from the center O of the sphere. Now we have to find
the field intensity E at this point. For this purpose a Gaussian
sphere of radius r is constructed. The intensity of the field at
all points on the Gaussian surface is constant and direction
will be perpendicular to the surface.
Consider small area dS around P. The electric flux
through with small area is given by
�ΦE = � ∙ �� = E dS cosθ
This is equal to the flux through the small area ‘dS’. But in
this case θ = 0, cos 0 = 1.
The total electric flux over a Gaussian surface is given by
�ΦE = ���
The total normal electric flux over the entire Gaussian Surface is given by
ΦE   dΦE   EdS
ΦE  E  dS
Φ E  E  4  r2  (1)
According to Gauss theorem
q
ΦE  (2)
0
From (1) and (2)

(4��2) =
�0

ELECTRICITY, MAGNETISM & ELECTRONICS 210


SRI CHANAKYA DEGREE COLLEGE

1
�=
4�� �2
0
Case II : If the point P lies on the surface of the sphere:
In this case r = R, Now the electric field at P on the surface,

1
�=
4�� �2
0
Case III: If the point P lies inside the sphere:
Consider a point ‘P’ inside the sphere at a distance r from the center ‘O’ of the sphere. Now we have
to find the field intensity ‘E’ at this point. For this purpose we construct a Gaussian sphere of radius ‘r’.
Consider a small area ‘dS ‘around ‘P’. The electric flux through with small area is given by
�ΦE = �. �� = ��� (∵ cos 0 = 1)
The total electric flux over a Gaussian surface is given by

ΦE   dΦE   EdS
ΦE  E  dS
ΦE  E 4 r2  (3)
According to Gauss theorem
 
4 3 q 
 4  r3    3  r  4 
3 
q 3  πR q  r3 
3 
ΦE       
    3
(4)
0 0 0 0  R 

From (3) and (4)


� �3
(4��2) = ( 3)
� �
0


�= ()
4��0

The variation of ‘E’ with distance ‘r’ as shown in figure.


(2) Field intensity due to a conducting infinite thin sheet of charge:
Consider an infinite charged conducting sheet. As the sheet is conducting, the charge will reside only
on the surface of the conductor. There will be no charge inside the sheet. Let σ be the charge density (charge
per unit area). We have to determine the electric field at a point P, near the surface and outside of sheet.
For this we construct a cylindrical Gaussian surface passing through a point P.
The Gaussian surface has one flat plane surface passing through P at right end and other flat surface
just inside the surface of conductor. There is a curved surface being perpendicular to the surface of
conductor.

ELECTRICITY, MAGNETISM & ELECTRONICS 211


SRI CHANAKYA DEGREE COLLEGE
From figure electric flux Φ through the
entire Gaussian cylinder is the contribution of
three surfaces.
At the right end, E is parallel to dS, i.e.,
ΦEright = EdS

At the left end there is no electric field


inside conductor. i.e., ΦEle�t = 0.
For the curved surface E is perpendicular to
dS, i.e., ΦE��rved = 0.
So, we have

According to Gauss law,


q σS
ES 
0 0
σ
E
0
Thus, the electric field intensity outside the infinite conducting sheet of charge is equal to (1/�0) times the
surface charge density.
ELECTRIC POTENTIAL
The electric field around a group of charges can be described by electric field strength E. This can
also be described by a scalar quantity known as electric potential. Electric intensity and electric potential
are intimately related to each other.

Consider an electric field due to a positive charge +q as shown in figure. Let there be a positive test
charge +q0 in this field. This test charge experiences an electric repulsive force F due to +q. Suppose the
test charge is moved from a point B to another point A. Now some work has to be done against the force
of repulsion. The ratio of work done in taking a test-charge from one point to other point in an electric field
to the magnitude of the test charge is defined as the electric potential difference between these points.
If W be the work done in moving the test charge q0 from point B to point A, then the potential
difference between A and B is

ELECTRICITY, MAGNETISM & ELECTRONICS 212


SRI CHANAKYA DEGREE COLLEGE
Suppose the point B (taken as reference point) is chosen at infinity, then the electric potential q0 at this
infinite is arbitrarily taken as zero.

where W is the work done by an external agent to carry the test charge q0 from infinity to point A.
Thus, electric potential at a point in the electric field is defined as the work done by an external agent in
carrying a unit positive test charge from infinity to that point against the electric force of the field.
SI units: volt
One volt is defined as the difference in potential between the points so that one joule of work is done
in carrying one coulomb of positive charge from one point to other (1 volt = 1 joule/1 coulomb).
EQUIPOTENTIAL SURFACES
Equipotential surface in an electric field is a surface on which the potential is same at every point.
In other words, the locus of all points which have the same electric potential is called equipotential surface.
As the potential difference between any two points on the equipotential is zero, hence no work is done in
taking a charge from one point to another. This is only possible when the charge is taken perpendicular to
the field. In this way, the equipotential surface at every point is perpendicular to the field (lines of force).
Eg: (a) In case of uniform field, where the
lines of forces are straight and parallel, the
equipotential surfaces are planes perpendicular to
the lines of forces.
Eg: (b) For a sphere of charge or a point
charge, the equipotential surfaces are a family of
concentric spheres.
Equipotential surfaces in electrostatics are similar to wavefronts in optics. The wave fronts in optics
are the locus of all points which are in the (a) Equipotential Surfaces (b) Same phase. These planes
perpendicular to the direction of rays. On the other hand, the equipotential surfaces are perpendicular to
the lines of force.
In case of equipotential surfaces
(i) The electric field along the equipotential surface is zero.
(ii) The electric field is always normal to the surface.
(iii) The work done in moving a charge on the equipotential surface is zero.
Work done = potential difference x charge = 0 x charge = zero.
(iv) When the charge is infinite, the equipotential surface is plane.
(v) The equipotential surfaces act as wave-fronts in optics.

ELECTRICITY, MAGNETISM & ELECTRONICS 213


SRI CHANAKYA DEGREE COLLEGE
POTENTIAL DUE TO A POINT CHARGE
Consider a point charge +q whose electric field E is
outward along radial line. Consider two points A and B along
radial line (for convenience). Let a test charge q0 be moved from
reference point A to B.
The force exerted by the field of charge q on test charge go is q0 E.
Now to move the test charge go towards B, a force - q0 E must be applied. The work done by external agent
to move the charge q0 through a small distance dr is given by

Now the total work done in moving the test charge q0 from A to B is

Where rA is the distance from A to B

The Potential difference between two points will be

To find the potential at point B, the reference point A is taken at infinity so that VA = 0. Hence,

On dropping the suffix, the required expression becomes

This expression shows that at a distance r on all sides of charge q, the potential is the same. So for an
isolated charge equipotential surfaces are sphere concentric with the point charge.
ELECTRIC POTENTIAL DUE TO CHARGED CONDUCTING SPHERICAL SHELL
A spherical shell is a conducting hollow sphere of negligible thickness. Let R be the radius of
spherical shell and σ be the charge density (charge per unit area). The total charge (q) on the spherical shell
is given by
q = area x charge density = (4 πR)2 σ

ELECTRICITY, MAGNETISM & ELECTRONICS 214


SRI CHANAKYA DEGREE COLLEGE
Case 1: When a point lies outside the shell
Let P be an external point at a distance r from the centre O of spherical shell. To calculate the
electric potential at point P, draw a spherical shell (Gaussian surface) with centre O and radius OP = r as
shown by dotted line. The electric field strength E at every point on the spherical shell will have the same
magnitude and direction along the outward normal drawn to the surface at that point. The total normal
electric flux over the whole Gaussian surface will be

According to Gauss's law,

Substituting the value of E above eq., we get

Case 2: When the point lies on the surface of the shell


In this case r = R (radius of the shell)

Now, the electric potential on the surface of the shall is given by

Case 3: When the point lies inside the shell


Let P be a point inside the hollow spherical shell as shown in shell. Now draw Gaussian spherical
surface with centre O and radius = OP. The Gaussian surface is shown by dotted line.
The charge enclosed by Gaussian surface is zero. Therefore,
the electric field inside hollow conducting spherical shell is zero.

Therefore, the potential inside the shell is given by

Inside the shell, the potential is constant and this is same as on the surface of the shell. The variation
of electric potential due to a charged conducting spherical shell is shown in figure.

ELECTRICITY, MAGNETISM & ELECTRONICS 215


SRI CHANAKYA DEGREE COLLEGE

POTENTIAL DUE TO UNIFORMLY CHARGED SPHERE (Non-Conducting Sphere)


We know that the expressions of electric field in case of uniformly charged sphere are
Case 1: At a point outside the charged sphere, the electric field

where r is the distance of the point from the center, and q is the uniformly distributed charge on the sphere.
Potential at a point outside the charged sphere

Substituting the value of E in above equation, we get

Case 2: At a point on the surface of charged sphere, the electric field

where R is radius of the sphere.


On the surface of the charged sphere r = R. Therefore, electric potential

3. At a point inside the charged sphere, the electric field

Now, we the electric potential will be

ELECTRICITY, MAGNETISM & ELECTRONICS 216


SRI CHANAKYA DEGREE COLLEGE
1.2 DIELECTRICS
Dielectrics are the substances which do not contain free electrons or the number of such electrons is
too low to constitute the electric current. In dielectrics, the electrons are tightly bound to the nucleus of the
atom. Mica, glass, plastic, etc. are examples of dielectrics. Faraday, first of all realized the importance of
dielectrics in electrical phenomena. He introduced a slab of dielectric medium between the plates of a
parallel plate condenser and found that the charge on the capacitor with dielectric is greater than that
without. Thus, the capacitance of the capacitor increases because the charge is larger.
The dielectrics are used for
(i) maintaining two large metal plates at very small separation.
(i) increasing the potential difference So that a capacitor can withstand without breakdown.
(iii) increasing the capacitance of a capacitor.
Difference between dielectrics and conductors
Following are the differences between dielectrics and conductors

Dielectric Conductor
(i) It is a material which does not contain free Conductors contain a fairly large number of free
electrons. The electrons are tightly bound to the electrons. The free electrons wander through the
nuclei of atoms. conducting material
(ii) The dielectric does not conduct electricity. Conductors conduct electricity
(iii) The charge given to a dielectric remains The Charge resides on the surface in case of
localized conductor
(iv) For a particular field strength (breakdown Conductivity increases with field strength
strength), the dielectric loses its insulation
character.
ELECTRIC DIPOLE MOMENT
The arrangement of two equal and opposite point charges at a fixed distance is called an electric
dipole. The product of the magnitude of either charge and the distance between the charges is called the
electric dipole moment.

Suppose the charges of dipole are - q and +q coulomb and the distance of separation is 2l metre. Then the
electric dipole moment p is given by
p = q x 2l = 2ql
The electric dipole moment is a vector quantity. Its direction is along the axis of dipole pointing to
the negative charge to the positive charge. The unit of dipole moment is coulomb-metre. Here it should be
remembered that the atom consisting of positive charges and negative charge not a dipole. The reason is
that the centre of positive charges and the centre of negative charges coinside with each other, i.e., 2l=0.

ELECTRICITY, MAGNETISM & ELECTRONICS 217


SRI CHANAKYA DEGREE COLLEGE
But when the atom is placed in an electric field it becomes a dipole because the positive and negative
centres are displaced relative to each other.
TYPES OF POLARIZATION AND POLARIZABILITIES
There are four different mechanisms by which electrical polarization can occur in dielectric materials when
they are subjected to an external electric field. They are:
1. Electronic polarizatlon
2. Ionic polarization
3. Orientational polarization
4. Space charge polarization
1. Electronic polarizatlon
The electronic polarization occurs due to the displacement of positive and negative charges in
dielectric material when an external electric field is applied. Figure (a) shows the charge distribution of an
atom in the absence of the field while Fig. (b) shows the charge distribution in presence of applied electric
field. This process occurs throughout the material and
the material as a whole is polarized.
On the application of electric field, the
displacement of positively charged nucleus and
negatively charged electrons of the atom in opposite
directions, results in electronic polarization.
As the nucleus and the centre of electron cloud are separated by a certain distance, dipole moment is created
in each atom.
The induced dipole moment (pe) is proportional to field strength (E), i.e. p ∝ E.
If there are N atoms in the dielectric, then
P ∝ N E or P = αe N E
where αe is electronic polarizability. The electronic polarizability is independent of temperature.
2. Ionic polarization

Ionic polarization occurs only in those dielectric materials having ionic bonds such as NaCl. When
such a material is subjected to an external electric field, the adjacent ions of opposite signs undergo
displacement as shown in Fig (b). The displacement causes an increase or decrease in the distance
separation between the atoms depending upon the location of ion pair. This leads to a net dipole moment.
Therefore, the ionic polarization (αi) is due to displacement of cations and anions in opposite directions.

ELECTRICITY, MAGNETISM & ELECTRONICS 218


SRI CHANAKYA DEGREE COLLEGE
The polarizability in this case is known as ionic polarizability. This occurs in ionic solids. This polarization
is also independent of temperature.
3. Orientational Polarization
Polar dielectrics (such as CH3Cl) exhibit orientational or dipolar polarizability. Even, in absence of
external electric field, the polar dielectrics exhibit dipole moment. The orientations of the molecules are
random and hence the net dipole moment is zero. The dipole orientation is shown in Fig. (a).

When an external field is applied to polar dielectrics, they tend to align themselves in the direction of
external applied as shown in Fig. (b). The polarization due to such alignment is called orientation
polarization (αo). The orientational polarization is strongly temperature dependent. This decreases with
increase of temperature. The polarizability in this case is known as orientational polarizability.
4. Space-Charge Polarization
Space charge polarization occurs due to the accumulation of charges at the electrodes or at the
interfaces in a multiphase materials as shown in Fig. The ions diffuse over appreciable distance in response
to the applied field. This gives rise to redistribution of charges in the dielectric medium. The space-charge
polarization is not an important factor in most common dielectrics.

Among the different polarizations, electronic and ionic polarizations are insensitive to temperature
changes. The total polarization α of a material is sum of Electronic, ionic and orientational polarizations
i.e., α = αe + αi + αo
DIELECTRIC CONSTANT
We have studied that when a dielectric is placed between the plates of a condenser its capacity is
increased. The ratio of the capacitance of a condenser with dielectric to the capacitance of the same
condenser without dielectric is defined as dielectric constant.

C Capacitance of the condenser with dielectric


Thus, K  (1)
C0 Capacitance of the condenser without dielectric

ELECTRICITY, MAGNETISM & ELECTRONICS 219


SRI CHANAKYA DEGREE COLLEGE
Instead of maintaining the two capacitors at the same potential difference, we can give the same
charge to each capacitor. It has been observed that the potential difference Vd between the plates of the
capacitor filled with dielectric is smaller than the potential difference Vo without dielectric.
The ratio of potential difference without dielectric to the potential difference with dielectric is defined
as dielectric constant.
Hence,
Vo
K (2)
Vd
According to Coulomb's law, the force of attraction or repulsion between two electric charges of
magnitudes q1 and q2 separated by a distance r in free space is given by
1 qq
F0   12 2
4πò0 r
when the charges are placed in some other medium, then
1 qq
F  12 2
4πò r
Where ϵ and ϵ0 are the permittivity of the medium and permittivity of free space respectively.
F 0 1
 
F0  k

k (3)
0
F0
k (4)
F
From eq (3) the dielectric constant may be defined as the ratio of permittivity of the medium to permittivity
of free space.
From eq (4), the dielectric constant may also be defined as the ratio of force between two charges in vacuum
to the force between the same charges in dielectric medium.
Dielectric constant is a ratio. Its value is one for vacuum and ∞ for metals.
Capacitance of the capacitor with dielectric
�= =
Capacitance of the capacitor with air or vacuum ( without dielectric) �0

Permittivity of the medium �


�= =
Permittivity of free space

Force betweentwo charges in air
�= =
Force between the charges in dielectric

Potential difference without dielectric �0


�= =
Potential difference with dielectric

The maximum electric field strength which a dielectric can withstand without breakdown called as
dielectric strength of the medium.

ELECTRICITY, MAGNETISM & ELECTRONICS 220


SRI CHANAKYA DEGREE COLLEGE
ELECTRIC SUSCEPTIBILITY
When a dielectric is placed in electric field it is polarized. The polarization vector P is proportional the
electric field E. Hence,
P∝ E or P=χE
where the constant of proportionality χ is known as electric susceptibility. The electric susceptibility may
be defined as the ratio of polarization vector to the electric intensity in the dielectric.
The electric susceptibility may also be defined as the ratio of induced surface charge density produced in
the dielectric to the resultant electric field in the dielectric.
Conclusion
The electrical susceptibility is defined as follows:

Polarization produced in the dielectric


χ = =
Electric intensity in the dielectric �

Induced surface charge density produced in dielectric


χ = = �
Resultant electric field in the dielectric �

RELATION BETWEEN DIELECTRIC CONSTANT AND SUSCEPTIBILITY


The polarization P is proportional to electric field E within the dielectric, i.e.,
P ∝ E or P=χE
here χ is called as electric susceptibility of the medium.
We know that
D = �0 E + P
D = �0 E + χ E (D = � E)
� = �0 + χ
� χ
=1+ �
�0 0
χ = ��
� =1+

0
χ = (�� − 1) �0
This is the relation between susceptibility and dielectric constant.
THREE ELECTRIC VECTORS AND THEIR RELATIONS
The three electric vectors are: (i) Electric intensity, (ii) Dielectric polarization, and (iii) Electric
displacement.
1) Electric Intensity E:
The electric intensity E at any point in the electric field is numerically equal to the force experienced by a
unit positive charge placed at that point. The direction of E being the same as that of the field.
(2) Dielectric polarization P:
When a dielectric is polarized, the distorted atom is called an electric dipole. The electric dipole moment
per unit volume is called as dielectric polarization P.

ELECTRICITY, MAGNETISM & ELECTRONICS 221


SRI CHANAKYA DEGREE COLLEGE
(3) Electric displacement D
The electric displacement at a point is defined as the product of electric field strength (E) at that point and
the permittivity of the medium (�).
D = � E =k �0 E
In magnitude D is equal to the surface charge density (�) of free charges

�= = �

RELATION BETWEEN D, E and P
When a dielectric slab is placed between the plates of a parallel plate condenser, the medium is
polarized. Now, induced surface charges appear. The charge is negative on the surface nearer the positive
plate of the condenser and positive charge nearer the negative plate. Let q' be the induced surface charge.
Now the charge q on the plate of the condenser and induced surface charge q' are related as

… (1)

(3)
where D is called as electric displacement.
In terms of dielectric polarization P, a general form of the Gauss's law for E can be expressed as

Hence, dielectric displacement D is defined as a vector quantity whose surface integral charged surface
over any (the flux of D), is equal to the free charge only within the surface.

ELECTRICITY, MAGNETISM & ELECTRONICS 222


SRI CHANAKYA DEGREE COLLEGE
Important Points
The following points should be noted:
(i) D is connected with free charge only. It is not altered by the introduction of the dielectric. The lines
of D begin and end on free charges
(ii) P is connected with polarization charge only. The lines of P begin and end on polarization charges.
(iii) E is connected with all charges that are free or actually present whether free or polarization. E is
reduced inside the dielectric, where there are fewer lines.

D and P in terms of E

The vectors D and P are separately connected to E. We know that E

The product k is called the permittivity � of the medium and hence, D = � E. The ratio is also termed

�0 �0
as relative permittivity because k is a ratio.
Putting the value of D in eq. (3), we get

The constant �0 (k -1) in the above eq. is called as electric susceptibility χ of the dielectric. Hence,
P=χE
�0, k and χ are different ways of describing the property dielectric. These are related by relation:

ELECTRICITY, MAGNETISM & ELECTRONICS 223


SRI CHANAKYA DEGREE COLLEGE
BOUNDARY CONDITIONS AT THE DIELECTRIC SURFACE
The rules governing the behavior of E and D at the boundary between two dielectrics are known as
boundary conditions.
Following are the two boundary conditions:
(i) The normal component of electric displacement D is the same on both sides of the boundary of two
media of different dielectrics or the normal component of displacement vector is continuous across the
charge free boundary between two dielectrics.
(ii) The tangential components of the electrical intensities are the same (continuous) on both sides of the
dielectrics.
Derivation of Boundary Conditions
We shall derive these boundary conditions in the following way
1) Let AB represents a small portion of the boundary between two media of absolute permittivities �1 and
�2 as shown in fig. The media are assumed to be homogeneous and isotropic.

A medium with same properties at every point is homogeneous and a medium with same properties
in all directions is isotropic. We now consider a small area dS on the boundary so that its curvature may be
neglected. Suppose D1 and D2 are the electric induction vectors in the media on either side of dS
respectively. ϴ1 and ϴ2 are the angles which D1 and D2 make with the normal to dS. In order to find the
boundary condition for D, let us construct a small pill box shaped surface which intersects the boundary
with its end faces parallel to it. The height h of the pill box is assumed to be negligibly small in comparison
with the diameter of the base.
Applying Gauss's theorem to the pill box surface, we have
… (1)
Let D1n be the average normal component of displacement-vector D1 to the face of the pill box in
medium I and D2n, the average normal component of displacement vector D2 to the face of the box in
medium I. It should be remembered that D2n is along inward normal. Because the height of the pill box is
negligibly small in comparison to the diameter of the base, the only contribution of flux of D will come
through the end faces. Thus, by Gauss's law
… (2)

ELECTRICITY, MAGNETISM & ELECTRONICS 224


SRI CHANAKYA DEGREE COLLEGE
where q is the total charge enclosed by the surface. The second term of eq. (2) is negative because D2n and
dS oppositely directed.
From eq. (2)
… (3)
where � is the charge per unit area on the boundary of two dielectrics. Eq. (3) shows that the normal
component of the displacement vector D changes at the charged boundary between two dielectrics by an
amount equal to the surface charge density.
If the boundary is free from charge, then � = 0. Now, eq. (3) reduces to
… (4)
Thus, the normal component of displacement vector is continuous across the charge free boundary between
two dielectrics.
(2) In order to consider the boundary condition for E, let us consider a rectangle PQRS of small width and
its length parallel to the boundary separating two dielectrics as shown in fig.

The rectangle lies with its longest sides parallel to the boundary. Let E1 and E2 be the electric intensities
in two media. The directions of the electric field vectors make angles ϴ1 and ϴ2 with the normal to the
boundary. Now the work done in taking a unit charge around the rectangle PQRS must vanish, i.e.,

… (5)
Here we have neglected the contribution of short sides QR and SP as they are taken very small. From eq.
(5)
…(6)
Thus, the tangential component of the field is continuous at the boundary of two dielectrics.

ELECTRICITY, MAGNETISM & ELECTRONICS 225


SRI CHANAKYA DEGREE COLLEGE

UNIT-II
2.1 ELECTRIC AND MAGNETIC FIELDS
INTRODUCTION
In 1820, Oersted discovered that a compass needle suffers a deflection when brought near a current
carrying wire. This shows that an electric charge in motion produces a magnetic field in the space around
it. It should be remembered that a charge (whether it is stationary or in motion) produces an electric field
around it but when it is in motion, then in addition to electric field it also produces a magnetic field. So
magnetism and electricity are two aspects of a single phenomenon. Now-a-days, electricity and magnetism
are related by electromagnetism.
Origin of magnetism
The earliest experiences with the magnetism involved Magnetite, the only material that occurs
naturally in a magnetic state. This mineral was also known as Lodestone, after its property of aligning
itself in certain directions if allowed to rotate freely, thus being able to indicate the positions of North and
South, and to some extent also latitude. The other well-known property of Lodestone is that two pieces of
it can attract or even repel each other.

BIOT-SAVARTS LAW
According to Oersted experiment, a current carrying conductor produces a magnetic field around it
as shown in figure. The magnetic field exists as long as there is current in the conductor. French
scientists Jean-Baptiste Biot and Félix Savart performed a series of experiments to study the magnetic field
produced by various current carrying conductors in 1820. They obtained a relation to determine B at any
point of space around a conductor that carrying current. The relation is called as Biot and Savart law.

Explanation:
Let AB be a conductor of any arbitrary shape in which a current i is flowing. Let P be a point at
which field is to be determined. According to Biot and Savart, the field B at any point can be computed by
dividing the conductor into short current elements.

ELECTRICITY, MAGNETISM & ELECTRONICS 226


SRI CHANAKYA DEGREE COLLEGE
Let dl be the length of one such element and r be the displacement vector of point P from this element.
According to Biot and Savart, magnetic field dB due to small element dl at P depend the following
(i) It is directly proportional to the current i flowing through the conductor
i.e., dB ∝ i
(ii) It is directly proportional to the length dl of the element
considered i.e., dB ∝ dl
(iii) It is directly proportional to the sine of the angle θ between
length of element and the line joining the element to the point P
i.e., dB ∝ sin θ
(iv) It is inversely proportional to the square of the distance r of the point P from the element dl
1
i.e., dB 
r2
Combining all these factors
i dl sin
dB 
r2
When the conductor is placed in vacuum or air, then
0 i dl sin
dB  (1)
4 r2
0
where is proportionality constant, is the permeability of free space.
4 �0
In vector form,
0 i dl  r
dB  
4
where r is the unit vector in the direction of the line drawn from the current element dl to the point of
observation P. This is known as position vector. The resultant field at P can be obtained by integrating eq.
(1).

� = ∫ ��

DIRECTION OF B
The direction of dB will be perpendicular
to the plane containing dl and r. This is given
by right hand rule. If magnetic field is directed
perpendicular and into the plane of the paper,
then it is represented by cross. When the
magnetic field is directed perpendicular and out
of the plane of the paper. it is represented by
dot.

ELECTRICITY, MAGNETISM & ELECTRONICS 227


SRI CHANAKYA DEGREE COLLEGE
MAGNETIC FIELD DUE TO LONG STRAIGHT CONDUCTOR (WIRE) CARRYING
CURRENT
Consider an infinitely long wire placed in vacuum and
carrying a current i ampere as shown in fig. Let the distance of P
from the conductor be R. O is the foot of the perpendicular from
P to the conductor. Consider a small element AB of length dl of
wire at a distance from O. Let r be the distance of the element from
the point P. Suppose θ be the angle in clockwise direction which
the direction of current makes with the line joining the element to
point P. According to Biot and Savart, magnetic field induction
‘dB’ at ‘P’ due to the small element ‘AB’ is given by

μ0 i dl sinθ
dB = (1)
4π r2
From figure,
1

r = l + R
2 2
,
2

R
sin 180 - θ = sinθ =
r
Substituting these values in the above equation
μ0 i dl R
Now, dB = 4π 3 (2)
l 2 +R 2  2

The magnetic field induction ‘B’ at ‘P’ due to the entire conductor is
 
0
B  dB   i dl R 3 (3)
4
 
l 2
 R2 2
In order to evaluate the integration substitute

l = R tanα , dl  R sec2α dα

The limits of integration under this substitution become − �� instead of -∞ to ∞

2 2

Then
2
 iR2 sec2 

0
B= d
 4  R 2 tan2  R2 32
2
 
i 2 sec2  d  0i 2 R2 sec2  d
 0 
4 R  1 tan  4 R  R 1 tan2   2
3 3
2 2 3
2 2

 0i sec   1 tan 2   sec 2 



2 2
= d
 3
4 R  sec 
2

ELECTRICITY, MAGNETISM & ELECTRONICS 228


SRI CHANAKYA DEGREE COLLEGE
0i
i

12 d  

2
 
 0  cos d
4 R  sec 4 R 
2 2

0i 
= 
2
4 R
   
2

0i sin  sin 


 4 R 2  2 
  
i
 0 11
4 R
i
B 0 web/m2 or tesla
2 R
Hence, this is the expression for the magnetic field induction near a long straight conductor.
MAGNETIC FIELD ON THE AXIS OF A CIRCULAR LOOP (COIL)
Consider a circular loop of radius a and carrying a current i. P is a point on the axis of the coil at
distant x from the centre. We are required to calculate the field at point P. Consider a small element AB of
length dl.

Let r be the distance of the element from the point P and θ be the angle which the direction of current
makes with the line joining the element to the point O. The magnetic field dB at point P due to current
element AB of length dl is given by

0 i dl  r  μ0 i dl sinθ
dB  
4 r3 4π r2
μ0 i dl
dB = ( θ  900 )
4π r2
The vector dB at P is perpendicular to r. This can be resolved into two components dB cos ϕ and dB sin ϕ.
Here dB cos ϕ at right angle to axis and dB sin ϕ along the axis of the coil.
If we take another element A'B' diametrically opposite to AB of the same length, it will also produce
magnetic field dB' at P. The direction of dB' will be opposite to the previous one and equal in magnitude.
This can also be resolved into components dB cos ϕ and dB sin ϕ. The components along the axis will add
up while the components perpendicular to the axis will cancel. Similarly, if we divide the whole circular
coil into a number of elements, the vertical components will cancel while the components along the axis
will add up.

ELECTRICITY, MAGNETISM & ELECTRONICS 229


SRI CHANAKYA DEGREE COLLEGE
The magnetic field induction at P due to the circular coil is given by

B   dB sin 
a  a
from fig., sin  
B   4π r  
μ0 i dl2
r  r
   
μ ia
 0 3  dl
4π r
μ0i a
=
3
2π a
4π r
μ 0i a2
=
2 r3
1

From figure, r =  a + x2 2
2

μ i a2
B = 0

2 a2 + x2  2
3

If the coil has N turns then


μ0i a 2 N
B= web/m2 or tesla
2  a 2 + x2  2
3

The direction of B is along the axis of the coil as shown in fig.


Different Cases
(i) If point at the center of the coil i.e., x = 0.
Thus, Magnetic field at the center of the coil
μ i Na2 μ Ni
B= 0
 0
2a3 2a
(ii) At very far off from the loop x >> a and (a2 +x2)3/2 = x3 then
μ i Na2
B= 0 3
2x
MAGNETIC FIELD INDUCTION DUE TO A SOLENOID
A long, tightly wound helical coil of wire is called as solenoid. Generally, the coil is wound as a spiral
on a cylinder of non-magnetic material. The length of the solenoid is far greater than its diameter. The
current is passed in the solenoid by a battery B as shown in the
figure.
Consider a long solenoid of length l metre and radius a
metre. Let N be the total number of turns. Then the number of
turns per metre will be n = N / l. Suppose the solenoid carries
current i ampere.

ELECTRICITY, MAGNETISM & ELECTRONICS 230


SRI CHANAKYA DEGREE COLLEGE

Now, we shall calculate the field in the following cases


(i) Field at an inside point of the solenoid
For this purpose we divide the solenoid into a number of narrow equidistant coils. We consider one small
coil of width dx. Now the coil has ndx turns. Let x be the distance of point P from the centre O of the coil.
The field at P due to elementary coil of width dx carrying a current i is given by

μ 0i a2 ndx
dB = web/m2 or tesla (1)
2 a + x 
3
2 2 2

From figure, consider ∆ABC, we have


rdθ rdθ
sinθ =  dx =
dx sinθ
From ΔAPO,

a 
3/ 2
a2 + x2  r 2  2
+ x2  r3

Substituting these values in eq. (1), we get


 rdθ 
μ i a2 n
0   μ ni a2dθ
sinθ
dB = = 0 2
2r3 2r sinθ
2
μ ni dθ  a 
 0  
2sinθ  r 
μ ni dθ
 0 sin2θ
2sinθ
μ0ni dθ sinθ
dB  (2)
2
The field induction B at P due to whole solenoid can be obtained by integrating the above eq. (2)
between the limits θ1 and θ2. θ1 and θ2 are the semi-vertical angles subtended at P by first and last turns of
the solenoid respectively.

ELECTRICITY, MAGNETISM & ELECTRONICS 231


SRI CHANAKYA DEGREE COLLEGE
The magnetic field induction B at P due to solenoid is
2
μ i n 2
B   dB  0
2 
sinθ dθ

1 1
μ0 i n μ0 i n
 cos θ 2
 - cos θ + cos θ 
1

2 1
2 2
μ0 i n
B cos θ - cos θ  (3)
1 2
2
(i) At any axial point P when it is well inside a very long solenoid, θ1 = 0 and θ2 = π.
Hence,
μ0 i n
B = cos 0 - cos  
2
μ0 i n
= [1-(-1)]
2
B = μ0in (4)

(ii) Field at an axial end point


Now, θ1 = 0 and θ2 = 90o
Hence,
μ0 i n
B = cos 0 - cos 90
2
μ in
= 0 [1- 0]
2
μ0in
B= (5)
2
This shovws that the field at either end is one half of its
magnitude at the centre.
The variation of B with distance from the centre of a solenoid
is shown in figure

(ii) Field at the centre of a solenoid of finite length l


Consider that point P is at the centre, i e, it is a distance l/2 from either end.
In this case,
l
adjacent side l
cos θ1 =   2 2 
4a  l 2 
1/ 2
a   l 2 1/ 2 2
hypotenuse
   
  2  

ELECTRICITY, MAGNETISM & ELECTRONICS 232


SRI CHANAKYA DEGREE COLLEGE
l l
cos   θ =  2
2 
4a  l2 
1/ 2
a   l 2 
2 1/ 2 2

   
  2  
cos θ  l  cos   θ    cos θ 
 2
4a  l2 
2 1/ 2 2
2

l
cos θ 
 l2  4a
2 1/ 2
2

Putting these values in eq. (3), we get


 
μ in l l
B  0 2  2 2 1/ 2 + 1/ 2 
4a  l  4a2  l 2  
 
 
μ in 2l
B  2  2 2 1/ 2 

4a  l 
0

 
μ0 i nl
B
4a  l2 
1/ 2
2

μ0 i N
B (6)
4a  l 
2 2 1/ 2

This expression gives the field at the centre of the solenoid of finite length.

Lines of Magnetic Induction


The lines of magnetic induction inside and around the solenoid are shown as follows.

LORENTZ FORCE
1. When a charged particle having charge (q) moves in an electric field (E), tho things can be observed
(i) If the charged particle moves in the direction of electric field, it experiences a force q E in tne direction
of electric field. As a result, the charge particle is accelerated in the direction of electric field.
(ii) If the charged particle moves in the opposite direction of electric field, it experiences a retarded force
-q E. As a result, the charged particle is decelerated.
2. When a charged particle having charge q travels with velocity v is a magnetic field B, it experiences a
force F= q(v × B) or F = qvB sin θ

ELECTRICITY, MAGNETISM & ELECTRONICS 233


SRI CHANAKYA DEGREE COLLEGE
Now,
(i) If the particle is rest in magnetic field (i.e., v = 0) then the particle will not experience any force.
(ii) If the particle is moving along the magnetic field, then v and B are parallel (i.e., θ =0). Hence, the
particle will not experience any force.
(iii) If the particle is moving perpendicular to magnetic field, it experiences a maximum force denoted by
Fm
The force on a charged particle moving in electromagnetic field (electric and magnetic field both) is
known as Lorentz Force.
The force in electric field = q E
The force in magnetic field = q (v x B)
Therefore, Lorentz Force F  qE  q(v  B)  q[E  (v  B)]

HALL EFFECT
Hall effect was discovered by E.H. Hall in 1879. According to Hall Effect, when a magnetic field is
applied perpendicular to a current carrying conductor, a potential difference is developed between the
points on opposite side of the conductor. This effect gives information about the sign of charged carriers
in electric conductor.
Consider a uniform, thick metal strip placed with its length parallel to X-axis. Let a current i be passed
in the conductor along X-axis and a magnetic field B be established along Y-axis. Due to the magnetic
field, the charge carriers experience a force F perpendicular to X-Y plane, i.e., along Z-axis. The direction
of this force is given by Fleming's left hand rule.

If the charge carriers are electrons, then they will experience a force in the positive direction of Z.
Hence, they will be accumulated on the upper surface of the strip, i.e., on face PQNM as shown in fig. Due
to this fact the upper side will be charged negatively while the lower side will be charged positively. Thus,
a transverse potential difference is created. This e.m.f. is known as Hall e.m.f.
If the charge carriers are positively charged particles like protons or holes, the sign of e.m.f. is
reversed. Thus, we can find the nature of charge carriers by determining the sign of Hall e.m.f. by a
potentiometer. Experiments showed that the charge carriers in metals are electrons, while the charge
carriers in P-type semiconductors are holes. Holes behave like positively charged particles. As discussed

ELECTRICITY, MAGNETISM & ELECTRONICS 234


SRI CHANAKYA DEGREE COLLEGE
above, there is a displacement of charge carriers. This gives rise to a transverse field known as Hall electric
field EH . This field acts inside the conductor to oppose the sideway drift of the charge carrier.

Hall Field and Hall Voltage


When the equilibrium is reached, the magnetic deflecting forces on the charge carriers are balanced
by the electric forces.
Magnetic deflecting force = q (vd x B)
Hall electric deflecting force = q EH (EH is Hall field)
As the net force on the charge carriers becomes zero
F  qEH  q(vd  B)  q[EH  (vd  B)]  0

EH  (vd  B)  0 or EH  (vd  B)
Writing in terms of magnitude only
EH  vd B (1)
We know that drift velocity vd is related to the current density j by the following relation, i.e.,
j
vd   j  nqvd  (2)
nq
where n is the number of charge carriers per unit volume. Substituting in eq. (1), we get
 1 
E  jB (3)
H  
 nq 
If VH is the Hall voltage in equilibrium, then
V  (4)
EH   H 
d
 
where d is the width of the bar.
Hall Coefficient
The ratio of Hall electric field EH to the product of current density j and magnetic induction B is known
as Hall coefficient. This is denoted by RH . So

E 
RH   H 
jB
 
EH  1 
 
jB  nq 

From eq.(3)
 1 
R 
H  
 nq 
Thus, measuring the potential difference VH between the two faces, EH can be calculated using eq. (4).
By measuring current i in the slab, the current density can be calculated by using (i/A), where A is

ELECTRICITY, MAGNETISM & ELECTRONICS 235


SRI CHANAKYA DEGREE COLLEGE
the area of cross-section of the slab. The magnetic field B can be measured by a Gauss-meter. So,
 1 
substituting the values of E , j and B in eq. (3), we can calculate the value of .
H  
 nq 
The Hall coefficient is negative when the charge carriers are electrons and positive when charge
carriers are holes.
Determination of Hall Coefficients
The arrangement for measurement of Hall voltage is shown in Fig.
A rectangular slab of given material is taken. A current (say i) is passed in this slab along X-direction with
the help of battery and rheostat Rh. The slab is placed between the pole piece of an electromagnetic such
that magnetic field is in a perpendicular direction of current (say in Y-direction). A voltmeter is connected
in Z-direction as shown in figure. The voltmeter measures the Hall voltageVH . By measuring current i in
the slab, the current density can be calculated by using (i/A), where A is the area of cross-section of the
slab. The magnetic field B can be measured by a Gauss-meter. Hall electric field can be measured using
formula E   VH  . So, substituting the values of E , j and B in eq. (3), we can determine the value of
H  d  H
 
Hall coefficient R   EH 
H  jB 
 

APPLICATIONS OF HALL EFFECT


Following are the applications of Hall effect:
(i) Hall effect gives information about the sign of charge carriers in electric conductor. It is found that
most metals have negatively charged electrons.
(ii) Hall effect is quite helpful in understanding the electrical conduction in metals and semiconductors.
(iii) Hall effect can be used to measure the drift velocity of the charge carriers. We know that
j
vd 
nq
where n is the number of charge carriers per unit volume, j is current density and q is the charge on
charge carrier.
(iv) Measurement of Hall coefficient gives the number of current carriers per unit volume. If n be the
number of charge carriers per unit volume and A be the face area of plate, then

ELECTRICITY, MAGNETISM & ELECTRONICS 236


SRI CHANAKYA DEGREE COLLEGE
i  nqAvd
EH
v 
d
B
 EH 
 i  nqA
 B 
 
Let L be the breadth and d the width of face area of conductor, then A = L d. So
 EH 
i  nqLd
 B 
 
 iB 
n  
 qLdEH 
For metals, the Hall coefficient is smaller than that for semi-conductors. The carrier
concentration in semiconductor is much smaller. Hence, Hall effect devices use semiconductors
rather the metals.
(v) The mobility of the caier can be measured by the conductivity of the material and Hall electric field

   EH

ELECTRICITY, MAGNETISM & ELECTRONICS 237


SRI CHANAKYA DEGREE COLLEGE
2.2 ELECTROMAGNETIC INDUCTION
The existence of the magnetic field due to the current flowing in a conductor was first discovered by
Oersted. Ampere derived the expression for the intensity of the magnetic field. Faraday estimated the
possibility of producing current from the magnetic field in 1831. He discovered that changing magnetic
flux changing with time gives rise to current. It stands as long as the change lasts. The induced e.m.f. giving
rise to such currents is called the induced electromotive force and the phenomenon is called electromagnetic
induction.
INDUCED EMF
Let us consider the magnet and a coil experiment. When the magnet
is moved towards the coil, the flux through the coil, increases. When the
magnet is moved away from the coil, the flux through the coil decreases.
In both the cases an induced e.m.f. is obtained in the coil during the
motion of the magnet.
FARADAY'S LAWS OF ELECTROMAGNETIC INDUCTION
1st law: Whenever the magnetic flux B linked with the coil changes an e.m.f is induced in it. This e.m.f
exists as long as the flux changes. If the flux is constant, there is no induced e.m.f.
2nd law: The magnitude of the induced e.m.f is directly proportional to the negative rate of change of
magnetic flux B .

� ) (1)
�= −(

This law is also known as Neumann's law.


���
If there are N turns in the coil, then � = −� ( )
��

Integral and Differential forms


Consider a closed circuit C of any shape which encloses a surface S and
magnetic field is produced by a stationary magnet or current carrying coil.
Let B be the magnetic flux density in the neighborhood of the circuit. The
magnetic flux through a small area dS will be B dS. Now the flux through the
entire circuit is

Φ� = ∫� �. (2)
��.
When magnetic flux is changed, an electric field is induced around the circuit. The line integral of the
electric field gives the induced e.m.f. in the closed circuit.

� = ∮ �. �� (3)
Where E is the electric field at an element dl of the circuit. Substituting the values of e and �� from
eqs. (3) and (2) in eq. (1), we have

ELECTRICITY, MAGNETISM & ELECTRONICS 238


SRI CHANAKYA DEGREE COLLEGE
This is the integral form of Faraday’s law.
The line integral of the electric field around any closed circuit is equal to the negative rate of change of
magnetic flux through the circuit.
By Stokes theorem,
From eqs. (4) and (5), we get

From the above equation or


This is the differential form of Faraday’s law
Faraday's law gives the correct direction of induced e.m.f. or current. Let us consider that north pole
is approaching the coil. The magnetic flux is increasing in a direction away from the observer. In this case,
(d∅ /dt) is negative i.e., (-(d∅ /dt)) is positive. Hence, this gives rise an e.m.f. and current in anticlockwise
direction.

On the other hand, when the north pole is moved away from the coil, then (d∅ /dt) is positive i.e.,
(-(d∅ /dt)) is negative. This gives rise to a clockwise e.m.f. and current in the coil.

Example 1: Consider a coil of wire connected in series with a


galvanometer. When a magnet is inserted in the coil, the galvanometer
shows a deflection in one direction and when it is withdrawn from the
coil, the galvanometer shows the deflection in the other direction. This
indicates a momentary current in the coil. When the magnet is
stationary, there is no deflection in the galvanometer.
If the experiment is repeated with other pole of magnet facing the coil, deflections are reversed. It is
further observed that when the magnet is moved fast, the deflection in the galvanometer is large when it is
moved slowly, the deflection is small, i.e, the deflection depends upon the rate at which magnet is inserted
or withdrawn.
Example 2: Consider a circuit in which a primary coil P
connected to a battery and secondary coil S connected to a
galvanometer. When the circuit is closed by pressing the key K
and then broken, the galvanometer connected in the secondary
shows a deflection first in one direction and then in the other
direction. It is observed that no deflection is produced in the
galvanometer if the current in the primary circuit flows continuously. The deflection is produced in the
galvanometer only at make and break.

ELECTRICITY, MAGNETISM & ELECTRONICS 239


SRI CHANAKYA DEGREE COLLEGE
Similar effects are observed while increasing or decreasing the primary current or changing the relative
position of the coils.
Lenz’s Law:
This law gives the direction of the induced e.m.f. The induced e.m.f (or current) will always act in
a direction such that it opposes the cause which has produced it.
The law is based on the principle of conservation of energy.
Thus, when the applied flux density B in a closed circuit is increasing,
the e.m.f. or current induced in the closed circuit is in such a direction
as to produce a field which tends to decrease B.
On the other hand, when the applied flux density is decreasing
in magnitude the current in the closed circuit is in such a direction as
to produce a field which tends to increase B.
Thus, the induced current is in a direction such that it produces a magnetic flux tending to oppose the
original change of flux, i.e, tending to keep the total flux constant in the circuit. Suppose the north pole of
the magnet is moved towards a coil connected to a galvanometer as shown in fig. As the magnet is pushed
towards the circuit, an induced current is set up in the coil.
The induced current produces its own magnetic field. Now the coil behaves as a magnet. The face of
the coil towards the north pole of the magnet becomes a north pole. So, there will be a force of repulsion
between them. Due to this force of repulsion, the motion of the magnet is opposed. This causes a change
of magnetic flux in the coil. Thus, the direction of induced current is such that it opposes the motion of the
magnet.
Conclusion
When the north pole N is approaching the coil, then magnetic flux is increasing through the coil i.e., induced
e.m.f. and current are set up in the coil.
According to Lenz's law, the induced current should be such that the motion of north pole towards the coil
is opposed. This is possible when there arises a north pole on the face of coil. As a result, the Current flows
in anticlockwise direction.
SELF INDUCTION
The phenomenon of self induction was discovered by J. Henry (American) in 1832. When a current
flows in a coil, magnetic field is set up in it. If the current in the coil changes with time, an induced e.m.f.
is set up in the coil. According to Lenz's law, the direction of induced e.m.f. is such as to oppose the change
in current. When the current increasing, the induced e.m.f. is against the current and when the current is
decreasing it is in the direction of current. So the induced e.m.f. opposes any change of the original current.
The phenomenon is called self induction.
The phenomenon of production of an induced emf in a circuit itself due to variation of current through
the same circuit (increasing or decreasing) is called self-inductance.
The property of the circuit by virtue of which any change in the magnetic flux linked with it, induces
an e.m.f. in it, is called inductance and the induced e.m.f. is called back e.m.f.

ELECTRICITY, MAGNETISM & ELECTRONICS 240


SRI CHANAKYA DEGREE COLLEGE
When the current in a coil is switched on, self induction opposes the growth of the current, and when
current is switched off, the self induction opposes the decay of current.
Coefficient of Self Induction or Self Induction (L)
The total magnetic flux D is proportional to the current i, flowing through it, i.e.

where L is a constant called the coefficient of self induction or self inductance of the coil.
Hence, the coefficient of self induction is numerically equal to the magnetic flux linked with the
coil when unit current flows through it.
The e.m.f. induced in the coil is given by

The negative sign indicates that the induced e.m.f. is in such a direction as to oppose the change the
coefficient of self-inductance is numerically equal to the induced e.mf. in the course when the rate of
change of current is unity.
��
= 1, � = −�
��
The unit of self-inductance is henry

INDUCTANCE OF LONG SOLENOID


Consider a long air core soleniod (of small diameter) of length and uniform cross-section area/metre
A metre. Let n be the number of turns per metre. Suppose a current i
amp. flows through it. The magnetic field inside the solenoid is given
by

B  0ni weber/metre
Magnetic flux through each turn
B  B * A  0niA weber
Now the magnetic flux linked with all the turns of solenoid

B  0niAN weber turn


where N is equal to total number of turns in the solenoid.

The self inductance of the solenoid is therefore.

ELECTRICITY, MAGNETISM & ELECTRONICS 241


SRI CHANAKYA DEGREE COLLEGE
Li=Total flux linked with the solenoid

where n is number of turns per unit length.


In terms of total number of turns N of the solenoid

The self inductance L depends upon:


(i) Length of the coil (l)
(ii) Number of turns in the coil (N)
(iii) Cross-sectional area of the coil (A).
ENERGY STORED IN MAGNETIC FIELD
Consider a very long solenoid of length l and cross-sectional area A. When a current flows in it, magnetic
field is established. This field is uniform inside and negligible outside. So the volume associated with the
magnetic field is A l.
We have seen that the amount of work done in establishing a current i in the solenoid is (L i)
where L is the inductance of solenoid. The work done is stored as energy in the magnetic field.

The inductance of the solenoid is given by

where n is number of turns in solenoid per metre

The magnetic field inside the solenoid

So the energy density (energy per unit volume) u in magnetic field is given by

ELECTRICITY, MAGNETISM & ELECTRONICS 242


SRI CHANAKYA DEGREE COLLEGE
COEFFICIENT OF MUTUAL INDUCTION

Consider two coils placed near to each other as shown in fig. When a current is passed in the primary coil
P, there is a change of magnetic flux linked with it, and an induced e.m.f. is set in the secondary coil S.
This phenomenon is called mutual inductance. Just as the primary circuit produces an induced e.m.f. in the
secondary, similarly the secondary circuit also induces an e.m.f. in the primary. Hence, the total induction
through the secondary during the time the induced current lasts in it, is the difference between the
inductions due to primary and secondary Any two circuits in which there is mutual induction are known as
mutually coupled circuit. Leta current i amp. in primary Produces a magnetic flux D in the secondary S.
For two given coils situated in fixed relative positions, it is observed that the flux linked with the secondary
is proportional to the current in primary. Thus,

where M is a constant called the "Coefficient of Mutual induction" or "Mutual inductance" of the two coils.
The e.m.f. induced in the secondry S is given by

The egs. (1) and (2) enable us to define the mutual inductance in the following two ways: 1. fis the flux
linked with a clrcult due to u unit current Jlowing through the other. 2. Itis the emf, induced in the cireui,
when the rate of adecay of eurrent in the other cireuit is unig: The unit of mutual inductance is henry. It is
the mutual inductance of two circuits when the current changing at the rate of one amp/sec in one circuit
induces an e.m.f. of I volt in the other eireuit. Important: Let 2 be the flux through coil 2 due to a current 4
in coil 1, then

where M21 is called as coefficient of mutual induction or mutual inductance of coil 2 due to coil 1. Let 2
be the flux through coil 1 due to a current in coil 2, then

where M2 is called as coefficient of mutual inductance of coil 1 due to coil 2.

ELECTRICITY, MAGNETISM & ELECTRONICS 243


SRI CHANAKYA DEGREE COLLEGE
Distinction between Self induction and Mutual induction
S.No Self induction Mutual induction
1 When the current flowing in a coil is When the current flowing in a coil is changed, an
changed, an induced current is prodced in induced current is prodced in the col itself. This
the col itself. This is called as self- is called as self-induction.
induction.
2 The induced current affect the main 2. The induced current flows in the other coil. It
current. does not affect main current of primary coil
3 There is only one coil in it There are 2 miorr

MUTUAL INDUCTANCE OF TWO GIVEN COILS


Consider a long air cored solenoid with primary A and secondary B as shown in fig. (12).
Let number of turns in the primary =n
length of primary coil =l
area of cross-section = a
number of turns in secondary = n2 current in the primary = i
Magnetic field inside the primary =4oiweber/metre2
Magnetic fux through each turn of primary

Since secondary is wound closely over the central position of primary and hence, the same flux i also linked
with each turn of the secondary. . Total magnetic flux linked with secondary

If M be mutual inductance of the two coils, the total flux linked with the secondary is M i

TRANSFORMER
Construction a transformer is an A.C. static device which transfers electric power from one circuit to
another. i can raise or lower the voltage in a circuit but with a corresponding decrease or increase in current.
Here it is worth mentioning that while transferring the power, frequency is not altered. A transformer is a
device which allows a voltage change in an A.C. supply voltage with small on of power Fig. shows a basic
transformer.

ELECTRICITY, MAGNETISM & ELECTRONICS 244


SRI CHANAKYA DEGREE COLLEGE

Construction
The transformer consists of two coils. One is known primary coil (P) while the other is knowns
secondary coil (S). The two separate coils (primary and secondary) are wound on the same ferromagnetic
core as shown in fig. Due to magnetic core, the mutual inductance between the two coils will be minimum.
The two coils are electrically insulated but they are connected magnetically. The energy from one coil is
transferred to other coil by means of magnetic coupling. The coil which receives energy from an A.C.
source is called primary (P) and the coil which delivers the energy to load is called secondary (S) as shown
in fig.

The number of turns in the primary are expressed by N, while the number of turns in secondary are
expressed by N2. The ratio N2/N1 is called as Turns ratio or Transformer ratio. This is represented by a.
When the number of turns in secondary (N2) is more than the number of turns in primary (N1) i.e., N2> N1
then the transformer is known as step-up transformer. When the number of turns is primary (N1) is more
than the number of turns in the secondary (N2) i.e., N1> N2, then the transformer is known as step-down
transformer.
Principle
A transformer operates on the principle of mutual induction. When an alternating voltage is applied
to the primary, an alternating current is set up in it. As the winding is linked with a magnetic e.m.f., it
produces an alternating flux in the core. This alternating flux links with the turns of the secondary coil.
Since the flux is alternating in magnitude, it induces a mutually induced e.m.f. in secondary of the same
frequency as the flux. This follows from Faraday's law of electromagnetic induction,
i.e., e = M (dI/dt)
Because of this induced e.m.f, the secondary coil is capable of supplying current and hence energy.
Consider that no load is connected in the secondary i.e., secondary is open. Now an a.c. current i1 will flow
through primary coil. This causes a magnetic flux through primary. This induces an e.m.f. equal and
opposite toV1. Let Φ be the flux through the core. We have,

(1)
The same flux is linked with the secondary coil. Therefore, the secondary voltage V2 is given by

ELECTRICITY, MAGNETISM & ELECTRONICS 245


SRI CHANAKYA DEGREE COLLEGE

(2)
Dividing eq. (2) by eq. (1), we get

where a is turn ratío or transformer ratio.


When N2> N1, then V2>V1, or a>1, the transformer is known as step up transformer.
When N1 > N2, then V1>V2 or a<1, the transformer is known as step down transformer.
For an ideal transformer, there is no loss of energy and we have

This equation shows that when there is a voltage increase (step-up transformer) the output current (i2)
will decrease. On the other hand, when there is a voltage decrease, (step-down transformer), the output
current i2 will increase
Step-up Transformer and Step-down Transformer
If N> N, then a > 1, transformer is called step-up transformer If N2> N1, then a<1 , transformer is called
step-down transformer. For an ideal transformer
Input V x A = Output V x A

ELECTRICITY, MAGNETISM & ELECTRONICS 246


SRI CHANAKYA DEGREE COLLEGE

UNIT-III
ALTERNATING CURRENT
An alternating current or a.c. is defined as one which passes through a cycle of changes at regular
intervals. The waveform of such a voltage or current is shown in fig. (1) and is mathematically represented
by

� = �� �����
� = �� �����
Here i or E represents the instantaneous value whereas the peak
or maximum value is represented by io or Eo. The term �� is called
the phase. The time of one cycle is known as time period represented
by T and the number of cycles per second gives the frequency of
supply (f =1/T).
One cycle of alternating current consists of two half cycles
during one of which the current is entirely positive whereas during the
next half-cycle it is entirely negative. So the d.c. meter will indicate zero deflection as it measures the
average value of complete cycle. Hence, the term root-mean square or effective value is used to measure
the AC. Current i(t) in a pure resistor R results in a power p(t) with an average value P. This same P could
be produced in resistance R by a constant current I. Then i(t) is said to have an effective value irms equivalent
to this constant current I. The same can be applicable to Voltage functions where the effective value is Erms.
Hence, a.c. instruments measure the square root of the mean square value or virtual value. Therefore,
when we say supply voltage in our homes is 230 volt, we are talking about the rms value. The peak voltage
in this case is √2 time the rms value.
The average value of the rectified current is the same as the average current in any half cycle. It is
2/π times the maximum current io. Then the d.c. meter can be calibrated accordingly to measure a.c.
Average Value of A.C. during Complete Cycle
Now, we shall mathematically prove that the average or mean value of a.c. in one complete cycle zero. The
value of current at any instant t is given by

� = �� �����
The average value of a sinusoidal wave over one complete cycle is given by

∫� � ���� − � |cos ��|�
� ��
0 �
= �
0
��� = �
∫0 �� �

� |cos 2πt �

|
=−
�� T 0


= − [cos 2π − cos 0]
��

=− [1 − 1] = 0

ELECTRICITY, MAGNETISM & ELECTRONICS 247


SRI CHANAKYA DEGREE COLLEGE
Thus, we see the average value of a.c. over one complete cycle is zero. Similarly, we can prove for
alternating e.m.f.
Mean or Average Value of A.C. Voltage for Half Cycle
The mean or average of A.C. is the average of the sum of the instantaneous values taken for half a cycle
(i.e., for half a period). Now the sum of the instantaneous values for half a cycle is given by
T /2 T /2

 i dt   i
0 0
o sint dt

Mean value of current is given by


T /2
io sin ωt dt 2 T /2
iavg 
T 
T /2  io sin ωt dt
 0
dt 0

-2i0
=

cos ωt0
T/2

-2i cos . - cos0


2π T
= 0
2π  T 2 
T
T
-i0 2i
i  i = [-1-1] = 0
avg
π π
2
i  i
avg
 o

2
Similarly E  E
avg
 o

RMS Value of A.C. Voltage or current


Root mean square value for complete cycle can be calculated as follows.

ieff2 R  i2R
i  i
eff RMS

i
T
o
2
sin 2ωt dt
i 2
 0

 dt
0

T
i0 2
= sin2ωt dt
T 0

  2π   2π  
2 T sin 2 T sin 2 T (0)
i  1- cos2ωt  i i  sin2ωt  2   T 
2 2
 T  
i   0   
= 0   dt = 0
 0
t -   0
T -
T 0 2  2T 2T  2ω 0 2 T   2π   2π  
2  2 
     

ELECTRICITY, MAGNETISM & ELECTRONICS 248


SRI CHANAKYA DEGREE COLLEGE

 i 2 
sin 4π  i2 i2
i 
2 0
T -  o
T  0  o
2T   4π   2 T 2
 


i i 
eff RMS

 2
o o
iRMS

Similarly, ERMS 

AC Through pure Resistance:


Consider a circuit containing only pure resistance ‘R’ and alternating e.m.f. E is applied.
E = E0 sinωt--------------------------- (1)
From Ohms law E = iR

E0 sin ωt  iR

i  (Eo / R) sin ωt - ----- (2)

i will be maximum when the term sin ωt is unity

i  io sin ωt - ----- (3)

where io  Eo / R

From (1) and (3) it is clear that voltage and current are in phase. Phase
diagram is shown in figure.
Voltage and current vectors for a pure resistance circuit have been shown
in figure. OA is the voltage vector and OB is the current vector

AC Through pure Inductance:


Suppose that an alternating e.m.f. is applied to an AC circuit containing an inductor L. Due to self-
di
inductance of coil an induced e.m.f. (L ) is generated opposite to the change in current through it.
dt

ELECTRICITY, MAGNETISM & ELECTRONICS 249


SRI CHANAKYA DEGREE COLLEGE
Now the instantaneous current ‘i’ is derived as
E = E0 sinωt------------------------------------ (1)
di
Induced emf = L
dt
di
∴ E0 sinωt = L
dt
E0 E0
But di  sint dt  i   sint dt
L L
E0
On integrating i  cost 
ωL
E   π 
i  0 sin ωt -
X   2 
L   
i  io sin (ωt -  /2) - ---- (2)
Here XL = ωL is called inductive reactance. Its S.I unit is ohm (  )
From equation of voltage and current, current lags behind the voltage by

π/2 radian or 90°. Hence, following is the vector-diagram by taking the voltage as reference.
XL = ωL=2πf L ohm, XL depends directly on frequency of the applied voltage. The higher the value of f,
the greater is the reactance offered and vice-versa.
A.C. THROUGH PURE CAPACITANCE ONLY
Let us apply an alternating voltage E = E0 sinωt to a pure
capacitor of capacitance C as shown in
fig. Then the capacitor will get charged first in one direction and
then in the opposite direction. If q
is the charge on plates at any instant, then
q = CE ------------------ (1)
but E = E0 sinωt ------------ (2)

Putting value of E, we get q = C E0 sinωt


Differentiate the above equation
dq
 E ωC cos ωt
0
dt

ELECTRICITY, MAGNETISM & ELECTRONICS 250


SRI CHANAKYA DEGREE COLLEGE

E0   π 
i sin ωt + 2
  
E0   π 
i sin ωt +
X   2 
C   
1
Here XC = is called capacitive reactance. Its S.I unit is ohm (  ).
ωC
 π
 i  i sin ωt + 2 - ------- (3)
 

From (2) and (3) it is clear that current through the capacitor leads the voltage by . Phaser diagram is
2
shown in the figure.

AC circuit containing Resistance and Inductance (RL or LR circuit):

Consider a circuit containing inductance ‘L’ and a resistance R in series with an alternating e.m.f E = E0
sinωt. Let i be the instantaneous value of the current in the circuit. Due to the changing current, an induced
e.m.f. [ L di / dt ] is set up in the inductance which opposes the applied e.m.f.

Now the effective e.m.f. in the circuit = E0 sin t  L di / dt 

According to Ohm's law, this must be equal to Ri. Hence,

E0 sin t  L di / dt  = iR

 di 
E0 sin t  iR  L  
 dt  - ----- (1)
 di 
L dt  iR  E0 sin t
 
 
We know that
The trial solution of eq (1) is

i  i0 sin t   ------ (2)


di
 i  cost -  
0
dt
Substitute these values in equation (1)

ELECTRICITY, MAGNETISM & ELECTRONICS 251


SRI CHANAKYA DEGREE COLLEGE
E0 sin t      R i0 sin t    L i0 cos t  

E0 sint   cos  cos t   sin   R i0sin t    L i0 cos  t  

Comparing the coefficients of sin(ωt-Ø), cos(ωt-Ø)

E0 cos  Ri0 -------------- (3)

E0 sin  XLi0 ---- (4)

(3)2 + (4)2 => E 2  {R2  X 2 ) i 2

=> i 2  E 02
0
R 2  X L2

E0
=> i0 
R2  (X L )2

But R2  X 2
= Z is called impedance of circuit. Its S.I unit is ohm (  ).

E0
.: i = - ------ (5)
Z
(3) XL
=> tan =
(4) R

-1 
XL 
 = tan  
 R 
VECTOR DIAGRAM OF RL OR LR CIRCUIT

Consider a shows a circuit containing resistance (R) and


inductance (L) connected to an alternating Source. The
current in all parts will be the same. Let ER and EL be
voltages across the resistance (R) and inductance (L)
respectively.
We know that
(i) voltage across resistance always remain in phase with the current.
(ii) The voltage across inductance lead over current by 90o.
ER  iR
Hence,
and EL  iL  iXL

ER may be represented along current line of the circuit while EL at 90° ahead to ER as shown in fig. These
are indicated by vectors OA and OB respectively.
By the law of parallelogram of vector addition, the diagonal OR represents the impressed voltage E across
the inductance and resistance in series. Hence,

ELECTRICITY, MAGNETISM & ELECTRONICS 252


SRI CHANAKYA DEGREE COLLEGE
E2  E2  E2

iZ   iR  iL


2 2 2

Z 2  R2  2L2

Z  R2  2L2

Where Z is the impedance of the circuit.

tan  
EL iXL iL L
  
ER iR iR R
Further, L 
  tan1 
 R 
 

AC circuit containing Resistance and Capacitance (RC or CR circuit):


Consider a capacitor of capacitance ‘c’ and resistance R
connected in series with an alternating e.m.f E = E0 sinωt.
Consider a circuit containing a resistance R and a capacitance C in series,
connected to alternating e.m.f. source (E = E0 sin ωt) as shown in fig. Let
q be the charge on the capacitor at any instant t and i be the current in the
circuit at that instant.
q
The potential difference across the capacitor at this instant is
C
q
This opposes the applied e.m.f., So the effective e.m.f. in the circuit will be E sin t 
0
C
According to Ohm's law, this must be equal to Ri.

q
Hence, E0 sin t   Ri
C
q
R i  E sin t ------ (1)
0
C
Differentiating this equation, we get

di i  E  cos t ------ (2)


R  0
dt C

The solution of eq. (2) is of the form

i  i0 sin t   ------ (3)

where i and o are constants to be determined


di
Then,  i  cost -  
dt 0
Substitute these values in eq. (2), we get

ELECTRICITY, MAGNETISM & ELECTRONICS 253


SRI CHANAKYA DEGREE COLLEGE
R i0 cost -    (1/ C) i0 sin t    E0 cos t  E0 cos(t - )  

R i0 cost -    (1/ C) i0 sin t    E0 cos t   cos  sin t   sin 

Comparing the coefficients of sin t    and cost -   in the above equation, we get

(1/ C) i0  -E0 sin

 -(1/ C) i0  E0 sin ------ (4)

R i0  E0 cos

 R i0  E0 cos ------- (5)

By doing (4)2 + (5)2  E2 R 2  (1/ C)2 i 2

 i 2
 E02
0
R2  (1/ C)2

E0 E0
i0   - ----- (6)
R2  (1/ C)2 R2  X C 2

E0
Impedance
Z  R 2  X C 2  R 2  (1 / C)2
i0
Z is called impedance of circuit. Its S.I unit is ohm (  ).

(1 / C)
By doing (4) ÷ (5)  tan  
R
   tan1 (1 / C) 
 
R
 
 XC 
   tan1
 
R
 

Substituting i0 in eq. (3) we get

E0
i  sin t   
R 2  (1/ C)2
1  X C 
where   tan
 
 R 
VECTOR DIAGRAM OF RC OR CR CIRCUIT
Consider a shows a circuit containing resistance (R) and
capacitance (C) connected to an alternating Source. The current in
all parts will be the same. Let ER and EC be voltages across the
resistance (R) and capacitance (C) respectively.

ELECTRICITY, MAGNETISM & ELECTRONICS 254


SRI CHANAKYA DEGREE COLLEGE
We know that
(i) Voltage across resistance always remain in phase with the current.
(ii) The voltage across the condenser lags behind the current by 90o.
ER  iR
Hence,
and EC  i / C  iXC

ER may be represented along current line of the circuit while EC at 90° below to ER as shown in figure.
These are indicated by vectors OA and OB respectively.
By the law of parallelogram of vector addition, the diagonal OR represents the impressed voltage E
across the capacitance and resistance in series. Hence,

E2  E2  E2

iZ   iR  (i / C)2


2 2

Z 2  R2  (1/  2 C 2 )

 1
Z  R2    
 C 
Where Z is the impedance of the circuit.
EC iXC i / C
tan  
1
  
ER iR iR CR
1  1 
Further,
  tan
 CR 
 

Series L-C-R Circuit:


Consider a capacitor of capacitance C, Inductor of inductance L
and resistance R are connected in series with an alternating e.m.f.
E = E0 sinωt.
Let i = instantaneous current in circuit and
q = instantaneous charge on the capacitor.
di
The potential difference across capacitor is q/C and back e.m.f. induced in the inductance is L .
dt
q di
The effective e.m.f. in the circuit is E sint  L
0
C dt
According to Ohm's law, this must be equal to Ri
q di
E sint   L  R i
0
C dt
di q
L  R i   E sint ------ (1)
0
dt C

ELECTRICITY, MAGNETISM & ELECTRONICS 255


SRI CHANAKYA DEGREE COLLEGE
Differentiate above equation
d 2i di
L 2 R  1/ C  i  E0 cos t ------ (2)
dt dt
The solution of eq. (2) is of the form
i  i0 sin t   ------ (3)
di
Then,  i  cost -   ------ (4)
0
dt
d 2i 2

 i0 sin t -  ------ (5)


dt2
Substitute the above values in eq. (2), we get
L i 2 sin t    R i  cos t    (1/ C) i sin t    E cost
0 0 0 0
 L i 2 sin t    R i  cos  t    (1/ C) i sin t    E cos(t   )  
0 0 0 0

 E0 cos t  cos  sin t   sin 

Comparing the coefficients of sin t    and cost -   in the above equation, we get

 L i 2  (1/ C) i  E sin


0 0 0

 L i0  (1/ C) i0  E0 sin ------ (6)

R i0 =E0 cos

 R i0 =E0 cos ------ (7)


  1  
2

By doing (6)2 + (7)2  E 2  R2   L  C   i 2


0 0
   

 i02  E0 2
  1  
2

R   L 
2
 
  C  

E0
 i0  ------ (8)
R   L 
2

 1 
L  i
 
C o
By doing (6) ÷ (7)  tan    
Rio
 1 
L 
 C 
tan   
R

ELECTRICITY, MAGNETISM & ELECTRONICS 256


SRI CHANAKYA DEGREE COLLEGE
 1 
 L  C  
   tan1  
 - ----- (9)
 R 
 

E 1  
2
 2 
From eq. (8),
0
 R   L     XC Z
i0   C  
L

E  2  1 
2

Here Z  
0
R  L  C   is the impedance of the circuit and has SI units ohms.
i0    
Substituting Eq. (8) in eq. (3), we get

E0
i  sin t   
1  
2
 2 
   
  C  
R L
 

The current lags in phase from the e.m.f. by an angle 

Here  is the phase difference between voltage ‘E’ and current ‘i’.
1
Case i: if L > then  is positive.
C
i.e., the current in the circuit lags behind the voltage by  .
1
Case ii: if L < then  is negative.
C
i.e., the current in the circuit is leads the voltage by  .
1
Case iii: if L = then  is zero.
C
i.e., the current in the circuit is phase with the voltage.
SERRIES RESONANCE CIRCUIT

Maximum current i0 from LCR Series circuit is i0 


 R   L 
2
C  

  1 
2

And the impedance Z of the circuit is given by Z  R2   L  
  C  

The L-C-R series circuit has a very large capacitive reactance (l/ωC) at low frequencies and large inductive
a verv resistance (ωL) at high frequencies. So at a particular frequency, the total reactance in the circuit is
zero (ωL = l/ωC). Under this situation, the resultant impedance of the circuit is a minimum (equal to R).

ELECTRICITY, MAGNETISM & ELECTRONICS 257


SRI CHANAKYA DEGREE COLLEGE
The particular frequency of A.C. at which impedance of a series L-C-R circuit becomes minimum (or the
current becomes maximum), [when ωL = l/ωC] is called the resonant frequency and the circuit is called as
series resonant circuit.
At resonant frequency XL = XC
1
=> ωL 
ωC
1
ω2 
LC
1
=> ω 
LC

1
We know that  = 2π f0 

So, the resonant frequency f0 of the series resonant circuit is given by f0 

The resonant frequency depends on the product of L and C and does not depend on R.
The L-C-R series circuit at this frequency is called series resonance crcuit.
The variation of the current peak value with the frequency of the applied e.m.f. is as shown in the fig. If
the resistance is low, then the curve is sharp. It is called sharpness of resonance. For higher resistance
values the peak losses its sharpness.
Observations:
(i) The maximum current occurs at a particular
frequency called as resonant frequency
(ii) The peak of the curve depends on the resistance of
the circuit. When R is low, the peak is high and vice-
versa. The peak is known as sharpness of resonance.
More is height of peak, sharper is the resonance.
(iii) The series resonant circuit is called as acceptor
circuit. Because out of all currents, it accepts the
current whose frequency is same as the resonance
frequency only.
VECTOR DIAGRAM OF SERIES LCR CIRCUIT
Consider an AC circuit containing an inductance (L),
capacitance (C) and resistance (R) in series.
Let EL, EC and ER be the potential differences across
inductance, capacitance and resistance respectively. io is the peak
value (rms value) of current in the circuit. The voltage and current
in the resistor will be in the same phase at all times. The voltage

ELECTRICITY, MAGNETISM & ELECTRONICS 258


SRI CHANAKYA DEGREE COLLEGE
across the inductance EL = io ωL, will lead the current by π/2 (90°) while the capacitive reactance
EC = io (1/ωC) will lag behind the current by π/2 (90°).
Therefore, voltage amplitude (OA) and current amplitude on resistor are expressed on x-axis in vector
diagram. Here EL and EC are in antiphase, expressed on y-axis. The resultant of the two is represented by
ELC = EL - EC = io { ωL - (1/ωC)}.
The resultant of ER and ELC (OB) can be obtained by vector addition method. This is represented by
OR.

Thus,

E 2  (OR)2   Ri   i L  1   i 2 R2  L  1  
2 2 2

0 o o C  o  C 
      

  1 2 2
1


E0  (OR)  io R2  L    = R   L  C
2

  C    

E0
We now that impedance Z 
i0

  1 
2

So, Z  R2   L  
  C  

io   L  1  
 L  C 
1
OB  EL  EC  C  
From Figure, tan       
OA ER io R R

L  C 
1
1 
  tan
 
 R 
 

Here ϕ will lead or lag depending upon the values of ωL and 1/ωC.

ELECTRICITY, MAGNETISM & ELECTRONICS 259


SRI CHANAKYA DEGREE COLLEGE
LCR PARALLEL RESONANT CIRCUIT
The Parallel resonant circuit is as shown in figure.
An inductance L and a resistance R are connected in series
in one branch and a condenser C in another branch. A
source of alternating e.m.f. is connected in the circuit. The
current from the generator is io. From Kirchhoff's law

i0  i1  i2

Let Z be the total impedance of the circuit.

Impedance of inductance and resistance branch, Z1  R  jL

1
Impedance of condenser branch, Z2 
jC

The above two branches are in parallel. Hence, the resultant impedance is given by
1 1 1
 
Z Z1 Z2

1 1 1
 
1
Z R  jL jC

Admittance Y 
1

1

1

R  jL
 jC
Z R  jL 1
jC
R  jLR  jL

R  jL
 jC 
R

jL
 jC
 Y=
R 2
  2 L2  R 2
  2 L2  R 2
  2 L2 
 
 Y= R
j L
C
 
R   L  R   2L2 
2 2 2
2 
 2  1/ 2
 
R
The magnitude of admittance = Y =  L
2
 C 
 
  R 2  2L2     R2   L
2 2

      
L
From the above eq, Admittance is minimum (or impedance is maximum) when C  or
R 2
 L 2 2

L
C
R2  2L2 

 CR2  C 2L2  L
 C 2L2  L  CR2
  2  L / L2C  CR2 / CL2
1 R2
   1 R
2
 2 
LC L2 LC L2

ELECTRICITY, MAGNETISM & ELECTRONICS 260


SRI CHANAKYA DEGREE COLLEGE

1 R2
We know that   2 f0  
LC L2
2
1 1 R
f0  
2 LC L2
At this frequency, the admittance is minimum (impedance is maximum) and hence, the current is
minimum. Such a frequency is called as resonant frequency. The circuit is known as parallel resonant
circuit. At resonant frequency, the value of admittance of the circuit will be
 2L2 
Yr =
R
or Zr 
R
2

R 2
 2L2  R

Substituting the value of 2 we get


 2  1 R2  2 
R    L 
  LC L2   L
Zr    Dynamic impedance
R RC
This depends upon the value of resistance R. The smaller the value of
R, the larger will be impedance. As R →0, the impedance Z→∞, The
variation of impedance with frequency as shown in fig.
The circuit is called as a rejector circuit because it rejects only one
frequency and excepts other.
Quality Factor:
Quality factor is defined as 2 π times the ratio of energy stored in the system to average to average
energy lost per period.
1
Energy stored in the circuit due to inductance is Li2
2
1
Energy stored in the circuit due to capacitance is CE2
2
Energy stored in the system
Q- factor Q  2
Energy lost per period

Energy stored in the system


Q  2
Power lost per sec x T

2 Energy stored in the system


Q
T Power lost per sec
1 2
Li
 2 f 2
1 2
iR
2

ELECTRICITY, MAGNETISM & ELECTRONICS 261


SRI CHANAKYA DEGREE COLLEGE
1 2
Li
 2 f 2
( P = Ei = iRi = i2R)
1 2
iR
2
L
 2 f
R
L XL
Q =
R R
1 2
Li
 2 f 2
( P = Ei = iRi = i2R)
1 2
iR
2
L
 2 f
R
L XL
Q =
R R
Similarly, it can be shown that Q =1/�CR.
So, the quality factor may also be defined as the ratio of reactance of either inductance or capacitance
to the resistance at the resonant frequency to the circuit. Since at resonance XL = XC, i.e, �L =1/�C, hence
the value of Q is the same from both the expressions.
Difference between series and parallel:
Series Resonant Circuit Parallel Resonant Circuit
1. In ideal case current is infinity 1. In ideal case current is zero
2. Series resonant frequency is given by 2. Parallel resonant frequency is given by
1
fo = 1 1 R2
f0  
2 LC 2 LC L2

3. At resonance, the power factor is unity and 3. Power factor is also unity but the
impedance is purely resistive impedance is given by
Zr = R Zr =L/C R

4. At resonant frequency current is 4. At resonant frequency current is minimum


maximum
5. At resonant frequency impedance is 5. At resonant frequency impedance is
minimum maximum
6. It is called accepter circuit 6. It is called rejecter circuit
7. At resonance, the circuit exhibits a voltage 7. At resonance, the circuit exhibits a current
magnification and it is equal to Q-factor magnification and it is equal to Q-factor

ELECTRICITY, MAGNETISM & ELECTRONICS 262


SRI CHANAKYA DEGREE COLLEGE
Power in AC circuit:
Consider an AC circuit containing resistor, inductor and capacitor. Let the instantaneous values of
voltage and current in the circuit are E = E0 sinωt and i = i0 sin(ωt- ) respectively.

Instantaneous power = E × i

= E0 sinωt i0 sin(ωt- )
T

0 E i dt
Average power consumed over one complete cycle = T

 dt
0

  E sint i sin (t   ) dt  E i


0 0 0 0 0
T
2sint sin (t   ) dt  E0 i0  cos - cos(2ωt-)dt
T

T
2T  2T 
 dt
0 0

0
T
Ei   2ωt-  T E0 i0   2.(2 /T)t- 
 0 0 cos.t - sin     cos .t - sin  
2T   2ω o 2T   2(2 /T) o
   2π  
 sin  2  T-   sin 2ω(0)    
Ei
00    T    cos(0) -
 cos.T -  
2T  2ω   2ω 
 
 
E0 i0  
 Tcos + sin  - 0 + sin 
2T  2   2ω 
E0 i0  sin  E0 i0
 Tcos + sin -  cos  E0 i0 cos

.
2T   2ω 
2ω  2 2 2

 Erms .irms .cos

True power = Apparent power × power factor


X L  XC
In this case cos ϕ is called power factor of the circuit for this circuit tan  
R
R
cos 
R2  ( X L  X C )2

Case i: If the circuit contains resistance only then ϕ is Zero.


Then power = Erms irms cos0

ELECTRICITY, MAGNETISM & ELECTRONICS 263


SRI CHANAKYA DEGREE COLLEGE
Power = Erms irms

Case ii: If the circuit contains inductor only then ϕ = π/2 Power
= Erms irms cos π/2 = 0

If the circuit contains capacitor only then ϕ = π/2 Power


= Erms irms cos π/2 = 0
Hence if the circuit contains inductance or capacitance then the true power become zero and the
current is called wattles current.

ELECTRICITY, MAGNETISM & ELECTRONICS 264


SRI CHANAKYA DEGREE COLLEGE

UNIT-IV
BASIC ELECTRONICS

SEMICONDUCTORS
A substance which has resistivity in between conductors and insulators is known as semiconductor.
For example germanium, silicon have resistivity (10-5 to 0.5 ohm-meter) between good conductors like
copper (1.7 x 10-8 ohm-metre) and insulators like glass (9 x 1011 ohm-metre). These substances are known
as semiconductors. Some other peculiar properties also there that separate semiconductors from
conductors, insulators and resistance materials.
These semiconductors may be classified as
(i) Pure or intrinsic semiconductors and (ii) Impure or extrinsic semiconductors

(1) Intrinsic Semiconductor:


These semiconductors are extremely in pure form. In these semiconductors electrons and holes are
exclusively created by thermal excitation process. For example, pure crystals like germanium and silicon.
For these semiconductors electron-hole pairs are formed while the electrons reaching the conduction band
from valence band due to thermal excitation. So these semiconductors have equal number of electron-hole pairs.

(2) Extrinsic Semiconductor:


At room temperature, the intrinsic semiconductor has little current capability. In order to increase
the conductivity, addition of some impurities are needed during the process of crystallization. Such
semiconductor is called impurity or extrinsic semiconductor. The process of adding impurity to a
semiconductor is known as doping.
Usually, the doping material is either pentavalent atoms [bismuth (83), antimony (51), arsenic (33),
and phosphorus (15) which have 5 valence electrons] or trivalent atoms [gallium (31), indium (49),
aluminum (13), and boron (5) which have 3 valence electrons].
The pentavalent doping atom is known as donor atom because it donates one electron to the
conduction band of pure semiconductor. The trivalent atom is, on the other hand, called as acceptor atom
because it accepts one electron from semiconductor atom.
Depending on the type of impurity added, the extrinsic semiconductors can be divided into two
classes.

ELECTRICITY, MAGNETISM & ELECTRONICS 265


SRI CHANAKYA DEGREE COLLEGE
(i) N-type semiconductor, and (ii) P-type semiconductor.
(i). N-TYPE EXTRINSIC SEMICONDUCTOR
When a small amount of pentavalent impurity is added to a pure
semiconductor crystal during the crystal growth, the resulting crystal is
called as N-type extrinsic semiconductor. For example, a pentavalent
arsenic is added to pure germanium crystal. Now the arsenic atom fits in
the germanium crystal in such a way that its four valence electrons form
a covalent bond with the four germanium atoms. The fifth electron of
arsenic atom is not covalently bonded but it is loosely bound to the
parent arsenic atom. This electron is available as a carrier of current
(ii) P-TYPE EXTRINSIC SEMICONDUCTOR
When a small amount of trivalent impurity is added to a pure
crystal during the crystal growth, the resulting crystal is called a P-
type extrinsic semiconductor.
For example, when trivalent boron (1s2 2s22p1) is added to
pure germanium crystal. Each atom of boron fits into the germanium
crystal with only three covalent bonds. In the fourth covalent bond,
only germanium atom contributes one valence electron and there is
deficiency of one electron which is called a hole. In other words, we
can say that the fourth bond is incomplete due to shortage of one
electron. Therefore, for each boron atom added, one hole is created.
A small amount of boron provides millions of holes which constitute current.
P-N JUNCTION DIODE
This is a two terminal device made of Ge or Si crystal consisting of a P-N junction. A P-N junction
is formed from a piece of Semiconductor (say germanium) by diffusing P-type material to one half side
and N-type material to other half side. The plane dividing the two zones is known as a junction.
The P-type and N-type regions are referred to as anode and
cathode respectively. When the diode is forward biased, the arrow
head shows the conventional direction of current flow, i.e., the
direction in which holes flow take place.
P-type and N-type semiconductor pieces before and after they are joined are shown in figure (a) and
(b). P-type semiconductor has negative acceptor ions and positively charged free holes which move about
on P-side. Similarly N-type semiconductor has positive donar ions and negatively charged free electrons
which move about N-side. The Junction is a border where P-type and N-type regions meet.

ELECTRICITY, MAGNETISM & ELECTRONICS 266


SRI CHANAKYA DEGREE COLLEGE
Depletion Layer
Now let us consider that the two pieces are joined together. As P-type material has a high
concentration of holes and N-type material has high concentration of free electrons, hence there is a
tendency of holes to diffuse over to N-side and electrons to P-side. The process is known as diffusion. So
due to diffusion, some of the holes from P-side cross over to N-side where they combine with electrons

and become neutral and vice-versa.


In this region there is no charge available for conduction. So, charge carriers (electrons and holes)
are depleted. It is termed as depletion layer or charged free region or space charge region.
Potential Barrier

The diffusion of holes and electrons continues till a potential barrier is developed in charged free
region. This prevents further diffusion or neutralization. The potential barrier can be increased or decreased
by applying an external voltage.
Junction Voltage
When the depletion layer is formed, there are negative immobile ions in P-type semiconductor and
positive immobile ions in N-type semiconductors. Now due to charge separation, a voltage VB is developed
across the junction under equilibrium condition. This voltage is known as junction voltage or internal
voltage. For Germanium it is generally 0.1 to 0.3 V.
WORKING OF DIODE
The working of a diode is happened in two connections.
(1) Forward Bias and (2) Reverse Bias.
(1) Forward Bias
When an external voltage is applied to P-N junction in such a direction that it cancels the potential
barrier and permits the current flow is called as forward bias. To apply a forward bias, the positive terminal
of a battery is connected to P-type while the negative terminal is connected to N-type of the diode.

ELECTRICITY, MAGNETISM & ELECTRONICS 267


SRI CHANAKYA DEGREE COLLEGE
The applied forward potential establishes an electric field opposite to the potential barrier.
Therefore, the potential barrier is reduced as show in figure. As this is very small (0.3 volt for Ge and 0.7
V for Si) therefore, a small forward voltage is sufficient to completely eliminate the barrier. When potential
barrier is eliminated by the forward voltage, junction resistance becomes almost zero.
In case of the forward bias, the holes from P-type semiconductor are repelled by the positive battery
terminal towards the junction and simultaneously, the electrons in N-type semiconductor are repelled by
negative battery terminal towards junction. If the battery voltage is more than junction voltage, these
carriers overcome the potential barrier and cross the junction to combine. When an electron-hole
combination takes place near the junction, a covalent bond near the positive terminal of battery breaks
down. This causes the discharge of an electron which enters the positive terminal. This action creates a

new hole which moves towards the junction. For each electron in N region that combines with a hole from
the negative terminal of the battery. This constant movement of electrons towards the positive terminal and
the holes towards the negative terminal produces a high forward current.
Reverse Bias
When an external voltage is applied to P-N junction in such a
direction that it increases the potential barrier, then it is called as reverse
bias. For reverse bias, the positive terminal of the battery is connected to
N-type and negative terminal to P-type of the diode as shown in figure. The
applied reverse voltage establishes an electric field which acts in the same
direction of potential barrier. Therefore, the resultant field at the junction is
strengthened and the potential barrier is increased. The potential barrier
prevents the flow of charge carriers across the junction. In this way a high
resistance path is established.
When the junction is reversed biased, the electrons in N-type semiconductor and holes in P-type
semiconductor are attracted away from the junction. Since there is no recombination of electron hole pairs
no current flows in the circuit.

(i) When P-N junction is forward biased, it has a low resistance path and hence current flows in the circuit.
On the other hand when it is reverse biased, it has high resistance path and no current flows in the circuit.

ELECTRICITY, MAGNETISM & ELECTRONICS 268


SRI CHANAKYA DEGREE COLLEGE
(ii) P-N junction diode is one way device which offers a low resistance when forward biased and behave like
an insulator when reverse biased. So it can be used as a rectifier (converts A.C into D.C).
VOLT-AMPERE CHARACTERISTICS OF P-N JUNCTION
The characteristics are studied under the following two heads
(i) Forward bias, and (ii) Reverse bias.
Forward Bias
For the forward bias of a P-N junction, P-type is connected to the positive terminal while the N-type
is connected to the negative terminal of a battery as shown in figure. The potential at P-N junction can be
varied with the help of potential divider. At some forward voltage (0.3 for Ge and 0.7 V for Si), the potential
barrier is eliminated and current starts flowing. This voltage is known as threshold voltage (Vth) or cut-in
voltage or knee voltage. It is practically same as barrier voltage VB. For this the current flow is negligible.

As the forward applied voltage increases beyond threshold voltage, the forward current rises exponentially.
The current is recorded with the help of milliammeter (mA) connected in series with diode. A graph is
drawn with voltage (in volts) applied on X-axis and the corresponding current (in milli-amperes) is taken
on Y-axis. The graph is shown in figure.
It should be remembered that if the forward voltage is increased beyond a certain safe value, it
produces an extremely large current which may destroy the junction due to overheating.
Reverse bias

For the reverse bias of P-N junction, P type is connected to negative terminal while N- type is
connected to positive terminal of the battery. The reverse potential at P-N junction can be varied with the
help of potential divider. In this case the junction resistance become very high and practically no current
flows through the circuit. However, in practice a small amount of current flows in the circuit due to minority
carriers. This is called reverse current. As the reverse voltage is increased from zero, the rivers current
quickly rises to its maximum or saturation value. This gives rise to a current called surface leakage current.
This is independent of temperature but depends on reverse voltage. If the reverse voltage is further
increased the kinetic energy of electrons due to minority carriers becomes so high that they knock out
electrons from the semiconductor atoms. At this stage breakdown of junction occurs and there is no sudden

ELECTRICITY, MAGNETISM & ELECTRONICS 269


SRI CHANAKYA DEGREE COLLEGE
rise of reverse current. Now the junction is destroyed permanently. This reverse current is measured with
micro ammeter connected in the circuit.
Conclusion
1. The width of depletion region increases with the reverse voltage increases.
2. The junction offers a high resistance.
3. Practically no current flows in the circuit due to high resistance of the junction.
4. Small current flows through the junction due to minority charge carriers.
ZENER DIODE
This is an example of junction device. Zener diode is a reverse biased heavily-doped silicon P-N
junction diode which is operated in the breakdown region. Due to higher temperature and current capability,
silicon is preferred in comparison to germanium. The symbol of a zener diode is shown in figure.

This is similar to a normal diode except the line representing the cathode is bent at both ends, i.e., like the
letter Z for zener.
Biasing of Zener Diode

(a) Forward biasing:


For forward biasing, the anode is connected to positive terminal of battery while the cathode is
connected to negative terminal of battery. This is identical to a forward biased diode while forward biasing.
This biasing is generally not used for Zener.
(b) Reverse biasing:
In this case, negative terminal is connected to anode while the positive terminal is connected to
cathode. Here, R is current limitation resistor. In reverse biasing, the zener diode is used as voltage
regulator.

ELECTRICITY, MAGNETISM & ELECTRONICS 270


SRI CHANAKYA DEGREE COLLEGE
V-I Characteristics of Zener Diode

The V-I characteristic is shown in figure. As the reverse voltage applied to P-N junction is increased
from zero, the current remains very small over a long range and increases very slightly with increasing bias
voltage. But when the reverse bias is made very high, the covalent bonds near the junction breaks down.
Now the reverse current increases abruptly to a large value. The corresponding voltage is called break down
voltage or zener voltage. In this region of characteristic curve, the voltage across the diode remains constant
over a large range of current. Hence, the zener diode may be used to stabilize voltage at a predetermined
value.
Difference between a Junction diode and a Zener diode
To a junction diode, external voltage can be applied either under forward bias condition or under
reverse bias condition while to a zener diode, reverse bias is only applied and operated in breakdown region.
There are two mechanisms of the breakdown.
(i) Zener breakdown
Zener breakdown takes place in very thin junction, i.e., when P-type and N-types are very heavily
doped and consequently the depletion layer is narrow. When a small reverse bias voltage is applied, a very
strong electric field (above 107 V/m) is set up across the thin depletion layer. This field is enough to break
the covalent bonds. Now extremely large number of electrons and holes are produced which constitute the
reverse saturation current (zener current). This breakdown mechanism is called zener breakdown. Zener
current is independent of the applied voltage and depends only on the external resistance.
(ii) Avalanche breakdown
This type of breakdown takes place when both sides of junction are lightly doped and consequently
the depletion layer is large. In this case electric field across the depletion layer is not so strong to produce
zener breakdown. Here minority charge carriers are accelerated by the field collision with the
semiconductor atoms in the depletion region. So due to the collision with valence electrons, covalent bonds
are broken and electron-hole pairs are generated. These new carriers so produced acquired energy from
applied potential and in-turn produce additional carriers. This cumulative process is called as avalanche
multiplication and the breakdown is called avalanche breakdown. This occurs at higher reverse voltages.
At reverse voltages less than 6 V, Zener breakdown predominates while at about 8 V, avalanche
breakdown predominates. So a diode in Zener breakdown should be called as Zener diode whereas in
avalanche breakdown it should be called as avalanche diode. When the breakdown voltage is reached in a
zener diode, the current increases rapidly with additional voltage. As a result, a diode in breakdown

ELECTRICITY, MAGNETISM & ELECTRONICS 271


SRI CHANAKYA DEGREE COLLEGE
maintains an almost constant voltage across itself over a wide range of current. Thus, the zener diode is
most suited for voltage regulation.
Applications
Following are few common applications of zener diode:
(i) Voltage regulation (ii) A peak clipper
(iii) Switching operation (iv) Meter protection
(v) As reference element
ZENER DIODE AS VOLTAGE STABILIZER

A simple circuit to stabilize voltage supplied to a load R L is as shown in figure. The zener diode is
connected to a supply voltage through resistor R. The battery B reverse-biases the zener diode. The load
RL is connected across the terminals of diode. The value of R is selected in such a way that in the absence
of load RL, maximum safe current flows in the diode as zener voltage.
As long as voltage across the load resistor RL is less than the breakdown voltage Vz, the zener diode does
not conduct. When the voltage increases, the voltage drop across load RL, (or zener diode) becomes greater
than the Zener breakdown voltage. Now zener operates in breakdown region. The resistance R limits the
current through Zener diode within the safe maximum limit (Iz)max.
From Kirchhoff s law, I = IZ +IL (1)
It is obvious from characteristics curve that voltage VZ across zener diode remains almost constant
even when zener current varies considerably.
Let us consider that supply voltage Vin increases. Now the current through zener diode and load
resistance increases. At the same time, the zener diode resistance decreases and the current through it
increases more than proportionately. As a result, a greater voltage drop occurs across R. As a consequence,
the output voltage Vout (or voltage across the diode) will become very close to the original value. The
reverse is also true.
Thus, a zener diode maintains constant voltage across the load as long as the supply voltage is more
than zener voltage.
Let us now consider the case when the load resistance RL decreases for constant input voltage Vin. As
a result, load current IL increases. It is clear from eq. (1) that IZ will decrease by the same amount so that
remains the same. This keeps the voltage drop across series resistance R constant. Therefore, output voltage
remains constant. On the other hand, if load resistance R L increases, the load current IL decreases. Now,
the Zener diode allows an extra current such that I remains the same. As a result, output voltage Vout remains
constant.

ELECTRICITY, MAGNETISM & ELECTRONICS 272


SRI CHANAKYA DEGREE COLLEGE
Thus, zener diode maintains a constant voltage across the load even whenever there is change in load
resistance.
TUNNEL DIODE
Esaki, a Japanese scientist in 1957 announced a new diode which utilizes the phenomenon of
tunnelling and hence it is called as tunnel diode or Esaki diode. A conventional P-N diode is doped by
impurity atoms in the concentration 1 part in 108. If the concentration of impurity atoms is greatly increased
in a P-N junction (by about 1000 times) then the depletion layer width reduces to about 10-6 cm and the
device characteristics are completely changed. Under this condition, many carriers punch through the
junction even when they do not have enough energy to overcome the potential barrier (0.3 V for Ge and
0.7 V for Si). Consequently, large forward current is produced even though the applied bias is much less
than 0.3 V or 0.7 V. This phenomenon is known as tunnelling.

Volt-Ampere Characteristics
Figure shows the V-I characteristic of tunnel diode. As soon as the forward bias is applied, significant
current is produced. The current quickly reaches its peak value Vp. It is represented by point A. This is due

to quantum mechanical tunneling of electrons through a small narrow space region in the junction. So the
voltage increases from 0 to Vp and current increases from 0 to Ip.
When forward voltage is further increased, the diode current starts decreasing. The current decreases
to Iv corresponding the valley voltage Vv. It is indicated with point B. Thus from point A to B, current
decreases as voltage increases. This is the negative resistance region. Here instead of absorbing power,
negative resistance produces power. This unique property make the diode useful in very high frequency
oscillators. For the voltages above Vv, the current starts increasing as a conventional P-N junction diode.
If the tunnel diode is reversed biased then it acts like a good conductor, i.e., the reverse current
increases with increasing reverse voltage.
So, current can be obtained in three different voltage regions. This feature makes the tunnel diode
useful in pulse and digital circuits.

ELECTRICITY, MAGNETISM & ELECTRONICS 273


SRI CHANAKYA DEGREE COLLEGE
Tunneling Theory:
The tunnelling phenomenon can be explained by considering the energy band diagram of P-type
and N-type semiconductor materials. In P-type material, due to heavy doping, there is an increased
concentration of holes in valence band and similarly for N-type material there is an increased of electrons
in conduction band. When P-type and N-type materials are joined, the energy level diagram is as shown in

figure.
1. No Forward Bias
Till no forward bias is applied, there is a rough
alignment of their respective valence and conduction
bands. The energy levels of holes in P-region are slightly
out of alignment with the energy levels of conduction
electrons in N-region of the junction. No current flows
across the junction.
2. Small Forward Bias
When a small forward voltage (= 0.1 V) is applied,
the energy bands in N-region upwards relative to P-type.
Now there is an exact alignment of bands on both side
and a very small gap between conduction band of N-type
and valance band of P-type as shown in figure. At this
stage, electrons tunnel through the depletion layer with the velocity of light and give rise to large current.
This tunneling current reaches a maximum value Ip at a forward bias Vp of the order of 0.1 volt.
3. Large Forward Bias
After Vp, as the applied voltage is increased, the
current starts decreasing because the energy level of N-
region are raised so high that two bands are out of alignment.
Now the distance between conduction band of N-type and
valance band of P-type increases. So, only part of the
electrons in the conduction band see energy level across the
barrier, i.e., In this case tunneling is stopped. The current reaches the minimum value (called valley
current). Between peak current Ip and valley current Iv, a negative dynamic resistance is obtained. At bias
voltage Vv, tunneling is completely stopped and if we rise the voltage above Vv, current increases with
voltage and works as ordinary junction diode.
Tunneling is much faster than a normal crossing. This enables a tunnel diode to switch ON and OFF
faster than an ordinary diode. Due to this reason, tunnel diode is extensively used in special applications

ELECTRICITY, MAGNETISM & ELECTRONICS 274


SRI CHANAKYA DEGREE COLLEGE
where very fast switching speeds are required like in high speed computer memory, high frequency
oscillators, etc.
Advantages
(i) This can withstand very large temperature changes.
(ii) It requires low power.
(iii) Small size and low cost.
(iv) It has long life and low noise.
(v) Speed is high.
(vi) It has environmental immunity.
Disadvantages
(i) There is no isolation between input and output. So, this leads to serious circuit design difficulties.
(ii) It is a two terminal device.
(iii) It has low output voltage swing.
Applications
The main applications are as follows:
(i) This is used as logic memory storage device.
(ii) It is an ultra-high speed switching device. This is possible due to tunneling mechanism, which occurs
at the speed of light. The switching time is of the order of nano-second (= 10-9 sec).
(iii) This is used in relaxation oscillator due to its negative resistance.
(iv) This is used in microwave oscillator at frequencies of the order of 10 GHz. This is possible due to
low values of inductance and capacitance.

Feature Zener diode Tunnel diode


Construction Made up of silicon with two layers Made up of germanium or gallium
(P-N) arsenide with two layers (P-N)
Doping Heavily doped Heavily doped
Operation Acting as breakdown device at Exhibits negative resistance at
reverse bias forward bias
Applications Constant voltage source, Voltage Microwave oscillator, Ultra high
regulator speed switching device

THE BIPOLAR JUNCTION TRANSISTOR


A junction transistor is simply a sandwich of one type of semiconductor material between two layers
of the other type. Accordingly, there are two types of transistors.
1. N-P-N transistor
2. P-N-P transistor.

ELECTRICITY, MAGNETISM & ELECTRONICS 275


SRI CHANAKYA DEGREE COLLEGE
When a layer of P-type material is sandwiched between two layers of N-type material, the transistor
material is known as N-P-N transistor. Similarly, when a layer of N-type material is sandwiched between
two layers of P-type material, the transistor is known as P-N-P transistor.

Transistors are made either from silicon or germanium crystal. The symbolic representation of N-P-
N and P-N-P transistors are shown in figures.
Although the two outer regions are of the same type but they cannot be interchanged. The reason is
that the two regions have different physical and electrical properties. The collector region is made
physically larger than emitter region. The base is very thin and lightly doped. The emitter is heavily doped
while the doping of collector is between the heavy doping of emitter and light doping of the base.
A transistor has the following sections:
(i) Emitter: This forms the left hand section or region of the transistor. The main function of this region is
to supply majority charge carriers (either electrons or holes) to the base and hence it is heavily doped in
comparison to other regions.
(ii) Base: The middle section of the transistor is known as base. This is very lightly doped and very thin
(10-6 m) as compared to either emitter or collector so that it may pass most of the injected charge carriers
to the collector.
(iii) Collector: The right hand section of the transistor is called as collector. The main function of the
collector is to collect majority charge carriers through the base. This is moderately doped. As regards the
symbols, arrowhead is always at the emitter. The direction indicates the conventional direction of current
flow, i.e., in case of N-P-N transistor it is from base to emitter (base is positive with respect to emitter)
while in case of P-N-P transistor it is from emitter to base (emitter is positive with respect to base).
TRANSISTOR BIASING
In a circuit, transistor can be biased such a way that the emitter-base junction is always forward-
biased while the collector-base junction is always reversed biased. For this purpose a battery VEE is
connected between emitter and base while a battery VCC is connected between collector and base. The
emitter-base junction of P-N-P is forward biased by transistor connecting the positive terminal of VEE to
emitter and negative terminal to base. P-N-P transistor is reverse-biased by connecting the negative
terminal of VCC to collector while positive terminal to base. Similarly, for N-P-N transistor, emitter-base
junction is connected in forward bias by connecting positive terminal of VEE to base and negative terminal
to emitter. For reverse bias, positive terminal of VCC connected to collector while negative terminal to base.

ELECTRICITY, MAGNETISM & ELECTRONICS 276


SRI CHANAKYA DEGREE COLLEGE
So, emitter circuit has low resistance while collector circuit has high resistance. In a transistor, it transfer a
signal from low resistance to high resistance circuit.

OPERATION OF P-N-P TRANSISTOR


In a PNP transistor, emitter-base junction is forward biased and collector-base junction as reverse
biased. The Operation of PNP transistor is as follows:

The holes of P region (emitter) are repelled by positive terminal of battery VEE towards the base. A
forward potential barrier at emitter junction is reduced as it is in forward biased and hence holes cross this
junction and penetrates N-region. This creates the emitter current IE. The width of the base region is very
thin and it is lightly doped and hence only two to five per cent of the holes recombine with the free electrons
of N-region. This constitutes the very small base current IB. The remaining holes (95% to 98%) able to drift
across the base and enter the collector region. They are swept up by the negative collector voltage V CC.
They constitute the collector current IC.
As each hole reaches the collector electrode, an electron is emitted from the negative terminal of
battery and neutralizes the hole. Now, a covalent bond near the emitter electrode breaks down. The
liberated electron enters the positive terminal of battery VEE while the hole immediately moves towards
the emitter junction. This process is repeated again and again. Here it should be remembered that:
(i) Current conduction within PNP transistor takes place by hole conduction from emitter to collector.
i.e., majortiy charge carriers in a PNP transistor are holes. The conduction in the external circuit is carried
out by electrons.
(ii) The collector current is slightly less than the emitter current. This is due to the fact that 2 to 5% of
the holes are lost in recombination with electron in base region. Thus, the collector current is slightly less
than emitter current.

ELECTRICITY, MAGNETISM & ELECTRONICS 277


SRI CHANAKYA DEGREE COLLEGE
(iii) The collector current is a function of emitter current, i.e., with the increase or decrease in the emitter
current, a corresponding change in collector current is observed.
Besides the hole current, there is electron current which flows from base region to emitter region.
This current depends upon emitter base potential. As the width of the base region is very small, the ratio of
hole current to electron current is very small. So for all practical purposes, the electron current may be
neglected.
Thus, only the hole current plays an important role in the operation of PNP transistor.
Therefore,
IE = IB + IC
OPERATION OF N-P-N TRANSISTOR
The biasing of a NPN transistor is shown in Figure.
The emitter junction is forward biased because electrons
are repelled from the negative emitter battery terminal
VEE towards the junction. The collector junction is reverse
biased because electrons are flowing away the collector
junction towards the positive collector battery terminal
VCC.
The electron in the emitter region are repelled from the negative terminal of battery towards the
emitter junction. Since the potential barrier at the junction is reduced due to forward bias and base region
is very thin and lightly doped, electrons cross the P-type base region. A few electrons combine with the
holes in P-region and are lost as charge carriers. Now the electrons in N region (collector region) readily
swept up by the positive collector voltage VCC.
For every electron flowing out the collector and entering the positive terminal of battery V CC
electron from the negative emitter battery terminal enters the emitter region. In this way electron
conduction takes place continuously so long as the two junctions are properly biased.
So, the current conduction in NPN transistor is carried out by electrons.
Therefore,
IE = IB + IC
Here, according to sign convention,
(i) the emitter current IE is positive while base current IB and collector current IC both are negative in PNP
transistor.
IE -IC - IB =0
IE = IC + IB
(ii) In case of NPN transistor, emitter current IE is negative while the base current IB and collector current IC
both are positive.
-IE +IC + IB =0
IE = IB + IC

ELECTRICITY, MAGNETISM & ELECTRONICS 278


SRI CHANAKYA DEGREE COLLEGE
TRANSISTOR CIRCUIT CONFIGURATIONS
Following are the three types of transistor circuit configurations
(1) Common-base (CB)
(2) Common-emitter (CE)
(3) Common-collector (CC)
Here the term Common is used to denote the transistor lead which is common to the input and
output circuits. This is because when a transistor is connected in a circuit, four terminals are required (two
for input and two for output) while a transistor has only three terminals. The difficulty is removed by
making one terminal of the transistor 'common' to both input and output terminals. The common terminal
is generally grounded. Each configuration has specific advantages and disadvantages. In any circuit
configuration, the emitter is always forward-biased while the collector is always reverse-biased.
COMMON-BASE (CB) CONFIGURATION

In this configuration the input signal is applied between emitter and base while the output is taken
from collector and base. As base is common to input and output circuits, hence the name common base
configuration.

Current amplification factor (�)


(i) When no signal is applied
The ratio of the collector current to the emitter current is called d.c. alpha (���) of a transistor
��
��� = −

(negative sign signifies that �� flows into transistor while IC flows out of it)
If we write ��� simply by �, then
��
�=− (1)
��

(ii) When signal is applied


The ratio of change in collector current to the change in emitter current at constant collector base
voltage is defined as current amplification factor

ELECTRICITY, MAGNETISM & ELECTRONICS 279


SRI CHANAKYA DEGREE COLLEGE
ΔIC
��� =
ΔI
E

� of a transistor is a measure of the quality of a transistor. The higher the value of �, the better is the
transistor in the sense that collector current approaches the emitter current. For all physical purposes, ��� =
��� = � and practical values in commercial transistors range from 0.9 to 0.99.
From eq. (1), considering only magnitudes of the currents

Total collector current


The collector current consists of the following two parts:
(i) The current produced by normal transistor action, i.e., component controlled by emitter current, this is due
to the majority carrier and its value is ���.
(ii) The leakage current Ileakage. This current is due to the motion of minority carrier across base-collector
junction due to reverse bias. This is much smaller than ���. The leakage current is abbreviated as ICBO
i.e.,

collector base current with emitter open.


����
∴ ����� ��������� +
��� ��������
������� =
��������
If �� = 0, (emitter circuit is open), even there will be small leakage current ���� in the collector
circuit. The current ���� is usually small and may be neglected in transistor circuit calculations.
COMMON-EMITTER (CE) CONFIGURATION

ELECTRICITY, MAGNETISM & ELECTRONICS 280


SRI CHANAKYA DEGREE COLLEGE
In this configuration, the input signal is applied between base and emitter and the output is taken from
collector and emitter. As emitter is common to input and output circuits, hence the name common emitter
configuration.
Current Amplification Factor (�)
(i) When no signal is applied

The ratio of collector current to the base current called dc beta (���) of transistor
��
� =�= (1)
�� ��

(ii) When signal is applied


The ratio of change in collector current to the change in base current is defined as base current
amplification factor. Thus,
∆��
��� = � =
∆�
From eq. (1), �� = ��� (2)
For almost all transistors, the base current is less than 5% of the emitter current. Due to this fact, � is
generally greater than 20. � ranges from 20 to 500. Hence, this configuration is frequently used for the
circuits where current gain as well as voltage gain is required.
Total Collector Current
Total collector current �� = ��� + ���� (3)
where ���� is the leakage current. Even though �� = 0 there is a leakage current from collector- emitter
junction. It is called ����, the subscript CEO stands for collector to emitter with base open.
We know that

From, eq. (3) and (4), we have


� 1
� = 1−� and =
1−�
����

ELECTRICITY, MAGNETISM & ELECTRONICS 281


SRI CHANAKYA DEGREE COLLEGE
COMMON-COLLECTOR (CC) CONFIGURATION

In this configuration, the input signal is applied between base and collector and the output is taken
from emitter. As collector is common to input and output circuits, hence the name common collector
configuration.

Current amplification factor (�)


(i) When no signal is applied
The ratio of emitter current to the base current is called as
dc. gamma (���) of the transistor.
��
��� = � =

(ii) When signal is applied


The ratio of change in emitter current to the change in base current is known as current amplification factor

∆��
�=
∆��
This configuration provides about the same current gain as common emitter circuit as ∆�� ≈ ∆�� but the
voltage gain is always less than one.
Total Emitter Current
We know that

Application
This configuration has very high input resistance (750 �Ω) and very low output resistance (25Ω).
So the voltage gain is always less than one. Hence, this configuration is seldom used for amplification. The

ELECTRICITY, MAGNETISM & ELECTRONICS 282


SRI CHANAKYA DEGREE COLLEGE
most important use is for impedance matching, i.e., for driving a low impedance load from a high
impedance source.
RELATIONS BETWEEN �, � and �
1. Relation between � and
�. We know that
�� ��
�= and � =
�� ��

�� = �� + �� or �� = �� − ��
�� ��/��
�= =
�� − 1 − (��/��)
��

� = 1−� (1)
Cross-multiplying eq. (1), we get
(1 − �) = �
or � − �� =

� = (1 + �)
� (2)
� = 1+�
1
It can be seen that 1−�= 1+�
(3)

2. Relation between � and �


We know that
�� ��
�= and � =
�� ��

�� = �� − ��

�= �� 1
=
�� − �� 1 − (��/��)
1
� = 1−� (4)
3. Relation between � and �
According to eq. (3), we have
1
(1 − �) = (1 + �)
Substituting this value in eq. (4), we have
1
� = 1−� = (1 + �) (5)
Conclusion:
� � 1
� = 1−� , � = 1+� , � = 1−� , � = (1 + �)

ELECTRICITY, MAGNETISM & ELECTRONICS 283


SRI CHANAKYA DEGREE COLLEGE
CHARACTERISTICS OF COMMON EMITTER TRANSISTOR CIRCUIT

In the circuit, the battery VBB provides forward bias to emitter-base junction with the help of
potential divider R1. The voltmeter V1 measures the base-emitter voltage VBE. The microammeter A1
measures the base current IB.
A Battery VCC is connected between collector and emitter through a potential divider R2. The positive
terminal of the battery is connected to emitter while the negative terminal is connected to the collector so
that the collector is reverse-biased. The voltmeter V2 measures the collector-emitter voltage VCE and the
milliammeter A2 measures the collector current.
We consider the following characteristics:
(1) Input characteristics (2) Output characteristics
(1) Input Characteristics
The curve between base current (IB) and base-emitter voltage (VBE) at constant collector-emitter
voltage (VCE) represents the input characteristic. For plotting the input characteristic, the collector-emitter
voltage VCE is fixed at particular value. The base emitter voltage VBE is varied with the help of potential
divider R1 and the base current IB is noted for each value of VBE.
A graph of IB against VBE is drawn. The curve so obtained is known as input characteristic. The
experiment is repeated for other fixed values of VCE.

Important points from the characteristic:


(i) The characteristic be similar to that of a forward-biased diode curve. This is because of the base-emitter
section (like a junction diode) of transistor connected in forward-bias.
(ii) In this case, IB increases less rapidly with VBE as compared to common-base configuration. This shows that
the input resistance of common-emitter circuit is higher than that of common-base circuit.

ELECTRICITY, MAGNETISM & ELECTRONICS 284


SRI CHANAKYA DEGREE COLLEGE
Input resistance:
The ratio of change in base emitter voltage (VBE) to the resulting change base current (IB) at constant
collector-emitter voltage (VCE) is defined as input resistance. This denoted by ri. Therefore,
∆���
�� |
∆� ���=constant
=

(2) Output Characteristics
The curve between collector current IC and collector emitter voltage VCE at constant base current IB
represents the output characteristic.

For plotting output characteristic, the base current IB is kept fixed. With the help of potential divider
R2, the value of VCE is varied in steps and the collector current IC is noted for each value of VCE. A graph
of IC against VCE is drawn. The curve obtained is known as output characteristic. The experiment is repeated
for different values of IB.
Important points:
(i) In the active region (collector junction is reverse-biased while emitter junction is forward-biased), for
small values of base current, the effect of collector voltage over collector current is small while for large
base current values this effect increases. Thus, the current gain of this configuration is greater than unity.
In this configuration, the transistor is used as an amplifying device, but it must be restricted in the active
region only.
(ii) When VCE has very low value (ideally zero), the transistor is said to be saturated and it operates in the
saturation region of characteristic. In the saturated region, the change in base current IB does produce a
corresponding change in collector current IC.
(iii) When VCE is increased too far, collector-base junction completely breaks down and due avalanche
breakdown, collector current increases rapidly. In this case, the transistor is damaged.
(iv) In the cutoff region, a small amount of collector current flows even when base current IB =0, is called
ICEO. Since, main collector current is zero, the transistor is said to be cutoff.
Output resistance
The ratio of change in collector-emitter voltage (VCE) to the resulting change in collector current IC
at constant base current is defined as output resistance. This is denoted by r0.
∆���
�0 = |
∆� ��=constant

ELECTRICITY, MAGNETISM & ELECTRONICS 285


SRI CHANAKYA DEGREE COLLEGE
HYBRID PARAMETERS OR h-PARAMETERS
Hybrid means "'mixed". These parameters have mixed dimensions and hence they are called as hybrid
parameters. These parameters are very useful at high frequencies. At high frequencies transistor has low
input impedance and high output impedance. Here Y and Z parameters becomes difficult. In this case, i1
and v2 taken as independent variables while v1 and i2 are taken as dependent variables. Hence,
�1 = (�1, �2) (1)
�2 = (�1, �2) (2)

Taking the total differentials, we get


��1 ��1
�� = + (3)
�� ��
1 ��1 1 ��2 2
��2
� = �� + �2
�� 2 (4)
2 ��1 1 ��2

For small a.c. signals limited to the quasi-linear region the partial derivatives become constants. Thus,
�1 = ℎ11 �1 + ℎ12 �2 (5)
�2 = ℎ21 �1 + ℎ22 �2 (6)

In matrix form
�1 ℎ11 ℎ12 �1
[ ]=[ ][ ] (7)
�2 ℎ ℎ22 �2

Appropriate choice of open circuit ( 1 = 0) and short circuit (�2 = 0) conditions applied to eqs. (5) & (6). If
we short circuit the output terminals, i.e., �2 = 0, now eqs. (5) & (6) become
�1
�1 = ℎ11 �1 + ℎ12 (0) ⟹ℎ11 =
�1
�2
�2 = ℎ21 �1 + ℎ22 (0) ⟹ℎ21 =
�1
1f we Open circuit the input terminals, i.e., �1 = 0, then
�1
�1 = ℎ11 (0) + ℎ12 �2 ⟹ ℎ12 = �2

�=ℎ (0) + ℎ � ⟹ℎ =2
2 21 22 2 22 �2

So h-parameters are defined as


��1 �1
ℎ11 = ℎ� = | = = Input Impedance with output short circuited, �2 = 0
1��
� =0
2 1 �
��1 �1
ℎ12 = ℎ� = | = = Reverse voltage ratio with input open circuited, �1 = 0
�2 �2
� �1=0
�2
��2
ℎ21 = ℎ� = | = = Forward current gain with output short circuited, �2 = 0
� 1 �2=0 �
� 1
��2 �2
ℎ22 = ℎ� = | = = Output admittance with input open circuited, �1 = 0
�2 �2
� �1=0

ELECTRICITY, MAGNETISM & ELECTRONICS 286


SRI CHANAKYA DEGREE COLLEGE
Equivalent Circuit

The equivalent circuit derived on the basis of eqs. (5) and (6) is shown in figure. The input circuit
resistance h11 in series with a voltage generator h12 V2. The output circuit consists of a current h21I1 and
shunt resistance h22. The input portion is a Thevenin equivalent (voltage with series resistance while the
output portion is a Norton equivalent (current generator with shunt resistance). Thus, the circuit is mixed,
i.e. hybrid. In common emitter configuration, these h-parameters are represented with hie, hre, hfe and hoe.
DETERMINATION OF h-PARAMETERS FROM STATIC CHARACTERISTICS
DETERMINATION OF PARAMETERS hfe AND hoe

The output characteristic curves of a transistor in common emitter configuration is as shown in figure.
The curve between collector current IC and collector emitter voltage VCE at constant base current represents
the output characteristic. For plotting output characteristic, the base current IB is kept fixed. With the help
of potential divider, VCE is varied in steps and the corresponding collector current IC is noted for each value
of VCE. A graph of IC against VCE is drawn.
As shown in the figure, different curves are drawn by changing the value of IB. In this figure, we
consider the curve for iB = IB. At a point P on this curve, the collector current and collector voltage are IC
and VC respectively. Through the point P we draw a vertical straight line which cuts the curves for iB1, and
iB2, and at points P1 and P2 respectively. The corresponding collector currents are iC1 and iC2, respectively
Using the definitions of hfe and hoe, we have
�� ��2−��1
= (1)
ℎ∆�� = � =
�� | �� ∆�� ��2−��1
� ��

��� ∆�� �� (2)


ℎ| = = =
�� �� ∆�� ��
� ��

ELECTRICITY, MAGNETISM & ELECTRONICS 287


SRI CHANAKYA DEGREE COLLEGE
DETERMINATION OF PARAMETERS hre AND hie

Figure shows the input characteristics of a transistor in common-emitter configuration. The curve
between base current IB and base-emitter voltage VBE at constant collector-emitter voltage VCE represents
the input characteristic. For plotting the input characteristic, the collector-emitter voltage VCE is kept fixed.
A graph is drawn between IB and VBE by changing the value of VCE with the help of potential divider. From
figure, we consider the curve for �� = ��. At a point on this curve, the quiescent base voltage and base
current are �� and ��. We draw a vertical line through this point P which cuts the curves for ��1 and ��2
at
points P1 and P2 respectively. The corresponding values of base voltages are ��1 and ��2 , respectively.
��� ∆�� ��2−��1 (3)
ℎ�� = = | =
�� ∆�� ��2−��1
� ��

��� ∆�� �� (4)



��
= = | =
�� ∆� � ��
� �

ELECTRICITY, MAGNETISM & ELECTRONICS 288


SRI CHANAKYA DEGREE COLLEGE
Hence, the slope of the appropriate input characteristic at the quiescent point P gives hie. This can
be evaluated by drawing a straight line tangential to the input characteristics at point P. This may also be
calculated by drawing incremental triangle ABC about point P and noting the values of AC and BC.
TRANSISTOR AS AN AMPLIFIER

The transistor amplifier circuit is as shown in figure. Here, the weak signal to be amplified is applied
between base-emitter circuit and the output is taken across the load resistor RL, connected in the collector
circuit. To achieve faithful amplification, the input circuit is always in forward bias. For this purpose, base
bias battery VBB is connected to set input circuit always forward biased. A small change in signal voltage
produces appreciable change in the base current which causes the same change in collector current. When
the collector current flows through the load resistance RL, a large voltage is developed across it. In this way
a weak signal is applied in the input circuit and amplified signal is obtained as output.

Let a small voltage change ∆�� between base and emitter causes a relatively large emitter current
change ∆��. The current amplification factor is given by
ΔIC
�=
ΔIB
∆�� = � ∆��

The change in output voltage across the load resistor


∆�� = �� × ∆��
= �� × � ∆��

Under these circumstances, the voltage amplification


∆��
�=
∆��

If the dynamic resistance of the emitter junction is ��, then ∆�� = �� × ∆��
∆�� �� × � �. ��
∴ �= =
∆� = ∆�� ��
� �� ×
Voltage gain (AV): ∆��

The voltage gain is defined as the ratio of change in output voltage (∆VCE) to the change in input voltage
(∆VBE) when transistor is connected in common emitter configuration.
∆��� �ℎ���� �� ������ ������� × ��������� ����
�� = =
�� �ℎ���� �� ����� ������� × ����� ����������
��� × ��

ELECTRICITY, MAGNETISM & ELECTRONICS 289


SRI CHANAKYA DEGREE COLLEGE
= ��
��� × ��
= �( )
��

Power gain (AP):


This is defined as the ratio of output signal power to input signal power.
2
�� =(�� )2 × ��
(� ) × �
� �

� ��� × ��
�� ) ( �� × �)
=( � �

��
= � × ��

So, Power gain = current gain × voltage gain

ELECTRICITY, MAGNETISM & ELECTRONICS 290


SRI CHANAKYA DEGREE COLLEGE

UNIT-5
DIGITAL ELECTRONICS
5.1. Digital Electronics
The digital electronics is a branch of electronics which deals with the generation, processing and storage of
digital signals. This helps in the analysis, design and construction of digital systems. Any variation that can be
transmitted through space is called a signal. Basically there are two types of signals i.e., analogue signal and digital
signal. Analogue signals are those continuously changing from minimum value to maximum values. On the other
hand, there are another type of signals which are confined to a limited number of discrete levels of current or voltage.
These signals are called as digital signals. These signals are coded as 0 or 1 numbers which correspond to OFF (low
voltage) or ON (high voltage) conditions. These are provided in a switch. George Boole is the inventor of digital
electronics. The algebra which is used in digital electronics is called as Boolean algebra. In digital electronics, any
information can be represented in terms of zero's and one's. It is represented by a bit.
In Analog circuits, the transistors as used as amplifiers of sinusoidal signal. For every change in the input
circuit, the linear amplifier produces a corresponding change in output circuit. So, the circuit acts as a linear circuit.
In Digital circuits, transistor can be used as a switching circuit, i.e., it can be used to operate as ON and OFF switch.
The magnitude and waveform of output have no relation with those of input. So, the circuit acts as a non-linear
circuit.

5.2. NUMBER SYSTEM -SOME BASIC TERMS


A number system is a code. Each distinct quantity is assigned to a symbol. After memorizing the code, we can
perform arithmetic operations. Hence, a number system gives relations between quantities and symbols.
(i) Digit: It is the basic symbol used in a number system.
(ii) Base: It is the number of digits or basic symbols in a number system. The decimal system has a base of ten while
the binary number system has a base of two.
(iii) Bit: It is an abbreviated form of Binary digit. Eg: 1010 has four binary digits or four bits.
1 nibble = 4 bits, l byte = 8 bits
(iv) Radix: It is a synonym of word base.
(v) Weight: It refers the position of a digit in a number. Each position has different decimal value in the number
system.

5.2.1 TYPES OF NUMBER SYSTEMS


The common numbers systems used in digital electronics are as follows.
(1) Decimal system (0 to 9)
(2) Binary system (0 or 1)
(3) Octal system (0 to 7)
(4) Hexa-decimal system (0 to 9, A, B, C, D, E, F)

Non suitability of decimal system in digital circuit:


Decimal system is not suitable for carrying out in digital circuits. This is because the supply voltages using
semiconductor devices is of the order of few volts. Hence, ten levels will naturally become crowded. Any adjoining
voltage levels will be quite close to each other resulting in level to be mixed. This will lead to misinterpretation of

ELECTRICITY, MAGNETISM & ELECTRONICS 291


SRI CHANAKYA DEGREE COLLEGE
voltage level. Whereas in case of binary system there will be only two fixed voltage levels: One is close to ground
level (say bit 0) and the other is close to supply voltage V CC (say bit 1). These two levels are fairly apart from each
other and hence, there is no possibility of misinterpretation of data. Generally, in positive logic, 0 to 1 volt represents
the lower level or 0 and 3 to 5 volt represents the higher level (i.e. 1).

5.2.2. THE DECIMAL NUMBER SYSTEM


This is the most commonly used number system in our daily life developed by Aryans around 5th century.
It contains 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, i.e., it has a base or radix 10.
Even though the absolute value of each digit is fixed, its decimal value depends on its position value or place value
or weight.
In decimal system, we have single digit numbers from 0 to 9. To get double digit number, after 9, we use the
second decimal digit, i.e., 1 followed by the first digit, i.e., 0 resulting in 10.
To get 11, 12, 13, ..., etc., we use second digit followed by the second, third, fourth , etc. This process goes up to 19.
After this we use the third decimal digit (i.e., 2) followed by first, second, third,..etc. to get 20, 21, 22, 23,..., etc. In
this way we can go up to 99. Similar logic follows for 100 or above.

The weights or place values of different digits in a mixed decimal numbers are as follows

1989 =1 x 103 + 9 x 102 + 8 x 101 + 9 x 100


   
1000 100 10 1
(Weights of digits in positions)

Here number 9 is least significant digit (LSD) and 1 is the most significant digit (MSD).

ELECTRICITY, MAGNETISM & ELECTRONICS 292


SRI CHANAKYA DEGREE COLLEGE
In general, a decimal number system can be expressed as
N  a 10n  a 10n-1  a 10n-2  ..  a1 10  a 0 10  a-1 10  ...  a-m 10-m
1 0 -1
n n-1 n-2

N =  ai 10 i
n

m

For example

(coefficients)
       
2021.0825  2  103  0 102  2  101  1 100  0 10-1  8 10-1  2  10-2  5 10-3
       
(weights)

5.2.3. BINARY NUMBER SYSTEM


In binary system, there are only two digits, i.e., 0 and 1. To express a number, the same decimal procedure
is adopted here. Thus, to express 2, we use the second binary digit (1) followed by the first (0). This gives 10 (read
as one zero and not ten).
Similarly, 3 can be represented by 11 (one-one). Now the two binary digits are exhausted. Thus, to get 4 in the binary
system, we use second digit followed by two first digits, i.e., 100 (one-zero-zero). Similarly, 5 can be expressed as
101 (one-zero-one) and so on.

Binary number 11111000101 can be written as

11111000101  1  210  1  29  1  28  1  27 1  26  0  25  0  24  0  23 1 22  0  21 1 20


The binary weights in a mixed binary number may be listed below

Any Binary number can be represented as


N  a 2n  a 2n-1  an-2 2n-2  ..  a1 2  a0 2  a-1 2  ...  a-m 2-m
1 0 -1
n n-1
n

N =  ai 2 i
m

ELECTRICITY, MAGNETISM & ELECTRONICS 293


SRI CHANAKYA DEGREE COLLEGE
Here ai values are either 0 or 1.

5.2.4. THE OCTAL NUMBER SYSTEM


The word 'octal' means eight. So, in the octal number system, the base or radix is 8, i.e., eight distinct
counting digits 0, 1, 2, 3, 4, 5, 6, 7 are used to express all possible numbers. These digits 0 to 7 have exactly the same
physical meaning as in decimal system. The highest digit in octal system is seven (7).
For counting beyond 7, a two-digit combinations are formed. The combinations are formed by taking second
digit followed by first, then by second and so on. Thus after 7, the next octal number will be 10 (second digit followed
by first), then 11 (second digit followed by second) and so on.

The position value (or weight) for each digit is given by different powers of 8 as shown below
Any number in octal system can be represented as
N  a 8n  a 8n-1  an-2 8n-2  ..  a1 8  a0 8  a-1 8  ...  a-m 8-m
1 0 -1
n n-1
n

N =  ai 8i
m

For example, decimal equivalent of 258 is

5.2.5 THE HEXADECIMAL NUMBER SYSTEM


The word hexadecimal is composed of hexa meaning 6 and decimal meaning 10. Hence, the word
Hexadecimal means sixteen. Thus, its base or radix is 16. The maximum value of any digit in this system is 15, i.e.,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Here A stands for 10, B stands for 11, C stands for 12. D stands for 13, E stands for 14, and F stands for 15.
After reaching F, we take the second digit followed by first digit, then second followed by second, then second
followed by third and so on.
Any number in hexa decimal system can be represented as
N  a 16n  a 16n-1  a 16n-2  ..  a1 16  a 0 16  a-1 16  ...  a-m 16-m
1 0 -1
n n-1 n-2

N =  ai 16 i
n

m

ELECTRICITY, MAGNETISM & ELECTRONICS 294


SRI CHANAKYA DEGREE COLLEGE

5.3. DECIMAL TO BINARY CONVERSION


5.3.1. Converting Integer Numbers from Decimal-to-Binary
It is a systematic way of converting integer numbers from decimal-to-binary. The procedure for conversion
is as given below:
Step 1. Begin by dividing the given decimal number by 2.
Step 2. Divide each resulting quotient by 2 until there is a 0 whole number quotient.
Step 3. The remainders generated by each division form the binary number. The first remainder to be produced is
the least significant bit (LSB) in the binary number, and the last remainder to be produced is the most significant bit
(MSB). In other words, reading the remainders from bottom-to-top constitutes the required binary number.
Example 1: Conversion of decimal 47 to its equivalent binary number:

ELECTRICITY, MAGNETISM & ELECTRONICS 295


SRI CHANAKYA DEGREE COLLEGE
Example 2: Conversion of decimal 45 to its equivalent binary number:

5.3.2. Converting Fractional Numbers from Decimal-to-Binary


We have already seen in the last article that the repeated division-by-2 method can be used to convert integer
(or whole number) decimal to its equivalent binary. Decimal fractions can be converted to binary by repeated
multiplication-by-2. Following is the procedure that is used for conversion:
Step 1. Begin by multiplying the given decimal fraction by 2 and then multiplying each resulting fractional part of
the product by 2.
Step 2. Repeat step 1 until the fractional product is zero or until the desired number of decimal places is reached.
Step 3. The carried bits or carries generated by the multiplication produce the binary number. The first carry produced
is the most-significant bit (MSB) and the last carry is the least significant bit (LSB). In other words, reading from
top to bottom constitutes the required fractional binary.
In order to illustrate the procedure, consider the conversion of 0.3125 to its equivalent binary Fraction

Since the fractional part is zero, so we will stop the repeated multiplication. Reading from top to bottom, the required
binary number is 0101.
0.312510 = 0.1012

5.4. BINARY TO DECIMAL CONVERSION


5.4.1 Converting an Integer (or Whole) Binary Number to Decimal Number
Following is the procedure for converting an integer (or whole) binary number to its equivalent decimal number.
Step 1. Write the binary number.
Step 2. Directly under the binary number, write the position values or weights of each bit working from right to left.

ELECTRICITY, MAGNETISM & ELECTRONICS 296


SRI CHANAKYA DEGREE COLLEGE
Step 3. If a zero appears in a digit position, cross-out the weight for that position.
Step 4. Add the remaining weights to obtain the decimal equivalent.

5.4.2. Fractional Binary-to-Decimal Conversion


We have already discussed the integer binary-to-decimal conversion. Let us now see how a binary fraction can be
converted into corresponding decimal equivalents. Consider for example the conversion of fractional binary number
0.1010 to decimal.

5.5. OCTAL-TO-DECIMAL CONVERSION


Following is the procedure to convert an octal number to its decimal equivalent.
Step 1. Write the octal number.
Step 2. Directly under the octal number write the position weight of each digit working from right to left.
Step 3. Multiply each octal digit by its position weight and take sum of the products.
In order to illustrate the method, consider an example, of converting 2374.

ELECTRICITY, MAGNETISM & ELECTRONICS 297


SRI CHANAKYA DEGREE COLLEGE

5.6 HEXADECIMAL-TO-DECIMAL CONVERSION


llowing is the procedure to convert a hexadecimal number to its equivalent decimal number:
Step 1. Write the hexadecimal number.
Step 2. Directly under the hexadecimal number, write the position weight of each digit working from right to left.
Step 3. Multiply the decimal value of each hexadecimal digit by its position weight and take sum of the products.
Hexa-decimal number: 2A6

I. Decimal number to Hexadecimal number.

The decimal number id divided by 16 and the remainders are converted in to Hexa notations. The
readings are taken from bottom to top.
16 2047
16 127 15 F (2047)10 = (7FF)16
7 15 F
II. Hexadecimal number or decimal number:
Multiply each hexadecimal digit by its weight and add the result.
(3A45)16=3 × 163 + 10 × 162 + 4 × 161 + 5 × 160
= (14917)10.

ELECTRICITY, MAGNETISM & ELECTRONICS 298


SRI CHANAKYA DEGREE COLLEGE
III. Binary number into Hexadecimal number:
Split the given number into 4-digit groups (supplying 0’s if necessary)and then give the hex
value.
Ex: (1011010111011)2
→ 0010 1101 0111 1011
↓ ↓ ↓ ↓
2 � 7 �
IV. Hexadecimal to binary number:
Convert each hexadecimal digit into its 4-bit equivalent using to hex number.
(7CF)16→ 7 C F
↓ ↓ ↓
0111 1100 1111
= (011111001111)2
(B2D)16→ � 2 D
↓ ↓ ↓
1011 0010 1101
= (101100101101)2

5.7. BINARY OPERATIONS


5.7.1. BINARY ADDITION
Binary addition is much easier than the decimal addition. Following are the rules to perform binary addition.

Rule1: 0+0 =0 carry 0


Rule2: 1+0=1 carry 0
Rule3: 0+1=1 carry 0
Rule4: 1+1=0 carry 1
Example:

Binary Decimal Binary. Decimal Binary Decimal


110 (6) 1011 (11) 11 (3)
+ 1011 (9) + 111 (7) + 101 (5)

1111 (15) 10010 (18) 1000 (8)

5.7.2. BINARY SUBTRACTION:


Following are the rules to perform binary subtraction.

Rule1: 0-0=0 No borrowing


Rule2: 1-0=1 No borrowing
Rule3: 0-1=0 No borrowing

ELECTRICITY, MAGNETISM & ELECTRONICS 299


SRI CHANAKYA DEGREE COLLEGE
Rule4: 1-1=1 with a borrow of 1
Example:
1101 1010 11011
-1010 -1001 -10111
0011 0001 00100

5.7.3. BINARY MULTIPLICATION AND DIVISION


The complete binary multiplication table is as follows
Rule1: 0 x 0 = 0

Rule2: 0 x 1 = 0
Rule3: 1 x 0 = 0
Rule4: 1 x 1 = 1
The rules of binary division are given below:
Rule 1: 0/1 = 0

Rule 2: 1/1 = 1
5.8. 1'S and 2'S COMPLEMENTs
Complement of a Number: In digital operation, there are two types of complements of a binary number
which are used for complemental subtraction.

(i) 1's Complement:


This is also known as radix-minus-one component. The 1's component of a binary number is obtained by
changing its each zero (0) into one (1) and each one (1) into zero (0).
For example, 1's complement of (1101)2 = (0010)2

(ii) 2's Complement:


This is also known as true complement. The 2's complement of a binary number is obtained by adding one
(1) to its l's complement. Thus,
2's complement = 1 +'s complement
To find out the 2's complement of (1011)2,
1's complement of (1011)2 = (0100)2
add 1 to this result : (0100)2 +1 = (0101)2
Now, we get (0101)2.
Hence, 2's complement of (1011)2= (0101)2

5.8.1. 1'S COMPLEMENTAL SUBTRACTION


For 1's complemental subtraction,
(i) First find the 1's complement of the subtrahend number.
(ii) Now we add this 1's complement to the minuend.

ELECTRICITY, MAGNETISM & ELECTRONICS 300


SRI CHANAKYA DEGREE COLLEGE
(iii) If there is a 1 carry in the most significant position, then this carry is removed and perform the end-around carry
of the last 1 (add carry 1 to the previous result).
(iv) If there is no end-around carry (i.e., 0 carry), then the answer is re-complemented (1’s complement) and put a
negative sign for the final result.
5.8.2. 2'S COMPLEMENTAL SUBTRACTION
For 2's complemental subtraction,
i) Change all 0’s to 1’s and 1’s to 0’s of subtrahend to get the 1's complement
ii) then add 1 to get 2's complement.
iii) add the 2's complemental to minuend.
iv) If carry is one (1), then drop the carry. The answer is positive and needs no re-complementing.
v) If there is no carry, we re-complement (2’s complement) the result and attach a negative sign to it.

5.9. BOOLEAN ALGEBRA


In our daily life, we have so many two valued problems like: is it true or false? good or bad? right or wrong?
etc. First of all, Aristotle tried to find out precise methods for getting the truth for such two valued or binary problems
based on a set of assumptions. Further, De Morgan proposed that the logic has connection with mathematics. But
George Boole (1815-1864) tried to perform a mathematical analysis of logic and constructed a logical algebra. This
algebra is commonly known as Boolean algebra. Thus, Boolean algebra is a system of mathematical logic. It differs
from both ordinary algebra and the binary number system.
In Boolean Algebra, only two logic variables are permitted, i.e., true or false, usually written as 1and 0. As
digital system works in binary, i.e., involves only two possible states, the Boolean Algebra has been used extensively
in digital electronics. So, Boolean Algebra is ideal for the design and analysis of logic circuits used in computers.
The three logical operators to form a logical function are:
1. OR operator, 2. AND operator and 3. NOT operator

1. OR Operator
In Boolean algebra, the OR operator is indicated with a plus (+) sign.
Similar to addition. Therefore, A + B = C states that if A is true (1) OR B is true
(l), then C will be true (1). C will be false (0) when both A and B are false (0).
The different combinations of A and B are shown below

2. AND Operator
In Boolean algebra the AND operator is defined by the use of
multiplication (x). For example, A x B = C means that if A is true AND B is
true, then C will be true. Except this, C will be false. The different
combinations of A and B are

3. NOT Operator
In Boolean algebra, the NOT operator is defined by the use of a bar (-). Thus the NOT operator represents
the inversion. Therefore, if A is true (1), then A will be false (0) and vice-versa.

ELECTRICITY, MAGNETISM & ELECTRONICS 301


SRI CHANAKYA DEGREE COLLEGE
5.9.1 BOOLEAN LAWS

(1) Laws of Complementation (NOT Laws)


The term complement means to invert. So, in Boolean Algebra, change 1 to 0 or 0 to 1. Thus, we have

Rule 1: 0  1 Rule 3 : If A = 0, then A  1


Rule 2 : 1  0 Rule 4 : If A = 1, then A  0

So, for a logic variable X, we have X . X = 0 and X + X = 1


(2) OR Laws
The OR operation is represented by + sign. If A and B are inputs and C is output, then
A+B=C
We know that 0 + 0 = 0; 0 + 1 = 1; 1 + 0 = 1; 1 + 1 = 1.
From these expressions, if both the inputs are 0, then output will be zero and if any input or both inputs is 1, then
output will be 1.

Law 1. A + 0 = A, Law 3. A + A = A
Law 2. A + 1 = 1 Law 4. A + A = l
(3) AND Laws

The AND operation is represented by multiplication. A  B = C shows the AND laws. So


0 . 0 = 0, 0.1= 0
1 . 0 = 0, 1.1=1
So, if any input is zero or both inputs are zero, then output will be zero while if both the inputs are 1, then only the
output will be one.

Law 1. A 0 = 0, Law 3. A A = A
Law 2. A 1 = A Law 4. A A = 0

(4) Commutative Laws


There are two commutative law. These laws allow change in the position of variables in OR and AND expressions.
These are

A+B=B+A
A  B= B  A
(5) Associative Laws
There are two associative laws. These laws allow removal of bracket from logical expression and regrouping of
variables. These laws can be stated as

Law 1 : A + (B + C) = (A + B) + C
Law 2: A  (B C) = (A  B)  C

(6) Distributive Laws


There are three distributive laws. These laws show that we can expand expressions by multiplying terms as in
ordinary algebra. The distributive laws are:

ELECTRICITY, MAGNETISM & ELECTRONICS 302


SRI CHANAKYA DEGREE COLLEGE
Law 1: A  (B + C) = (A  B) + (A  C)
Law 2: A + (B  C) = (A + B)  (A + C)
Law 3: A + (A  B) = A + B

(7) Absorptive Laws


There are three absorptive laws. These are

Law 1: A + (A  B) = A
Law 2: A  (A + B) = A
Law 3: A  (A + B) = AB

ALL Boolean laws are

1. A + 0 = A 11. A = A
2. A + 1 = 1 12. A + B = B + A
3. A + A = A 13. A  B = B  A
4. A + A = 1 14. A + A  B = A
5. A  0 = 0 15. A + A B = A + B
6. A  1 = 1 16. (A + B) + C= A + (B + C)
7. A  A = A 17. (A  B)  C = A  (BC)
8. A  A = 0 18. A  (B + C)= A B + A C
9. 0 = 1 19. A + BC = (A + B)  (A +C)
10. 1 = 0 20. A  (A + B) = A B
5.10. DEMORGANS LAWS:
1st law: The complement of sum of two (or) more variables is equal to the product of complements of the variables.
i.e, A  B = A . B

Proof: the only two values for the variables A and B are 0 and 1

Case i: if A= 0, B = 0.

L.H.S = 0+0=1
R.H.S = 0.0 =1.1=1
L.H.S = R.H.S
Case ii: if A=1, B = 0.

ELECTRICITY, MAGNETISM & ELECTRONICS 303


SRI CHANAKYA DEGREE COLLEGE
L.H.S = 1+0 = 1 = 0

R.H.S = 1.0 = 0.1 = 0


L.H.S = R.H.S
Case iii: if A = 0, B = 1.
L.H.S = 0+1 = 1 = 0

R.H.S = 0. 1 = 1.0 = 0
L.H.S = R.H.S
Case iv: if A=1, B=1.
L.H.S = 1+1 = 1 = 0

R.H.S =1 .1 = 0.0 = 0
L.H.S = R.H.S
Thus the first law is verified

2ndlaw: The complement of the product of two (or) more variables is equal to sum of complements of the variables.
i.e, A.B = A  B .

Proof: the only two values for the variables A and B are 0 and 1
Case i: if A = 0, B = 0.
L.H.S = 0.0 = 0 = 1

R.H.S = 0 + 0 = 1+1 = 1
L.H.S = R.H.S
Case ii: if A=1, B = 0.
L.H.S = 1.0 = 0 = 1
R.H.S = 1+0 = 0 +1 = 1
L.H.S = R.H.S
Case iii: if A= 0, B =1.
L.H.S = 0.1 = 0 = 1

R.H.S = 0+1 = 1+0 = 1

ELECTRICITY, MAGNETISM & ELECTRONICS 304


SRI CHANAKYA DEGREE COLLEGE
L.H.S = R.H.S
Case iv: if A = 1, B = 1.

L.H.S =1.1=1=0
R.H.S =1+1=0+0=0
L.H.S = R.H.S
Thus the second law is verified

5.11. BASIC LOGIC GATES

Circuits which areused to process digital signals are called logic gates. Gateisadigitalcircuit with one
or more input voltages but only one output voltage. By connecting these gates in different ways, we can
build circuits that can perform arithmetic and other functions that are associated with the human brain. The
gates are often called logic circuits. The most basic gates are called the AND gate, the OR gate and the NOT
gate.
Logic gates are of two types- combinational and sequential. In combinational gates, the output at
any instant depends upon the inputs at that instant. Here the previous input does not have any effect on the
output. Eg: OR, NOT, NAND, NOR, XOR. But sequential gates, the output depends upon the order or
sequence in which the inputs are applied. Hence, sequential gates possess a memory function. Eg: Flip-
Flops, counters and Registers.
For analysis and design of digital circuits, 3 basic gates are used for fundamental operations.
(1) OR gate for addition (+)
(2) AND gate for multiplication (x) and

(3) NOT gate for inverting (represented by a bar over the variable).
5.11.1. OR gate
An OR gate has two or more input signals but only one output signal. In OR gate, output voltage is
high if any or all the input voltages are high (or) Output is low only when the two inputs are low. The
symbolic representation of OR gate is shown in fig.

The electrical equivalence of the OR logic can be explained with


circuit diagram.
In the electrical circuit, the switches A and B are connected in parallel with each other. The lamp (output)
will glow only when A or B or both switches are closed.
The logic is indicated by expression A + B  X

ELECTRICITY, MAGNETISM & ELECTRONICS 305


SRI CHANAKYA DEGREE COLLEGE

The construction of OR gate can be done with two diodes and the operation of the OR gate as follows.
(i) When both A and B are at zero levels or grounded (low, 0), the two diodes are non-conducting
(reverse biased). No current flow to the output. So the output voltage is low (0).
(ii) When A is 1ow (0) and B is high (1), diode B is forward biased so that Current flows through RL, and
output, X is high (1).
(iii) When A is high (1) and B is 1ow (0), diode A is forward biased so that Current flows through RL,
and output, X is high (1).
(iv) when both A and B are high (1), both the diodes are conducting (Forward biased) and hence X is high
(1).
Based on the above logic, we have three Boolean algebraic laws.
i.e., A + 1 =1, A + 0 = A and A + A = A

These laws can be verified in the cases when A = 0 and A = 1.


5.11.2. AND gate
An AND gate has also two or more input signals but only one output signal. In AND gate, output
voltage is low if any or all the input voltages are low (or) Output is high only when all the inputs are high.
The operation of an AND gate is similar to multiplication (.). The symbolic representation of AND gate
and its electrical equivalent diagram is as shown in fig.

In the electrical equivalent circuit, the switches A and B are connected in series with each other.

ELECTRICITY, MAGNETISM & ELECTRONICS 306


SRI CHANAKYA DEGREE COLLEGE
The lamp (output) will glow only when A and B both switches are closed.
The logic is indicated by expression A B  X
The following is the construction of AND gate using two diodes and the corresponding Truth table is also
provided.

Operation of AND gate:


(i) When both A and B are zeros i.e., the cathode of each diode is grounded, the two diodes are
conducting as they are forward biased. Now the diodes have very less resistance, So the output voltage
(current x resistance) w.r.t. earth is zero. The whole voltage VCC will be dropped across RL only. So
the output voltage is low (0).
(ii) When A is zero (low) and B = 5V (high), the diode D1 is grounded and diode D2 is reversed-biased.
Due to reverse-biasing, the diode D2 stops conducting. The diode D1 will now conduct due to forward-
biasing. Therefore, the output will be zero as above.
(iii) When A is 5 V (high) and B is zero (low). In this case, D1 in forward biased (conducting) and D2 in
reverse biased (non-conducting). Here also due to D1 less resistance appears at output terminal.
Hence, output is zero.
(iv) When A and B are high, both the diodes are non-conducting. Since the diodes are off, there is no
current through RL. Now the supply voltage VCC = 5 V appear at the output. Therefore, output is
high.
Based on the above logic, we have three Boolean algebraic laws.
i.e., A ∙ 0 = 0, A ∙ 1 =A and A ∙ A = A

These laws can be verified in the cases when A = 0 and A = 1.

ELECTRICITY, MAGNETISM & ELECTRONICS 307


SRI CHANAKYA DEGREE COLLEGE
5.11.3. NOT gate
The NOT gate is a gate with only one input and one output. Here, always output is the
complement of the input. So the NOT gate is also called an inverter. When the input voltage is high,
the output is low and vice-versa. The following is the symbolic representation of NOT gate and its
electric equivalent circuit.

From the electrical analog of NOT gate, when switch A is closed (input is high) the bulb will not glow (i.e.,
output is low) and vice-versa.
NOT Circuit Operation

Fig. shows the common-emitter circuit which is used as a NOT gate. The circuit operation is quite simple.
When Vin is high, the transistor is driven into saturation so that V out is low. If Vin is low, i.e., base voltage is not
present, the transistor is in cut off so that Vout is high. Hence, we see that whenever input is high, the output is low
and vice-versa which verifies the NOT Truth-table.

The NOT operation is represented by a line drawn over the top of the input. The negation of A is �, called
NOT A or sometimes A-bar.

The NOT laws are quite simple 0= 1 and 1= 0 Also, � = A


5.11.4. NAND gate
NAND gate is A logic circuit in which a NOT gate followed by AND gate. So, NAND gate is a combination
of AND gate and a NOT gate. The symbol of a NAND gate and corresponding equivalent circuit diagram is as shown
in fig. Here the bubble on the output reminds us of the inversion after ANDing. Mathematically it is expressed as

� = �∙�

ELECTRICITY, MAGNETISM & ELECTRONICS 308


SRI CHANAKYA DEGREE COLLEGE

From the circuit, the bulb will glow only when either A and B or both are opened. If both are closed then short
circuited, so bulb will not glow.

(i) When A = 0, B = 0 then AB = 0 and � = ��= 1


(ii) When A = 0, B = 1 then AB = 0 and � = ��= 1
(iii) When A = 1, B = 0 then AB = 0 and � = ��= 1
(iv) When A = 1, B = 1 then AB = 1 and � = ��= 0

5.11.4.1. Circuit of NAND gate


The output of a NAND gate is given by X = A .B. Fig. shows circuit of
NAND gate. Here a diode AND circuit is connected to a transistor NOT
circuit which gives the NAND circuit. It can be seen that when the two
inputs are zero, the transistor will not conduct. So the output will be
+VCC. On the other hand, when positive voltages are applied to the two
inputs the transistor will conduct into saturation region. Now the output
will drop to zero. In this way the circuit behaves as a reverse AND circuit
and hence called as NAND circuit. As we already know OR and AND
gates can be built by using diodes or transistors but a NOT gate can be
built by using transistors only.

5.11.4.2. NAND GATE AS A UNIVERSAL GATE


The NAND gate is called a universal gate since any logic circuit (OR, AND, NOT) can be built by using NAND
gate.

1 As NOT gate
If the two inputs of NAND gate are connected together, then we get a NOT gate.

2. As AND gate
The AND gate can be produced by connecting two NAND gates in series.

ELECTRICITY, MAGNETISM & ELECTRONICS 309


SRI CHANAKYA DEGREE COLLEGE

3. As OR gate
OR gate can be produced by three NAND gates as shown in fig. It is important to mention here that OR function
may not be clear from this figure because De Morgan's theorem is needed to prove that � ∙ � = � + �

5.11.5. NOR GATE

NOR gate coming from the words NOT and OR. NOR gate = OR gate + NOT gate. From the figure, the
bubble in the output signifies that inversion takes place after the OR ring.
As is evident from this figure the lamp will not glow (output is zero) when either of the inputs A or B is
high.
Following is the truth table for NOR gate

The output of a NOR gate can be written as X = A + B.


(i) When A = 0, B = 0, then A + B = 0  X = A + B =1
(ii) When A = 0, B = 1, then A + B = 1  X = A + B = 0
(iii) When A = 1, B = 0, then A + B = 1  X = A + B = 0
(iv) When A = 1, B = 1, then A + B = 1  X = A + B = 0

ELECTRICITY, MAGNETISM & ELECTRONICS 310


SRI CHANAKYA DEGREE COLLEGE
5.11.5.1. Circuit of NOR gate
Fig. shows the circuit of a NOR gate. As seen from the
figure, the output X is 1 only when both transistors are cut off,
i.e., when A = 0 and B = 0. For any other condition of input
one or both transistors saturate and the result is that the output
X is 0.

5.11.5.2. NOR GATE AS A UNIVERSAL GATE


NOR gate is a universal gate because it can be used to
perform the basic logic functions OR, AND and NOT.

1. As NOT gate
When the inputs of NOR gate are tied together, the output is A + A as shown
in fig. By De Morgan's theorem this is equivalent to A (i.e., A + A =
A). This is the function of NOT gate.

2. As OR gate
This gate can be realized by connecting output of a NOR gate to NOT gate. This is shown in fig.
The output of NOR gate is A + B. This is inverted by NOT gate to give X = A+B. This is inverted by
NOT gate to give X =A +B. This is a function of OR gate.

3. As AND gate
AND gate can be made out of three NOR gates.
Here, two NOR gates are used to invert the inputs
and the third one is used to combine the inverted
inputs.

The output AB is a function of AND gate. This


can be proved with the help of De Morgan's law.

5.11.6. Exclusive OR Gate (XOR Gate):


The symbolic representation of XOR Gate is shown in figure. There are two inputs and one output. The
exclusive OR operation is denoted by  . Hence the output is given by X  A B

ELECTRICITY, MAGNETISM & ELECTRONICS 311


SRI CHANAKYA DEGREE COLLEGE

X  A B  A.B + A.B

The other way to implement XOR logic are shown in fig

X  AB (A  B)
The truth table for EX-OR Gate is shown below

Truth Table:

A B A. B A.B X  A B
 A.B  A. B
0 0 0 0 0
1 0 0 1 1
0 1 1 0 1
1 1 0 0 0

Case 1: if A = 0, B=0, then output X = 0.


Case 2: if A = 0, B=1, then output X = 1.
Case 3: if A = 1, B=0, then output X = 1.
Case 4: if A = 1, B=1, then output X = 0

From the truth-table, output is 1 only when the inputs are different. XOR operation also called mod-2
addition.

Applications of XOR gate:


(1) XOR gate can be used as Binary to Gray code converter.
(2) It can be used as a parity checker.
(3) It is also used in Half-adder circuit.

ELECTRICITY, MAGNETISM & ELECTRONICS 312


SRI CHANAKYA DEGREE COLLEGE
5.12. HALF ADDER:
Half adder is an electronic logic circuit that adds two single bits and produce a sum and a carry to be used in
the next higher position. It consists of two inputs A and B and two outputs carry Q and sum S. It does not accept a
carry input or previous carry Q'. To accept a previous carry (Q') a full adder is used. Here sum represents the output
of Exclusive OR Gate and carry represents the output of AND Gate. The standard symbol for half adder is shown in
figure.

Truth table:
Carry Sum
A B Q S
0 0 0 0
1 0 0 1
0 1 0 1
1 1 1 0
Case 1: if A=0, B=0, then Q=0, S=0.
Case 2: if A=0, B=1, then Q=0, S=1.
Case 3: if A=1, B=0, then Q=0, S=1.
Case 4: if A=1, B=1, then Q=1, S=0.
The circuit is called half-adder because it cannot accept a carry in from previous additions. For this purpose,
we need a 3-input adder called full-adder.

5.13. FULL ADDER:


Half-adder can add only two lower significant bits. It cannot be used for addition of higher position bits
because those have previous carry values also. We can define full-adder as a logic circuit that adds three bits and
produce SUM (S) and CARRY OUT (Q). This CARRY OUT is taken as CARRY IN (Q') in the next addition. In
this way we have 3 inputs for addition. Two are bits to be added and the third is CARRY IN (Q') generated from
previous addition. In full adder two half adders and one OR-Gate over cascaded as shown in figure.

The standard symbol for FULL ADDER is as follows.

ELECTRICITY, MAGNETISM & ELECTRONICS 313


SRI CHANAKYA DEGREE COLLEGE

Implementation of full adder using logic gates as follows

The truth table for FULL ADDER is given below

5.14. PARALLEL BINARY ADDER


A single full adder is capable of adding two one-bit numbers and an input CARRY. For addition of binary
numbers with more than one bit, additional full-adders are required. Thus, for n-bit numbers, n füll-adders are
required. For implementing the addition of higher order binary numbers higher-order adder are needed. Consider a
two –bit adder for two-bit binary number. The CARRY output of each adder is connected to the CARRY input of
the next higher-order adder as shown in fig.

Four-bit parallel adder

ELECTRICITY, MAGNETISM & ELECTRONICS 314


SRI CHANAKYA DEGREE COLLEGE

A four-bit binary parallel adder circuit is shown in fig. The two numbers being added are A3, A2, A1, A0 and
B3, B2, B1, B0. Their sum is S4, S3, S2, S1, and S0, as shown in fig.

The full-adder circuit in each position has three inputs: an A bit, a B bit and a C in (CARRY IN) bit and it
produces two outputs: a SUM bit and a CARRY OUT bit. For example, full-adder FA0 has inputs A0, B0 and Cin. It
produces output S0 and C1. Here carry C1 is forwarded for next full-adder. The procedure is repeated for other full
adders.

Operation of 4-Bit Adder

(i) The first adder performs 0 + 1 binary addition. This is gives a sum of l and a carry of 0.
(ii) 1 and 1 are supplied from two registers A and B simultaneously. The sum 1 appears on the display
panel and carry 0 is passed to the next full-adder.
(iii) The second adder: adds 1 + 1 + 0 (carry), produce sum 0 with carry 1.
(iv) The third adder performs 0 + 0 + l (carry) and produce sum 1 with carry 0.
(v) The fourth adder adds 1 + 1 + 0 (carry) and produce sum 0 with carry 1 (both of which appear on
display unit).

ELECTRICITY, MAGNETISM & ELECTRONICS 315


SRI CHANAKYA DEGREE COLLEGE
(vi) Therefore, the final number appears as 10101

EXCERCISES ON NUMBER CONVERSION


Conversion of Binary into decimal System:
1. (1011)2 =
2. (1111)2 =

3. (1101001)2 =

4. (1011101)2 =

5. (11010011)2 =

6. (0.101) 2 =

7. (0.1001) 2 =
8. (1011.101) 2 =

9. (10010.1011) 2=
Conversion of Decimal to Binary system:
1. (11)10 =
2. (57)10 =

3. (45)10 =
4. (211)10=

5. (0.625)10=

6. (0.5625)10=

7. (57.59375)10=

8. (47.5625)10 =

ELECTRICITY, MAGNETISM & ELECTRONICS 316


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 317


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 318


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 319


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 320


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 321


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 322


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 323


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 324


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 325


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 326


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 327


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 328


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 329


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 330


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 331


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 332


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 333


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 334


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 335


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 336


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 337


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 338


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 339


SRI CHANAKYA DEGREE COLLEGE

MODERN PHYSICS 340


SRI CHANAKYA DEGREE COLLEGE

Introduction
unit-i
MEANING
The word 'statistics' has been derived from the Latin word 'status', German word 'status.

In ancient times, the government used to collect the information regarding the size of
the population in the country, property of the country, military force, etc. But at present,
statistics are used by the economist, managers, scientist, politicians, etc. So these days,
there is hardly a place where statistics are not used. The word 'statistics' can be used
both singulars as well as plural sense.
DEFINITION
1. SELINGMAN: "Statistics is the science, which deals with the methods of collecting,
classifying, presenting. Companing and interpreting the numerical data"
FEATURES OF STATISTICS
The basic features of statistics as a quantitative or numerical data run a follows:
1. AGGREGATE OF FACTS
Single or isolated figures are not considered to be statistics because such figures are
unrelated and cannot be compared It is just a numerical statement the fact. Statistical
data are concrete numbers which represent objects
2. SYSTEMATICALLY ARRANGED
A proper plan should be prepared before collecting the statistical data. Therefore,
data should be collected in a systematic manner
3. STATISTICS ARE ESTIMATED OR ENUMERATED
According to the feature of statistics, data can be enumerated or estimated
4. STATISTICS ARE NUMERICALLY EXPRESSED
All statistics are expressed numerical figures i.e. expressed in numbers and related
to quantitative information only.
5. STATISTICAL DATA COLLECTED FOR A PRE DETERMINED PURPOSE
Collected should be, for a pre-determined purpose. The figures are collected with
some goal objective in mind. Without any objective collected data will be useless
6. PLACED IN RELATION TO EACH OTHER
Numerical information's must be mud related and comparable. In the absence of such
a quality the statistics would, purpose. For example, statistics related to number of

BASIC STATISTICS 341


SRI CHANAKYA DEGREE COLLEGE

children born, exports country, coal production etc. have no relevance for statistical
analysis.
CHARACTERISTICS
1. Collection of Data
The first step is statistical enquiry is to collection of data. The collection of data is
the main for objective of the study.
2. Classification and Tabulation of data
The collected data should be organized in a proper form which involves editing,
classification and tabulation
3. Presentation of Data
After classification of the data are presented in some suitable manner either by
diagrams or graphs.
4. Analysis of data:
Analysis follows the presentation of data simple mathematical techniques are
applied in analysis. These include measures of central tendency, dispersion,
skewness, correlation and regression etc.
5. Interpretation of data
The last step in statistical Investigation is to interpretation of the data. It involves
statistical thinking, skill, and experience. It give final conclusion.
7. FUNCTIONS
1. Presents facts in. simple form
Statistics presents facts and figures in a definite form. That makes the statement
logical and convincing than mere description.
2. Reduces the Complexity of data
Statistics simplifies the complexity of data. The raw data are unintelligible. We make
them simple and intelligible by using different statistical measures.
3. Facilitates comparison
Comparison between different sets of observation is an important function of statistics.
Comparison is necessary to draw conclusions
4. Test hypothesis
Formulating and testing of hypothesis is an important function of statistics.
This helps in developing new theories
5. Formulation of Policies
Statistics helps in formulating plans and policies in different fields. Statistical analysis
of data forms the beginning of policy formulations.

BASIC STATISTICS 342


SRI CHANAKYA DEGREE COLLEGE

6. Forecasting
The future is uncertain. Statistics helps in forecasting the trend and tendencies.
Statistical techniques are used for predicting the future values of a variable.
8. IMPORTANCE AND LIMITATIONS
1. GOVERNMENT:
Statistics was developed "as a science of kings or kings subject". It is said that
statistics are the eyes of administration and arithmetic of human welfare
2. ECONOMICS:
All branches of Economics like production, consumption, exchange and distribution
are described, compared and correlated with the aid of statistics
3. BUSINESS AND COMMERCE
The businessman should be able to take correct decisions at the correct time. Correct
decisions are possible only when the reliable facts and figures are available. Statistical
information is required right from the time the business is started. The ratio of fixed
working capital should be decided in advance. Sales and output should be forecasted and
eliminate losses
4. INDUSTRY
Statistical quality control (SQL) helps in reducing and stabilizing process variation that
may reduce cost significantly.
5. MATHEMATICS
Statistics and mathematics are very closely in touch with each other. Both have helped
jointly is the development of other social and physical sciences
6. PLANNING
We need planning at all levels. Our good plans must be fully supported by adequate
statistics. Sound planning should be based on sound data.
LIMITATIONS OF STATISTICS
1. QUALITATIVE ASPECT IGNORED
The qualitative phenomena, which cannot be measured and expressed in figures
and therefore statistical methods cannot be used Ito study them.
2. IT DOES NOT DEAL WITH INDIVIDUALS
The Statistics deals only with aggregates of facts and not with individual cases. It
reveals the characteristics of the group as a whole. It does not of each individual item
3. RESULTS TRUE ONLY ON THE AVERAGE
The statistics is not as accurate a science as other sciences are the statistical methods
are not very precise and correct.

BASIC STATISTICS 343


SRI CHANAKYA DEGREE COLLEGE

4. STATISTICS CAN BE MISUSED


Statistics can be misused by ignorant or wrongly motivates persons.
5. IT CAN BE USED BY EXPERTS ONLY
The techniques of statistics are not so simple to be used by any person. It can be used
by the experts, they knowing the application of statistics methodologies.
8. PRIMARY AND SECONDARY DATA
The statistical data can be collected in two ways such as and Secondary Data
1. PRIMARY DATA
Primary data are collected originally for a specific purpose. The data is collected
by the investigator for the first time. According to Wessel "Data originally
collected in the process of investigation are known as primary data".
METHODS OF COLLECTING PRIMARY DATA
A) DIRECT PERSONAL INVESTIGATION
In this method, the investigator collects the data personally, by meeting the
concerned persons. The investigator contact get the information directly. This
method is more accurate and relevant them other methods.
MERITS
1. It will be more accurate
2. The response will be more
3. Supplementary information useful for final results obtained)
DEMERITS
1. This method is very costly.
2. It is very time consuming
3. It requires extra personal Qualities of the Investigator
4. Sometimes can give wrong results)
5. It can be used only small area.
B) INDIRECT PERSONAL INVESTIGATION
It is also known as Indirect oral interviews. Under this method the investigator
contents third parties or witnesses, who are concerned with the information indirectly
MERITS
1. The investigator can take the help of expert enumerators.
2. Intensive and extensive Investigation is possible.
3. It is simple and convenient method of investigation.

BASIC STATISTICS 344


SRI CHANAKYA DEGREE COLLEGE

DEMERITS
1. Information obtained may not be reliable
2. It is enumerators are not expert in their field, then wrong data may be collected.
C) MAILS QUESTIONNAIRE
Under this method a questionnaire is prepared and sent by post to the persons
concerned. The Questionnaire contains questions pertaining to the enquiry. The
respondents are required to answer the questions and return the questionnaire within a
specified data.
MERITS
1. Wide coverage is possible
2. It saves time
3. It is economical and cheapest cost
DEMERITS
1. Information can get literates only.
2. It involves uncertainty response.
3. It is not possible to get within a stipulated time
SECONDARY DATA
Secondary data are data collected from already existing sources. An investigator makes
use of data already compiled by some other person, he is said to be making use of
secondary data Sometimes it is not possible to collect first hand information for want of
resources in terms of money, time etc. In that situation, secondary data is used. This
type of data is generally available in magazines, journals, bulletins etc.
A) PUBLISHED DATA
The published data may be obtained from various international, national and local
publications. This data includes:-
1. Official publications of the central and state Government (National Income,
savings, Investments, employment, committee reports etc.).
2. Internal publications (Annual Reports, labour organization reports of
international etc.)
3. News papers and magazines
4. Private publications of trade associations, trade unions, co- operative societies
etc.
5. Periodical reports of joint stock companies etc.

BASIC STATISTICS 345


SRI CHANAKYA DEGREE COLLEGE

B) UNPUBLISHED DATA
Data collected by private institutions may not have been published for various
reasons. Such unpublished data may be furnished on request.
DISTINGUISH BETWEEN PRIMARY DATA AND SECONDARY DATA
Important points of distinction between primary and secondary data are given below

QUESTIONNAIRE

Questionnaire is a statement, which is a set of questions relating to the enquiry. The


necessary information is collected from the respondent, through a questionnaire. It is
essential that a questionnaire is carefully designed on scientific lines so that data
collected are reliable, relevant and accurate. It is prepares by an expert with sharp
intelligence, who can construct a good questionnaire.

Features or Essentials of a good questionnaire:-

1. The questions should be simple and easily under stood.

2. The number of questions should be reduced, Irrelevant questions may be ignored.

3. Questions should be so framed as to answers like 'Yes' or 'No'.

BASIC STATISTICS 346


SRI CHANAKYA DEGREE COLLEGE

4. The questions should be arranged in a sequence.

5. The questions asked should be well worded

6. Questions should not strain the memory of informants,

7. Mathematical calculations should be avoided.

8. The statistical units should be clearly defined.

9. The purpose of Investigation should be told to the informants.

CLASSIFICATION OF DATA

The process of arranging the data in groups or classes according to their common
characteristics is technically known as classification. The main object of statistics is to
facilitate comparative study

OBJECTIVES/USES / IMPORTANCE OF CLASSIFICATION

1. To simplify the complexities of the collected data

2. To make the data more intelligible

3. To make the characteristics of similarities and dissimilarities clear.

4. To make a comparative study possible, because it should be stable.

5. It helps in huge mass of data to simplify in short way.

6. It is helpful in the presentation of data in the shape of tables, diagrams, graphs etc.

TYPES OF CLASSIFICATION

1. Qualitative classification

2. Chronological classification

3. Geographical classification

4. Quantitative classification

BASIC STATISTICS 347


SRI CHANAKYA DEGREE COLLEGE

DIAGRAMMATIC PRESENTATION

A diagram is a visual form for presenting statistical data for highlighting the basic facts
and relationship which are inherent in the data. The diagrammatic presentation is more
understandable and it is appreciated by everyone

IMPORTANCE OR UTILITY OF DIAGRAMS

1. Diagrams give a very clear picture of data.

2. We can make comparison between different samples very easily

3. This technique can be used universally at any place and at any time.

4. Diagrams have impressive value also. A common man is impressed easily by good
diagrams.

5. This technique can be used for numerical type' of statistical analysis. e.g. to locate
Mean, Mode, Median or other statistical values.

6. It does not save only time and energy but also is economical

7. These give us much more information as compared to tabulation.

RULES OR DIRECTIONS FOR MAKING DIAGRAMS

1. It must be attractive.

2. Its presentation must be portion ate in height and width

3. It must be Economical in terms of money, energy and time.

4. It must be Intelligible.

5. Scale must be presented along with diagram

6. Size of figure should be such that it may occupy considerable polilon of paper.

7. It must be neat and clean.

8. If some points are to be clarified, foot notes may be given.

BASIC STATISTICS 348


SRI CHANAKYA DEGREE COLLEGE

A) HISTOGRAM

It consists of a no, of rectangles, those are vertically and rectangles are formed of the
height proportionate to vertically adjacent. Class intervals are taken an x-axis and
frequencies their frequencies. It may be two types. They are:

i) Histogram with un-equal class intervals.

B) FREQUENCY POLYGON

It can be constructed by taking middle points of class intervals on x-axis and


frequency on y-axis. These points are joined two extremes are joined with base in such

a way that they touch the x-axis at half the distance of class interval outside the
extreme points.

C) FREQUENCY CURVE (OR) SMOOTHED HISTOGRAMS

Unlike frequency polygon, where points are joined by straight lines, we make use of
freehand joining of those points in order to get a smoothed frequency curve. It is used
to remove the ruggedness of polygon and to present in a good form.

D) OGIVE (OR) CUMULATIVE FREQUENCY CURVE

In this case there are two types of Ogives (i) Less than ogive (ii) More than ogive

For less than ogive we cumulative the frequencies from above as usual and plot the
point of upper limit of class interval against the value of corresponding cumulative
frequency. These points are joined freehand curve,

ORIGIN OF STATISTICS

The word statistics has been derived from the Latin word "Status", the Italian word
"Statista" or German word "Statistik". All these words mean a 'political state' In the
early years "Statistics" means a collection of facts about the state or the people in the
state for political purposes. Thus, it helped in collecting data about economic and social

BASIC STATISTICS 349


SRI CHANAKYA DEGREE COLLEGE

conditions of the people living in different parts of the country. For proper functioning
of the state, it is essential to know the conditions, under which the people live and
work, earn income and spend the wealth. This science was known as the science of
state because it was used by the state.

LORENZ CURVE

Ans. Lorenz Curve is a cumulative percentage curve in which the percentage of items
or frequencies is shown with the corresponding percentage of factors like income,
wealth, profits etc. The curve is used to study the distribution of land, wages income
among the population of the country, graphically the dispersion is studied by means of
the Lorenz Curve.

BASIC STATISTICS 350


SRI CHANAKYA DEGREE COLLEGE

MEASURES OF CENTRAL TENDENCY


unit-iI
1. Define Measures of Central Tendency (Average). What are the objectives and
Characteristics of measures of central tendency?
Ans. Measures of central tendency are a combination of two words i.e. 'measure' and
'Central tendency'. Measure means methods and central tendency means average value
of any statistical series. Thus we can say that central tendency means the methods of
finding out the central value or average

ESSENTIALS OF A GOOD AVERAGE/CHARACTERISTICS:


1. The Average should be based on all observations of the data.
2. The Average should not be unduly affected by extremely high (or) low values in the
distribution.

3. The Average should be rigidly defined.

4 The Average should be simple to understand and easy to calculate.


5. The Average should be capable of further algebraic treatment, like measures of
Dispersion, Correlation etc,

2. EXPLAIN THE DIFFERENT TYPES OF AVERAGES

PROPERTIES OF ARITHMETIC MEAN:


1. The sum of deviations of the items from their arithmetic mean is always zero, i.e.
Σ (x – X) = 0.

2. The sum of the squared deviations of the items from Arithmetic Mean (A.M) is
minimum, which is less than the sum of the squared deviations of the items from
any other values.

3. If each item in the arithmetic series is substituted by the mean, then the sum of
these replacements will be equal to the sum of the specific items.

MERITS OF MEAN:
1. Arithmetic mean rigidly defined by Algebraic Formula.

BASIC STATISTICS 351


SRI CHANAKYA DEGREE COLLEGE

2. It is easy to calculate and simple to understand.

3. It is based on all observations of the given data.

4. It is least affected by the fluctuation of sampling.

5. For every kind of data mean can be calculated.

DEMERITS OF ARITHMETIC MEAN:


1. It can neither be determined by inspection or by graphical location.

2. Arithmetic mean cannot be computed for qualitative data like data on


intelligence honesty and smoking habit etc.

3. Arithmetic mean cannot be computed when class intervals have open ends.

GEOMETRIC MEAN
G.M. is obtained by multiplying the values of the items and extracting the root of the
product corresponding to the number of items. Its calculation is very difficult So, that it
is not used in the ordinary situations.

MERITS
1. It can be calculated with mathematical precision provided all the values are positive.

2. It is based on all items of the series.

3. It gives more weight to small items and less weight to big items.
4. It is useful for construction of Index numbers.

DEMERITS:
1. It cannot be used when any item is zero (or) negative value.
2. It is not easily understand.

3. It is very difficult to calculate.

HARMONIC MEAN
The calculation of H.M. is based on division form. The relation of A.M, G.M. and H.M
Averages as A.M. is always greater than G.M.

BASIC STATISTICS 352


SRI CHANAKYA DEGREE COLLEGE

MERITS
1. It is determinate.

2. It is based on all the items of the series.

3. It gives largest weight to the smallest item and least weight to the largest item.

4. It is an algebraic treatment.

DEMERITS:
1. It is not easy to understand and its calculation is difficult.
2. It is not possible to calculate when the both positive negative values in the data.
3. It may not be an actual item in the series.

MEDIAN
It is a production (location) Average. Median refers to the middle value of the
distribution, when the series is arrange in Ascending order (or) Descending order. In
other words Median is the value which divides the series into two equal parts.

Median = Size of ( )th item.

MERITS
1. It is easy to understand and easy to calculate.
2. It is not affected by the presence of extreme items in the series.
3. It can be calculated by graphically.

4. It is an actual items taken from the series.

DEMERITS
1. It may not be representative, if the series are irregular.

2. All items of the series are not taken into account.

3. It is not rigidly defined.

BASIC STATISTICS 353


SRI CHANAKYA DEGREE COLLEGE

MODE
It is a productive Average. It is also known as Model value. It is that value in a series
of observations which occurs, with the greatest frequency, which means the value
occurs more the number of times than others.

MERITS
1. It is easy to understand.

2. It can be calculated without the knowledge of the values of the extreme items.
3. It can be determined graphically.

DEMERITS
1. It is often ill-defined and indefinite.
2. All number of observations are not taken into account
3. It is not suitable for future algebraic treatment.

3. Explain the relationship between Mean, Median and Mode


 Mean is the average of the data set which is calculated by adding all the data values
together and dividing it by the total number of data sets.
 Median is the middle value among the observed set of values and is calculated by
arranging the values in ascending order or in descending order and then choosing the
middle value
 Mode is the number from a data set which has the highest frequency and is
calculated by counting the number of times each data value occurs.
Mean - Mode = 3 (Mean - Median)

BASIC STATISTICS 354


SRI CHANAKYA DEGREE COLLEGE

MEASURES OF dispersion
unit-iiI
1. What is Dispersion? Explain its properties and Uses
The measures of central tendency give us one single value represents the entire data.
But the average alone cannot adequately describe a set of observations unless all the
observations are the same. It is necessary to describe the variability or dispersion of the
observations of two or more distributions. Measures of dispersion help us in studying
the important characteristic of the distribution. Dispersion means distance.
DEFINITION
According to Bowley "Dispersion is a measure of variation of the items"
PROPERTIES OR FEATURES OF DISPERSION
1. It should be capable of treating it by algebraic or statistical techniques.
2. It should be easy to calculate
3. It should be easy to understand
4. It should not be affected by different samples
5. The quality and quantity of each term must affect it.
6. To compare two or more series with recorded their variability,
USES OR OBJECTS OF DISPERSION
1. TO USE OTHER STATISTICAL METHODS
After getting value of dispersion we can proceed to other techniques such as to
locate co relation or lines of Regression.
2. TO TEST RELIABILITY OF AVERAGE
When the differences between the central value and the given values are smaller,
the uniformity is less. It means that this sum should be minimum for the
reliability of the averages.
3. TO COMPARE VARIABILITY
In general habit of comparison of two or more series. It may be income, weight,
height, temperature, score of the players, life of the bulbs etc. To achieve the
required degree of result and one tries to improve to achieve the required result.
4. TO ESTABLISH TRENDS IN TIME SERIES
In time series we remove, cyclical, seasonal or random fluctuations, which we
form after studying central values.

BASIC STATISTICS 355


SRI CHANAKYA DEGREE COLLEGE

2. Explain the different types of Dispersion.


The following methods are used to calculate dispersion.
1. Range
2. Quartile Deviation
3. Mean Deviation
4. Standard Deviation
1. RANGE
Range is the simplest method of studying dispersion. It is defined as the difference
between values of the smallest item and the largest item.
Range - L-S
Where, L Largest value; S = smallest value The relative measure corresponding to
range called as "The co- efficient of Range" is obtained by applying the following
formula. L-S L+S Co-efficient of Range =
ADVANTAGES OF RANGE
1. It is easy to calculate and simple to understand even for a beginner.
2. It is one of those measures which are rigidity defined.
It is used to check the quality of a product for quality control.
4. It gives us the total picture of the problem even with a single glance.
5. Meteorological Department also makes forecasts about the weather by keeping range
of temperature in view.
DISADVANTAGES
1. Range is not based on all the items, it will take only large value and small value.
2. It is not a reliable measure of dispersion
3. Range does not change, even the variables are changed.
4. Range is too much affected by fluctuations of sampling.
5. It is not possible to find dispersion in case of open end classes.
2. QUARTILE DEVIATION
The range is a measure of dispersion and has a number of limitations. For this purpose
there has been developed on another measure called "Inter-Quartile range", which
includes the middle of 50% of the distribution.
Inter Quartile Range = Q3 - Q1
Quartile Deviation = ; CO-efficient f Q.D =

BASIC STATISTICS 356


SRI CHANAKYA DEGREE COLLEGE

MERITS
1. It can be easily calculated and simply understood.
2. It does not involve much mathematical difficulties.
3. As it takes middle 50% terms hence it is a measure better than Range and Percentile
Range.
DEMERITS
1. As Q and Q are both positional measures hence are not capable of further algebraic
treatment.
2. Calculation is much more, but the result obtained is not of much importance.
3. It is too much affected by fluctuations of samples.
3. MEAN DEVIATION
Mean deviation is also known as average deviation. It should be based on all
observations. The mean deviation is defined as "The absolute deviations taken from the
measures of central tendency and counting all such deviations are positive". The mean
deviation is obtained by sum of deviations taken from the average by the total number
of observations.
M.D. , Where D Absolute deviations
(Deviations taken from average)
Co-efficient of M.D. =

MERITS
1. It is simple to understand.
2. It is easy to calculate.
3. It is based on all the observations of a series.
4. It is not very much affected by the values of extreme items of a series.
5. It facilitates comparison between different items of a series.
DEMERITS
1. It is not rigidly defined in the sense that it is computed from any central value
viz. Mean, Median, Mode etc. and thereby it can produce different results.
2. It is not capable of further algebraic treatment.
3. It is affected much by the fluctuations in sampling.

BASIC STATISTICS 357


SRI CHANAKYA DEGREE COLLEGE

4. STANDARD DEVIATION
The concept of S.D. was introduced by "Karl Pearson" in 1893. The mean deviation has
been replaced by standard deviation. The term S.D. is assigning to this measure of
variation probably become it is most commonly used. This S.D. has always computed
around the mean. It is the square root of A.M. of the squared deviations. It will spread
over in all setup observations.

Standard Deviation or σ= √

MERITS
1. This is the most rigidity defined measure of dispersion and therefore is dependable.
2. It is further capable of Algebraic Treatment; Coefficient of S.D., Variance and
Coefficient of Variation are used to test the variability and consistency by using S.D.
(VD) non
3. Unlike Mean Deviation, Combined S.D. for given two or more series can be
computed if Xs and S.D. are given.

DEMERITS
1. It is not understood by a common man.
2. Its calculation is difficult as it involves many mathematical models and processes.
3. It is affected very much by the extreme values of a series in as much as the squares
of deviations of big items proportionately bigger than the squares of the smaller items.

BASIC STATISTICS 358


SRI CHANAKYA DEGREE COLLEGE

MEASURE OF CORRELATION
QUESTION & ANSWERS
EXPLAIN WHAT IS CORRELATION?
MEANING
To measure the degree of association or relationship between two variables
quantitatively, an index of relationship is used and is termed as co-efficient of
correlation
CORRELATION ANALYSIS IS REQUIRED FOR
1. Finding characteristics of psychological and educational tests (reliability, validity,
item analysis, etc.)
2. Testing whether certain data is consistent with hypothesis.
3. Predicting one variable on the basis of the knowledge of the other(s).
4. Building psychological and educational models and theories.
5. Grouping variables/measures for parsimonious interpretation of data.
IMPORTANCE OF CORRELATION
1. Most of the variables show some kind of relationship. For instance, there is
relationship between price and supply, income and expenditure etc. With the help of
correlation analysis we can measure in one figure the degree of relationship.
2. Once we know that two variables are closely related, we can estimate the value of
one variable given the value of another. This is known with the help of regression.
3. Correlation analysis contributes to the understanding of economic behavior, aids in
locating the critically variables on which others depend

BASIC STATISTICS 359

You might also like