Computer Networks, Database Management, and C Programming
Network Architecture
Network architecture is the design or structure of a computer network that defines how computers communicate and share resources with each other.
There are two types of network architecture:
1. Client-Server Architecture
In this architecture, one computer acts as a server and provides services and resources to other computers called clients. The server manages data, security, and other network resources. It is suitable for large organizations.
Example: A bank network where a central server stores customer information.
2. Peer-to-Peer (P2P) Architecture
In this architecture, all computers have equal status and can share resources directly with one another without requiring a dedicated server. It is simple and less expensive to set up, making it suitable for small networks.
Example: Two computers sharing files directly with each other.
Conclusion: Client-server architecture uses a central server to manage resources, whereas peer-to-peer architecture allows computers to share resources directly.
Wired Transmission Media
Wired transmission media is a type of transmission medium in which data is transmitted from one device to another through physical cables. It is also known as guided transmission media. There are three types of wired transmission media: twisted pair cable, coaxial cable, and optical fiber cable.
1. Twisted Pair Cable
Twisted pair cable consists of two insulated copper wires twisted together to reduce noise and interference. It is commonly used in telephone lines and computer networks. It is of two types: UTP (Unshielded Twisted Pair) and STP (Shielded Twisted Pair).
- Advantages: Cheap, flexible, and easy to install.
- Disadvantages: Limited transmission distance and more affected by interference than other cables.
2. Coaxial Cable
Coaxial cable consists of a central copper conductor surrounded by an insulating layer, a metallic shield, and an outer protective cover. It is commonly used in cable television and internet connections.
- Advantages: Better protection against interference and higher bandwidth than traditional twisted pair cable.
- Disadvantages: More expensive than twisted pair cable and less flexible.
3. Optical Fiber Cable
Optical fiber cable transmits data in the form of light signals through thin strands of glass or plastic. It is commonly used in high-speed internet, telecommunications, and long-distance communication.
- Advantages: Very high transmission speed and bandwidth, and completely immune to electromagnetic interference.
- Disadvantages: Expensive to install and difficult to repair and maintain.
Conclusion: Wired transmission media provides reliable communication through physical cables. Twisted pair cable is economical, coaxial cable provides better protection against interference, and optical fiber cable offers the highest speed and bandwidth.
Wireless Transmission Media
Wireless transmission media is a type of transmission medium in which data is transmitted from one device to another without using physical cables. It uses electromagnetic waves to transmit data through the air or space. It is also known as unguided transmission media. The main types of wireless transmission media are radio waves, microwaves, and infrared waves.
1. Radio Waves
Radio waves are electromagnetic waves that can travel long distances and pass through walls and buildings. They are used in radio broadcasting, television broadcasting, Wi-Fi, and mobile communication.
- Advantages: Cover large areas and can penetrate buildings.
- Disadvantages: May experience interference and provide less security.
2. Microwaves
Microwaves are high-frequency electromagnetic waves used to transmit data over long distances. They usually require a direct line of sight between the transmitting and receiving antennas. They are used in satellite communication, mobile networks, and radar systems.
- Advantages: High-speed data transmission and capability to carry large amounts of data.
- Disadvantages: Obstacles can block signals and weather conditions may affect transmission.
3. Infrared Waves
Infrared waves are electromagnetic waves used for short-distance communication. They generally cannot pass through walls and require devices to be within a limited range. They are used in TV remote controls and short-range device communication.
- Advantages: Inexpensive and produce less interference between separate rooms.
- Disadvantages: Short transmission range and inability to pass through solid objects.
Conclusion: Wireless transmission media allows data communication without physical cables. Radio waves are suitable for wide-area communication, microwaves are useful for high-speed and long-distance transmission, and infrared waves are mainly used for short-distance communication.
Classification of Transmission Media
Transmission media is a communication channel through which data is transmitted from one device to another. It is mainly classified into two types: guided transmission media and unguided transmission media.
1. Guided Transmission Media
Guided transmission media transmits data through physical cables. It is also known as wired transmission media. Its types are:
Twisted Pair Cable: It consists of two insulated copper wires twisted together. It is used in telephone lines and computer networks.
Coaxial Cable: It consists of a central copper wire surrounded by insulation and a metallic shield. It is used in cable television and internet connections.
Optical Fiber Cable: It transmits data in the form of light signals through thin glass or plastic fibers. It is used in high-speed internet and long-distance communication.
2. Unguided Transmission Media
Unguided transmission media transmits data through air or space without using physical cables. It is also known as wireless transmission media. Its types are:
Radio Waves: Used in radio broadcasting, Wi-Fi, and mobile communication.
Microwaves: Used in satellite communication and mobile networks.
Infrared Waves: Used in TV remote controls and short-distance communication.
Conclusion: Transmission media helps transfer data between devices. Guided media uses physical cables, whereas unguided media uses electromagnetic waves without cables.
Network Topologies
Network topology refers to the physical or logical arrangement of computers and other devices in a network. It describes how the devices are connected and how data flows between them. The main types of network topologies are:
1. Bus Topology
In bus topology, all computers are connected to a single main cable called a backbone. Data travels through the main cable to reach the destination device. It is simple and inexpensive to install, but if the main cable fails, the entire network may stop working.
2. Star Topology
In star topology, all computers are connected to a central device, such as a hub or switch. All data passes through this central device. It is easy to install, manage, and troubleshoot. However, if the central device fails, the entire network stops working.
3. Ring Topology
In ring topology, all computers are connected in a circular arrangement, with each computer connected to two neighboring computers. Data travels from one device to another around the ring. It provides orderly data transmission, but a break in the ring can disrupt the network.
4. Mesh Topology
In mesh topology, each computer is connected to many or all other computers through separate links. It provides high reliability because data can travel through alternative paths if one link fails. However, it is expensive and difficult to install due to the large number of connections required.
5. Tree Topology
In tree topology, computers are arranged in a hierarchical structure, combining features of bus and star topologies. It is suitable for large networks and makes network expansion easier. However, failure of the main backbone can affect a large part of the network.
6. Hybrid Topology
Hybrid topology is a combination of two or more different types of network topologies, such as star and bus topology. It is flexible and can be designed according to the needs of an organization. However, it is complex and expensive to design and maintain.
Conclusion: Different network topologies have different advantages and disadvantages. The choice of topology depends on the size, cost, reliability, and requirements of the network.
The OSI Reference Model
The OSI (Open Systems Interconnection) reference model is a conceptual framework developed by ISO (International Organization for Standardization) to explain how data is transmitted from one computer to another over a network. It consists of seven layers, and each layer performs a specific function.
The seven layers of the OSI reference model are:
- Physical Layer: It transmits raw bits from one device to another through a physical medium such as cables.
- Data Link Layer: It provides node-to-node data transfer and detects errors in the transmitted data.
- Network Layer: It determines the best path for data transmission and handles logical addressing and routing.
- Transport Layer: It ensures reliable data delivery and provides error recovery and flow control when required.
- Session Layer: It establishes, manages, and terminates communication sessions between devices.
- Presentation Layer: It converts data into a suitable format and handles encryption, decryption, and compression.
- Application Layer: It provides network services directly to users and applications, such as email and file transfer.
Conclusion: The OSI reference model helps us understand network communication by dividing the communication process into seven organized layers.
Database Normalization
Normalization is the process of organizing data in a database to reduce data redundancy and avoid insertion, deletion, and update anomalies.
1. First Normal Form (1NF)
A table is in 1NF if each cell contains only a single value and there are no repeating groups.
Example: Instead of storing multiple phone numbers in one cell, store each phone number in a separate row.
| Student_ID | Name | Phone |
|---|---|---|
| 1 | Ram | 9800000001 |
| 1 | Ram | 9800000002 |
2. Second Normal Form (2NF)
A table is in 2NF if it is in 1NF and every non-key attribute depends on the whole primary key.
Example: If Student_ID and Course_ID form a composite key, Student_Name depends only on Student_ID. So, student details should be stored in a separate table.
3. Third Normal Form (3NF)
A table is in 3NF if it is in 2NF and has no transitive dependency between non-key attributes.
Example: If Department_Name depends on Department_ID rather than Student_ID, department details should be stored in a separate table.
4. Boyce-Codd Normal Form (BCNF)
A table is in BCNF if it is in 3NF and every determinant is a candidate key.
Example: If a teacher determines the subject they teach but Teacher is not a candidate key, the table may violate BCNF and should be divided into smaller tables.
Conclusion: Normalization reduces duplicate data, maintains data consistency, and improves database efficiency. The main normal forms are 1NF, 2NF, 3NF, and BCNF.
Database Security
Database security refers to the process of protecting a database from unauthorized access, misuse, modification, destruction, and data theft. It ensures the confidentiality, integrity, and availability of data.
The major measures of database security are:
- Authentication: It verifies the identity of users through usernames, passwords, or other methods before allowing access to the database.
- Authorization: It gives users permission to access or modify only the data they are allowed to use.
- Data Encryption: It converts data into an unreadable form to prevent unauthorized users from understanding it.
- Regular Backup: It maintains copies of database data so that information can be recovered if it is lost or damaged.
- Antivirus and Firewall: These protect the database system from viruses, malware, and unauthorized network access.
Conclusion: Database security protects valuable information, maintains data accuracy, and prevents unauthorized access and data loss.
C Programming Exercises and Solutions
Student Records Using Structures
WAP to input roll, name, marks in three different subjects and display roll, name and total marks of 50 students using structure.
#include <stdio.h>
struct student
{
int roll;
char name[50];
int m1, m2, m3, total;
};
int main()
{
struct student s[50];
int i;
for (i = 0; i < 50; i++)
{
printf("\nEnter roll, name and marks in 3 subjects:\n");
scanf("%d %s %d %d %d",
&s[i].roll, s[i].name,
&s[i].m1, &s[i].m2, &s[i].m3);
s[i].total = s[i].m1 + s[i].m2 + s[i].m3;
}
printf("\nRoll\tName\tTotal Marks\n");
for (i = 0; i < 50; i++)
{
printf("%d\t%s\t%d\n",
s[i].roll, s[i].name, s[i].total);
}
return 0;
}Filter Employee Salary Using Structure
WAP to input employee ID, name, post, salary of 100 employees and display employee ID, name, post having salary 50000 to 75000 using structure.
#include <stdio.h>
struct employee
{
int id;
char name[50], post[50];
float salary;
};
int main()
{
struct employee e[100];
int i;
for (i = 0; i < 100; i++)
{
printf("Enter id, name, post and salary:\n");
scanf("%d %s %s %f", &e[i].id, e[i].name,
e[i].post, &e[i].salary);
}
printf("\nID\tName\tPost\n");
for (i = 0; i < 100; i++)
{
if (e[i].salary >= 50000 && e[i].salary <= 75000)
{
printf("%d\t%s\t%s\n",
e[i].id, e[i].name, e[i].post);
}
}
return 0;
}Sum and Average Using User-Defined Function
WAP in C to compute and display the sum and average of any three given integers using a user-defined function.
#include <stdio.h>
void calculate(int a, int b, int c)
{
int sum;
float avg;
sum = a + b + c;
avg = sum / 3.0;
printf("Sum = %d", sum);
printf("\nAverage = %.2f", avg);
}
int main()
{
int a, b, c;
printf("Enter three integers: ");
scanf("%d %d %d", &a, &b, &c);
calculate(a, b, c);
return 0;
}Simple Interest Using User-Defined Function
WAP in C to compute and display simple interest using a user-defined function.
#include <stdio.h>
void interest(float p, float t, float r)
{
float si;
si = (p * t * r) / 100;
printf("Simple Interest = %.2f", si);
}
int main()
{
float p, t, r;
printf("Enter principal, time and rate: ");
scanf("%f %f %f", &p, &t, &r);
interest(p, t, r);
return 0;
}Filter Vehicle Records by Type Using Structure
Write a program in C to create a structure named Vehicle with members Vehicle ID, Type, Engine Number, Number of Seats. The program stores details of N vehicles and displays the details of vehicles whose type is car.
#include <stdio.h>
#include <string.h>
struct Vehicle
{
int id;
char type[20];
char engine[30];
int seats;
};
int main()
{
struct Vehicle v[100];
int n, i;
printf("Enter number of vehicles: ");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
printf("\nEnter Vehicle ID, Type, Engine Number and Seats:\n");
scanf("%d %s %s %d", &v[i].id, v[i].type,
v[i].engine, &v[i].seats);
}
printf("\nDetails of cars:\n");
for (i = 0; i < n; i++)
{
if (strcmp(v[i].type, "car") == 0)
{
printf("\nVehicle ID: %d", v[i].id);
printf("\nType: %s", v[i].type);
printf("\nEngine Number: %s", v[i].engine);
printf("\nNumber of Seats: %d\n", v[i].seats);
}
}
return 0;
}