BRIEF OF SQL AND NETWORKS
BRIEF OF SQL AND NETWORKS
What is Database?
A database is an organized collection of interrelated data stored together to serve applications. It work like a
container which may contains various database objects.
Most of the databases store data in the form of Relations (also called Tables). Such Databases are known as
Relational Database: A Software used to store and manage Relational database is called RDBMS (Relational
Database Management System).
Example of RDBMS software: Oracle, MySQL, MS SQL Server, SyBase and Ingress etc.
Advantages of using Database:
Database reduces Redundancy: Removes duplicity of data because data are kept at one place.
Database controls Inconsistency: Data updation maintains consistency and unambiguity.
Database facilitates Sharing of Data: The data stored in the database can be shared among several users.
Database ensures Security: Data are protected against disclosure to unauthorized users.
Database maintains Integrity: DBMS enforces integrity rules to insure the validity or correctness of data.
Relational Data Model:
Data model describes ‘How data is organized or stored’ in the database. A Database can be categorized in various
models as per organization of records like Relational Data Model, Network Data Model, Hierarchical Data Model
and Object Oriented Data Model.
Relational Data Model: In Relational model, data is organized in the form of Relation or Table consisting rows and
columns. This model is mostly used by RDBMS software.
Relation: A Relation or Table is Two-Dimensional structure containing in Rows and Columns. It has the following
properties-
Column homogeneous- All values in a column are of same data type.
Unique columns- Each column assigned a unique name and must have atomic (indivisible) value.
Unique rows- All rows of a relation are distinct i.e. no two identical records can exist in the Relation (Table).
Tuple/Entity/ Record: A Row of a table is called Tuple or Record.
Attribute/ Field: A column of a table is called Attribute or Field.
Domain: It is collection (set) of possible values from which the value for a column is derived.
Degree: Number of columns (attributes) in a table.
Cardinality: Number of Records in a table.
Concept of Keys:
A table may have several columns and some column or combination of columns which can identifies a record in
the table uniquely. Such column(s) are called Key of the Table. Keys can be categorized in following types.
Primary Key: A column or group of Column, which uniquely identify a Record/Tuple in a Table is called Primary
Key. The Primary key cannot have null or duplicate values. A table can have only ONE primary key. Example:
Vehicle Number, Enrolment number, Admission No, Roll No,PNR Number , Aadhaar , PAN No. etc.
Candidate Key: A Table may have multiple keys having candidature to work as primary key. Collection of all such
key-columns is called candidate keys. Note that Primary key is one of the candidate key.
Alternate Key: All candidate key other than Primary key are called Alternate key (Secondary Key) because they
can be used as an alternative to Primary key.
Foreign Key: is a non-key attribute, which establish a relation with another table. Mostly it is common column in
two tables and works as primary key of another table.
Consider the following tables and their columns:
EMPLOYEE (EmpNo, Name, Designation, City, AadharNo, DeptNo)
DEPARTMENT (DeptNo, Dname, HODName)
Candidate Keys of EMPLOYEE Table : (EmpNo, AadharNo)
Primary Key of EMPLOYEE Table- EmpNo & Primary Key of DEPARTMENT Table- DeptNo
Foreign Key of EMPLOYEE Table- DeptNo. (because it is common to both table and is primary key in Department
Table)
MySQL:
MySQL is an open source Relational Database Management System (RDBMS) software based on SQL. The main
features of MySQL are –
Quick Revision Material: Class XII - Informatics Practices (2024-25) Page: 11 of 25
Open Source & Free: It is Open Source and available free of cost.
Portability: It can be installed and run on any types of Hardware and OS like Linux, MS Windows or Mac etc.
Security: It offers security and authorization feature to keep database secure.
Connectivity: The MySQL database can be connected with Programming Languages like Python, Java etc.
Query Language: It uses SQL (Structured Query Language), which is standardized by ANSI.
Types of SQL (MySQL) Commands:
SQL commands may categorised into two category as their usage:
DDL (Data Definition Language): Commands to define structure of data i.e. Database and Table.
DML (Data Manipulation Language): Commands to process records stored in the table.
DDL Commands (Works with Table/Database) DML Commands (Works with Records)
CREATE Creates Database and Tables SELECT Displays records from the table.
ALTER Modifies structure of Table INSERT Insert records in the table
DROP Deletes Database and Table DELETE Deletes records from the table
UPDATE Modifies values of existing records.
Apart from these commands, MySql the following miscellaneous commands –
SHOW DATABASES: Displays list of Databases available.
SHOW TABLES: Displays list of tables stored in currently opened database.
USE <Database Name>: Opens a database for working. Example : USE EMPLOYEE
DESCRIBE <Table>: Display structure of table. Example – DESCRIBE Student
Data Types in MySQL:
A column of the Table stores same type of values as defined while creating a table. Commonly used MySQL data
types for a column are-
INTEGER (Size)/INT (size) : Stores numbers without decimal upto given size.
DECIMAL (M, D)/NUMERIC (M, D)/FLOAT (M,D) : Numbers with decimal points upto M size and D decimal places.
Ex: Decimal (8,2) will store like 123456.78
CHAR (size): Stores string/text upto given size. Maximum size is 255 and default is 1, if size not given.
VARCHAR (size): Stores variable size string upto given size. Maximum size is 65535.
DATE: Stores date string in YYYY-MM-DD format.
TIME: Store time string in HH:MM:SS format.
Note: All values must be enclosed in single or double quotes except Integer and Decimal numbers.
Working with DDL Commands
Creating Database and Table:
CREATE DATABASE <Data base Name>
CREATE TABLE < Table Name> (<Col name1><data type>[(size)] [Constraints],….);
Constraints:
Constraints are the rules, condition or checks applicable to a column or table which ensures the integrity or
validity of data. The commonly used constraints are-
Constraints Purpose
NOT NULL Ensures that a column cannot have NULL value.
UNIQUE Ensures that all values in a column are different.
DEFAULT Provides a default value for a column, when nothing is given.
CHECK Ensures that all values in a column should satisfy certain condition.
PRIMARY KEY Defines Primary Key of the Table that can identify a row uniquely.
FOREIGN KEY Defines Foreign key which makes a relation with any other table to ensure Referential
Integrity of the data.
Note: Constraints are optional. A table may have multiple Unique constraints but only one Primary Key.
Creating Database and table. Creating table with constraints.
CREATE DATABASE SCHOOL; CREATE TABLE Student
USE SCHOOL; (StCode char(3) NOT NULL PRIMARY KEY,
CREATE TABLE Employee Stname char(20) NOT NULL,
(Code char(3), StAdd varchar(40),
EmpName char(20), AdmNo char(5) UNIQUE,
City varchar(40), StSex char(1) DEFAULT ‘M’,
Pay Numeric(8,2)); StAge integer CHECK (StAge>=5) );
A computer network is a collection of two or more computing devices which are interconnected to share data and
other resources. The Computer network facilitates transfer or exchange of information in the form of text, image,
and audio, video through wired or wireless transmission medium.
A computer Network may include-
Hosts or Nodes: Devices receives or sends data like computers, laptops, mobiles etc.
Network devices: Devices manages transfer of data like Switch, Router and Modem etc.
Transmission Media (wired or wireless): Media which carries data signals like wire or Bluetooth etc.
Protocol: Set of rules which control the communication.
Advantages of Computer Network:
Sharing Resources: Network facilitates sharing of hardware and software resources like sharing of data,
programs and printer etc. among users irrespective of their physical location.
Improved Communication: Computer network enables fast, reliable and secure communication between
users like Sending e-mail, SMS and MMS etc.
Reduced Communication cost: Sharing resources also reduces its communication cost. Internet and Mobile
network playing very important role in sending and receiving text, image, audio and video data at low cost.
Types of Computer Network:
A network may vary in size, complexity and coverage area. On the basis of coverage of geographical area, data
transfer speed and complexity, a computer network may be classified as:
LAN (Local Area Network) : LAN connects devices placed in limited geographical area like a single room, a
floor, buildings or campus. LAN usage wires (Ethernet cables) or wireless (Wi-Fi) to connect devices and offers
high speed data transfer rates usually varies from 10-100 Mbps.
MAN (Metropolitan Area Network): The MAN may connects several LANs and covers a larger geographical
area like a city or a town. Cable TV network or cable based broadband internet services are examples of MAN.
This kind of network may be extended up to 100 km.
WAN (Wide Area Network): The WAN covers large geographical area like countries and continents. A WAN is
formed by connecting several LANs and MANs. The Internet is the largest WAN that connects billions of
computers, smart phones and millions of LANs from different continents.
PAN (Personal Area Network): The PANs are small network which connects devices in small proximity up to 10
meters using wired USB connectivity or wireless system like Bluetooth, Infrared , Wi-Fi etc. PAN facilitates
transfer of files like songs, videos, images etc. from one computer, mobile to other.
PAN LAN MAN WAN
Covered Area Approx. 10 mt. Room, Building, May cover a city Country or
complex or campus continents.
Media used Data cable, Ethernet , Coaxial Optical fiber, Radio Microwave and
Infrared/Bluetooth. cable, Wifi etc. wave, Microwave satellite etc.
Network Cable, Dongle LAN card,Hub, MODEM, Router, MODEM, Router,
Devices used Switch, Repeater Gateway Gateway
Transmission Media:
A Transmission medium is a medium of data transfer over a network. The selection of media depends on the cost,
data transfer speed, bandwidth and distance.
Transmission Medium is divided into two major categories:
(A) Wired (Guided) Media:
Twisted Pair Cable: Twisted pair or Ethernet cable is most common media which consists of four insulated
pairs of wires twisted around each other. It is low-cost, flexible and easy to install cables and can transfer
data upto 100 mts distance. It uses RJ-45 Connector for connecting devices.
Co-Axial Cable: This cable consists a solid insulated wire surrounded by wire mesh separated by foil or
insulator. Co-axial Cable or Coax, is mostly used in Cable TV transmission and can carry data upto 500 mts.
Optical Fiber: An optical fiber is a thin, flexible, and transparent strand of glass or plastic that carry light
signals instead of electric current. Signal are transmitted in the form of light emitted from source using
Light Emitting Diode (LED) or LASER beam. Optical fibers offers secure and high speed transmission upto a
long distance.
Quick Revision Material: Class XII - Informatics Practices (2024-25) Page: 16 of 25
(B) Wireless (Unguided) Media:
Infrared Wave: It used for short-range (approx. 5 mt) communication using wireless signals. It is mostly
used in Remote operated devices like TV, Toys, Cordless phones etc.
Bluetooth: Bluetooth is a wireless technology for creating personal networks operating within a range of
10 meters.
Wi-Fi (Wireless Fidelity): Wi-Fi communication is similar to Bluetooth in operation, but it covers a large
coverage (50-200 mts.)
Radio waves: Radio wave is used to make broadcast network like FM Radio within city. Radio wave
propagates in Omni direction (surrounding) and can penetrate solid walls/buildings etc.
Microwaves: Microwave are high energy electromagnetic waves propagates in line of sight direction. It is
high speed wave and can cover distance upto 100 km.
Satellite: Satellite works like a Trans-Receiver Antenna in the space, which receives, regenerates and
redirects signals using Microwave. Services like DTH, VSAT, GPS and Satellite phones etc. are offered by
the satellite.
Network Devices:
Networking devices are equipment that receive or transmit data or signal and make communication channel.
Some common Networking devices are-
Network Interface Card (NIC): A NIC (Network Interface Card) or LAN Card enables computer to connect with
a network using a RJ-45 port. Each LAN card possess a unique 6 Byte Physical (static) address known as Media
Access Control (MAC) Address, which is used to identifies a device uniquely over the network. WLAN
(Wireless) card is also used for connecting PC/Laptops with Wireless Network.
Hub: A Hub is a device which connects multiple computers together to form a Local Area Network (LAN). Hub
makes Broadcast type Network and do not manage traffic over the network channel. Nowadays Hub is
obsolete technology and Switch is used in place of Hubs.
Switch: Switch is similar to Hub that also connects several nodes to form a Network. But Switch is faster than
hub due to better traffic management and control over Network. Switch can also be used to combine various
small network segments to form a big Network.
Repeater: A Repeater is a device that regenerates the received signals and re-transmits to its destination. In
case of twisted pair cable (Ethernet), signals become weak after 100 meters. So, Repeaters are required at
each 90- 100 meters to maintain signal strength. A Hub or Switch also works as a repeater.
Router: Router is an inter-networking device which connects multiple Networks to form a big Network. The
basic role of Routers is to determine the best possible route (shortest path) for the data packets to be
transmitted. In a large network (WAN), multiple routers work to facilitate speedy delivery of data packets.
Gateway: A Gateway device connects dissimilar networks having different protocols. Gateway is also called
protocol converter, since it converts data packets from one protocol to other while connecting two dissimilar
networks. Usually it is implemented by software within a router device.
MODEM: A MODEM (MOdulator-DEModulator) device connects Telephone line to the Computer. It converts
Digital signal into Analog (Modulation) and Analog to Digital (Demodulation). This conversion is required
because Telephone lines can’t carry digital data. Generally it is used to connect a PC with Telephone lines to
access Internet or make voice call using PC.
Network Topologies:
The layout of interconnection of computers and devices in a network is called Topology.
The selection of topology for a network, depends on Cost of media, Flexibility to add more devices and Reliability
of network (Fault detection in case of Network failure). Some commonly used Topologies are-
Bus Topology:
In the bus topology, all devices are connected to a main or backbone cable. It is simple and oldest topology used
in the early days of computer networking.
Ring Topology:
In a ring topology, all nodes are connected to a main cable making a closed loop (ring). All data packet travel in the
ring in the same direction and passes through each node.
Tree Topology:
Tree topology combines multiple star topology networks together onto a bus (Bus-Star approach). In its simplest
form all connecting devices (hub or switch) are connected to the bus network to make "root" of the network tree.
Quick Revision Material: Class XII - Informatics Practices (2024-25) Page: 17 of 25
Mesh Topology:
In Mesh topology, all devices are directly connected to each other, forming a mesh-like structure. Mesh topology
is most expensive and complex to implement and manage.
Introduction to Internet:
Internet is a network of networks that consists of millions of private, public, academic, business, and
government networks, that are linked by various wired, wireless, and optical networking technologies.
The Internet is a global system of interconnected computer networks that use the standard Internet protocol
suite (TCP/IP) to serve billion users worldwide.
The modern Internet is an extension of ARPANet (Advanced Research Project Agency Network), created in
1969 by the American Department of Defense.
The Internet carries variety of information resources and services, such as the inter-linked hypertext
documents of the World Wide Web (WWW), communicational infrastructure to support e-mail, chat and
transfer of Text, Images, Audio, Video etc.
Application of Internet:
World Wide Web (WWW):
Word Wide Web (WWW) or Web is a collection of inter-linked hypertext pages accessed through Web
Browser program using internet. A web page may contains information in form of text, images, audio,
video or Animation. The resources on the web can be shared or accessed through the Internet. The Web
pages (HTML pages) are stored on web server and transferred via the Hypertext Transfer Protocol (HTTP)
using a software application called a web browser.
Tim Berners Lee, a British computer scientist invented the revolutionary World Wide Web in 1990 by
defining three fundamental technologies i.e. HTML, WWW and URL.
HTML: Hyper Text Markup Language (HTML) is a language which is used to design Web Pages. A web page
is designed using HTML tags like <HEAD>,<BODY> etc. to define the web page layout and organized
contents which to be displayed by the web browser. Webpages are stored as .html or .htm files.
URL (Uniform Resource Locator) : URL is a unique address of web resources located on the web. It
provides the location and mechanism (protocol) to access the web resource. URL is also called a web
address. A URL contains protocol, subdomain, Domain and name of webpage along with path/directory.