You are on page 1of 143

Informatics Practices

Work Book

Grade 12 CBSE
Academic Session 2016-2017

This Work Book belongs to


____________________
COURSE DESIGN
Class XII (2015-16) (THEORY)

Period
Unit Topic Total periods
Theory Practical
1 Networking and Open Standards 20 4 24
2 Programming 46 44 90
3 Relational Database Management System 50 40 90
4 It Aplications 10 26 36
Total 126 114 240

Unit 1: Networking and Open Standards


Computer Networking:
 Networking: a brief overview,
 Communication Media: Wired Technologies – Co-Axial, Ethernet Cable, Optical Fiber; Wireless
Technologies – Blue Tooth, Infrared, Microwave, Radio Link, Satellite Link;
 Network Devices: Hub, Switch, Repeater, Gateway – and their functions
 Types of network: LAN, MAN, WAN, PAN;
 Network Topologies: Star, Bus, Tree
 Network Protocols: HTTP, TCP/IP, PPP,Remote access software such as Team Viewer;
 Identifying computers and users over a network:Basic concept of domain name, MAC (Media
Access Control), and IP Address, domain name resolution
 Network security: denial of service, intrusion problems, snooping
 Internet Applications: SMS, Voice Mail, Electronic Mail, Chat, Video Conferencing
 Wireless/Mobile Communication: GSM, CDMA, WLL, 3G, 4G
 Network Security Concepts: Cyber Law, Firewall, Cookies, Hackers and Crackers

Open Source Concepts:


 Open Source Software (OSS), common FOSS/FLOSS examples (GNU/Linux, Firefox,
OpenOffice, Java, Netbeans, MySQL), common open standards (WWW, HTML, XML, ODF, TCP,
IP)
 Indian Language Computing: character encoding, UNICODE, different types of fonts (open
type vs true type, static vs dynamic), entering Indian Language Text – phonetic and key map
based, Inscript.

Unit 2: Programming
Review of Class XI;
Programming Fundamentals
(Refer to Appendix A for Swing Control Methods & Properties, and Appendix B for sample
guidelines of GUI Programming)
 Basic concept of Access specifier for class members (data members and methods)
 Basic concept of Inheritance
 Commonly used libraries:
 String class and methods: toString(), concat(), length(), toLowerCase(), toUpperCase(),
trim(), substring()
 Math class methods: pow(), round()
 Accessing MySQL database using ODBC/JDBC to connect with database.
 Web application development: URL, Web server, Communicating with the web server,
concept of Client and Server Side
 HTML based web pages covering basic tags – HTML, TITLE, BODY, H1..H6, Paragraph (P), Line
Break (BR), Section Separator (HR), FONT, TABLE, LIST (UL, OL), FORM
 Creating and accessing static pages using HTML and introduction to XML

Unit 3: Relational Database Management System


Review of RDBMS from Class XI
Database Fundamentals
 Concept of Database transaction, Committing and revoking a transaction using COMMIT and
ROLLBACK.
 Grouping Records: GROUP BY, Group functions - MAX(), MIN(), AVG(), SUM(), COUNT(); using
COUNT(*), DISTINCT clause with COUNT; Group Functions and Null Values.
 Displaying Data From Multiple Tables: Cartesian product, Union, Intersection concept of
Foreign Key, Equi-Join
 Creating a Table with PRIMARY KEY and NOT NULL constraints,Viewing Constraints, Viewing
the Columns Associated with Constraints using DESC command.
 ALTER TABLE for
 deleting column(s), modifying data type(s) of column(s),
 adding a constraint, enabling constraints, dropping constraints.
 DROP Table for deleting a table

Unit 4: IT Applications
 Front-end Interface: Introduction; content and features; identifying and using appropriate
component (Text Box, Radio Button, CheckBox, List etc. as learnt in Unit 2 (Programming)) for
data entry, validation and display.
 Back-end Database: Introduction and its purpose, exploring the requirement of tables and its
essential attributes.
 Front-End and Database Connectivity: Introduction, requirement and benefits
 Demonstration and development of appropriate Front-end interface and Back-end Database
for e-Governance, e-Business and e-Learning applications
 Impact of ICT on society: Social, environmental and Economic benefits.

In each of the above domains, identify at least two real-life problems, list the expected outputs
and the input(s) required for the output, and describe the problem solving approach and develop
relevant front-end interface and back-end database.
COURSE DESIGN
Class XII (Practical) (2015-16)
S.No. Description Marks

1 Problem Solving using Java 10

2 SQL Queries 4

3 Practical Record 6
 Identify Network configuration and OSS used in school 1
 Simple problems using IDE Java 2
 SQL Queries 1
 IT Applications 2

4 Project Work 5
5 Viva Voce 5
Total 30

Evaluation of Practical Examination

1. Problem Solving using Java


Student is required to solve programming problems based on all concepts covered in theory throughout
the year and maintain a record of these in the practical file.
Student will be given a problem to be solved using Java during final practical examination to be
conducted at the end of the academic session.

2. SQL Queries
Students will be practicing SQL queries in MySQL throughout the year alongwith course coverage in
theory.
Student will be asked to write four queries based on one or two tables during final practical examination
to be conducted at the end of the academic session

3. Practical Record File


A practical record file is required to be created during the entire academic session. It should be duly
signed by the concerned teacher on regular basis and is to be produced at the time of Final Practical
Examination for evaluation. It should include the following:
 At least 12 solutions of simple problems using IDE based Java (refer to Appendices „A‟ & „B‟)
 Network Configuration and open source software used in your school.
 Solution of at least 2 simple problems incorporating Java Application & Database connectivity
 At least 24 SQL queries based on one and/or two tables
 At least two web pages using HTML

4. Project File
Students in group of 2-3 are required to work collaboratively to develop a project using Programming
and Database skills learnt during the course. The project should be an application in any one of the
domains – e-Governance, e-Business and e-Learning - with GUI front-end and corresponding database at
the back-end.

5. Viva Voce
Students will be asked oral questions during practical examination to be conducted at the end of the
course. The questions will be from the entire course covered in the academic session.

Question Paper Design


Class-XI (2015-16) and XII (2015-16)
S.No. Typology of Questions Very Short Short Long Total %
Short Answer-I Answer-II Answer Marks Weightage
Answer (SA-I) (SA-II) (L.A)
(VSA) (2 marks) (4 marks) (6 marks)
(1 mark)
1 Knowledge Based 4 3 2 - 18 25.7

2 Conceptual 4 5 1 - 18 25.7
Understanding

3 Reasoning Based 4 - 2 1 18 25.7


4 Skill based - 1 2 1 16 22.9
Total marks 12 9 7 2 70(30) 100

1. No chapter wise weightage. Care to be taken to cover all the chapters.


2. The above template is only a sample. Suitable internal variations may be made for generating similar
templates keeping the overall weightage to different form of questions and topology of questions same.
3. Questions may be case based requiring problem solving skills.
4. LA Questions may be case-based requiring problem–finding and problem –solving skills.
References
Suggested Reference Books

Introduction to Computer System


1. Rajaraman, FUNDAMENTALS OF COMPUTERS 4th Edition, Prentice Hall of India.
2. Peter Norton, INTRODUCTION TO COMPUTER 4th Edition, Tata McGraw Hill

Introduction to Programming
1. Heiko BöckThe Definitive Guide to the NetBeans Platform 6.5, Apress

Relational Database Management System and SQL


1. Lerry Ulman, MYSQL Database, Pearson Education, 2008

Computer Network
1. A.S. Tanenbaum, Computer Network 4th Edition, Prentice Hall of India P. Ltd.
2. Williams Stalling, Data Communication and Networks 5th Edition, Prentice Hall of India P. Ltd.

Suggested online tutorials


1. MySQL - http://dev.mysql.com/usingmysql/get_started.html
2. Netbeans - http://netbeans.org/kb/docs/java/quickstart.html

Suggested Websites on e-Governance


 www.mit.gov.in
 www.esevaonline.com
 bhoomi.kar.nic.in
 aponline.gov.in
 www.chips.nic.in

Suggested Websites on e-Business


 www.salesforce.com
 www.zoho.com
 www.itcportal.com

Suggested Websites on e-Learning


 www.moodle.org
 www.atutor.ca
 www.w3schools.com
 portal.unesco.org
Table of Contents
S.No Chapter 1: Computer Networks Pg.No
1 Computer Networking 1
2 Network Terminologies 3
3 Network Devices 3
4 Network Topology 5
5 Identifying computers and users over Network 10
6 Transmission Media 14
7 Network Protocol 20
8 Types of Network 21
9 Network Security Concepts 24
Lab Exercise 26
Work Sheet 28
Assignment 31

S.No Chapter 2: Open Source Concepts Pg.No


1 Open Source Software (OSS) 32
2 OSS can also be called as 32
3 Proprietary Software 33
4 Freeware 33
5 Shareware 33
6 Examples of FOSS/FLOSS 33
7 Two Organization of OSS 34
8 Technical Standards 35
9 Common Open Standards 36
10 Technical Specification 38
11 Font Configuration 38
Work Sheet 40

S.No Chapter 6: Database Connectivity Pg.No


1 Program 1 & 2:
41
To the table created in MySQL, inserting rows via GUI Application
2 Program 3: 45
Search by Primary Key
3 Program 4:
47
Search by Unique Key
4 Program 5:
50
Viewing the table in “Table component”

S.No Chapter 7: Web Applications Pg.No


1 Program 1: Structure of HTML 54
2 Program 2: Structure of HTML with Paragraph Tag 54
3 Program 3: Heading Tags 54
4 Program 4: Paragraph Tags 55
5 Program 5: Line Break 55
6 Program 6: Center Tag 55
7 Program 7: Horizontal Tag 56
8 Program 8: Preserve Tag 56
9 Program 9: Alignment 57
10 Program 10: Bold Text 57
11 Program 11: Italic Text 58
12 Program 12: Underlined Text 58
13 Program 13: Strike Text 58
14 Program 14: Superscript Font 59
15 Program 15: Subscript Font 59
16 Program 16: Inserting Image 59
17 Program 17: Setting Width and Height 60
18 Program 18: To display text with no line or paragraph breaks 61
19 Program 19: To display text with line or paragraph breaks 61
20 Program 20: To display paragraphs in various alignments 62
21 Attributes of Body Tag 63
1) Adding background Image 63
2) Adding background color, text color and link color 63
3) Setting left and top margin 64
4) Font Tag 64
a) Face 64
b) Size 64
c) Color 64
22 Attributes of Horizontal Rule (HR) Tag 65
1) Size attribute 65
2) No Shade attribute 65
3) Width attribute 66
23 Attributes of Image 67
1) SRC 67
2) Alternate 67
3) Border 67
4) Align 67
5) Height 67
6) Width 67
24 List 68
1) Unordered List 68
2) Ordered List 69
3) Nested List 70
4) Definition List 71
25 Creating tables in HTML 72
Attributes of Table Element 73
1) Border
2) Cellspacing
3) Bgcolor
4) Align
5) Cellpadding

Attributes of Table Row Element 75


1) Align
2) Bgcolor
3) Border

Attributes of Data Elements 75


1) Align
2) Valign
3) Bgcolor
Adding Image to a Table 75
26 Creating Forms 77
Attributes of Form Element 77
1) Name
2) Action
3) Method

Attributes of Input Element 77


1) Type
2) Name
3) Value

Form using Text Field and Password Field 78


Form using Radio Button 79
Form using Check Box 80
Form using Combo Box 81
Form using Text Area 81
Sample Forms to create 82

S.No Chapter 8: MySQL – a review Pg.No


1 To create database 83
2 To use the created database 83
3 To create a table 83
4 Adding rows to the table 83
5 To view the contents of the table 83
6 Retrieving single column 83
7 Changing the order of columns 84
8 Displaying the list of tables created 84
9 Displaying the list of databases created 84
10 Viewing the structure of the table 84
11 Doing changes in the column 85
1) Adding a column
2) Modifying a column name
3) Deleting a column
12 Eliminating duplicate values 85
13 Using arithmetic operators with select statement 86
14 Using relational operators 86
15 Using logical operators 87
16 Column Alias 87
17 Condition based on range 88
18 Condition based on list 88
19 Condition based on Patter matches 88
20 Sorting results 89
21 Update statement 89
22 Delete statement 89
23 Single Row Functions 92
 Numeric Function 92
1) Power Function 92
2) Round Function 92
3) Truncate Function 93

 String Function 93
1) Length Function 93
2) Concatenation Function 93
3) Instring Function 94
4) Lower Case Function 94
5) Upper Case Function 94
6) Left Function 95
7) Right Function 95
8) Left Trim Function 95
9) Right Trim Function 96
10) Trim Function 96
11) Substring Function 96
12) ASCII Function 97

 Date and Time Function 97


1) Current date Function 97
2) Now Function 98
3) System Date Function 98
4) Date Function 98
5) Month Function 98
6) Year Function 98
7) Day Name Function 98
8) Day of Month Function 98
9) Day of Week Function 99
10) Day of Year Function 99
Work Sheet 100

S.No Chapter 9: More on Databases and SQL Pg.No


1 Multiple Row Functions 103
2 Creating Table With Constraints 107
3 Drop Table 112
4 Group by and Having 112
5 Displaying data from multiple tables 117
1) Cartesian Product
2) Equi Join

S.No Chapter 11: IT Applications Pg.No


1 Front-end 120
2 Back-end 120
3 E-Governance 120
4 E-Business 122
5 E-Learning 128
Chapter – 1: Computer Networks

Computer Network

1) Computer Network:

Definition:

A computer network is a collection of interconnected computers and other devices which are able to
communicate with each other and share hardware and software resources.

2) Need of networking:
1. Resource sharing
2. Cost saving
3. Collaborative user interaction
4. Time saving
5. Increased storage

• Resource Sharing:
1. Allows all the network users to share data, programs and the hardware devices connected to the
network.
2. Network resources and users may be located at different places.
3. Example: all the computers are connected to a printer over a network. Print can be taken from any
of these interconnected computers. No need of separate computer for each computer.
4. Hence, resource sharing leads to cost saving.
1
• Collaborative user interaction:
1. Allows us to communicate to the network users.
2. Example: if we are working on a computer which is a part of a computer network, we can
communicate with any other user of the network through e-mail or chatting. It takes less time to send and
receive messages.
3. Collaborative user interaction leads to time saving.

• Increased storage:
1. A file can have copies on two or three different machines, so if one of them is unavailable, the other
copies could be used.
2. For military, banking and many other applications, it is of great importance.

3) Application of Networks:

1. Sharing of data, services and resources.


2. Access to remote database.
3. Communication facilities.

4) Advantages and disadvantages of network:

Advantages Disadvantages
1. Allows different users to share resources, such 1. Large computer networks can sometimes be
as printers and scanners. This saves cost because difficult to run. As the size of network grows,
each user need not buy separate devices. trained staff is required to run it, thereby
increasing costs.
2. Allows sharing of software installed centrally 2. The central server that contains all the software
on a server by different users. This results in cost and files might fail, thereby causing heavy loss to
saving, as buying licenses for software to install the organization.
on individual computers would be costly.
3. Allows user to share the data present on 3. Poor management of network services may
computers connected to a network anytime. result in decreased productivity.
4. Allows users to collect information from 4. Websites are not completely secure.
websites.

2
Network Terminologies

5) Elementary Terminology of Networks:

1. Node: The term nodes refer to the computers that are attached to a network and are seeking to share the
resources.

2. Server: A computer that facilitates the sharing of data, software and hardware resources on the network.
Servers are classified into two types,
1. Dedicated servers
2. Non-dedicated servers
Dedicated servers:
• A dedicated server is a computer that is used to work only as a server on a network.
• The network using such a server is known as MASTER-SLAVE network.

Non-Dedicated servers:
• A non-dedicated server is a server that performs the function of both a workstation and a server
simultaneously on a network.
• The network using such a server is known as PEER-TO-PEER network.

3. Workstation: The Computer directly connected to the network is called workstation.

Network Devices
6) Network Devices:
Network devices are required to form computers other than transmission media. Some of the devices
are,
1. NIC
2. Hub
3. Switch
4. Repeater
5. Gateway

 NIC:

1. NIC stands for Network Interface Card or Network Interface Controller or Network Interface Unit (NIU).
3
2. NIC is a device that enables a computer to connect to a network and communicate.
3. Any computer which has to be a part of a computer network must have an NIC installed in it.

 Hub:

1. A Hub is an electronic device that connects several nodes to form a network and redirects the received
information to all the connected nodes in broadcast mode.

2. Whenever a computer has to send information to some other computers, the information is sent by the NIC
to hub. Then the hub retransmits this information to other computers attached to it. The intended computer
accepts the information. Other computers on the internet simply reject the information.

3. Hub has 8 ports.

 Switch:
1. Switch is an intelligent device that connects several nodes to form a network and redirects the received
information only to the intended nodes.
2. Switch can also be otherwise called as an intelligent hub.
3. It looks like hub and it has a same function like hub.
4. But the only difference between hub and switch is that, switch sends the information only to the intended
nodes instead of sending the information to all the computers attached to it.
5. Switch has 24 ports.

4
 Repeater:
1. A repeater is a device that is used to regenerate a signal which is on its way through a communication
channel. A repeater regenerates the received signal and re-transmits it to its destination.

 Gateway:
1. A gateway is a device, which is used to connect different types of networks and perform the necessary
translation so that connected networks can communicate properly.

Network Topology
7) Network Topology:
Definition:

A topology is an arrangement of physical connections among nodes in a network.

Different types of topologies:

Point to Point Topology


Bus Topology
Star Topology
Tree Topology
Mesh Topology
Fully Connected Topology
Ring Topology
5
* Point to Point Topology:
1. Connection between two computers.
2. Both the computers can send and receive files.

* Bus Topology:
It is a series of node which all connected to a backbone.

Characteristics of bus topology:


1. It is easy to install.
2. It requires less cable length and hence it is cost effective.
3. Failure of a node does not affect the network.
4. In case of cable or terminator fault, the entire network breaks down.
5. At a time only one node can transmit data.

Advantages of Bus Topology:


a. It is easy to handle and implement.
b. It is best suited for small networks.

Disadvantages of Bus Topology:


a) The cable length is limited. This limits the number of stations that can be connected. b) This network
topology can perform well only for a limited number of nodes.

6
* Star Topology:

1. In star topology, each node is directly connected to a hub/switch.


2. If any node has to send information to any other node, it sends the signal to the hub/switch.
3. In case of hub, the signal is sent to all the connected nodes but received by the intended node.
4. In case of switch, the signal is sent to the intended node.

Characteristics of star topology:


1. It is easy to install.
2. It is more efficient topology as compared to bus topology.
3. It is easy to diagnose the fault in star topology.
4. Failure of hub/switch leads to failure of entire network.
5. It requires more cable length as compared to bus topology.

Advantages of Star Topology:


a) Due to its centralized nature, the topology offers simplicity of operation.
b) It also achieves an isolation of each device in the network.

Disadvantages of Star Topology:


a) The network operation depends on the functioning of the central hub.
b) Hence, the failure of the central hub leads to the failure of the entire network.

* Tree Topology:
1. It is a combination of bus and star topology.
2. It is used to combine multiple star topology networks.
3. All the star topologies are connected together like a bus.
7
Characteristics of tree topology:
1. Even if one network fails, the other networks remain connected and working.

Advantages of Tree Topology:


a) Easy to extend
b) Fault isolation

Disadvantages of Tree Topology:


a) Dependent on the root.

*Ring Topology:
A Ring network is circular in shape and every node will have one node on either side of it.

Advantages of Ring Topology:


a) The data being transmitted between two nodes passes through all the intermediate nodes.
b) A central server is not required for the management of this topology.

Disadvantages of Ring Topology:


a) The failure of a single node of the network can cause the entire network to fail.
b) The movement or changes made to network nodes affects the performance of the entire network.

8
*Mesh Topology:
1. In this topology, each node is connected to more than one node.
2. Mesh topology is excellent for long distance networking.

Advantages of Mesh Topology:


a) It is possible to transmit data from one node to many other nodes at the same time.

Disadvantages of Mesh Topology:


a) May cause confusion.
b) Difficult to find the error.

*Fully Connected Topology:


1. Each node is connected to each other node directly.

Advantages of fully connected topology:


a) Can share information directly to the intended node.
b) A fault in one terminal on the network will not affect the rest

Disadvantages of fully connected topology:


a) A large amount of cabling is required.

9
Identifying computers and users over network
8) Identifying computers and users over network
If a node X sends some proper information for node Y on a network, then it is mandatory that node X
and Y are uniquely identifiable on the network. Let us see how it is achieved.
o MAC Address
o IP Address
o Domain Name
o Domain Name Resolution
 MAC Address:
Definition:
A MAC (Media Access Control) address is a unique 12 digit (6 digits for manufacturer code and 6 digits for
serial number) hexadecimal number assigned to each NIC. MAC address of an NIC never changes.

1. Each NIC has a universally unique address assigned to it by its manufacturer. This address is known as
MAC address of the card.
2. It has 6 bytes, separated by colon (:)
3. The first half of a MAC address contains the ID number of the adaptor manufacturer. The second half of a
MAC address represents the serial number assigned to the adaptor (NIC) by its manufacturer.

 IP Address:
Definition:
1. Every machine in a network has another unique identifying number, called its IP (Inter Protocol) address.
2. An IP address is a group of four bytes (32 bits) each of which can be a number from 0 to 255.
3. Four bytes are separated by dot(.).
4. IP address settings of a node can be changed by the user.
3. A typical IP address looks like,
10
MAC address and IP address:

On a network, IP address of a machine is used to identify it, not the MAC address.

MAC address used only when a specific machine is to be targeted.

For example,

* Suppose we want to block a specific PC from the use of internet.

* If we use the PCs IP address to block a system from the use of internet, then the system is not
blocked permanently as its IP address may change.

* Instead, if the PCs MAC address is used for blocking a system, then the work is done.

Difference between MAC address and IP address:

MAC IP

1. It has 6 bytes, separated by colon (:) 1. It has 4 bytes, separated by dot (.)

2. MAC address of a system can never be changed. 2. IP address of a system can be changed.

3. MAC address is assigned by the manufacturer. 3. IP address is assigned by the Internet Service
Provider (ISP).

4. From the MAC address it is not possible to track 4. From the IP address it is possible to track the
the location of the system. location of the system.

5. To find the MAC address of a system: 5. To find the IP address of a system:


StartRuncmdgetmac. StartRuncmdipconfig.

11
 Domain Name:
Definition:

Domain names are used to identify one or more IP addresses.Domain names are used in URLs to identify
particular Web pages. For example, in the URL, http://www.hello.com/index.html, the domain name is
www.hello.com.

Domain name usually has more than one part,


1. Top Level Domain or Primary Domain Name.
2. Sub-Domain Name(s).

For example,
In the domain name cbse.nic.in,
in is the top level domain name;
nic is the sub-domain of in or second level domain.
cbse is the sub-domain name of nic or second level domain.

A domain name consists of the following three parts:

1. WWW
2. Name of the website
3. Top Level Domain (TLD), such as .com, .net, .org, .in. TLS represents the most general part of the
domain name in an IP address.
The following are some examples of domain name:
www.ebay.in www.cbse.nic.in www.yahoo.com

There are only a limited numbers of top level domain, and these are divided into two categories,

1. Generic Domain Names


2. Country Specific Domain Names
12
Generic Domain Names:

• gov - Government agencies


• edu - Educational institutions
• org - Organizations (nonprofit)
• mil - Military
• com - commercial business
• net - Network organizations

Country Specific Domain Names:

• ca – Canada
• pk - Pakistan
• ch – China

 Domain Name Resolution (DNR):

Definition:

Domain Name Resolution is the process of getting corresponding IP address from a domain name.

To find the IP address of a website:


StartRuncmdping “domain name”

Example: ping www.gmail.com

Domain Name Resolution Process:

DNR Process takes place in the background, and it can be explained in the following steps:
1. Enter the domain name of the website that you want to access in the web browser.
2. The web browser issues a command to the operating system of your computer to generate the IP address of
the given domain name.
3.  Generally, the operating system maintains a HOSTS file, which contains a list of the IP addresses of
some domain names. Therefore, the OS first checks this file to find the IP address of the given domain name.
 If the IP address is not found in the HOSTS file, the operating system connects to the DNS server on a
network. The DNS server maintains a directory containing a list of all the domain names and IP addresses that
are registered on the internet. The DNS server finds the IP address of the given domain name and returns it to
the operating system.
4. After obtaining IP address, the operating system (OS) sends it to the web browser that has requested it.
5. And now we can able to view the requested website.
13
Transmission Media
Networking Hardware:
To form a computer network, lot of hardware devices are required. Some of these devices are
described below,

9) Transmission Media:
Definition:

A transmission medium is a medium of data transfer over a network. It can be guided(wired) or


unguided(wireless).

Communication Medium

Guided (Wired) Unguided (Wireless)

Twisted Pair Cable Co-axial Cable Optical Fiber Cable

UTP STP Radio Waves Micro Waves Infrared Waves

Wired Media
• Twisted Pair Cable:
1. Most widely used cable for creating small network.
2. It has 4 twisted pairs. These pairs are colour coded.
3. It is of two types,
 UTP (Unshielded Twisted Pair)
 STP (Shielded Twisted Pair)

14
UTP (Unshielded Twisted Pair):

1. Individual pairs are not covered.


2. RJ-45 connector is used to connect this cable to computer.
Characteristics of UTP Cable:
1. It is a low cost cable.
2. It is thin and flexible cable.
3. It offers ease of installation.
4. It can carry data up to a length of 100m at a stretch.

STP (Shielded Twisted Pair):

1. Individual pairs are covered.


2. An outer shield then covers all the pairs like in UTP.
3. RJ-45 connector is used to connect this cable to computer.
Characteristics of STP Cable:
1. It is expensive than UTP cable.
2. As compared to UTP cables, STP is difficult to install.

15
• Co-axial Cable:

1. It consists of two conductors that share a common axis.


2. The inner conductor is the straight wire.
3. The outer conductor is a shield that might be braided or foil.
4. Earlier Co-axial cable was also used for connecting computers in small network but now UTP/STP cables
are more commonly used.
Characteristics of co-axial Cable:
1. It can carry data for a larger distance (185m – 500m) at a stretch.
2. Bulkier and less flexible than twister cable.
3. It is difficult to install as compared to twisted cable.

• Optical Fiber Cable:


1. They are long and thick about a human hair.
2. They are arranged in bundles called optical fiber cables and used to transmit data through light signals over
long distances.
3. An optical fiber has the following three parts,
 Core: It is a thin glass rod through which light travels.
 Cladding: It surrounds the core and reflects the light back into the core.
 Buffer Coating: It is the plastic coating that protects the cable from damage.
4. These optical fibers are arranged in bundles of hundreds and thousands and are protected by the cable’s
outer covering, called jacket. 16
NOTE: difference between wired media is given in text book. (Pg. no: 6)

Wireless Media

Electromagnetic waves are used for wireless communication over networks. Frequencies of waves are
measured in Hertz (Hz). Based on their frequencies, electromagnetic waves are categorized as, (increased
order of frequency)

 Radio Waves
 Micro Waves
 Infrared Radiation
 Visible Light
 Ultraviolet Radiation
 X-rays
 Gamma rays
Out of these only radio waves, micro waves and infrared rays are used for wireless communication.

• Radio Waves:

1. Frequency range of 3 KHz to 3GHz.


2. Used for communication over distances ranging from a few meters.
3. Can penetrate (pass) building easily. Hence, they are used for communication both indoors and outdoors.
4. Examples: Walkie-talkie, Cordless Phones.

17
Fig: Radio Wave Tower

Characteristics of Radio Wave Transmission:

1. Waves are omni-directional.


2. Transmitting and receiving antennas are not needed.
3. Inexpensive than wired media.
4. Less secure mode of transmission.
5. Permission from concern authorities in needed for the use of radio wave transmission.

• Micro Waves:

1. Frequency range of 300 MHz to 300GHz.


2. Micro waves travel in straight line.
3. Cannot penetrate any solid object.
4. For long distance communication, high towers are built and microwave antennas are put on their tops.

Characteristics of Micro Wave Transmission:

1. Waves are unidirectional.


2. Transmitting and receiving antennas are needed.
3. Inexpensive than wired media.

Transmitter
Receiver

18
• Infrared Waves:

1. Frequency range of 300 GHz to 400THz.


2. These waves are used for short range communication (app. 5m).
3. These waves cannot penetrate through solid object.
4. Infrared system in one room of a building will not interfere with a similar system in adjacent rooms.
5. Example: you cannot control TV in another room with the remote in your hand in a room.
Characteristics of Infrared Wave Transmission:

1. It is a line of sight transmission. Therefore, information passed to one device is not leaked to another
device.
2. No government license is required.
3. At a time only two devices can communicate.
4. Performance drops with longer distances.

• Bluetooth:

1. Bluetooth technology uses radio waves in the frequency range of 2.402 GHz to 2.480 GHz.
2. Used for short range communication (app. 10m).
3. Example: Cell phones.

Characteristics of Bluetooth Transmission:

1. Bluetooth can communicate up to 8 devices simultaneously.


2. Slow data transfer (up to 1Mbps).

• Satellite Link:

1. Used for very long distance communication which may range from city to continent.
2. Transmission from a satellite to the earth is known as uplink.
3. Transmission from a earth to satellite is known as downlink.
4. Frequency used for uplink varies from 1.6 GHz to 30.0 GHz.
5. Frequency used for downlink varies from 1.5 GHz to 20.0 GHz.
6. Downlink frequency is always lower than the uplink frequency.
7. Communication satellites are normally owned by government or by government approved organizations of
various countries.

19
Characteristics of Satellite Link Transmission:

1. Covers large area of earth.


2. Expensive.
3. Requires legal permissions.

Network Protocol
Network Protocol  Definition

A network protocol is a set of rules for communication among networked devices. Protocols generally include
rules of,

1. How and when a device can send or receive the data?


2. How is sent data packaged?
3. How it reaches the destination?

Three types of protocols:

1) HTTP
2) TCP/IP
3) PPP

HTTP (Hyper Text Transfer Protocol):

1. Allows us to transfer resources (comprising files and other data) from one computer to another across
the globe.

2. When the HTTP request is sent from the HTTP client (Browser) to the HTTP server (web server), the
request is being processed by the server and accordingly the response is being sent back to the client.

3. The transfer of request and response between the client (browser) and server (web server) is done
through the HTTP Protocol.

20
TCP/IP (Transmission Control Protocol / Internet Protocol):

1. It is the basic protocol of the internet.


2. Facilitates the communication between two computers on the internet.
3. It is two-layered protocol.

4. Function of TCP Protocol:

When data is to be sent from one computer to another over internet, it is first broken into smaller
packets (pieces) which are actually sent. When the packets are received by the receiver computer, they are
assembled into the original message.

5. Function of IP Protocol:

The IP protocol ensures that the data has been sent to the correct destination.

PPP (Point to Point Protocol):

1. Allows us to establish the direct communication between two computers.


2. PPP is generally used by ISP (Internet Service Provider) to provide dial-up access for the internet to its
users.
3. Example: a connection established between the PC and server through a phone line.

Types of Networks
On the basis of area covered computer networks are classified as,
• PAN
• LAN
• MAN
• WAN
PAN (Personal Area Network):

21
• PAN is a small network consisting of devices, such as cell phones which are within a range or reach of
an individual.

• It covers an area of few meters radius (2m).

• Example: 1) connection between two cell phones using Bluetooth.

2) connection between a laptop and a mobile.

• PAN can be setup using guided media (USB cable) or Unguided media (Bluetooth).

LAN (Local Area Network):

• LAN is a network of computing/communicating devices in a room, building or campus.

• It can cover an area of a few meters to a few kilometers radius.

• LAN allows resource sharing among network users.

• Example: a networked office building, school usually contains a single LAN.

• LAN can be set up using wired media (UTP cables, Co-axial cable) or wireless media (radio waves).

• If a LAN is setup using unguided media, it is called WLAN (Wireless LAN).

MAN (Metropolitan Area Network):

• MAN is a network of computing / communicating devices within a city.

• It can cover an area of few kilometers to a few hundred kilometers radius.

• Example: a network of banks within a city.

• MAN is usually formed by interconnecting a number of LANs and individual computers.

• All types of communication media are used to setup a MAN.

22
WAN (Wide Area Network):

• WAN is a network of computing / communicating devices crossing the limits of a city, country or
continent.

• It can cover an area of over hundreds of kilometers.

• WAN is usually formed by interconnecting a number of LANs, MANs and individual computers.

• Example: a network of international organizations, ATMs spread over a country, continent.

• All types of communication media are used to setup a WAN.

• Best Example  internet

23
Difference between the types of network

Criteria LAN MAN WAN

Cost Low High Higher

Network Size Small Larger Largest

(few meters to a few (few kilometers to a few (an area over hundreds of
kilometers radius) hundred meters radius) kilometer radius)
Speed Faster Slower Slowest

No.of.computers Smallest Large Largest

Network Security Concepts


1. Cookies:

1. An HTTP cookie (also called web cookie, Internet cookie, browser cookie or simply cookie), is a small
piece of data sent from a website and stored in the user's web browser while the user is browsing.

2. Every time the user loads the website, the browser sends the cookie back to the server to notify the user's
previous activity such as,

• items added in the shopping cart in an online store

• clicking particular buttons, logging in, or recording which pages were visited in the past

3. Cookies can also store passwords and form content a user has previously entered, such as a credit card
number or an address.

4. The security of an authentication cookie generally depends on the security of the issuing website and the
user's web browser.

24
2. Firewall:

1. It is a technique used in a secured computer system or network to block unauthorized access and allow only
authorized users.
2. Firewall can be implemented in either hardware or software, or a combination of both hardware and
software.
3. It is normally placed between a protected network (usually a LAN) and an unprotected network (usually a
WAN) and acts like a gate to protect all resources to ensure that nothing goes out without permission and
nothing unwanted comes in into the system.

3. Cyber Law:

1. The propagation of a virus, worms and Trojan is one of the common means of making cyber crime.
2. Like traditional crimes such as theft, fraud, forgery, cyber crimes are also treated criminal in nature.
3. Information Technology Act 2000 (The IT Act 2000) is a law currently existing in India, which provide
legal support to the computer users against the cyber crime.
4. These laws have been described as “paper laws” for “paperless environment”.

4. Hackers:

1. A hacker is someone who seeks and exploits weaknesses in a computer system or computer network.
2. Hackers may be motivated by a multitude of reasons, such as profit, protest, challenge, enjoyment, or to
evaluate those weaknesses to assist in removing them.
3. Hackers steal sensitive information.
4. Hackers are most often programmers.

5. Crackers:
1. A cracker is someone who breaks into someone else's computer system, often on a network, by passes
passwords or licenses in computer programs or in other ways intentionally breaches computer security.
2. A cracker can be doing this for profit, maliciously, for some altruistic purpose or cause, or because the
challenge is there.
3. Crackers create nothing but destroy much.

25
Chapter – 1: Computer Networking

Lab Exercises

1. Find the IP address of atleast 3 computers in your school.

Start Run cmd ipconfig

2. Find the MAC address of atleast 2 computers in your lab. Then verify their manufacture’s name on the net.

a) Start Run cmd ipconfig /all

b) To find the manufacturer’s name:

Step 1: Make a note of the system’s MAC address.

26
Step 2: Go to  www.macvendors.com

Step 3: Type the MAC address and get the manufacturer’s name.

4. Find the name of Internet Service Provider (ISP) of your school.

Step 1: Go to  www.whatismyipaddress.com

Step 2: Get the details of your ISP name.

5. Find the IP address of your school’s website.

Start  Run  cmd  ping www.gked.in

27
Computer Networks
Work Sheet
(1 MARK QUESTIONS)
1. Ms. Kant Sengupta wants to prevent unauthorized access to/from his company’s local area network. Write the
name of a system (software/hardware), which he should install to do the above.
Ans: _______________________________

2. Seven Brother Fashion Inc. is a fashion company with design unit and market unit 130 meters away from each
other. The company recently connected their LANs using Ethernet cable to share the stock related information.
But, after joining their LANs, they are not able to share the information due to loss of signal in between. Which
device out of the following should you suggest to be installed for a smooth communication?
(i) Modem (ii) Repeater (iii) UPS Ans: _______________________________

3. Which of the following is not a feature of Networking?


(i) Resource sharing (ii) Reliability (iii) Uninterrupted power supply (iv) Reduced cost
Ans: _______________________________

4. Raj kamal International school is planning to connect all computers, each spread over distance within 45
meters. Suggest an economical cable type having high-speed data transfer, which can be used to connect these
computers. Ans: _______________________________

5. Write the name of the most suitable wireless communication channels for each of the following situations.
(i) Communication between two offices in different countries.
(ii) To transfer the data from one mobile phone to another.
Ans: _______________________________

6. Chander vardhan is not able to identify the Domain Name in the given URL. Identify and write it for him.

Ans: _______________________________

7. Why is a switch called an intelligent hub?


Ans: ______________________________________________________________________________________

__________________________________________________________________________________________

8. What is the use of Repeater in a Network?


Ans: ______________________________________________________________________________________
28
(2 MARK QUESTIONS)
1. Identify the type of topology from the following:
a) In it, each node is connected with the help of a single co-axial cable.
b) In it, each node is connected with the help of independent cable with the help of a central switching
(communication controller).
Ans: a) _______________________________________________________

b) _______________________________________________________

2. Define the following with reference to Threats to network security.


(i) Worm (ii) Trojan Horse
Ans:
Worm:
__________________________________________________________________________________________

__________________________________________________________________________________________

Trojan Horse:
__________________________________________________________________________________________

__________________________________________________________________________________________

3. Ms. Rani Sen, General Manager of Global Nations Corporate recently discovered that the communication
between her company’s accounts office and HR office is extremely slow and signals drop quite frequently. These
offices are 125 meters away from each other and connected by an Ethernet cable.
(i) Suggest her a device, which can be installed in between the offices for smooth communication.
(ii) What type of network is formed by having this kind of connectivity out of LAN,MAN and WAN?
Ans: (i) _______________________________________________

(ii) ______________________________________________

4. Give suitable example of URL and Domain name.

Ans: Example of URL: ________________________________________________

Example of Domain Name: ________________________________________________

5. Give suitable example of IP and MAC Address.

Ans: Example of IP address: ________________________________________________

Example of MAC Address: ________________________________________________

29
5. Give an advantage of using Star topology over Bus topology. Show a network layout of star topology to
connect 5 computers. (Twice in 2012 & 2013)

6. Write the difference between IP and MAC Address.

7. Identify the following device :


(i) A device that is used to connect different types of network. It performs the necessary translation so that the
connected network can communicate properly? Ans: ______________________________________
(ii) A device that converts data from digital bit stream into an analog signal and vice versa.
Ans: _________________________________________

8. Define ‘Domain Name Resolution’.


Ans:______________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

9. What do you understand by Network Security? Name two common threats to it. (Twice in 2013 & 2015)
__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________
30
Chapter – 1: Computer Networking

Assignment – 1

Date of Issue: Date of Submission:

Total Marks: 30
1. Write down the steps to find the IP address of a system. 2

2. Write down the steps to find the MAC address of a system. 2

3. Write down the steps for finding the IP address of a website (Domain Name Resolution). 2

4. Represent the following IP address in binary form. 8

a) 191.123.1.5

b) 75.29.56.22

c) 55.12.40.39

d) 87.100.255.4

5. Represent the following MAC address in binary form. 8

a) A8-B9-DE-02-A0-FA

b) 27-32-CA-5B-6C-01

c) A1-B2-34-D5-E6-F7

d) 12-34-A3-B0-AA-FF

6. Diagrammatically show how you would connect 4 PCs, 1 server, 2 printers in the
following topologies, 6
A. Ring
B. Star
C. Mesh
D. Fully Connected
E. Bus
F. Tree

7. How is domain name different from URL. Explain with example. 2

31
Chapter – 2: Open Source Concepts

(1) Open Source Software (OSS):


1. Open Source Software (OSS) refers to software whose source code is available to customers (users).
2. An OSS on the other hand, can be freely used but it does not have to be free of charge.
3. OSS, generally, give users freedom,
• To run/use the software for any purpose.
• To study and modify the program,
• To redistribute copies of either the original or modified program.

Examples of OSS:

 Linux OS
 Google Chrome OS
 Open Office
 NetBeans
 Java
 PHP
 Pyhton

(2) OSS can also be called as,

Free Software: (Freedom Software)


FOSS (Free and Open Source Software)
FLOSS ( Free / Liberal Open Source Software)

1. Software available for


 free of cost
 can be modified and redistributed
2. Free software should give the following 4 freedoms to users,
• Freedom 0: Freedom to run the program for any purpose.
• Freedom 1: Freedom to study how the program works and change it to make it do what you
wish.
• Freedom 2: Freedom to redistribute the copies.
• Freedom 3: Freedom to improve the program and release your improvements to the public.

32
(3) Proprietary Software:
 A software that is neither open nor freely available.
 Its source code is not available.
 Modification is either forbidden or requires special permission by the supplier or vendor.
Example: MS Office, Adobe Photoshop

(4) Freeware:

 A software which is available for free of cost.


 Allows copying and distribution.
 Source code is not available.
 Modification cannot be done.
Example: Mozilla Firefox, Google Chrome

(5) Shareware:
 Software for which license fee should be paid after its trial period.
Example: Team Viewer

(6) Examples of FOSS/FLOSS in detail:


 GNU/Linux:
o GNU stands for GNU’s Not Unix.
o GNU and Linux are operating System (OS).
o GNU is often used with the Linux kernel.
o The combination of GNU and Linux is the GNU/Linux operating system which is OSS.

 Firefox:
o It is a free and open source web browser produced by Mozilla Foundation.
o Firefox runs on various versions of GNU/Linux, Microsoft Windows and many other Unix like
Operating System.
o It can be downloaded from www.mozilla.org.
 Open Office or Open Office.org (OOo):

o It is the open source office suite for,


i. Word processing  Writer
ii. Spreadsheets  Calc
33
iii. Presentations  Impress
iv. Databases, etc.
o Open Office can be downloaded from www.openoffice.org

 NetBeans:

o The NetBeans project is an open source project. What this means is:
1. The NetBeans Platform is free for commercial and non- commercial use.
2. The source codes to both are available to anyone to reuse as they see fit under the terms
of the license.
o It can be downloaded from www.netbeans.org

 MySQL:
o It is one of the most popular open source database system in the world.
o MySQL works on many different platforms such as Linux, Windows XP, etc.
o It also supports many programming languages such as C, C++, Java, Perl, PHP, Python.
o MySQL can be downloaded from www.mysql.com.
 Java:

o It is a programming language which is open source.


o Java was invented by James Gosling.
o Java can run on various operating systems like Windows, Linux.

(7) Two organizations of Open Source Software:

1. NRCFOSS:
 NRCFOSS stands for National Resource Centre for Free and Open Source Software.
 NRCFOSS contributes to the growth of FOSS in India through
o Research and Development
o Human Resource Development
 NRCFOSS serves as the reference point for all FOSS related activities in the country.

2. OSI:
 OSI stands for Open Source Initiative.
 It is an organization for promoting OSS.
 It was founded in Feb 1998 by Bruce Pernes and Erics Raymond.
 It specifies the criteria for open source software.

34
(8) Technical Standards:

Definition of technical Standards:

 A technical standard or simply a standard refers to an established set of rules or requirements, which
are approved by a recognized body and is widely used across various software platforms.
 The technical standards can be classified into:
Proprietary Standards and Open standards

Proprietary Standards:

 These standards are those, for which users have to buy license to use them.
 Their specification is not publicly available.
 These standards are owned by a single company/ person/ vendor or a group of vendors.
 Example: Microsoft Office Formats (eg, .doc, .docx, .ppt, .xls, etc).
 Proprietary Standards are also otherwise called as closed standards or exclusive standards.

Dangers of proprietary software:

1. Recipient may not able to read the file:

If you create a document in MS Word 2007 and send it to your friend who does not have Word 2007, then
he/she would not be able to open and read the file.

2. Single supplier or vendor has total control over the functionality and usefulness of the product:

Since a proprietary standard is the property of a certain company or vendor, other users and developer cannot
add new functionality to it.

Open Standards:

 Open standards are internationally accepted technical standards that guarantee that data can be
exchanged across platforms and applications.

 The specification of open standards is open to all.

 Example: Open Document Format (ODF), Ogg Vorbis.

Advantages of open standards:

1. Making the data accessible to all:

Open standards remove the restriction of using any specific software or license. Hence, people will be able
to open the files using software of their choice. 35
(9) Common open standards:

1. Open Document Format (ODF):

 It is a format for office documents such as spreadsheets, presentations and word-processing


documents.
 Open document is a free and open format.
 It is a standard format which supports files created in any office suite such as MS Office, Open Office,
Star Office and K Office.
 Open documents file extensions are,
.odt (Open Document Text) for word document.
.ods(Open Document Spreadsheet) for spreadsheets.
.odp (Open Document Presentation) for presentations.
.odg (Open Document Graphic) for graphic files.
.odb (Open Document dataBase) for database files.

2. Ogg Vorbis:
 It is a new audio compression format developed by Xiph.org.
 It is a open source.
 It was developed to replace all the proprietary formats currently used for audio compression (MO3,
WMA, etc).

3. HTML (Hyper Text Markup Language):

 HTML is the standard language for the web.


 It can be read on any platform.

4. WWW (World Wide Web):

 It is an open standard specified by World Wide Web Consortium (W3C).


 After the introduction of WWW in 1989, the use of the internet changed radically.
 WWW is an application consisting of programs, standards and protocols that help you create and
display multimedia files on the internet.

5. XML (Extensible Markup Language):

 It is a text-based markup language for processing and displaying data in a structured format.

36
 The platform independent nature of the language makes the XML file an ideal format for exchanging
textual data between different applications.

6. IP (Internet Protocol):

 It is an open source specification of Internet Engineering Task Force (IETF) for transmitting data over
a network.

7. TCP (Transmission Control Protocol):

 It is an open source specification of IETF for implementing streams of data (packets of data) on top of
IP.

10. Fonts:

 Font refers to a group of printable and displayable text characters which have some particular style and
size.

 A font is the most important tool for character encoding because it is the font through which a
character is represented on screen (or printer).

 Fonts can be classified into two as follows,

1 Technical Specification

2 Font configurations

37
Technical Specification:

 Under technical specification, fonts can be classified into two,

1 True Type Font (TTF)

2 Open Type Font (OTF)

True Type Font:

 TTF has been developed by Apple and Microsoft in 1980s.

 It is a 8 bit font.

 It is the Native Operating System Font Format for Windows and MacOS.

 It is easier to install.

Disadvantages:

 This font is not cross-platform compatible (different files needed for platforms like
windows and Mac os).

 It will not work with some older printing devices.

 There are better quality fonts available.

Open Type Font:

 It is an extension of TTF.

 It is a 16 bit font.

 Permits handling of large Glyph (an alternate character to a character) sets.

 OTF’s character set is based on UNICODE representation. Thus, OTF contains 65,536
characters.

Advantages:

• Provides output in better quality.

• Supports cross platform environment.

Disadvantages:

• Not easier to install.

Font Configuration:

 Under font configuration, fonts can be classified into two,

1 Static Font.
38
2 Dynamic Font.

Static Font:

 Whenever printing takes place, the same character (identical shape) is displayed every
time.

 Maximum fonts belong to this class only.

 Example: Times New Roman, Arial, etc.

Dynamic Font:

39
OPEN SOURCE CONCEPTS
Work Sheet
(1 MARK QUESTIONS)
1. Name any two Indian scripts included in Unicode. (Twice in boards, 2011 &2012)
__________________________________________________________________________________________

__________________________________________________________________________________________

2. Write examples of one Proprietary and one Open Source Software.


__________________________________________________________________________________________

__________________________________________________________________________________________

3. Name any two most popularly used internet browsers.


__________________________________________________________________________________________

__________________________________________________________________________________________

4. What is UNICODE? Name one Indian language, which is supported by UNICODE. (2013 again repeated)
__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

5. Expand the following terms:


(i) FLOSS ______________________________________________________

(ii) HTTP ______________________________________________________

6.Expand the following terms: (i) OSS (ii) ODF


__________________________________________________________________________________________

__________________________________________________________________________________________

(2 MARKS QUESTIONS)
1. Mr. Vidya Chauhan is confused between Proprietary and Open source software. Mention at least two points
of differences to help her understand the same. (Thrice in boards 2011 ,2014 &2015)

40
Chapter – 6: Data Connectivity
Connecting Database to NetBeans

Program 1:

Step 1: Create a table in MySQL.

Step 2: Create the application in NetBeans and code as follows,

jButton1(Add Rows):

import java.sql.Connection;

import java.sql.Statement;

import java.sql.DriverManager;

import javax.swing.JOptionPane;

String Name=jTextField1.getText();

String Mobile=jTextField2.getText();

String Email=jTextField3.getText();

try

Class.forName("java.sql.DriverManager");

Connection con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root","school");
41
Statement stmt=(Statement)con.createStatement();

String query="insert into contact values ('"+Name+"','"+Mobile+"','"+Email+"');";

stmt.executeUpdate(query);

catch (Exception e)

JOptionPane.showMessageDialog(this, e.getMessage());

jButton2(Exit):

System.exit(0);

Step 3: Run your application and insert the data.

Step 4: Type the following query in MySQL, Select * from details;

42
Program 2:

Step 1: Create a table in MySQL.

Step 2: Create the application in NetBeans and code as follows,

jButton1(OK):

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.Statement;

import javax.swing.JOptionPane;

String Emp_No=jTextField1.getText();

String Emp_Name=jTextField2.getText();

String Designation=jTextField3.getText();

String Salary=jTextField4.getText();

try

Class.forName("java.sql.DriverManager");

Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/grade12","root","school");

Statement stmt=(Statement)con.createStatement();
43
String query="insert into Employee values ('"+Emp_No+"','"+Emp_Name+"','"+Designation+"','"+Salary+"');";
stmt.executeUpdate(query);

catch (Exception e)

JOptionPane.showMessageDialog(this, e.getMessage());

Step 3: Run your application and insert the data.

Step 4: Type the following query in MySQL, Select * from details;

Task 1: Create a table named “Student” in the database test, with the specified table structure.

44
Task 2: Create a table in the database test, with the specified table structure.

Program 3: To search for a matching row and display corresponding information from the table “details” using
database connectivity.(search by mobile no).

jButton1(Search):

String mobile=jTextField2.getText();

jTextField1.setEditable(false);

jTextField3.setEditable(false);

if(mobile.isEmpty())

JOptionPane.showMessageDialog(this, "Enter mobile no");

try

Class.forName("java.sql.DriverManager"); 45
Connection con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root","school");

Statement stmt=(Statement)con.createStatement();

String query="select name,email from details where mobile=' "+mobile+" ';";

ResultSet rs=stmt.executeQuery(query);

if(rs.next( ))

String Name=rs.getString("Name");

String Email=rs.getString("Email");

jTextField1.setText(Name);

jTextField3.setText(Email);

else

JOptionPane.showMessageDialog(this, "sorry, No match");

catch (Exception e)

JOptionPane.showMessageDialog(this, e.getMessage());

Output

46
Task 1: Write a java program to search for a matching row and display corresponding
information from the table “employee” using database connectivity.(Search by Emp_No).

Program 4: To search for a matching row and display corresponding information from the table “details” using
database connectivity.(search by Name).

jButton1(Search):

String name=jTextField1.getText();

jTextField2.setEditable(false);

jTextField3.setEditable(false);

if(name.isEmpty())

JOptionPane.showMessageDialog(null, "Enter name");

try 47
{

Class.forName("java.sql.DriverManager");

Connection con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/cbse","root","school");

Statement stmt=(Statement)con.createStatement();

String query="select Mobile,Email from details where Name='"+name+"';";

ResultSet rs=stmt.executeQuery(query);

int found=0;

while(rs.next())

String Mobile=rs.getString("Mobile");

String Email=rs.getString("Email");

jTextField2.setText(Mobile);

jTextField3.setText(Email);

JOptionPane.showMessageDialog(null, "Click OK to continue");

found++;

if(found = = 0)

JOptionPane.showMessageDialog(this, "sorry, No match");

catch (Exception e)

JOptionPane.showMessageDialog(this, e.getMessage());

48
Output 1

Output 2

49
Task 1: Write a java program to search for a matching row and display corresponding
information from the table “employee” using database connectivity.(Search by Emp_Name).

Program 5: To display records retrieved from the backend in the table component.

Step 1: Create two tables of same columns in MySQL.

Step 2: Create the following application.

50
Step 2.1: Right click the table component and select Table Contents…

Step 2.2: Following Dialogue box appears.

Step 2.3:

i. Select Rows option.

ii. By default 4 rows will be added. Select all the 4 rows as shown below and click Delete button.

Step 2.4:

i. Select Columns option.

ii. Delete unwanted columns and give column names as shown below.

51
Step 3: Do the following coding.

52
Step 4: Check the output.

53
Chapter – 7: Web Applications

Program 1:

<!DOCTYPE html> Output


<html>
<title> I am the title</title>
<head> I am the head of this html coding</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

Program 2:

<!DOCTYPE html> Output


<html>
<head><h1>This is a heading</h1></head>
<title>This is document title</title>
<body>
<p>Document content goes here.....</p>
</body>
</html>

Program 3: Heading Tags

<html> Output
<head><title>Heading Example</title> </head>
<body><h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body> </html>
54
Program 4: Paragraph Tag

<!DOCTYPE html> Output


<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>

Program 5: Line Break Tag (Example of empty element)

<!DOCTYPE html> Output


<html>
<head>
<title>Line Break Example</title>
</head>
<body>
<p>Hello<br>
You delivered your assignment ontime.<br>
Thanks<br>
Vaishu</p>
</body>
</html>

Program 6: Center Tag

<html>
<head>
<title>Centering Content Example</title>
</head>
<body> <p>This text is not in the center.</p>
<center> <p>This text is in the center.</p> </center>
</body> </html> 55
Output

Program 7: Horizontal Tag (Example of Empty elements)

<!DOCTYPE html> Output


<html>
<head>
<title>Horizontal Line Example</title>
</head>
<body>
<p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at
bottom</p>
</body>
</html>

Program 8: Preserve Tag

<html> Output
<head>
<title>Preserve Formatting Example</title>
</head>
<body>
<pre>
function testFunction( strText ){
alert (strText)
}
</pre>
</body>
</html> 56
Program 9: Alignment

<!DOCTYPE html>
<html>
<head>
<title>Align Attribute Example</title>
</head>
<body>
<p align="left">This is left aligned</p>
<p align="center">This is center aligned</p>
<p align="right">This is right aligned</p>
</body>
</html>
Output

Program 10: Bold Text

<html>
<head>
Output
<title>
Bold Text Example
</title>
</head>
<body>
<p>The following word uses a <b>bold</b>
typeface.</p>
</body>
</html>

57
Program 11: Italic Text

<!DOCTYPE html>
<html> Output
<head>
<title>Italic Text Example</title>
</head>
<body>
<p>The following word uses a <i>italicized</i>
typeface.</p>
</body>
</html>

Program 12: Underlined Text

<!DOCTYPE html>
<html> Output
<head>
<title>Underlined Text Example</title>
</head>
<body>
<p>The following word uses a <u>underlined</u>
typeface.</p>
</body>
</html>

Program 13: Strike Text

<!DOCTYPE html>
<html>
<head>
<title>Strike Text Example</title>
</head> Output

<body>
<p>The following word uses a
<strike>strikethrough</strike> typeface.</p>
</body>
</html> 58
Program 14: Superscript Font

<!DOCTYPE html>
<html> Output
<head>
<title>Superscript Text Example</title>
</head>
<body>
<p>The following word uses a
<sup>superscript</sup>
typeface.</p>
</body>
</html>

Program 15: Subscript Font

<html>
<head> Output
<title>Subscript Text Example</title>
</head>
<body>
<p>The following word uses a <sub>subscript</sub>
typeface.</p>
</body>
</html>

Program 16: Inserting Image

<html>
<head>
<title>Using Image in Webpage</title>
</head>
<body>
<p>Simple Image Insert</p>
<img src="E:\light-blue-background-3.jpg" alt="Test
Image" />
</body>
</html> 59
Output 1 Output 2

Program 17: Setting width and height

<html>
<head>
<title>Using Image in Webpage</title>
</head>
<body>
<p>Simple Image Insert</p>
<img src="E:\light-blue-background-3.jpg" width=150 height=100 />
</body>
</html>

Output

60
Program 18: To display text with no line or paragraph breaks.

<html>
<title> text with no breaks</title>
<body>
Hello! welcome to my personal web page. I hope you like it.

I'm a student at DPS delhi, studying in class 9. I grew up in Bangalore, and i did my class 8 from there itself.

This is my first attempt at a web page. Enjoy!


</body>
</html>

Output

Program 19: To display text with line or paragraph breaks.

<html>
<title> text with breaks</title>
<body>
Hello! welcome to my personal web page. I hope you like it.

<p>I'm a student at DPS delhi, studying in class 9. I grew up in Bangalore, and i did my class 8 from there
itself.</p>

<p>This is my first attempt at a web page. Enjoy!</p>


</body>
</html>
Output

61
Program 20: To display paragraphs in various alignments.

Write a HTML program to display the following output.

62
Attributes of Body Tag
1. Background Image
2. Background Color, Text Color, Link Color
3. Setting left and top margins
4. <Font> tag
a. Face
b. Size
c. Color

1. Background Image:
To display a background image on your web page. Output
<html>
<title> Background Image</title>
<body background=E:\CIN-BLUE.jpg>
sample web page for background image
</body>
</html>

2. Background Color, Text Color, Link Color:


To make the background appear pink, text blue, links yellow, recently visited links red and selected link as
green.
<html> Output
<title> Attributes of Body tag</title>
<body bgcolor="pink" text="blue" link="yellow"
alink="red" vlink="green">
Sample Text
</body>
</html>

The output will become more clear when you learn to add links also. Since there are no links in the above
example, only background and text color are visible.

63
3. Setting left and top margins:
To make body text appear 60 pixels away from the top edge of page and 75 pixels away from left edge of page.

<html>
<title> Attributes of Body tag</title>
<body topmargin=60 leftmargin=75>
hello students! Notice that the blank area on the left and top side of text. this is because of left and top margin
attributes of the body tag.
</body>
</html>
Output

The <Font> tag


This font tag is used to change the size, style and color of text.

<html>
<title> text with breaks</title>
<body>
<font size=7 color="blue">
T </font>
<font face=Arial,Times New Roman </font>his is my first attempt at a web page. Enjoy!</p>
</body>
</html>
Output

64
Attributes of Horizontal Rule <HR> Tag
1. Size attribute

2. No shade attribute

3. Width attribute

1. Size attribute:

<html>
<title> text with breaks</title>
<body>
<hr size=20> <br>
</body>
</html>
Output

2. No shade attribute:

<html>
<title> text with breaks</title>
<body>
<hr size=20 noshade> <br>
</body>
</html>
Output

65
3. Width attribute

<html>
<title> text with breaks</title>
<body>
<hr width=100> <br>
<hr width=200><br>
<hr width=30%><br>
<hr width=75%><br>
</body>
</html>
Output

66
Attributes of Image
1. SRC
2. Alternate
3. Border
4. Align
5. Height
6. Width

Program 21: Using all attributes of image in one program.

<html>
<title> Example on image </title>
<body>
<img src=" E:\htmlexample.jpg" alt=”Test Image” border=5 align="right" height=500 width=700>
</body>
</html>
Output

67
List

There are three basic types of lists in HTML: Unnumbered (unordered), Numbered (ordered), definition. Lists
can be nested as well. (having list inside other list).

Unordered List (Unnumbered List)


<html>
<title> Unordered list </title> Output
<body>
<ul>
<li> apple
<li> orange
<li> banana
</ul>
</body>
</html>
<html>
<title> Unordered list </title> Output
<body>
<ul type=circle>
<li> apple
<li> orange
<li> banana
</ul>
</body>
</html>
<html>
<title> Unordered list </title> Output
<body>
<ul type=square>
<li> apple
<li> orange
<li> banana
</ul>
</body>
</html>

68
Ordered List (Numbered): Output
<html>
<title> Ordered list </title>
<body>
<ol>
<li> apple
<li> orange
<li> banana
</ol>
</body> </html>
<html>
<title> Ordered list </title> Output
<body>
<ol type=A>
<li> apple
<li> orange
<li> banana
</ol> </body> </html>

<html>
<title> Ordered list </title> Output
<body>
<ol type=a>
<li> apple
<li> orange
<li> banana
</ol>
</body> </html>
<html>
<title> Ordered list </title> Output
<body>
<ol type=a start=5>
<li> apple
<li> orange
<li> banana
</ol> </body> </html>
69
<html>
<title> Ordered list </title> Output
<body>
<ol type=1 start=5>
<li> apple
<li> orange
<li> banana
</ol>
</body> </html>
<html>
<title> Ordered list </title> Output
<body>
<ol type=I start=3>
<li> apple
<li> orange
<li> banana
</ol>
</body> </html>
<html> Output
<title> Ordered list </title>
<body>
<ol type=i start=3>
<li> apple
<li> orange
<li> banana
</ol>
</body> </html>
Nested List
<html> Output
<title> Ordered list </title>
<body>
<ol type=i start=3>
<li> apple
<li> orange
<li> banana
<ul>
70
<li> banana1
<li> banana2
</ul>
</ol></body> </html>

Definition List:

Definition list consists of,

a. Definition term ( <DT> )

b. Definition description ( <DD> )

<html> Output
<title> Ordered list </title>
<body>
<dl>
<dd>NetBeans IDE
<dd> NetBeans IDE is a platform to work in java.
</body></html>

71
Creating Tables in HTML

Tables are very useful in the communication of data in a meaningful way.

Table is a container element which has both opening _____________ and closing tags___________.

Table element has the following elements in it,

1. Table Heading <th>…</th>  Column Name

 This tag is used inside the table element.

2. Table Row <tr>…</tr>  Used to define table rows

 This tag is used inside the table element.

3. Table Data <td>…</td> Used to specify the text in a cell of the table.

 This tag is used inside the table row element.

4. Caption <caption>…</caption>  Name of the table

Let’s see how to create a table in HTML,

Program 1: Program 2:

<html> <html>
<title> Creating Tables </title> <title> Creating Tables </title>
<body> <body>
<table border=2> <table>
<caption> Name List </caption> <caption> Name List </caption>
<tr> <tr>
<td> S.No </td> <th> S.No </th>
<td> Name of a student </td> <th> Name of a student </th>
<td> Class </td> <th> Class </th>
</tr> </tr>
<tr> <tr>
<td> 1 </td> <td> 1 </td>

<td> Md. Shariff </td> <td> Md. Shariff </td>


<td> Grade 12 </td> <td> Grade 12 </td>
</tr> </tr>
<tr> <tr>
<td> 2 </td> <td> 2 </td>
<td> Rebecca Abraham </td> <td> Rebecca Abraham </td>
<td> Grade 12 </td> <td> Grade 12 </td>
</tr> </tr>
<tr> <tr>
<td> 3 </td> <td> 3 </td>
<td> Sindhu </td> <td> Sindhu </td>
<td> Grade 12 </td> <td> Grade 12 </td>
</tr> 72 </tr>
</table> </table>
</body> </body>
</html> </html>
Output Output

Attributes of Table Element

1. Border 2. Cellspacing 3. Bgcolor 4. Align 5. Cellpadding

Program 3: Output: (Without cellpadding)


<html>
<title> Creating Tables </title>
<body>
<table border=2 cellspacing=3 cellpadding=10
bgcolor=" pink" align =”left”>
<caption> Name List </caption>
<tr>
<th> S.No </th>
<th> Name of a student </th>
<th> Class </th>
</tr>
<tr>
<td> 1 </td>
<td> Md. Shariff </td>
Output (with cellpadding)
<td> Grade 12 </td>
</tr>
<tr>
<td> 2 </td>
<td> Rebecca Abraham </td>
<td> Grade 12 </td>
</tr>
<tr>
<td> 3 </td>
<td> Sindhu </td>
<td> Grade 12 </td> 73
</tr>
</table>
</body>
</html>

Attributes of Table Row element

1. Align 2. Bgcolor 3. Border

Program 4:
<html> Output:
<title> Creating Tables </title>
<body>
<table border=2 cellspacing=10 bgcolor=" pink"
align="left">
<caption> Name List </caption>
<tr border=5 align="right" bgcolor="blue">
<th> S.No </th>
<th> Name of a student </th>
<th> Class </th>
</tr>
<tr>
<td> 1 </td>
<td> Md. Shariff </td>
<td> Grade 12 </td>
</tr>
<tr>
<td> 2 </td>
<td> Rebecca Abraham </td>
<td> Grade 12 </td>
</tr>
<tr>
<td> 3 </td>
<td> Sindhu </td>
<td> Grade 12 </td>
</tr>
</table>
</body>
</html>

74
Attributes of Table Data elements

1. Align 2. Valign 3. Bgcolor

Program 5: Output

<html>
<title> Creating Tables </title>
<body>
<table border=2 cellspacing=10 bgcolor=" pink"
align="left">
<caption> Name List </caption>
<tr border=5 align="right" bgcolor="blue">
<th> S.No </th>
<th> Name of a student </th>
<th> Class </th>
</tr>
<tr>
<td align="center" valign=""
bgcolor="yellow"> 1 </td>
<td> Md. Shariff </td>
<td> Grade 12 </td>
</tr>
<tr>
<td> 2 </td>
<td> Rebecca Abraham </td>
<td> Grade 12 </td>
</tr>
<tr>
<td> 3 </td>
<td> Sindhu </td>
<td> Grade 12 </td>
</tr>
</table>
</body>
</html>

Adding image in a table

Program 6:
<html> Output
<title> Creating Tables </title>
<body>
<table border=2 cellspacing=3 cellpadding=10 75
bgcolor=" pink" align =”left”>
<caption> Name List </caption>
<tr>
<th> S.No </th>
<th> My fav game </th>
</tr>
<tr>
<td> 1 </td>
<td> <img src="football.jpg" width=50
height=50></td>
</tr>
</table>
</body>
</html>

Create the following tables in HTML.

Student Details

Name Age Gender

Nishi 14 Female

Rajat 16 Male

76
Creating Forms

We can make a web page interactive by creating forms in it. A form allows the user to enter some data and send
this data to another web page.

Form element:

It is a container element which has both open_____________ and close tags________________.

Attributes of Form element

1. Name 2. Action 3. Method

Input Element:

It is an empty element specified by <input> tag.

It is used to provide input field in a form where the user can enter the data.

Input element is always used within the form element.

Attributes of Input element

1. Type 2. Name 3. Value

Type can be the following,

Text  text field Checkbox  Check box

Password  password field Submit  button

Radio  radio button Reset  Clearing the text fields

Select  Combo box Textarea  Text Area

1. Create an html document named welcome.html 2. Create an html document named form1.html

<html> <html>
<title> Welcome Page </title> <title> form </title>
<body> <body>
<h1> Welcome all </h1> <form name=form1 action="welcome.html"
</body> method="get">
</html> <input type = "submit" value="Welcome">
</form>
</body></html>

77
3. Create an html document named quote.html 4. Create an html document named form2.html

<html> <html>
<body> <title> sample form </title>
<h1> I never dreamed about success. I worked for it <body>
</h1> <form name="form2" Action="quote.html"
</body> method="get">
</html> <h1> Sample Form Page </h1>
<br>
Name:
<input type="text" Name="t1">
<br>
<br>
Email:
<input type="text" Name="t2">
<br> <br>
<input type="Submit" value="click me">
</form>
<body>
</html>

Output:

Form Using Text Field and Password Field

78
Form Using Radio Button

4. Create an html document named 5. Create an html document named radio.html


lion.html
<html>
<html>
<body>
<body>
<form name="form3" action="lion.html" method="get">
<img src="lion.jpg" height=100
width=250> <input type="radio" name="Animal" >Lion <br>

<img src="elephant.jpg" height=100 <input type="radio" name="animal" > Tiger<br>


width=250> <input type="radio" name="animal" > Elephant <br>
<img src="tiger.jpg" height=100 <input type="submit" name="Submit">
width=250>
</form>
</body>
</body>
</html>
</html>

Output:

79
Form Using Checkbox

6. Create an html document named 7. Create an html document named radio.html


radiosample.html
<html>
<html>
<body>
<body>
<form name="form3" action="lion.html" method="get">
<img src="lion.jpg" height=100
width=250> <input type="checkbox" name="Animal" >Lion <br>

<img src="elephant.jpg" height=100 <input type="checkbox" name="animal" > Tiger<br>


width=250> <input type="checkbox" name="animal" > Elephant <br>
<img src="tiger.jpg" height=100 <input type="submit" name="Submit">
width=250>
</form>
</body>
</body>
</html>
</html>

Output:

80
Form Using Combo Box

8. Program using check box. Output:

<html>
</title> Combo Box </title>
<body>
<form name="form3" >
Select your state:
<br>
<select name="select" id="select">
<option> Tamil Nadu </option>
<option> Karnataka </option>
<option> Delhi </option>
</select>
</form>
</body>
</html>

Form Using Text area

9. Program using check box.

<html> Output:
<html>
</title> Combo Box </title>
<body>
<form name="form3" >
Select your state: <br>
<select name="select" id="select">
<option> Tamil Nadu </option>
<option> Karnataka </option>
<option> Delhi </option>
</select> <br> <br>
Any Comments: <br>
<textarea rows="4" cols="50">
</textarea>
</form>
</body> </html>

81
Write html coding to get the following output. Write html coding to get the following output.

<html>
<title> Form </title>
<body>
<form name="form4">
First Name:
<input type="text"><br>
Last Name:
<input type="text">
<br>
Email:
<input type="text">
<br>
<input type="radio" name="r1"> Male <br>
<input type="radio" name="r1"> Female <br>
<input type="submit" Value="Send">
<input type="reset" value="Reset">
</form>
</body> </html>

82
Chapter – 8: MySQL
1. To create database.
Syntax: create database database_name;
mysql> create database ip;

2. To use the created database.


Syntax: use database_name;
mysql> use ip;

3. To create a table.
Syntax: create table table_name ( column_name1 data_type1, column_name2 data_type2,….,
column_nameN data_typeN);
mysql> create table class (Admission_num integer, Name varchar(20), Grade varchar(20));

4. Adding rows to the table.


Syntax: insert into table_name values (value1, value2, …., valueN);
mysql> insert into class values (501, “Arun”, “Grade1”);
mysql> insert into class values (502, “Sneha”, “Grade1”);
mysql> insert into class values (503, “Harish”, “Grade2”);
mysql> insert into class values (504, “Srinika”, “Grade3”);
mysql> insert into class values (505, “Varun”, “Grade4”);
mysql> insert into class values (506, “Haritha”, “Grade5”);
mysql> insert into class values (507, “Krish”, “Grade5”);

5. To view the contents of the table.


Syntax: select * from Table_name;
mysql> select * from class;

6. Retrieving single column.


Syntax: select column_name from table_name;
mysql> select Admission_num from class;

Retrieving multiple column.


83
Syntax: select column_name1, column_name2 from table_name;
mysql> select Admission_num, Name from class;

7. Changing the order of display columns.


mysql> select Name, Admission_num, from class;

Task 1:
• Create a table named Grade11.
• Column names and the data types are follows,
o Roll_no of integer data type.
o Name of varchar data type and its size is 15.
o Father_Name of varchar data type and its size of 20.
o Mother_Name of varchar data type and its size of 20.
• Add minimum 5 rows to the table.
• View the contents of the table.
• View any two columns of the table.

8. Mr. Ravi wants to see the names of all the tables in the database. It is done by using the following query.

Syntax: show tables;

mysql> show tables;

9. Ms. Anne created three databases. And now she wants to know the name of the database in which she is
working.

Syntax: select database( );

mysql> select database( );

10. Viewing structure of table:

 The describe statement is used to see the structure of a table.

 It displays the column names and their data types.

Syntax: describe table_name; or desc table_name;

mysql> describe class;


84
mysql> desc class;

11. Doing changes in the columns.

Using alter statement, we can also do the following changes in the columns,

a. Adding a column b. Removing a column c. Modify a column

a. Adding a column:

Syntax: alter table table_name add column_name data_type;

mysql> alter table class add school varchar(20);

mysql> select * from class;

b. Deleting a column:

Syntax: alter table table_name drop column_name;

mysql> alter table class drop school;

mysql> select * from class;

c. Modifying column names:

Syntax: alter table table_name modify column_name;

mysql> alter table class modify GRADE varchar(10);

mysql> select * from class;

Task 2:
• To the created table add a new column named Address of varchar(20) data type.
• View the table.
• Delete the newly added column.
• View the table.
• Modify the column name “Roll_no” as “Roll_No”.

12. Eliminating duplicate values.

mysql> select Grade from class;

Syntax: select distinct column_name from table_name;

mysql> select distinct Grade from class;

85
Task 3:
• Create a table named Intelli_Systems.

Emp_No Emp_Name Designation Salary Branch Gender

1001 Kumar Manager 23000 T.Nagar M

1002 Rajesh Sales Man 15000 Porur M

1003 Suresh Manager 50000 Ashok Pillar M

1004 Kavitha Clerk 9000 Porur F

1005 Sridhar Director 56000 T.Nagar M

1006 Saritha Clerk 9500 Ashok Pillar F

1007 Kaviya Clerk 12000 Porur F

1008 Vignesh Director 63000 Ashok Pillar M

1009 Anandhi Manager 24000 T.Nagar F

1010 Seetha Sales Girl 20000 Ashok Pillar F

13. Using arithmetic operators with select statement.

mysql> select salary+500 from Intelli_Systems;

mysql> select salary*2 from Intelli_Systems;

mysql> select salary/2+1000 from Intelli_Systems;

mysql> select * from Intelli_Systems;

14. Using Relational Operators.

Retrieving specific rows using WHERE clause.

Syntax: select column_name from table_name where condition;

mysql> select Emp_Name, Salary from Intelli_Systems where Salary > 50000;
mysql> select Emp_Name, Salary from Intelli_Systems where Salary >= 50000;
mysql> select Emp_Name, Salary from Intelli_Systems where Salary < 20000;
mysql> select Emp_Name, Salary from Intelli_Systems where Salary <= 20000;
86
mysql> select Emp_Name, Salary from Intelli_Systems where Salary = 20000;
mysql> select Emp_Name, Salary from Intelli_Systems where Salary != 20000;

Task 4:

 Retrieve names and designation of employees who works in T.Nagar branch.

__________________________________________________________________________________

 Retrieve names and designation of female employees.

__________________________________________________________________________________

 Retrieve names and salary of male employees.

__________________________________________________________________________________

 Display Emp_No and designation of employees whose salary is greater than 25000.

__________________________________________________________________________________

 Display Names of employees whose Emp_No is not equal to 1008.

_________________________________________________________________________________________

 Display Emp_No and designation of employees whose salary is lesser than 25000.

_________________________________________________________________________________________

15. Using Logical Operators.

mysql> select Emp_Name, Salary from Intelli_Systems where Salary>10000 and Salary<50000;

mysql> select Emp_Name, Salary from Intelli_Systems where Salary>10000 && Salary<50000;

mysql> select Emp_Name, Branch from Intelli_Systems where Branch=”T.Nagar” || Branch=”Ashok Pillar”;

mysql> select Emp_Name, Branch from Intelli_Systems where Branch=”T.Nagar” or Branch=”Ashok


Pillar”;

16. Column Alias.

Syntax: select column_name as “column_alias” from Table_name;

mysql> select * from Intelli_Systems;


mysql> select Emp_Name as “Employee_Name” from Intelli_Systems;
mysql> select * from Intelli_Systems;
87
17. Condition based on range.

mysql> select Emp_Name, Salary from Intelli_Systems where Salary between 10000 and 50000;

mysql> select Emp_Name, Salary from Intelli_Systems where Salary not between 10000 and 50000;

18. Condition based on list.

mysql> select Emp_Name, Salary from Intelli_Systems where Salary in (20000,56000,9000);

mysql> select Emp_Name, Salary from Intelli_Systems where Salary not in (20000,56000,9000);

19. Condition based on pattern matches.

mysql> select Emp_Name, Salary from Intelli_Systems where Emp_Name like ‘K%’;

mysql> select Emp_Name, Salary from Intelli_Systems where Emp_Name like ‘%sh’;

mysql> select Emp_Name, Salary from Intelli_Systems where Emp_Name like ‘S%a’;

mysql> select Emp_Name, Salary from Intelli_Systems where Emp_Name like ‘%and%’;

mysql> select Emp_Name, Salary from Intelli_Systems where Emp_Name not like ‘K%’;

mysql> select Emp_Name, Salary from Intelli_Systems where Emp_Name not like ‘%sh’;

mysql> select Emp_Name, Salary from Intelli_Systems where Emp_Name not like ‘S%a’;

mysql> select Emp_Name, Salary from Intelli_Systems where Emp_Name not like ‘%and%’;

Task 5:

• Display names of employees whose salary lies on the following list 9500, 50000 and 20000.

• Display Emp_No of employees whose name starts with a letter ‘S’.

• Display Emp_No of employees whose name ends with a letter ‘h’.

• Display Emp_No of employees whose name not ends with a letter ‘a’.

• Display names of employees whose salary lies within the range of 15000 and 25000.

88
20. Sorting the results – Order by.

mysql> select Emp_No, Emp_Name from Intelli_Systems order by Emp_Name;

mysql> select Emp_No, Emp_Name from Intelli_Systems order by Emp_Name desc;

21. Update Statement.  To do changes in the rows.

Syntax: update table_name set column_name=value where condition;

mysql> select * from Intelli_Systems;

mysql> update Intelli_Systems set Emp_Name=”Sashidhar” where Emp_Name=”Sridhar”;

mysql> update Intelli_Systems set Designation=Manager” where Emp_Name=”Sashidhar”;

Task 6:

Change Emp_No of Kaviya to 2007.

Change Designation of Seetha to Manager.

Change Seetha’s Salary to 35000.

22. Delete statement.

Syntax: delete from table_name where condition;

mysql> delete from Intelli_Systems where Emp_No=2007;

mysql> Select * from Intelli_Systems;

Task 7:

• Delete Kumar’s details from the table.

________________________________________________________________________

• Delete Kaviya’s details from the table.

________________________________________________________________________

89
Important Questions

1. What is DBMS?
A Database Management System (DBMS) is a program that controls creation, maintenance and use
of a database. DBMS can be termed as File Manager that manages data in a database rather than saving it in
file systems.

2. What is RDBMS?
RDBMS stands for Relational Database Management System. RDBMS store the data into the
collection of tables, which is related by common fields between the columns of the table. It also provides
relational operators to manipulate the data stored into the tables.
Example: SQL Server.

3. What is SQL?
SQL stands for Structured Query Language , and it is used to communicate with the Database. This is
a standard language used to perform tasks such as retrieval, updation, insertion and deletion of data from a
database.
Standard SQL Commands are Select, Alter, Update,…

4. What is a Database?
Database is nothing but an organized form of data for easy access, storing, retrieval and managing of
data. This is also known as structured form of data which can be accessed in many ways.
Example: School Management Database, Bank Management Database.

5. What are tables and Fields?


A table is a set of data that are organized in a model with Columns and Rows. Columns can be
categorized as vertical, and Rows are horizontal. A table has specified number of column called fields but
can have any number of rows which is called record.
Example:.
Table: Employee.
Field: Emp ID, Emp Name, Date of Birth.
Data: 201456, David, 11/15/1960.

6. What is a primary key?


A primary key is a combination of fields which uniquely specify a row. This is a special kind of
unique key, and it has implicit NOT NULL constraint.90It means, Primary key values cannot be NULL.
7. What is a unique key?
A Unique key constraint uniquely identified each record in the database. This provides uniqueness for
the column or set of columns.
A Primary key constraint has automatic unique constraint defined on it. But not, in the case of Unique
Key.
There can be many unique constraint defined per table, but only one Primary key constraint defined
per table.

8. What is a foreign key?


A foreign key is one table which can be related to the primary key of another table. Relationship
needs to be created between two tables by referencing foreign key with the primary key of another table.

9. What is a join?
This is a keyword used to query data from more tables based on the relationship between the fields of
the tables. Keys play a major role when JOINs are used.

10. What is a query?


A DB query is a code written in order to get the information back from the database. Query can be
designed in such a way that it matched with our expectation of the result set. Simply, a question to the
Database.

11. What is subquery?


A subquery is a query within another query. The outer query is called as main query, and inner query
is called subquery. SubQuery is always executed first, and the result of subquery is passed on to the main
query.

12. What are the types of subquery?


There are two types of subquery – Correlated and Non-Correlated.
• A correlated subquery cannot be considered as independent query, but it can refer the column in a
table listed in the FROM the list of the main query.
• A Non-Correlated sub query can be considered as independent query and the output of subquery are
substituted in the main query.

91
Functions in MySQL

Functions

Single row functions Multiple row


functions

Single Row Functions:

o Single row functions operate on a single value to return a single value.

o Single row functions are categorized into,

Numeric Functions

String (Character) Functions

Date and Time Functions

Numeric Functions:

MySQL numeric functions perform operations on numeric values and return numeric values.

o Power Function

o Round Function

o Truncate Function

 Power Function

Syntax: POWER(X, Y) or POW(X, Y)

mysql> select pow(2,4); ______________________________

mysql> select power(3,2); ______________________________

mysql> select power(salary,2) from Intelli_Systems;

mysql> select pow(salary,3) from Intelli_Systems;

 Round Function

Syntax: ROUND(X, D) or ROUND(X)

mysql> select round(5.64); ______________________________

mysql> select round(5.64,1); ______________________________


92
mysql> select round(5.64,0); ______________________________

mysql> select round(salary) from Intelli_Systems;

 Truncate Function

Syntax: TRUNCATE(X, D)

mysql> select truncate(12.3 , 1); _____________________________

mysql> select truncate(236.56 , 3); _____________________________

mysql> select truncate(248.56 , 0); _____________________________

mysql> select truncate(salary,0) from Intelli_Systems;

String Functions:

MySQL numeric functions perform operations on string values and returns either string or integer values.

1. Length 7. Right
2. Concatenation 8. Left trim
3. Instring 9. Right trim
4. Lower Case 10. Trim
5. Upper Case 11. Substring
6. Left 12. ASCII

 Length Function:
o Used to find the number of characters in the string.

Syntax: LENGTH(string);

Mysql> select length(“Vaishnavi”); ____________________________

Mysql> select length(“Smart”); ____________________________

Mysql> select length(“Stay Strong”); ____________________________

Mysql> select length(Emp_Name) from Intelli_Systems;

Mysql> select length(Designation) from Intelli_Systems;

 Concatenation (Concat) Function:

o Used to join two or more strings.

Syntax: CONCAT(string1, string2); 93


Mysql> select concat(“Vaishnavi”, ”Gunasekaran”); ____________________________

Mysql> select concat(“Infromatics”, “Practices”); ____________________________

Mysql> select concat(Emp_Name,Designation) from Intelli_Systems;

 Instring Function:

o It returns the position of the first occurrence of substring in string.

Syntax: INSTR(string, substring);

Substring part of the string

Mysql> select instr(“Smart”, “art”); ____________________________

Mysql> select instr(“Smart”, “pet”); ____________________________

Mysql> select instr(“Smart”, “S”); ____________________________

Mysql> select instr(Emp_Name, “s”) from Intelli_Systems;

Mysql> select instr(Designation, “M”) from Intelli_Systems;

 Lower Case Function:

o Changes the string to lower case.

Syntax: LOWER(string); or LCASE(string);

Mysql> select lower(“Be ThE ChAnGe”); ____________________________

Mysql> select lower(“Take ChaNces”); ____________________________

Mysql> select lcase(“Work Hard”); ____________________________

Mysql> select lower(Emp_Name) from Intelli_Systems;

Mysql> select lcase(Designation) from Intelli_Systems;

 Upper Case Function:

o Changes the string to upper case.

Syntax: UPPER(string); or UCASE(string);

Mysql> select upper(“Be ThE ChAnGe”); ____________________________


94
Mysql> select upper(“Take ChaNces”); ____________________________

Mysql> select ucase(“Work Hard”); ____________________________

Mysql> select upper(Emp_Name) from Intelli_Systems;

Mysql> select ucase(Designation) from Intelli_Systems;

 Left Function:

o It returns the specified number of characters from the left side of the string.

Syntax: LEFT(string,n);

n integer

Mysql> select left(“Be ThE ChAnGe”,2); ____________________________

Mysql> select left(“Take ChaNces”, 6); ____________________________

Mysql> select left(“Work Hard”, 7); ____________________________

Mysql> select left(Emp_Name,3) from Intelli_Systems;

Mysql> select left(Designation,3) from Intelli_Systems;

 Right Function:

o It returns the specified number of characters from the right side of the string.

Syntax: RIGHT(string,n);

n integer

Mysql> select right(“Be ThE ChAnGe”,6); ____________________________

Mysql> select right(“Take ChaNces”, 2); ____________________________

Mysql> select right(“Work Hard”, 4); ____________________________

Mysql> select right(Emp_Name,3) from Intelli_Systems;

Mysql> select right(Designation,3) from Intelli_Systems;

 Left Trim Function:

o Removes spaces from the left side of the string.

Syntax: LTRIM(string);
95
Mysql> select ltrim(“ Hai”); ____________________________

Mysql> select ltrim“ Hello”); ____________________________

Mysql> select ltrim(“ Hello World”); ____________________________

Mysql> select ltrim(“ Happy Friends”); ____________________________

 Right Trim Function:

o Removes spaces from the right side of the string.

Syntax: RTRIM(string);

Mysql> select rtrim(“Hai ”); ____________________________

Mysql> select rtrim(“Hello ”); ____________________________

Mysql> select rtrim(“Hello World”); ____________________________

Mysql> select rtrim(“Happy Friends ”); ____________________________

Mysql> select rtrim(“Happy ”); ____________________________

 Trim Function:

o Removes spaces from the both sides of the string.

Syntax: TRIM(string);

Mysql> select trim(“ Hai ”); ____________________________

Mysql> select trim(“ Hello ”); ____________________________

Mysql> select trim(“ Hello World ”); ____________________________

Mysql> select trim(“ Happy Friends ”); ____________________________

 Substring Function:

o Returns the specified number of characters from the middle of the string.

Syntax: SUBSTRING(string,m,n); or MID(string,m,n);

mposition of character

n number of characters to be displayed

Mysql> select substring(“Heart”,3); ____________________________

Mysql> select substring(“Heart”,2,3); 96


____________________________
Mysql> select substring(“All is well”,1,3); ____________________________

Mysql> select substring(“All is well”,8); ____________________________

Mysql> select Emp_Name from Intelli_Systems;

Mysql> select substring(Emp_Name,3) from Intelli_Systems;

Mysql> select substring(Emp_Name,3,2) from Intelli_Systems;

 ASCII Function:

o Returns the ascii value.

Syntax: ASCII(character); or ASCII(n); or ASCII(string);

Mysql> select ascii(“A”); ____________________________

Mysql> select ascii(“2”); ____________________________

Mysql> select ascii(“a”); ____________________________

Mysql> select ascii(“Apple”); ____________________________

Mysql> select ascii(“apple”); ____________________________

Date and Time Functions

It allows us to perform many types of tasks on data type data. The default date format in MySQL is yyyy-
mm-dd.

1. Current date 6. Year

2. Now 7. Day name

3. System Date 8. Day of month

4. Date 9. Day of week

5. Month 10. Day of year

 Current date Function:

Syntax: CURDATE( );

Mysql> select curdate( ); _______________________________

97
 Now Function:

Syntax: NOW( );

Mysql> select now( ); _______________________________

 System date function:

Syntax: SYSDATE( );

Mysql> select sysdate( ); _______________________________

 Date function:

Syntax: DATE( expr );

Mysql> select date(‘2016-05-20 01:02:03’ ); _______________________________

 Month function:

Syntax: MONTH(date);

Mysql> select month(‘2016-05-20’ ); _______________________________

 Year function:

Syntax: YEAR(date);

Mysql> select year(‘2016-05-20’ ); _______________________________

 Day name function:

Syntax: DAYNAME(date);

Mysql> select dayname(‘2016-05-20’ ); _______________________________

Mysql> select dayname(‘2016-06-20’ ); _______________________________

 Day of month function:

Syntax: DAYOFMONTH(date);

Mysql> select dayofmonth(‘2016-05-20’ ); _______________________________

98
 Day of week function:

Syntax: DAYOFWEEK(date);

Mysql> select dayofweek(‘2016-05-20’ ); _______________________________

 Day of year function:

Syntax: DAYOFYEAR(date);

Mysql> select dayofyear(‘2016-05-20’ ); _______________________________

Multiple Row Functions (or Aggregate Functions):

o Multiple row functions operate on a set of rows to return a single value.

o Examples: SUM( ), AVG( ), MAX( ), MIN( ) and COUNT( ).

99
Single Row Functions

Single row functions are categorized into three,


a) Numeric Functions
b) Character (String) Functions
c) Date and time functions

a) Numeric functions operate on numeric data types and returns numeric values as output. They are
categorized into three,

S.No Functions Syntax


1 Power Function pow(x,y)
2 Round Function round(x)
round(x,d)
round(x,-d)
3 Truncate Function truncate(x,d)
truncate(x,-d)
1. Power Function:

2. Round Function:

3. Truncate Function:
b) String (Character) Functions:

Character functions operate on string inputs and returns integer or string outputs.

NOTE: the following are the three string functions which returns integer values,

Length function In string function ASCII function

Numeric functions are categorized into the following,

S.No Functions Syntax


1 Length Function Length(string)

2 Concat Function Concat(string1, string2)

3 In string Function Instr(string1,string2)

4 Upper Function Upper(string)

Ucase(string)
5 Lower Function Lower(string)

Lcase(string)
6 Left Function Left(string,n)

7 Right Function Right(string,n)

8 Trim Function trim(string)

9 Left Trim Function Ltrim(string)

10 Right Trim Function Rtrim(string)

11 ASCII Function Ascii(‘n’)

Ascii(‘char’)
12 Substring Function Substring(string,m,n)

Mid(string,m,n)

1. Length Function:

2. Concat Function:
3. In String Function: (occurrence of second string in first string)

4. Upper Function:

5. Lower Function:

6. Left Function: 7. Right Function:

8. Trim Function:

9. Left Trim Function:

10. Right Trim Function:

11. Ascii Function:


12. Substring Function:

b) Date and Time Functions:


S.NO Functions Example

1 Curdate( )

2 Now( )

3 Sysdate( )

4 Date(expression)

5 Month(date)

6 Year(date)

7 Dayname(date)

8 Dayofmonth(date)

9 Dayofweek(date)

10 Dayofyear(date)
Chapter - 8

Work Sheet

1. A table STUDENT has 5 rows and 3 columns. Table ACTIVITY has 4 rows and 2 columns. What will be the
cardinality and degree of the Cartesian product of them?
Ans: _____________________________________________________________________________________

2. Name the SQL commands used to :


(i) Physically delete a table from the database. __________________________________________

(ii) Display the structure of a table. __________________________________________

3. Write one similarity and one difference between UNIQUE and PRIMARY KEY constraints.
Ans: _____________________________________________________________________________________

4. Write one similarity and one difference between CHAR and VARCHAR data types.
Ans: _____________________________________________________________________________________

5. Write the UPDATE command to increase the commission (Column name: COMM) by 500 of all the
Salesmen who have achieved Sales (Column name : SALES) more than 200000. The table’s name is
COMPANY.
Ans: _____________________________________________________________________________________

6. While using SQL pattern matching, what is the difference between ‘_’ (underscore) and ‘%’ wildcard
symbols?
Ans: _____________________________________________________________________________________

7. Saumya had previously created a table named ‘Product’ in a database using MySQL. Later on she forgot the
table structure. Suggest her suitable MySQL command through which she can check the structure of the already
created table.
Ans: _____________________________________________________________________________________

8. Amit works as a database administrator in a Multinational bank. He wants to undo the changes made in the
current transaction. Suggest to him a suitable MySQL command for the same.
Ans: _____________________________________________________________________________________

100
9. (a)Observe the table ‘Club’ given below:
Member_id Member_Name Address Age Fees
M001 Sumit New Delhi 20 1000
M002 Nisha Gurgaon 19 1500
M003 Niharika New Delhi 21 2100
M004 Sachin Faridabad 18 1500

i.What is the cardinality and degree of the above given table?


ii. If a new column contact_no has been added and two more members have joined the club then
how these changes will affect the degree and cardinality of the above given table.

(b)Write the output of the following SQL queries:


i. SELECT INSTR(‘INTERNATIONAL’, ‘NA’);
ii. SELECT LENGTH(CONCAT(‘NETWORK’,’ING’));
iii.SELECT ROUND(563.345,-2);
iv. SELECT DAYOFYEAR(‘2014-01-30’);

10. Write SQL query to create a table ‘Bank_Customer’ with the following structure:

11. In a Bank’s database, there are two tables ‘Customer_info’ and‘Transaction__Detail’ as shown below.

i. Is it possible to have primary key and foreign key in one table? Justify your answer.
__________________________________________________________________________________________
ii. A table can have maximum how many primary keys and foreign keys?
101
__________________________________________________________________________________________
12. Write two examples of DBMS software.
__________________________________________________________________________________________
13. What is meant by NULL value in MySQL?
__________________________________________________________________________________________
14. How is NULL value different from 0 (zero) value ?
__________________________________________________________________________________________
15. Write two examples of DML commands of SQL.
__________________________________________________________________________________________

16.

102
Chapter-9:
Functions

Single row functions Multiple row


functions

Topic 1:

Multiple Row Functions (Aggregate Functions, Group Functions):

• A multiple row functions works on multiple values.


• Multiple row functions are as follows,
o MAX ( ) o SUM( )

o MIN ( ) o COUNT ( )

o AVG( )

1. Create the following three tables,

103
2. Populate the tables as follows,

104
MAX():

 This function is used to find the highest value of any column.

3. mysql> select max(cost) from shoes;

mysql> select max(cost) from shoes where type=’School’;

mysql> select max(cost+cost*margin/100) from shoes;

mysql> select round (max(cost+cost*margin/100),2) from shoes;

mysql> select round (max(cost+cost*margin/100),3) from shoes where type=”Tracker”;

mysql> select max(order_qty) from orders;

MIN():

 This function is used to find the lowest value of any column.

4. mysql> select min(cost) from shoes;

mysql> select min(cost) from shoes where type=’School’;

mysql> select min(cost+cost*margin/100) from shoes;

mysql> select round (min(cost+cost*margin/100),2) from shoes;

mysql> select round (min(cost+cost*margin/100),3) from shoes where type=”Tracker”;

mysql> select min(order_qty) from orders;

AVG():

 This function is used to find the average value of any column.

5. mysql> select avg(cost) from shoes;

mysql> select round(avg(cost),3) from shoes;

mysql> select avg(order_qty),3) from orders;

mysql> select avg(cost) from shoes where type=’School’;

mysql> select avg(cost) from shoes where type=’Office’;

mysql> select avg(order_qty) from orders where Shoe_Code=1011;

105
SUM():

 This function is used to find the total value of any column.

6. mysql> select sum(cost) from shoes;

mysql> select round(sum(cost),3) from shoes;

mysql> select sum(order_qty),3) from orders;

mysql> select sum(cost) from shoes where type=’Sports’;

mysql> select sum(cost) from shoes where type=’Office’;

mysql> select sum(order_qty) from orders where Shoe_Code=1011;

COUNT():

 This function is used to count the number of values in a column.

7. mysql> select count(*) from shoes;

mysql> select count(*) from customers;

mysql> select count(*) from orders;

mysql> select count(*) from customers where category= ‘A’;

mysql> select count(*) from orders where order_qty > 300;

Aggregate Functions and NULL values:

o Aggregate function will not take NULL into consideration.

o NULL is simply ignored by all the aggregate functions.

8. mysql> select count(*) from shoes;

mysql> select count(margin) from shoes;

mysql> select count(qty) from shoes;

mysql> select avg(qty) from shoes;

mysql> select max(qty) from shoes;

mysql> select min(qty) from shoes;

106
Creating Tables with constraints

Question: Write the query to create table using the structure given below.

1. Table Name: ip

Field Type Null Key Default Extra


Name Varchar(20) YES NULL
Mobile Int(11) YES NULL
Email Varchar(20) YES NULL

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

2. Table Name: ip1

Field Type Null Key Default Extra


Name Varchar(20) NO
Mobile Int(11) YES NULL
Email Varchar(20) YES NULL

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

107
3. Table Name: ip2

Field Type Null Key Default Extra


Name Varchar(20) NO
Mobile Int(11) NO PRI NULL
Email Varchar(20) YES NULL

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

4. Table Name: ip3

Field Type Null Key Default Extra


Name Varchar(20) YES UNI NULL
Mobile Int(11) YES NULL
Email Varchar(20) YES NULL

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

Write down the constraints used above,


1.

2.

3.

108
5. Table Name: student

Field Type Null Key Default Extra


Roll No Int(2) NO PRI
Class Varchar(10) YES NULL
Admsn_no Int(5) NO PRI 0

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

6. Table Name: Emp

Field Type Null Key Default Extra


Emp_id Int(2) NO
Emp_name Varchar(10) NO PRI NULL
Emp_code Int(5) NO PRI 0

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

ALTER TABLE

Alter table command is use to,

1. to add a constraint

2. to remove a constraint

3. to remove a column from the table

4. to modify a table column


109
To add a constraint:

Table Name ip

Field Type Null Key Default Extra


Name Varchar(20) YES NULL
Mobile Int(11) YES NULL
Email Varchar(20) YES NULL

Place Varchat(25) NO

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

To remove a constraint:

Table Name ip

Field Type Null Key Default Extra


Name Varchar(20) YES NULL
Mobile Int(11) YES NULL
Email Varchar(20) YES NULL

Place Varchat(25) NO

___________________________________________________________________________________________

___________________________________________________________________________________________

___________________________________________________________________________________________

110
To modify a table column:

Table Name: student

a.
Field Type Null Key Default Extra
Roll No Int(2) NO PRI
Class Varchar(10) NO NULL
Admsn_no Int(5) NO PRI 0

b. Table Name: student

Field Type Null Key Default Extra


Roll No Int(2) NO
Class Varchar(10) NO NULL
Admsn_no Int(5) NO PRI 0

c. Table Name: ip3

Field Type Null Key Default Extra


Name Varchar(20) NO PRI
Mobile Int(11) NO PRI 0
Email Varchar(20) YES NULL

To remove a table column:

Mysql> alter table ip3 drop Email;

Mysql> alter table ip2 drop Email, drop Name;

111
DROP TABLE

Mysql> drop table_name;

Mysql> drop ip3;

Mysql> drop ip;

GROUP BY and HAVING

GROUP BY Clause:

In practical applications many times there arises a need to get reports based on some groups of data. SQL
provides GROUP BY Clause to handle all such requirements.

Syntax:

SELECT column_name, aggregate_function(column_name)


FROM table_name
GROUP BY column_name;

1.

2. Display the types of shoes from shoe table.

112
3. Display number of rows in each type of shoes.

4. Display type and sum of qty for all the types of shoes.

5. Display type ,
min of margin,
max of margin,
avg of margin,
sum of qty for all the types of shoes.

6.

113
7. Display different categories from the table customers.

8. Display number of rows of each category from customers table.

9.

10. Display number of rows from orders for each Cust_Code.

Using where clause in GROUP BY clause:

Syntax:

SELECT column_name, aggregate_function(column_name)


FROM table_name
WHERE column_name operator value
GROUP BY column_name;

114
11. For each type, display type and size from the table shoes whose size is equal to 6.

12. Display code,name,type,size from shoes whose cost is greater than or equal to 200. Group by size.

HAVING Clause:

Sometimes we do not want to see the whole output produced by a statement with GROUP BY Clause. We want to
see the output only for those groups which satisfy some condition. This can be done using HAVING clause.

Syntax:

SELECT column_name, aggregate_function(column_name)


FROM table_name
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;

13.

14.

115
15.

16.

Using where clause in HAVING clause:

Syntax:

SELECT column_name, aggregate_function(column_name)


FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;

17.

18.

116
Displaying data from multiple tables
Displaying data from multiple tables:

Data can be displayed from multiple tables using the following two concepts,

1. Cartesian Product (Cross Join)

2. Equi-Join

Cartesian Product:

 Cartesian product of two tables is a table obtained by pairing up each row of one table with each row of other
table.
 If two tables contain 3 rows and 2 rows respectively, then their Cartesian product will contain 6 rows (3*2=6).

Example:

Notice that the


arrows indicate the
“Ordered Pairing”.

Create the following three tables and populate it.

117
1. Mysql> select * from order_table, product;

2. Mysql> select * from product, order_table;

Question No: 1
How many rows will be displayed when the following query is executed,
select * from product, order_table,suppliers; ?

Ans: _______________________________

118
3. Display Sup_code column from the tables Supplier and Order_Table.

Question No: 2

Write a query to display name column from both the tables’ product and Supplier.

Ans:
_________________________________________________________________________________________

Draw the output of the query.

Equi Join  Refer text book Pg.No: 289


119
Chapter-11: IT Applications

An IT application has two major parts: Front-end (the user interface) and back-end (the database).

Front-end:
o The front-end of an IT application is usually a group of one or more forms through which the
user enters the input values.
o A good front-end ensures the acceptance of the application in the first go.

Back-end:
o The back-end of an IT application is the database in which all the data is stored. This database
resides in the server. All the data which is requested by the front-end is supplied by back-end.
o A good back-end ensures sustainability, efficiency and easy modification of the application.

E-GOVERNANCE
It refers to application of electronic means in governance with an aim of fulfilling the requirements of common
man at affordable costs and in fastest possible time.

Social impacts of E-Governance:


 Improved the efficiency of administration and service delivery
 Reduced waiting time
 Reduced Cost
 Increased public participation
 Increased transparency

Some E-Governance websites are:


Name of Website Purpose

Advantages of E-Governance
1. Speed – Technology makes communication speedier. Internet, Phones, Cell Phones have reduced the time
taken in normal communication.

120
2. Cost Reduction – Most of the Government expenditure is appropriated towards the cost of stationary. Paper-
based communication needs lots of stationary, printers, computers, etc. which calls for continuous heavy
expenditure. Internet and Phones makes communication cheaper saving valuable money for the Government.

3. Transparency – Use of ICT makes governing profess transparent. All the information of the Government
would be made available on the internet. The citizens can see the information whenever they want to see. But
this is only possible when every piece of information of the Government is uploaded on the internet and is
available for the public to peruse. Current governing process leaves many ways to conceal the information from
all the people. ICT helps make the information available online eliminating all the possibilities of concealing of
information.

4. Accountability – Once the governing process is made transparent the Government is automatically made
accountable. Accountability is answerability of the Government to the people. It is the answerability for the
deeds of the Government. An accountable Government is a responsible Government.

Challenges:

E-Governance: Major Challenges in India Poor people and poor infrastructure are major challenges in
countries like India. It poses a major challenge in reaping the full benefits of service provision under e-
governance. The various barriers can be enumerated as follows:

1. Poverty: Accessing Internet is a costly affair for the poor who struggle for their livelihood in developing
countries like India. Required infrastructure in the form of installing the necessary telephone lines needed for
internet or email access is equally unaffordable in most poor countries.

2. Technical illiteracy: There is general lack of technical literacy as well as literacy in countries like India.

3. Language Dominance: The dominance of English on the internet constrains the access of non-English
speaking population. In the case of India, 95 percent of the population does not speak English. Due to such
overwhelming dominance of English over these communication channels, computers and the internet are quite
useless in Indian villages.

4. Unawareness: There is general lack of awareness regarding benefits of E-Governance as well as the process
involved in implementing successful G-C, G-G and G-B projects.

5. Inequality: Inequality in gaining access to public sector services between various sections of citizens,
especially between urban and rural communities, between the educated and illiterate, and between the rich and
poor.

6. Infrastructure: Lack of necessary infrastructure like electricity, internet, technology and ways of
communications will affect the speed which delays the implementation.

121
E-BUSINESS

Electronic Business, also known as "e-Business" or "e-Business", is defined as the utilization of


information and communication technologies (ICT) in support of all the activities of business. It refers to any
form of transaction (exchange) that uses an electronic medium to facilitate the transaction.

Activities using e-Business tools include:

 Trading of goods or services online, such as e-Procurement, primarily through the web-sites;
 Electronic retailing (e-Tailing);
 Use of the internet, intranets or extranets to conduct research and manage business activities;
 Web-site marketing;
 Online communications, such as e-mail; and
 Online training for staff (e-Learning).

e-Business tools include:

 Mobile phones;
 Personal digital assistants (PDA);
 Electronic Data Interchange;
 File transfer;
 Facsimile;
 Video conferencing, internet, intranets and extranets.

Benefits:
The benefits of implementing e-Business tools is not so much in the use of technology, but in the streamlining
of business processes and the ease in finding new markets. Some of the advantages and disadvantages include:

 Quicker and easier communications.


 Strengthened marketing capabilities and reach.
 Increased hours of operation (a web-site provides 24-hour seven day information to existing and
potential customers).
 Access to broader information through research.
 Reducing the cost of doing business by lowering transaction costs and increasing efficient methods for
payment, such as using online banking and reducing stationery and postage costs.
 The opportunities to adopt new business models and develop tailored customer support.

Social impacts of E- Business:


 Reductions in transactions and other costs.
 Increase in the internet users.
 Un-shortened supply chain.
 Improved customer service.
 Increased productivity/efficiency.
 Access to international markets.

122
Some E-Business websites are:

Net Banking (Internet Banking)

One of the main reasons that people decide to begin using Internet banking over regular banking is in reference
to convenience. Everybody wants methods that are going to save them time and make daily tasks easier on
them, and that is exactly what Internet banking does.

Internet banking was introduced in the early 80s. Many people have started availing to its facilities. Now, one
does not have to wait in long queues at the bank nor to pay bills at some shopping center and None of us want to
stand in the queue for hours and hours also.
You can notify the bank of your change of address directly over the computer . Many other services that
you would typically have to pay for are free as well when you complete them online with Internet banking, and
this is primarily due to the fact that by completing Internet banking services you are saving the bank from
having to use bank tellers, or manpower, to do the work for you.
The best thing about Internet banking is that it is fast and is available to a person in any part of the world, at
anytime he or she needs it.

What can be done by online banking:

1. Money transfer from one account to another account of same bank.


2. Money transfer from one account of a bank to another account of other bank. This is also known
as NEFT OR RTGS.
3. Rail ticket booking on www.irctc.co.in
4. Equity (Share), mutual fund, and IPO purchasing.
5. Hotel booking.
6. Online PPF deposit electronically if the PPF account is in the same branch.
7. Fixed Deposit , Recurring deposit, Term Deposit, Demand Draft making can be controlled with your
finger tips round the clock.
8. Account statement checking round the clock.
9. Mobile recharging. Prepaid or Postpaid.
10. Insurance premium payment.
11. Status of the insurance can be viewed any time round the clock.
12. Electronic product like music , ebooks etc can be bought .
13. NSTSE (National Science Talent Search Examination ) form filling and its payment can be done in a
minute.
14. Job form filling and its payment if any.
15. Tax payment.
16. News paper advertising payment.
123
System needed for internet banking (My recommendation as per my experience):

1. A computer.
2. Internet connectivity.
3. Original Operating System.( e.g. XP PROFESIONAL ).
4. Original Antivirus, Not a free version.

Mobile Banking:

Mobile banking is a service provided by a bank or other financial institution that allows its customers to
conduct some financial transactions remotely using a mobile device such as a mobile phone or tablet.

After the success of online banking, mobile banking is the next revolutionary step which has attracted
huge customers from all over the country. With this service you can perform all the banking actions such as
money transfer, credit card payment, bill payment, account updates and other transactions. Further all the other
information related to your account can be accessed via your mobile phone within a span of few seconds.
However the nature of banking activities that can be done depends on the facilities provided by your bank. Read
on to know more about this banking service.

How to apply for Mobile Banking:


To get access to your account through mobile, you have to register for mobile banking you’re your
respective bank. The registration process entails furnishing your beneficiary mobile number following which
your bank provides a unique Mobile Personal Identification Number (MPIN) for your cell phone. In addition to
this, you will be given a seven digit Mobile Money Identity (MMID) number. With MPIN and MMID you can
use your mobile phone for all your bank actions.

Mode of Transfer
Once the above mentioned procedure is completed, mobile banking transaction can be made using
different modes of transfer. For instance, you can use the SMS service or download the mobile banking
application on your cell phone to start your banking activities. Although both of these modes are popular in
their own way, it is better to go with the one that your bank offers and your mobile phone supports too.

Safety Issues in Mobile Banking


For safe mobile transactions it is always better to use alphanumeric password and do inculcate the habit
of changing your password often. Further if you are doing large transactions, it is better to do it through the
bank directly, rather than using mobile banking.

Benefits of Mobile Banking Service


• With the technological growth, mobile banking is gaining popularity over internet banking. In case of
internet or online banking you need a computer and internet connection to access your account and this
becomes a problem during urgency or when you don’t have internet connection. However this is not a problem
with mobile banking as you will get network connection even in the remote areas.
• Personally going to bank for transferring money or for any other transaction takes more time and energy.
On the other hand, with the use of mobile banking you can get your work done within few minutes.
• With the implementation of new user friendly applications and software, mobile banking through your
cell phone has become simpler. As a result of this, more and more people are attracted towards it.
124
• Mobile banking keeps you updated with any activity done in your account. For instance a money
withdrawal, money transfer and other transactions to and from your account will be brought to your knowledge
via SMS.
• Information such as mini-statement of your account, Insurance and mutual fund statement, loan updates,
credit card statements etc. can be obtained on your mobile phone.
• Mobile banking is not only used for banking service but also serves as a way to sell the products of bank
such as credit cards, loans etc.
• If you are interested in stock market and other real time investment then this is the best option for you.
With this modern technology of banking you can keep yourself updated with portfolio management services,
real-time stock and other news on stock market.

125
E-LEARNING

It is a flexible term used to describe a means of teaching through technology such as a network, browser,
CDROM or DVD multimedia platform.

Social impacts of E- Learning:


 Availability of same course to millions.
 Boon for working class.
 Apprehensive Employers.
 Cultural differences obstruct the true aim of e- learning.
 High Dropout rate.

Advantages of e-Learning to the teachers:


Some of the most outstanding advantages to the trainer or organization are:
• Reduced overall cost is the single most influential factor in adopting e-learning. The elimination of costs
associated with instructor's salaries, meeting room rentals, and student travel, lodging, and meals are
directly quantifiable. The reduction of time spent away from the job by employees may be the most
positive offshoot.
• Learning times reduced, an average of 40 to 60 percent.
• Increased retention and application to the job averages an increase of 25 percent over traditional
methods.
• Consistent delivery of content is possible with asynchronous, self-paced e-learning.
• Expert knowledge is communicated, but more importantly captured, with good e-learning and
knowledge management systems.
• Proof of completion and certification, essential elements of training initiatives, can be automated.

Advantages to the students


Along with the increased retention, reduced learning time, and other aforementioned benefits to students,
particular advantages of e-learning include:

• On-demand availability enables students to complete training conveniently at off-hours or from home.
• Self-pacing for slow or quick learners reduces stress and increases satisfaction.
• Interactivity engages users, pushing them rather than pulling them through training.
• Confidence that refresher or quick reference materials are available reduces burden of responsibility of
mastery.

Some E-learning websites are:

126
127

You might also like