Feb 6th BSC Material All Subjects
Feb 6th BSC Material All Subjects
UNIT – I
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
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
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.
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.
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
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
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]
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.
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.
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.
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.
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
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
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.
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
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
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
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 −
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-
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-
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.
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
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
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.
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.
One-to-One Relationship
One-to-Many or Many-to-One Relationship
Many-to-Many Relationship
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.
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
DBMS 28
SRI CHANAKYA DEGREE COLLEGE [Pick t
If A or B is having total participation, then that should be a modified table.
DBMS 29
SRI CHANAKYA DEGREE COLLEGE [Pick t
EER is a high-level data model that incorporates the extensions to the original ER model.
These concepts are used when the comes in EER schema and the resulting schema diagrams
called as EER Diagrams.
DBMS 30
SRI CHANAKYA DEGREE COLLEGE [Pick t
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
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
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.
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.
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
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.
Relational Instance: It is the collection of records present in the relation at a given time.
DBMS 36
SRI CHANAKYA DEGREE COLLEGE
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.
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.
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.
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
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.
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.
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’.
DBMS 42
SRI CHANAKYA DEGREE COLLEGE
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
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
DBMS 43
SRI CHANAKYA DEGREE COLLEGE
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.
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
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:
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:
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'.
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.
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:
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.
Emp_Id → Emp_Name
DBMS 47
SRI CHANAKYA DEGREE COLLEGE
Example:
Example:
ID → Name,
Name → DOB
DBMS 48
SRI CHANAKYA DEGREE COLLEGE
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.
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.
DBMS 49
SRI CHANAKYA DEGREE COLLEGE
EMPLOYEE table:
EMP_ID EMP_NAME EMP_PHONE EMP_STATE
14 John 7272826385, UP
9064738238
14 John 7272826385 UP
14 John 9064738238 UP
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
DBMS 51
SRI CHANAKYA DEGREE COLLEGE
201010 UP Noida
02228 US Boston
60007 US Chicago
06389 UK Norwich
462007 MP Bhopal
DBMS 52
SRI CHANAKYA DEGREE COLLEGE
***Q1. What is SQL and give brief History and its benefits?
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.
DBMS 53
SRI CHANAKYA DEGREE COLLEGE
There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.
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.
CREATE
ALTER
DROP
TRUNCATE
Example:
DBMS 54
SRI CHANAKYA DEGREE COLLEGE
( Name VARCHAR2(20),
Email VARCHAR2(100),
DOB DATE );
b. DROP: It is used to delete both the structure and record stored in the table.
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.
d. TRUNCATE: It is used to delete all the rows from the table and free the space containing the
table.
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.
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.
b. UPDATE: This command is used to update or modify the value of a column in the table.
For example: UPDATE students SET User_Name = 'Sonoo' WHERE Student_Id = '3'
DCL commands are used to grant and take back authority from any database user.
Here are some commands that come under DCL:
Grant
Revoke
Example
GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;
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;
COMMIT;
b. Rollback: Rollback command is used to undo transactions that have not already been saved to
the database.
Syntax: ROLLBACK;
c. SAVEPOINT: It is used to roll the transaction back to a certain point without rolling back the
entire transaction.
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.
For example: SELECT emp_name FROM employee WHERE age > 20;
DBMS 57
SRI CHANAKYA DEGREE COLLEGE
There are Three types of binary Datatypes which are given below:
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.
float -1.79E + 308 1.79E + 308 It is used to specify a floating-point value e.g.
6.2, 2.9 etc.
DBMS 58
SRI CHANAKYA DEGREE COLLEGE
Data Description
type
timestamp It stores the year, month, day, hour, minute, and the second value.
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;
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;
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;
1. SELECT COMMAND
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>;
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
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>;
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);
DBMS 66
SRI CHANAKYA DEGREE COLLEGE
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;
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
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.
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;
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:
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
DBMS 71
SRI CHANAKYA DEGREE COLLEGE
Let's assume 'variable a' and 'variable b'. Here, 'a' contains 20 and 'b' contains 10.
- It is used to subtract the right-hand operand from the left-hand a-b will give
operand. 10
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
= 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 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
Operator Description
BETWEEN It is used to search for values that are within a set of values.
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
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.
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.
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.
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.
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
comparison
AND conjunction
OR inclusion
DBMS 79
SRI CHANAKYA DEGREE COLLEGE
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
SQL>start d://condi.sql
b=70
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
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.
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 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 ‘*/’
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.
[declaration statements]
BEGIN
[execution statements]
EXCEPTION
[exception handler]
END [procedure_name ];
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.
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( SQLERRM );
END;
DBMS 87
SRI CHANAKYA DEGREE COLLEGE
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;
/
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.
Advantages of Triggers
DBMS 89
SRI CHANAKYA DEGREE COLLEGE
Syntax for creating trigger:
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
UNIT- I
1. Define Database system. write their away
2. write the difference between file band approach &Database approach
UNIT-II
1. Explain about codd's Rules
UNIT - III
DBMS 92
SRI CHANAKYA DEGREE COLLEGE
UNIT - IV
1. Explain about Joins in SQL
UNIT – V
1. write the structure of PL/SQL
2. write the control structures in PL/SQL
DBMS 93
SRI CHANAKYA DEGREE COLLEGE
OBJECT ORIENTED
SOFTWARE ENGINEERING
UNIT-I
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
UNIT-V
UNIT - I
Q) Discuss about the overview of software engineering?
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
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.
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
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.
The general concepts of OOP which form the heart of Java language are
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)
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
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
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.
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).
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 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;
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.
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.
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.
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
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.
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.
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.
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.
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.
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:
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
UNIT - II
Q) EXPLAIN ABOUT SOFTWARE REQUIREMENTS ANALYSIS AND
SPECIFICATION(SRS)?
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.
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."
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.
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.
In the Unified Modeling Language (UML), a use case diagram can summarize the details of your
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:
Goals that your system or application helps those entities (known as actors) achieve
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.
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.
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.
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.
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.
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.
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
Scenario:
A customer searches for a product, adds it to the cart, and proceeds to checkout.
Steps:
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?
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.
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.
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.
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.
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.
Following are the rules that are to be followed for drawing an activity diagram:
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.
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.
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.
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:
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.
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.
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.
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.
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.
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:
Software construction involves writing code, integrating modules, and building the software
system based on the design. Its objectives are:
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).
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.
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.
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: 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
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.
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.
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.
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.
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.
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:
Multipurpose Language: Python can be used for web development, data analysis,
machine learning, artificial intelligence, automation, and more.
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.
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.
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.
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.
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:
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."
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.
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.
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.
Purpose:
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
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.
# Code to be tested
def add(a, b):
return a + b
# Unit Test
import pytest
def test_add():
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.
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)
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 ?
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.
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.
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:
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.
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.
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:
MINIMUM_AGE = 21
if age > MINIMUM_AGE:
print("Eligible")
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 total_price(amount):
return calculate_tax(amount) + amount
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.
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:
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
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 is_eligible_age(age): print("Eligible")
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?
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.
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.
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.
6. Audit and Compliance: Supports code auditing by keeping a log of who made which
changes and when.
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.
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.
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.
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.
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.
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.
o Formal techniques and automated validation tools can be used on models to detect
inconsistencies, errors, or gaps in functionality early in the process.
6. Better Communication:
o Models act as a common language between stakeholders, including developers,
business analysts, and end-users.
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.
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.
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.
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?
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,
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-
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.
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.
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.).
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.
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.
UNIT-I
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
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.
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.
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.
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.
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.
1. User Management:
2. File Management:
It allows administrators decide the location of data storage and control user access to
the data
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
Reference model, describe how data is transmitted and received between devices. There
are two popular reference models
This model was developed by International Standard organization (ISO). It has seven
Interconnected layers.
i) Physical Layer,
ii) Data Link layer
iii) Network layer
iv) Transport layer
v) Session Layer
vi) Presentation layer
vii) Application layer
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.
4. Signals: It determines the type of signal used for transmitting the information
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.
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.
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:
2. Addressing: It adds the source and destination address to the header of the frame.
4. Packetizing: This layer receives the packets from the upper layer and converts them
into packets.
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
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:
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.
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.
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
It is a fundamental framework for computer networking. These are the core protocols of
the internet. It consists of four layers
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
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:
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
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.
* Key protocols:
It ensures reliable ordered and error free delivery of data. It establishes a connection
between sender and receiver
4. Application layer: This layer provides network services directly to the users
applications. It handles high level protocols encoding and dialog control.
* Key protocols:
X.25 network’s
Frame relay
X.25 NETWORKS
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
(b)Micro Waves
(c)Infrared Waves.
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.
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.
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
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.
Category 1: These are used in telephone lines and low-speed data systems.
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
Disadvantage of UTP
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
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
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:
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
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
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)
Properties of PSTN
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.
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.
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.
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.
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°
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.
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
Φ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
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
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.
Now the total work done in moving the test charge q0 from A to B is
To find the potential at point B, the reference point A is taken at infinity so that VA = 0. Hence,
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 σ
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.
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
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.
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.
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.
… (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.
D and P in terms of 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:
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)
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.
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.
� = ∫ ��
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.
μ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
=
2
4 R
2
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.
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
μ 0i a2 ndx
dB = web/m2 or tesla (1)
2 a + x
3
2 2 2
a
3/ 2
a2 + x2 r 2 2
+ x2 r3
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)
2
cos θ l cos θ cos θ
2
4a l2
2 1/ 2 2
2
l
cos θ
l2 4a
2 1/ 2
2
μ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.
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 θ
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
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
EH
Φ� = ∫� �. (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
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.
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
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
So the energy density (energy per unit volume) u in magnetic field is given by
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
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.
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
(2)
Dividing eq. (2) by eq. (1), we get
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
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
i dt i
0 0
o sint dt
-2i0
=
Tω
cos ωt0
T/2
2
Similarly E E
avg
o
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
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
E0 sin ωt iR
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
π/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)
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.
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.
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 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
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,
Z 2 R2 2L2
Z R2 2L2
tan
EL iXL iL L
ER iR iR R
Further, L
tan1
R
q
Hence, E0 sin t Ri
C
q
R i E sin t ------ (1)
0
C
Differentiating this equation, we get
R i0 cost - (1/ C) i0 sin t E0 cos t cos sin t sin
Comparing the coefficients of sin t and cost - in the above equation, we get
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
tan1 (1 / C)
R
XC
tan1
R
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.
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
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
Comparing the coefficients of sin t and cost - in the above equation, we get
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
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
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
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).
1
We know that = 2π 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
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.
i0 i1 i2
1
Impedance of condenser branch, Z2
jC
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 jL jC
Admittance Y
1
1
1
R jL
jC
Z R jL 1
jC
R jLR jL
R jL
jC
R
jL
jC
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
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
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
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
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
Case ii: If the circuit contains inductor only then ϕ = π/2 Power
= Erms irms cos π/2 = 0
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
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.
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.
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
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
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
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.
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.
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
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.
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.
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.
(negative sign signifies that �� flows into transistor while IC flows out of it)
If we write ��� simply by �, then
��
�=− (1)
��
� 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
The ratio of collector current to the base current called dc beta (���) of transistor
��
� =�= (1)
�� ��
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.
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
�� = �� + �� or �� = �� − ��
�� ��/��
�= =
�� − 1 − (��/��)
��
�
� = 1−� (1)
Cross-multiplying eq. (1), we get
(1 − �) = �
or � − �� =
�
� = (1 + �)
� (2)
� = 1+�
1
It can be seen that 1−�= 1+�
(3)
�� = �� − ��
�= �� 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 + �)
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.
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
�
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
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
� ��
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
� ��
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
∆�� = � ∆��
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.
∆��� �ℎ���� �� ������ ������� × ��������� ����
�� = =
�� �ℎ���� �� ����� ������� × ����� ����������
��� × ��
� ��� × ��
�� ) ( �� × �)
=( � �
�
��
= � × ��
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.
The weights or place values of different digits in a mixed decimal numbers are as follows
Here number 9 is least significant digit (LSD) and 1 is the most significant digit (MSD).
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)
N = ai 2 i
m
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
N = ai 16 i
n
m
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
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.
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.
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.
Law 1. A + 0 = A, Law 3. A + A = A
Law 2. A + 1 = 1 Law 4. A + A = l
(3) AND Laws
Law 1. A 0 = 0, Law 3. A A = A
Law 2. A 1 = A Law 4. A A = 0
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
Law 1: A + (A B) = A
Law 2: A (A + B) = A
Law 3: A (A + B) = AB
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 (BC)
8. A A = 0 18. A (B + C)= A B + A C
9. 0 = 1 19. A + BC = (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.
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
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
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 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
In the electrical equivalent circuit, the switches A and B are connected in series with each other.
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.
� = �∙�
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.
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.
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 � ∙ � = � + �
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
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.
X A B A.B + A.B
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
From the truth-table, output is 1 only when the inputs are different. XOR operation also called mod-2
addition.
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.
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.
(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).
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 =
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
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.
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.
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.
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
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
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
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
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
1. It must be attractive.
4. It must be Intelligible.
6. Size of figure should be such that it may occupy considerable polilon of paper.
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:
B) FREQUENCY POLYGON
a way that they touch the x-axis at half the distance of class interval outside the
extreme points.
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.
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
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.
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.
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.
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.
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.
MERITS
1. It is determinate.
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.
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.
DEMERITS
1. It may not be representative, if the series are irregular.
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.
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.
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.
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.
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