Computer Networks and MySQL - Notes
Computer Networks and MySQL - Notes
ARPANET (Advanced Research Agency Network). It was the first network that came into existence in
1969, which was used by US Department of Defence (DoD).
NSFNET (National Science Federation Network): It was more capable than ARPANET and was used only
for academic research .
INTERNET ARPANET + NSFNET + PRIVATE NETWORKS = INTERNET (1990) - Later, many privately owned
businesses with their very own private systems joined with ARPANET and NSFNET to make the Internet.
Bandwidth: It is the maximum amount of data that can be transferred per second on a link. Unit: bits
per second(bps), Mega bits per second(Mbps) or Giga bits per second(Gbps).
Data transfer rate: It is the speed at which data is transferred from one device to another. It is generally
measured in Mega bits per second(Mbps) or Mega bytes per second(MBps).
For example, if bandwidth is 100 Mbps but data rate is 50 Mbps, it means maximum 100 Mb data can be
transferred but channel is transmitting only 50 Mb data per second.
IP address: Internet Protocol Address. It is either a four-byte (IPv4) or a sixteen-byte (IPv6) address.
Internet Service Provider provides IP Address. It is not fixed for a computer.
MAC address: Media Access Control Address. It is a six byte hexadecimal address. NIC Card’s
Manufacturer provides the MAC Address. It is fixed for a computer.
PAN: Personal Area Network, It is mostly personal devices network equipped within a limited area. PAN
includes mobile devices, tablet, and laptop. It offers only short-range solution up to ten meters
LAN: Local Area Network. group of computer and peripheral devices which are connected in a limited
area such as school, laboratory, home, and office building.
MAN: Metropolitan Area Network. computer network across an entire city, college campus, or a small
region. It mostly covers towns and cities in a maximum 50 km range. Mostly used medium is optical
fibers, cables
WAN: Wide Area Network. computer network that which is spread across a large geographical area.
WAN network system could be a connection of a LAN which connects with other LAN’s using telephone
lines and radio waves. It is mostly limited to an enterprise or an organization.
Star Topology : Star topology is basically used for Local Area networks in which all nodes are
connected to a central point called Hub, which connects them into the communication channel. Here
communication between nodes are done through central node i.e., hub or router. The complexity of
Star topology is really simple. The cost of star topology is lower than tree topology. Star topology is used
in LAN as setup and modification is easy
Bus Topology : Bus topology is a type of network topology in which all the devices are connected to a
single cable which is called the backbone of the network. It consists of a terminator at each end of the
cable. When data reaches the end of the cable it is removed by the terminator from the data line. It is
the easiest network topology when the devices are to be connected in a linear fashion.
Tree Topology :Tree topology is a type of network topology in which the nodes are organized in the
form of a tree. In tree topology, design starts at the head top known as the root from which the
branching cable starts. The branching cable with no loops connect the root with all other nodes for
communication. Tree topology is more expensive as it is densely wired.
HTTP- Hyper Text Transmission Protocol. Connects through port 80. It is the backbone of the World
Wide Web (WWW).
FTP-File Transfer Protocol. Connects to Port 20 & 21, FTP is the underlying protocol that is used for
downloading and uploading of file
PPP-Point to Point Protocol (PPP) is a communication protocol of the data link layer that is used to
transmit multiprotocol data between two directly connected (point-to-point) computers.
SMTP- Connects to port 25, Simple Mail Transport Protocol (SMTP) is the standard TCP/IP email protocol
that Sends email over the Internet. Does not encrypt message. Emails are stored in the servers.
IMAP -Internet Messaging Access Protocol (IMAP) is a standard mail protocol that Stores messages until
users log on and download the messages. Emails get stored in the user computer.
TCP/IP- Transmission Control Protocol/ Internet Protocol. This is the underlying protocol that governs
the Internet.
POP3-Post Office Protocol (POP3) is a standard mail server that is used for receiving the incoming
emails. Does not encrypt messages
HTTPS- Hyper Text Transfer Protocol Secured. It helps to keep browsing safe by securely connecting the
browser or app with the websites visited. HTTPS relies on encryption technology—SSL or TLS—to secure
these connections.
TELNET- It is a type of protocol that enables one remote computer to connect to local computer over
the internet. It is also known as remote login.
VoIP- Voice of over Internet Protocol. It is used to make voice calls using a broadband Internet
connection instead of a regular (or analog) phone line.
GSM-Global System for Mobile Communication. It uses narrowband Time Division Multiple Access
(TDMA) for providing voice and text based services over mobile phone networks.
GPRS- General Packet Radio Service. It is a 3G technology that keeps the users online, allows to make
voice calls, and access internet on-the-go.
WLL-Wireless in local loop. It connects users to the local telephone company's network via wireless links
rather than traditional copper cables.
WWW- Word Wide Web. Also known as Web, is a collection of websites or web pages stored in web
servers.
Hyper Text Markup Language (HTML)- is the standard markup language for Web pages
Extensible Markup Language (XML)- It is a markup language similar to HTML where we can define our
own tags. This is a powerful way to store data in a format that can be stored, searched, and shared.
Domain names-A domain name is a unique, easy-to-remember address used to access websites, such as
‘google.com’, and ‘facebook.com’.
DNS- It is a directory service that provides a mapping between the name of a host on the network and
its numerical address.
URL- Uniform Resource Locator. Also known as a web address, contains the domain name of a site as
well as other information, including the transfer protocol and the path. For example
‘https://cloudflare.com/learning/flare.pdf’,
Web servers-It is the computer connected to the internet that store the websites and provides access
24/7 across the globe.
Web hosting- It is the service of uploading the website onto a web server.
1G: Voice Only - 1980s, first generation of wireless cellular technology, supports voice only calls. It is
analog technology, and the phones using it had poor battery life and voice quality, little security, and
were prone to dropped calls. The maximum speed of 1G technology is 2.4 Kbps.
2G: SMS and MMS – 1991, GSM networks, digital communication. The 2G telephone technology
introduced call and text encryption, along with data services such as SMS, picture messages, and MMS.
The maximum speed of 2G with General Packet Radio Service (GPRS) is 50 Kbps.
3G: More Data, Video Calling, and Mobile Internet – 1998. The term "mobile broadband" was first
applied to 3G cellular technology. The maximum speed of 3G is estimated to be around 2 Mbps for non-
moving devices and 384 Kbps in moving vehicles.
4G: The Current Standard - 2008. It supports mobile web access like 3G does and also gaming services,
HD mobile TV, video conferencing, 3D TV, and other features that demand high speeds. The max speed
of a 4G network when the device is moving is 100 Mbps.
5G: The Next Standard – 2021. 5G promises significantly faster data rates, higher connection density,
much lower latency, and energy savings, among other improvements. The anticipated theoretical speed
of 5G connections is up to 20 Gbps per second.
Circuit Switching- Wired connectivity. Entire path is established physically before communication takes
place. It is slower but more reliable. More expensive.
Packet Switching- Wireless connectivity. No physical path is established. Data moves from one point to
another using store and forward. It is faster and cheaper.
Repeater – It is used to regenerate the signal to avoid data loss as an amplifier does for analog signals.
Hub – A hub is basically a multiport repeater. It is used to broadcast data and has many ports for
connecting multiple computers.
Bridge – A bridge is a used to connect two LANs working on different protocol with an added
functionality of filtering content by reading the MAC addresses of source and destination
Switch – A switch is an intelligent hub with the functionality of finding out the best path for data
packets in the network. A switch can perform error checking.
Routers – It is a device that connects a LAN to a WAN. It is used to routes data packets based on their
IP addresses.
Gateway – A gateway is a passage to connect two networks together that may work upon different
networking models. They basically work as the messenger agents that take data from one system,
interpret it, and transfer it to another system. Gateways are also called protocol converters.
NIC – NIC or network interface card is a network adapter that is used to connect the computer to the
network. It is installed in the computer to establish a LAN.
Difference Between Twisted pair cable, Co-axial cable, and Optical fiber
Affected due to
External magnetic external magnetic The external magnetic The external magnetic
field field. field is less affected. field is not affected.
Sr.
No. Basis Radio wave Micro wave Infrared wave
Signal/data
5. loss high. medium low.
Distance
8. Range 3 km 50km to 1000 km 5m
Few Tips to solve the networking applications
1. Topology: Star (most appropriate) keeping the place that holds the maximum computer as the
central node.
2. Type of network
a. For buildings/wings/offices separated by distance(metres) – LAN
b. For buildings/wings/offices separated by distance(max 50 km in a city) – MAN
c. For buildings/wings/offices separated by distance(more than 100km across country) –
WAN
3. Hilly area economically – radio wave
4. Plane area economically – micro wave
5. Across country economically – satellite link
6. Irrespective of distance and landscape, most effectively, fast, reliable without any economical
restriction – optical fibre
7. In a LAN – UTP cables
8. Server to be placed in the building/wing/office with maximum computers
9. Modem as well as router to be placed in the building hosting the server.
10. Switch or hub to be placed in every building/office/wing for connecting all the computers there.
11. Repeater to be placed in the cable exceeding a distance of 100 mtrs.
MySQL
MySQL – It is an open source RDBMS. It is used at the backend to manage the data stored in the
database. There are two components of MYSQL: SQL commands and Database. SQL stands for
Structured Query Language and database is a collection of tables.
SQL is a non-procedural language that uses a predefined a set of programs called commands to retrieve
and manipulate data in the database. These commands are not case sensitive and are categorized under
4 heads:
1. DDL commands – Data Definition Language, a set of commands that are used to modify the
structure of a table. Example: create table, drop table, alter table
2. DML commands – Data Manipulation language, a set of commands that are used to modify the
contents of a table. Example: select, insert, delete and update
3. DCL commands – Data Control Language, a set of commands that are used to control the access
of the data in the database. Example: grant, revoke
4. TCL commands – Transaction Control Language, a set of commands that are used to control the
transaction issued on the database. Example: commit, rollback
14. Union – This is a type of join operation that is applied to two tables, the result table has number
of rows that is the sum of the number of rows of the two tables subtracting the number of
duplicate rows in both and number of columns as the sum of the number of columns of any of
the two tables. There is a pre requirement to the union operation and that is:
1) Both tables must have same number of columns
2) The data types of the corresponding attributes of the two tables must be same.
R2=5, C2=3
101 Rohit 16
102 John 17
103 Soham 18
104 Sidd 16
201 Ram 16
202 Shyam 17
203 Babita 19
204 Rupam 17
15. Cartesian product: This is product operation that is applied to two tables, the result table has
number of rows that is the product of the number of rows of the two tables and number of
columns as the sum of the number of columns of two tables.
Table: A Table: B
R2=4, C2=3
Query: Select * from A, B;
R3=12(R1*R2), C3=3(C1+C2)
Datatypes: int/ int(<size>), decimal/decimal(<total places>,<number of places after decimal point), date,
char(<number of characters>, varchar(<number of characters>)
Various commands:
Table: student
1 Rohit 12 Science 89
2 Samal 11 NULL 67
3 Gaurav 12 Commerce 90
4 Anil 12 Science 75
5 Sunil 11 Arts 65
The queries formed for the following SQL operators/ clauses and functions are w.r.t. the above table.
8) Order by
select * from student where marks > 80 order by marks desc;
select * from student order by name;
9) Like, %, _
select * from student where name like ‘__r%’;
10) Group by
select count(*), stream from student group by stream;
2. Creating two linked tables using primary key foreign key relationship
student teacher
5 Sunil 11 Arts
create table student( roll int primary key, name varchar(20), class varchar(10), stream int);
create table teacher( tid int, tname varchar(20), age int, roll int, primary key(tid), foreign key(roll)
references student(roll));
1. Natural Join :
Natural Join joins two tables based on same attribute name and datatypes. The resulting table will
contain all the attributes of both the table but keep only one copy of each common column.
Example:
Consider the two tables given below:
Student Table Marks Table
2. Inner join can have equality (=) and other operators (like <,>,<>) in the join condition. Equi join only
have equality (=) operator in the join condition. The inner JOIN is used to return rows from both tables
that satisfy the given condition.
Benefits of JOIN
• JOINS allow us to combine data from more than one table into a single result set.
• JOINS have better performance compared to sub queries
• INNER JOINS only return rows that meet the given criteria.
• OUTER JOINS can also return rows where no matches have been found. The unmatched rows
are returned with the NULL keyword.
• The major JOIN types include Inner, Left Outer, Right Outer, Cross JOINS etc.
• The frequently used clause in JOIN operations is “ON”. “USING” clause requires that matching
columns be of the same name.
• JOINS can also be used in other clauses such as GROUP BY, WHERE, SUB QUERIES, AGGREGATE
FUNCTIONS etc.
Inner Join joins two table on the basis of the column which is explicitly specified in the ON clause. The
resulting table will contain all the attributes from both the tables including common column also.
Example:
Consider the above two tables and the query is given below:
SELECT *
FROM student S INNER JOIN Marks M ON S.Roll_No = M.Roll_No;
Output :
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.
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.
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.
CARTESIAN JOIN: The CARTESIAN JOIN is also known as CROSS JOIN. In a CARTESIAN JOIN there is a
join for each row of one table to every row of another table.
SELF JOIN: As the name signifies, in SELF JOIN a table is joined to itself. That is, each row of the table is
joined with itself and all other rows depending on some conditions. In other words we can say that it
is a join between two copies of the same table.
How to create two tables with primary key – foreign key relationship – alternate approach
mysql> create table salesman(sid int primary key, sname varchar(20),age int,city
char(10));