Vous êtes sur la page 1sur 1475

E-LEARNING MODULES NOTES

1

Contents
Contents ...................................................................................................................................................... 0
HTML ............................................................................................................................................................ 9
Introduction to HTML ................................................................................................................................. 9
HTML Structures and Elements ............................................................................................................. 15
Creating a Web Page .............................................................................................................................. 29
Hyperlinks, Tables, and Forms .............................................................................................................. 35
Image Maps and Style Sheets ............................................................................................................... 54
Enhancing Web Pages ............................................................................................................................ 64
Client-side and Server-side Scripts ....................................................................................................... 74
Advanced Markup Languages ............................................................................................................... 81
Managing and Connecting to Databases ............................................................................................. 89
Understanding Advanced Web Techniques ......................................................................................... 96

EXCEL ..................................................................................................................................................... 101
Opening an Excel 2010 Workbook ...................................................................................................... 101
Introducing the Excel 2010 Interface ................................................................................................... 109
Creating a New Excel 2010 Workbook and Entering Data .............................................................. 122
Opening Workbooks and Entering Data in Excel 2010 .................................................................... 134
Formatting Text and Cells in Excel 2010 ............................................................................................ 137
Aligning data in Excel 2010 .................................................................................................................. 148
Formatting Numbers in Excel 2010 ..................................................................................................... 154
Formatting Data in Excel 2010 ............................................................................................................. 167
Introducing Formulas and References in Excel 2010 ....................................................................... 170
Inserting Formulas in Excel 2010 ........................................................................................................ 179
Editing and Correcting Common Formula Errors .............................................................................. 192
Entering a Formula and Using References in Excel 2010 ............................................................... 202
Using Tables and Applying Table Styles in Excel 2010 ................................................................... 205
Applying Conditional Formats in Excel 2010 ..................................................................................... 217
Using Sparklines in Excel 2010 ........................................................................................................... 226
Using Tables, Conditional Formatting, and Sparklines .................................................................... 239

Operating Systems................................................................................................................................. 242
2

UNIX Philosophy and History ............................................................................................................... 242
UNIX Portability and Standards ........................................................................................................... 248
UNIX Distributions .................................................................................................................................. 255
Choosing a UNIX Distribution ............................................................................................................... 261
UNIX Implementations ........................................................................................................................... 266
The Basics of Using UNIX .................................................................................................................... 273
Getting Started with a UNIX System ................................................................................................... 284
Understanding UNIX Shell Scripts ....................................................................................................... 288
Choosing UNIX Shells ........................................................................................................................... 302
Creating and Running an Executable File in UNIX ........................................................................... 308
Choosing UNIX Shells and Running Scripts ...................................................................................... 320
UNIX Command Execution ................................................................................................................... 326
Redirection in UNIX ............................................................................................................................... 334
Substitution and Patterns in UNIX ....................................................................................................... 345
Using UNIX Commands in a Script ..................................................................................................... 353
UNIX Files and Directories ................................................................................................................... 359
The UNIX File System ........................................................................................................................... 366
File Creation, Deletion, and Permissions in UNIX ............................................................................ 383
Using the UNIX File System ................................................................................................................. 393
Searching UNIX Files with Patterns .................................................................................................... 398
Working with UNIX directories ............................................................................................................. 417
Searching and Organizing a UNIX File System ................................................................................ 433
Introduction to Windows 7 ..................................................................................................................... 443
The Windows 7 Desktop ....................................................................................................................... 451
The Windows 7 Start Menu and Taskbar ........................................................................................... 458
Getting Around the Windows 7 Interface ............................................................................................ 469
Using Windows Explorer ....................................................................................................................... 471
Searching for Files and Folders ........................................................................................................... 485
Navigating Windows and Searching for Files .................................................................................... 491
Installing and Removing Programs...................................................................................................... 494
Installing and Using Printers ................................................................................................................. 501
Working with Programs, Printers, and the Control Panel ................................................................. 513
System Maintenance ............................................................................................................................. 516
3

Windows 7 Security ............................................................................................................................... 530
Backing up and Restoring Folders and Files ..................................................................................... 540
Performing Maintenance and Security Tasks .................................................................................... 554
Customizing the Windows 7 Desktop.................................................................................................. 558
Customizing the Start Menu ................................................................................................................. 568
Customizing the Taskbar ...................................................................................................................... 576
Customizing the Windows 7 Interface ................................................................................................. 584
DBMS ....................................................................................................................................................... 587
Overview of Databases and DBMSs ................................................................................................... 587
The Database Architectures and Models ........................................................................................... 597
Identifying Database Systems .............................................................................................................. 612
Relational Database Concepts ............................................................................................................. 620
The Relational Database Schema ....................................................................................................... 630
Database Normalization ........................................................................................................................ 639
Identifying the Relational Database Concepts and Schema ........................................................... 646
Designing a relational database ........................................................................................................... 652
The database design life cycle ............................................................................................................. 659
Database design requirements analysis ............................................................................................. 665
Interviewing for business requirements gathering ............................................................................ 669
Developing the conceptual database design ..................................................................................... 679
Creating a conceptual database design ............................................................................................. 686
Database design using Entity-Relationship modeling ...................................................................... 691
Designing a database using Entity-Relationship modeling .............................................................. 701
Normalizing the database design ........................................................................................................ 707
Modeling complex relationships in the database design .................................................................. 714
A database design Entity-Relationship model ................................................................................... 721
Completing the logical database design ............................................................................................. 723
Implementing the database design...................................................................................................... 732
Creating a physical database design .................................................................................................. 741
Databases v. Database Management Systems ................................................................................ 747
Database requirements ......................................................................................................................... 755
A sample database system ................................................................................................................... 757
Database models ................................................................................................................................... 760
4

Database architectures ......................................................................................................................... 769
Designing a database architecture ...................................................................................................... 779
OLTP databases v. data warehousing ................................................................................................ 781
Oracle RDBMS and ORDBMS ............................................................................................................. 783
The Oracle9i database server .............................................................................................................. 786
Relational Database Concepts ............................................................................................................. 796
Relational database characteristics ..................................................................................................... 803
The relational database schema .......................................................................................................... 806
Relational database integrity ................................................................................................................ 813
Operations in a relational database ..................................................................................................... 815
Formulating algebraic operations in a database ............................................................................... 824
Using SQL in a relational database ..................................................................................................... 829
Writing basic SQL statements .............................................................................................................. 840
Manipulating data in Oracle9i databases ........................................................................................... 844
Using DML statements in an Oracle9i database ............................................................................... 855
Database transactions and concurrency problems ........................................................................... 861
Resolving concurrency problems in a database ................................................................................ 867
Database security................................................................................................................................... 874
Oracle9i database users ....................................................................................................................... 880
Privileges in an Oracle9i database ...................................................................................................... 885
Programming languages ....................................................................................................................... 889
The Evolution of Computers and Software Programming ............................................................... 889
Software Development Life Cycle ....................................................................................................... 900
Programming Basics .............................................................................................................................. 908
Program Development Tools ................................................................................................................ 914
Understanding Programming Basics ................................................................................................... 921
Algorithms Explained ............................................................................................................................. 929
Creating an Algorithm ............................................................................................................................ 946
Structuring an Algorithm ........................................................................................................................ 952
IF Statements .......................................................................................................................................... 963
CASE Statements .................................................................................................................................. 976
Solving a Problem using Branching Statements ............................................................................... 986
Completing Selection Statements...................................................................................................... 1001
5

FOR Loops ............................................................................................................................................ 1007
WHILE Loops ........................................................................................................................................ 1016
Solving a Repetition Problem ............................................................................................................. 1028
Using Loops .......................................................................................................................................... 1044
The history of computers ..................................................................................................................... 1050
Programming princples ....................................................................................................................... 1059
Software life cycle phases .................................................................................................................. 1070
Program development ......................................................................................................................... 1075
Defining algorithms .............................................................................................................................. 1083
Construction an algorithm ................................................................................................................... 1093
Creating an algorithm .......................................................................................................................... 1102
Variables, constants, and data types ................................................................................................ 1107
Expressions and statements .............................................................................................................. 1114
Building expressions ............................................................................................................................ 1122
Variables, Constants, and Data Types ............................................................................................. 1131
Expressions and Statements .............................................................................................................. 1140
Building Expressions ........................................................................................................................... 1153
Arrays ..................................................................................................................................................... 1159
Procedures and Functions .................................................................................................................. 1170
Using Arrays and Procedures ............................................................................................................ 1186
Software Engineering concepts ......................................................................................................... 1193
Analyzing Requirements Using Models SkillBriefs ......................................................................... 1193
SkillBrief ................................................................................................................................................. 1194
Use Case Modeling .............................................................................................................................. 1194
Usage Modeling Techniques .............................................................................................................. 1199
Usage Modeling Techniques .............................................................................................................. 1203
Data and Behavior Modeling Techniques ........................................................................................ 1207
Class Diagrams .................................................................................................................................... 1210
Solution Development Methodologies .............................................................................................. 1212
Business Rules ..................................................................................................................................... 1215
Data Flow Diagrams ............................................................................................................................ 1218
Data Flow Diagrams ............................................................................................................................ 1221
Activity Diagrams .................................................................................................................................. 1225
6

Refining and Documenting Requirements SkillBriefs .................................................................... 1228
Functional Requirements .................................................................................................................... 1229
Quality of Service Requirements ....................................................................................................... 1231
Decomposing Requirements .............................................................................................................. 1233
Constraints and Assumptions ............................................................................................................. 1235
Requirements Attributes ...................................................................................................................... 1237
Types of Requirements Documents .................................................................................................. 1239
Validating and Verifying Requirements ............................................................................................. 1241
Software testing .................................................................................................................................... 1244
The Necessity of Software Testing .................................................................................................... 1244
What is Software Testing? .................................................................................................................. 1251
Meeting Software Test Objectives ..................................................................................................... 1255
General Software Testing Principles ................................................................................................. 1261
Applied Software Testing Principles .................................................................................................. 1265
The Importance of Software Testing and Mitigating Harm ............................................................ 1272
The Fundamental Software Test Process ........................................................................................ 1278
Exit Criteria and Test Closure Activities ............................................................................................ 1286
The Psychology of Software Testing ................................................................................................. 1291
Contrasting Software Testers and Developers ................................................................................ 1298
Organizing Testers and the Software Test Process ....................................................................... 1302
Software Development Models .......................................................................................................... 1307
Component and Integration Testing .................................................................................................. 1314
System and Acceptance Testing ....................................................................................................... 1320
Testing to Reveal Defects ................................................................................................................... 1328
Functional and Non-functional Software Testing ............................................................................ 1333
Structural and Changed-based Software Testing ........................................................................... 1341
Maintenance Software Testing ........................................................................................................... 1350
Models of Software Testing and Development ................................................................................ 1356
ENGLISH ............................................................................................................................................... 1360
SkillBrief ................................................................................................................................................. 1361
End Punctuation Marks ....................................................................................................................... 1361
Using the Comma Correctly ............................................................................................................... 1363
Using Connectors and Separators .................................................................................................... 1364
7

Using Other Punctuation Marks ......................................................................................................... 1366
Business Grammar: Sentence Construction SkillBriefs ................................................................. 1369
Sentence Parts, Phrases, and Clauses ............................................................................................ 1369
The Rules of Subject-Verb Agreement ............................................................................................. 1371
Rules of Agreement for Pronouns and Antecedents ...................................................................... 1373
Sentence Fragments, Comma Splices, and Modifiers ................................................................... 1375
Business Grammar: Common Usage Errors SkillBriefs ................................................................. 1378
Recognizing Commonly Confused Word Pairs ............................................................................... 1378
Using Prepositions Idiomatically ........................................................................................................ 1380
Recognizing Commonly Misused Verbs and Other Words ........................................................... 1382
Business Grammar: Parts of Speech SkillBriefs ............................................................................. 1384
Recognizing the Eight Parts of Speech ............................................................................................ 1384
Using Verbs Correctly .......................................................................................................................... 1386
Using Adverbs and Adjectives ........................................................................................................... 1388
Using Nouns Correctly ......................................................................................................................... 1390
Rules for Constructing Prefixes and Suffixes .................................................................................. 1393
Rules for Forming Plurals ................................................................................................................... 1395
Rules for Forming Possessives ......................................................................................................... 1396
Basic Spelling Rules ............................................................................................................................ 1398
Business Grammar: The Mechanics of Writing SkillBriefs............................................................. 1400
The Correct Use of Abbreviations ..................................................................................................... 1400
The Correct Methods of Capitalization .............................................................................................. 1402
Writing Numbers ................................................................................................................................... 1405
Interpersonal Communication: Communicating with Confidence SkillBriefs .............................. 1408
The Essential Elements of Confident Communication ................................................................... 1408
The Use and Impact of Confident Communication Behaviors ...................................................... 1410
Trust, Credibility, Rapport, and Confidence ..................................................................................... 1412
Business Writing: How to Write Clearly and Concisely SkillBriefs ............................................... 1415
Techniques for Writing Clearly ........................................................................................................... 1415
Applying the Techniques of Concise Writing ................................................................................... 1417
Organizing Content to Increase Understanding .............................................................................. 1420
Developing an Effective VOICE ......................................................................................................... 1436
Methods for Improving Your Voice .................................................................................................... 1437
8

The Benefits of a Well-placed Pause ................................................................................................ 1440
Understanding the Seven Levels of Listening ................................................................................. 1441
The Most Common Obstacles to Listening ...................................................................................... 1443
Overcoming Self-made Barriers to Listening ................................................................................... 1445
Recognizing Non-verbal Messages ................................................................................................... 1446
Interpreting Four Modes of Non-verbal Expression ........................................................................ 1448
Responding Appropriately to Body Language ................................................................................. 1450
Workplace Communication Skills SkillBriefs .................................................................................... 1451
Three Interpersonal Communication Styles ..................................................................................... 1452
Four Types of Assertive Responses ................................................................................................. 1454
Assertive Interpersonal Negotiation Techniques ............................................................................. 1456
Using Constructive Criticism and Feedback .................................................................................... 1457
Criteria for Giving Constructive Criticism .......................................................................................... 1458
Accepting Criticism in a Positive Manner ......................................................................................... 1460
Using Open and Closed Questions ................................................................................................... 1461
How to Use Exploratory Questions.................................................................................................... 1462
Using Leading Questions to Persuade ............................................................................................. 1463
Listening Basics SkillBriefs ................................................................................................................. 1464
The Seven Components of Communication .................................................................................... 1465
The Seven Components of Communication .................................................................................... 1466
How People Communicate Simultaneously ..................................................................................... 1467
How You Receive Information ............................................................................................................ 1468
Three Types of Attention Problems ................................................................................................... 1470
Common Causes of Misinterpreted Messages ................................................................................ 1471
Strategies for Improving Your Listening Skills ................................................................................. 1472
Factors That Influence Your Listening Attitudes .............................................................................. 1473






9

HTML

Introduction to HTML
Learning Objectives
After completing this topic, you should be able to
identify the current HTML standards
recognize what HTML is
identify common HTML editing applications and their functions
1. Introduction to HTML
Hypertext Markup Language, or HTML for short, is the authoring language used to create web
documents. It was developed from Standard Generalized Markup Language, or SGML which is
a more complicated markup language.

HTML has evolved since its beginnings in 1989. The current release of HTML is HTML 4.01,
which has been available since late 1999. A working draft of the HTML 5.0 specification is
available since 2008 but has not yet been finalized.
Hypertext is a method of preparing and publishing text that enables you to link documents to
each other.

HTML consists of descriptive symbols and codes, called markup, which tell a browser how to
display a web page's content for a user. Each piece of markup code is referred to as an
element.
Markup languages aren't the same as programming languages. Programming languages, such
as Java, are used to generate tasks for the computer to complete. Markup languages, such as
HTML, simply describe how a browser should display information.
HTML code can be written using a text editor, such as Notepad, or more sophisticated
applications, such as Microsoft Expression Web and Adobe Dreamweaver. Expression Web and
Dreamweaver are called WYSIWYG editors. WYSIWYG is short for what you see is what you
get. These editors display the web page as it will look in the browser.

All HTML web pages are saved with the .htm or .html file extension.


10

Question
Identify the characteristics of HTML.
Options:
1. It's a markup language
2. It's an SGML
3. It can be written using a text editor
4. It's a programming language
5. It can be written using a WYSIWYG editor
Answer
Option 1: Correct. HTML uses descriptive elements to tell a browser how to display the content
contained in the web page.
Option 2: Incorrect. HTML is a simplified version of SGML.
Option 3: Correct. HTML can be generated using a simple text editor, such as Notepad. It can also
be generated in a WYSIWYG editor.
Option 4: Incorrect. HTML can't be used to ask the computer to perform tasks, as programming
languages do. It simply describes how content will appear in a browser.
Option 5: Correct. HTML can be written in WYSIWYG editors and text editors. WYSIWYG editors
display the web page as it would appear in a web browser.
Correct answer(s):
1. It's a markup language
3. It can be written using a text editor
5. It can be written using a WYSIWYG editor
2. HTML standards
The World Wide Web Consortium, or W3C, is the international organization responsible for
setting the standards for HTML and other web development languages. It was established in
1994.
HTML 2.0, developed in 1995, was the basis for the core HTML features that are used today. In
1996, the W3C approved HTML version 3.2, which added support for tables and text flow
around images. Version 3.2 was backward compatible with version 2.0.

11

HTML 4.0 was released in 1998. It added support for new scripting languages, multimedia
options, style sheets, and improved printing. HTML 4.01 was released in 1999 to repair some
bugs that were present in version 4.0.
There are three varieties of HTML 4.01.
HTML 4.01 Strict
HTML 4.01 Strict is a trimmed-down version of HTML 4.01 that emphasizes structure over
presentation. You can use Cascading Style Sheets, or CSS, with HTML 4.01 Strict. It enables you
to achieve accessible, structurally rich documents that easily adapt to style sheets and different
browsing situations. Some older browsers may not be able to support HTML Strict.

You shouldn't use deprecated tags those that will become obsolete in a later version of HTML
in HTML Strict documents.
HTML 4.01 Transitional

HTML 4.01 Frameset
Web pages that contain frames must use HTML 4.01 Frameset, which is a variation of HTML
4.01 Transitional. HTML 4.01 Frameset can contain deprecated tags and is supported by more
browsers than HTML 4.01 Strict.
XHTML was released in 2001. It combines the strengths of HTML and Extensible Markup
Language, or XML, by defining HTML as an XML application.

Their release creates a language compatible with a wide range of browsers. They're also
simpler, and therefore easier to use.
Note
The current release of XHTML is 1.1.There is a working draft for the XTML 2.0 standard but it has
not been finalized as a standard.
XHTML is far more precise than previous versions of HTML. XHTML, for instance, is case
sensitive, so all its elements must be written in lower case. HTML on the other hand is far less
strict. Its elements can be written in upper case, lower case, or a mixture of the two.
To create a well formatted and executed document, XHTML requires that tags and attributes
follow one of three XML document type definitions:
XHTML Strict
XHTML Strict is used when you want to create clean, clear markup. Unlike XHTML Transitional
and Frameset, XHTML Strict is restrictive. It doesn't support the use of any deprecated elements
12

or attributes. Deprecated elements and attributes are HTML tags that have been replaced by
newer, more functional adaptations. It also doesn't support the use of frames.
XHTML Transitional, and
XHTML Transitional is compatible with a wide range of browsers, as it supports the use of
presentational features and deprecating elements and attributes.
XHTML Frameset
Although modern browsers all support XHTML to a certain extent, HTML 2.0 is still the most
widely supported version it's supported by almost every browser today.
Question
Which XHTML document type definition enables you to use deprecated elements and attributes?
Options:
1. XHTML Transitional
2. XHTML Frameset
3. XHTML Strict
Answer
Option 1: Correct. XHTML Transitional is compatible with most browsers. It supports the use of
deprecated elements and attributes.
Option 2: Incorrect. XHTML Frameset is specifically designed for use on web pages that use
frames.
Option 3: Incorrect. XHTML Strict doesn't support the use deprecated elements and attributes. It
also doesn't support the use of framesets.
Correct answer(s):
1. XHTML Transitional
3. HTML editors
There are two types of HTML editors:
GUI editors and
Graphical User Interface, or GUI, editors are used to create web pages without having to write
HTML code. By using various menu and toolbar commands, you design your web page while the
program automatically enters the appropriate HTML code. For this reason, GUI editors are often
13

referred to as WYSIWYG editors. This helps you to determine how your page will be displayed
and formatted as you create it. As a result, they can greatly speed up the process of web page
creation.
text editors
If you use a text editor to create your web page, you must enter all the code manually. Text
editors give you complete control over the content and the "look and feel" of your web page.

Using a text editor is more time consuming than using a GUI editor. Common text editors include
Notepad and SimpleText. Microsoft Word can also be used to create HTML files but isn't
recommended, as it creates a lot of unnecessary HTML code.
GUI editors enable you to manually edit the HTML code. Examples of common GUI editors are
Microsoft Expression Web and Adobe Dreamweaver.

GUI editors also include some advanced functions, such as enabling you to see what your web
page will look like in different browsers, File Transfer Protocol, or FTP, access, link checking,
and code validation. Being able to perform all these tasks in one application greatly speeds up
the production process.
Question
Identify the applications that can be used as WYSIWYG HTML editors.
Options:
1. Adobe Dreamweaver
2. Microsoft Expression Web
3. Notepad
4. Microsoft Word
Answer
Option 1: Correct. Adobe Dreamweaver enables you to create your web pages without having to
type any HTML code. It also enables you to edit the HTML code manually.
Option 2: Correct. Microsoft Expression Web is a WYSIWYG editor, which uses a GUI interface to
enable you to create web pages by using various menu and toolbar commands. The HTML code is
automatically generated.
Option 3: Incorrect. Notepad is a text editor. It has no GUI interface so all HTML code has to be
manually entered.
14

Option 4: Incorrect. Microsoft Word can be used as a text editor, but it has no GUI interface, so it
isn't a WYSIWYG editor. As a text editor, Word creates unnecessary HTML code, so it isn't
recommended.
Correct answer(s):
1. Adobe Dreamweaver
2. Microsoft Expression Web
Summary
HTML is the authoring language used to create web documents. It was first developed in 1989,
and it evolved from SGML. Hypertext refers to HTML's ability to navigate between linked
documents. Markup consists of descriptive elements, which tell a browser how to display a web
page's content to a user.

The W3C is the international organization responsible for setting the standards for HTML. It was
formed in 1994 and since then it has overseen the development of HTML from version 2.0 to the
current version XHTML 1.0 and HTML 4.02. Varieties of XHTML are XHTML Strict, XHTML
Transitional, and XHTML Frameset.

There are two types of HTML editors text and GUI. With a text editor, you enter the HTML
code manually. This allows a great degree of control over the web page structure. GUI HTML
editors use menus and toolbar options to build the web page. The HTML code is generated
automatically. GUI editors also provide extra functionality, such as browser previews, FTP
access, link checking, and code validation.










15

HTML Structures and Elements
Learning Objectives
After completing this topic, you should be able to
recognize the tags that define the structure in an HTML document
recognize the basic elements of an HTML document
1. HTML tag components
HTML documents consist of text and tags. Tags, also known as elements, are used to tell the
browser how to display the text and any other content you want to include in your web page.

Tags consist of a text command inside angle brackets, known as wickets.
Graphic
An example of a tag is <html>.
Code
<html>

<head>

<title>EarthFarm</title>

</head>

<body>

<font face="Arial">Welcome to the EarthFarm web site</font>

<hr>

</body>

</html>
There are two types of tags:
Code
16

<html>

<head>

<title>EarthFarm</title>

</head>

<body>

<font face="Arial">Welcome to the EarthFarm web site</font>

<hr>

</body>

</html>
container tags and
Container tags enclose the text inside an opening and a closing tag. The opening tag starts the
instruction, and the closing tag ends it. Only the text within the tags will be displayed on the web
page.

The closing tag is always the same as the opening tag. The only difference is that the closing tag
has a forward slash after the first angle bracket and before the start of the name of the tag. An
example is the paragraph tag, which has <p> as the opening tag and </p> as the closing tag.
empty tags
Empty tags are opening tags that don't have a closing tag. Some examples include the list <li>,
horizontal line <hr>, and the line break <br> tags. If you need to make HTML code XHTML-
compliant, you should include a forward slash in empty HTML tags. For example <br> should be
written as </br>.
Common formatting techniques can be performed in html documents by enclosing the text
inside some simple tags.

To format the text in bold, you place the <b> tag before and the </b> tag after the text you want
formatted. Placing <u> </u> on either side of some text will underline the enclosed text. The
<i> </i> tags will italicize the enclosed text.
Code
<html>

<head>
17


<title>EarthFarm</title>

</head>

<body>

<font face="Arial"><b>Welcome to the EarthFarm web site</b></font>

<hr>

</body>

</html>
Tags can also be nested or contained inside other tags. The <body> </body> tags enclose all
the content visible in the document window of the browser. This content is enclosed by many
other tags to format the content for display.
Code
<html>

<head>

<title>EarthFarm</title>

</head>

<body>

<font face="Arial"><b>Welcome to the EarthFarm web site</b></font>

<hr>

</body>

</html>
Tags often include attributes. An attribute identifies a specific characteristic relating to the tag,
and a value defines this characteristic. The structure of the tag, attribute, and value is displayed.
The order is the tag name first and then the attribute name, followed by an equals sign and the
value included in quotation marks.

In the code, font is a tag, face is the attribute, and Arial is the value.
18

Code
<html>

<head>

<title>EarthFarm</title>

</head>

<body>

<font face="Arial"><b>Welcome to the EarthFarm web site<b></font>

<hr>

</body>

</html>
Syntax
<tagname attribute_name = "value">
Question
You want to format the text "Welcome to the EarthFarm web site" in italics.

Enter the necessary tags and text.
Code
<html>

<head>

<title>EarthFarm</title>

</head>

<body>

<font face="Arial">INSERT THE MISSING CODE
Answer
19

To format "Welcome to EarthFarm web site" in italics you type <i>Welcome to the EarthFarm
web site</i>.
Correct answer(s):
1. <i>Welcome to the EarthFarm web site</i>
Question
In the HTML code <font size="2">, match each individual component with the correct
description.
Options:
A. 2
B. font
C. size
Targets:
1. Attribute
2. Tag
3. Value
Answer
The size attribute tells the browser to display the text enclosed within the <font></font> tags at
a specified size.
The <font> </font> tags tell the browser to format the enclosed text in a particular way.
The value of 2, combined with the <font> </font> tags and the attribute, size, tells the browser
that this portion of the text should be displayed at size 2.
Correct answer(s):
Target 1 = Option C
Target 2 = Option B
Target 3 = Option A
20

2. Structural HTML tags
Every HTML page has common structural tags that are needed to build the page.
Code
<html>

<head>

<title></title>

</head>

<body>



</body>

</html>
There are several common structural tags needed in each HTML page:
Code
<html>

<head>

<title></title>

</head>

<body>



</body>

</html>
<html> </html>
21

The <html> </html> tags define your document as an HTML page for the browser. It encloses
all the other tags and the content in your HTML document. The opening <html> tag can have
attributes such as lang, which is used to specify the language that the HTML document is written
in. For example, you can specify English as the language:

<html lang = "en">
<head> </head>, and
The <head> </head> tags are used to provide information about the page. The <head>
</head> tags contain other tag elements such as the <title> </title> tags and <meta>
tags.

The text you enter in the <title> </title> tags is displayed in the Title bar of your browser.

Meta tags are used to provide information about your web site. The content placed inside the
meta tag varies widely depending upon the value that is set within the name and content
attributes of the tag. Common values for the name attribute include keywords which is used to
associate keywords with the site and description. These keywords provide a description of
the site for display in search engine results:

<meta name="keywords"content="organic, fruit, vegetables">
<body> </body>
The <body> </body> tags enclose all the information that will be visible to the users on your
web pages.

The opening <body> tag can have several attributes. For example, if you want to specify the
background color for your web page, you add the bgcolor attribute and specify a hexadecimal
color value. For example, you can change the background color of your web page to red:

<body bgcolor ="#ff0000">
The Document Type Definition, or DTD, describes the markup language used to create the
document. It states whether the page was created using HTML 4.01 Strict, HTML 4.01
Transitional, or HTML 4.01 Frameset. The example shows that this web page was created using
HTML 4.01 Transitional.

The absence of this tag may restrict the use of advanced browser features.
Graphic
The DTD is <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">.
Code
22

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">
<html>

<head>

<title></title>

</head>

<body>



</body>

</html>
Question
You are starting to build your first web page, and you have entered the structural tags that are
needed for the basic structure of the page. You now want to add the title "EarthFarm" to your web
page.

Enter the title with the appropriate tags.
Code
<html>

<head>

INSERT THE MISSING CODE

</head>

<body>



</body>

</html>
Answer
23

To give your web page the title "EarthFarm" you enter <title>EarthFarm</title> inside the
<head> </head> tags.
Correct answer(s):
1. <title>EarthFarm</title>
2. <title> EarthFarm </title>
3. <title> EarthFarm</title>
4. <title>EarthFarm </title>
Question
Which set of tags can be used, with the relevant attributes, to relay keywords associated with the
site to search engines?
Options:
1. <body> </body>
2. <html> </html>
3. <meta>
4. <title> </title>
Answer
Option 1: Incorrect. The <body> </body> tags enclose all the information that the user views
onscreen.
Option 2: Incorrect. The <html> </html> tags define your document as an HTML page for the
browser. They enclose all the other tags and the content in the HTML document.
Option 3: Correct. You use <meta> tags, along with the name attribute set to keywords and the
content attribute containing the relevant keywords, to enable search engines to index your web
site correctly.
Option 4: Incorrect. The <title> </title> tags are used to display the title of your web page in
the browser Title bar.
Correct answer(s):
3. <meta>
24

3. Elements of an HTML document
The <body> </body> tags contain all the contents of the document, such as the text and
images, that will be visible in the document window of the browser. Different tags are used to
format the text and display the images.
Code
<html>
<head><title>EarthFarm</title></head>
<body>
<h1><font face= "Arial">Welcome to EarthFarm</font></h1>
<hr>
<p><font face="Arial" size="2">
Here at EarthFarm, we base our farming techniques on the
development of biological diversity and the maintenance and
replenishment of soil fertility.<br>
We grow vegetables, crops, flowers, and herbs in a completely
organic environment.</font></p>
<p><font face="Arial" size="2">We specialise in:
<ul>
<li>Organic food
<li>Organic vegetables
<li>Organic fruit
<li>Organic meat
<li>Flowers and herbs
</ul></font></p>
<p><img align="center" src="ef_cows.jpg" border="0"></p>
</body>
</html>
The most common tags used in the body of the HTML document are
Code
<html>
<head><title>EarthFarm</title></head>
<body>
<h1><font face= "Arial">Welcome to EarthFarm</font></h1>
<hr>
<p><font face="Arial" size="2">
Here at EarthFarm, we base our farming techniques on the
development of biological diversity and the maintenance and
replenishment of soil fertility.<br>
We grow vegetables, crops, flowers, and herbs in a completely
25

organic environment.</font></p>
<p><font face="Arial" size="2">We specialise in:
<ul>
<li>Organic food
<li>Organic vegetables
<li>Organic fruit
<li>Organic meat
<li>Flowers and herbs
</ul></font></p>
<p> <img align="center" src="ef_cows.jpg" border="0"></p>
</body>
</html>
<h1> </h1>
The <h1> </h1> tags are heading tags. In HTML you can have up to six different heading sizes.
The tag <h1> defines the largest header and <h6> defines the smallest header. Paragraph
breaks occur automatically at the end of each heading element.
<p> </p>
The <p> </p> tags are used to format text in paragraphs. In HTML documents you can't
separate blocks of text into paragraphs by pressing the Enter key because white space is not
recognized. You have to enclose the text inside the <p> </p> tags.
<br>
The <br> tag creates a single line break in text wherever it is inserted. The <br> tag has no
closing tag.
<hr>
The <hr> tag creates a horizontal rule. This is a straight line which extends across a page. This
can be used to divide the content into sections. The <hr> tag has no closing tag.
<img>, and
The <img> tag defines an image and attaches it to your web page. This tag requires the src
attribute for a graphic to load correctly. The src attribute specifies the name of the graphic file
and the location of the file on the computer:

<img src = "image_name.file_extension">

Different types of graphic files can be displayed such as JPEG, gif, and PNG files. Other
attributes such as the height and width of the image can be specified. The <img> tag has no
closing tag.
<font> </font>
The <font> </font> tags are used to format text. The face attribute enables you to set the
font type:

<font face ="font_ name">Text</font>
26


The size attribute specifies the size of the text and the color attribute enables you to set the
color.
You may want to display some content in bulleted or numbered lists. There are different tags
used for each of these lists.

For a bulleted list, the <ul> </ul> tags are used. The tag <ul> stands for unordered list,
which is a bulleted list. It doesn't display the list items numerically or alphabetically.

To create an ordered, numerical list, you use the <ol> </ol> tags.

In both types of list, the list items must be preceded by the <li> list item tag. There is no
closing tag.
Code
<html>
<head><title>EarthFarm</title></head>
<body>
<h1><font face= "Arial">Welcome to EarthFarm</font></h1>
<hr>
<p><font face="Arial" size="2">
Here at Earthfarm, we base our farming techniques on the
development of biological diversity and the maintenance and
replenishment of soil fertility.<br>
We grow vegetables, crops, flowers, and herbs in a
completely organic environment. Our livestock are fed a carefully
prepared organic diet and are allowed to roam free across our
parkland.</font></p>
<p><font face="Arial" size="2">We specialise in:
<ul>
<li>Organic food
<li>Organic vegetables
<li>Organic fruit
<li>Organic meat
<li>Flowers and herbs
</ul></font></p>
<p><img align="center" src="ef_cows.jpg" border="0"></p>
</body>
</html>
Question
27

You want to format the text "Welcome to EarthFarm" in Arial font face.

Without adding unnecessary spaces to the code, enter the appropriate tags and text.
Code
<html>
<head><title>EarthFarm</title></head>
<body>
<h1>INSERT THE MISSING CODE
Answer
To display the text "Welcome to EarthFarm" in Arial, you type <font face="Arial">Welcome
to EarthFarm</font>.
Correct answer(s):
1. <font face="Arial">Welcome to EarthFarm</font>
Question
Match the tags with their descriptions.
Options:
A. <img>
B. <hr>
C. <font> </font>
D. <p> </p>
Targets:
1. Embeds a graphic in a web page
2. Creates a straight line which extends across the page
3. Formats text size and type
4. Groups text into paragraphs
Answer
The <img> tag uses the src attribute to specify the graphic file to embed and the location of the file.
The <hr> tag creates a horizontal rule, which can be used to divide content into sections.
28

The <font> </font> tags enable you to specify the font face and size by using the face and
size attributes.
The <p> </p> tags organize blocks of text into paragraphs.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Summary
HTML tags, also referred to as elements, tell the browser how to display content. Tags consist of
a text command inside angled brackets. There are two types of tags container tags and empty
tags. Container tags have opening and closing tags and empty tags only have opening tags.
Tags have attributes and values.

There are several key structural tags that are common to every HTML page. These include the
<html> tag, which defines the document as an HTML page, the <head> tag, which contains
information about the page, and the <body> tag, which contains the information that will be
visible to the user. The DTD describes the markup language used to create the document.

Because the body of the HTML document contains the visible content, the <body> tag contains
many other nested tags. Some of the most common ones are those for attaching an image
<img>, creating a paragraph <p>, creating a horizontal rule <hr>, and formatting text <font>
</font>.









29

Creating a Web Page
Learning Objective
After completing this topic, you should be able to
create a basic web page
Exercise overview
In this exercise, you're required to create a basic web page displaying product information.

This involves creating a web page.
You work for a company called EarthFarm, which sells organic foodstuffs and herbs. You want
to create a web page containing some basic information about the company products.
Task 1: Creating a web page
You are starting to build the Produce page of the site. So far, you've entered the structural tags.
You now want to build up the rest of the page.
Code
<html>
<head>

</head>
<body>



</body>
</html>
Question
You have given the title "EarthFarm Produce" to your web page.

Add the closing tag for the title of your web page.
Code
<html>
<head>
<title>EarthFarm ProduceINSERT THE MISSING CODE
30

</head>
<body>



</body>
</html>
Answer
The closing tag has the same name tag as the opening tag. It also has a forward slash (/) after the
first angle bracket and before the start of the name tag. To close the title tag, you add the closing
</title> tag.
Correct answer(s):
1. </title>
Question
You want to change the background color of your web page from the default white color to a yellow
color.

Enter the attribute to change the background color to a shade of yellow. The hexadecimal color
value is #FFFFCC.
Code
<html>
<head>
<title>EarthFarm Produce</title>
</head>
<body INSERT THE MISSING CODE>



</body>
</html>
Answer
To change the color of your web page to a shade of yellow, you enter the body tag attribute
bgcolor="#FFFFCC".
Correct answer(s):
31

1. bgcolor="#FFFFCC"
Question
You want the main heading on the page to be "About our produce".

Enter the code to create the main heading.
Code
<html>
<head>
<title>EarthFarm Produce</title>
</head>
<body bgcolor="#FFFFCC">
INSERT THE MISSING CODE



</body>
</html>
Answer
The <h1> </h1> tags are heading tags. To display "About our produce" as the main heading, you
type <h1>About our produce</h1>. The tag <h1> defines the largest header.
Correct answer(s):
1. <h1>About our produce</h1>
Question
You have entered the text for your first paragraph and now you want to add an extra line break after
the word "wreaths".

Enter the tag to do this.
Code
<html>
<head>
<title>EarthFarm Produce</title>
</head>
<body bgcolor="#FFFFCC">
<h1>About our produce</h1>
<p>
32

Here at EarthFarm, we grow a wide variety of vegetables,
crops, and fruit, including tomatoes, pumpkins, wheat,
asparagus, peppers, squash, apples, and strawberries. We also
rear cattle, sheep, goats, and chickens, and we produce
organic honey from our beehive. We also grow flowers and
herbs, which we sell to order or in ready-tied bouquets and
wreaths.
</p>
INSERT THE MISSING CODE


</body>
</html>
Answer
The <br> tag creates a single line break in text wherever it is inserted. The <br> tag has no closing
tag.
Correct answer(s):
1. <br>
Question
You have created the structure of an unordered list and now you need to enter the list items.

Add the text "Pumpkins" as your first list item.
Code
<html>
<head>
<title>EarthFarm Produce</title>
</head>
<body bgcolor="#FFFFCC">
<h1>About our produce</h1>
<p>
Here at EarthFarm, we grow a wide variety of vegetables,
crops, and fruit, including tomatoes, pumpkins, wheat,
asparagus, peppers, squash, apples, and strawberries. We also
rear cattle, sheep, goats, and chickens, and we produce
organic honey from our beehive. We also grow flowers and
herbs, which we sell to order or in ready-tied bouquets and
wreaths.
</p>
<br>
33

<h2>Organic Vegetables</h2>
<ul>
INSERT THE MISSING CODE


</body>
</html>
Answer
List items must be preceded by the <li> list item tag. There is no closing tag. To create a list item
called "Pumpkins", you type <li>Pumpkins.
Correct answer(s):
1. <li>Pumpkins
Question
After you complete the bulleted list, you want to add the text "We sell only organic produce." and
format it in Arial font face.

Add the appropriate code to your HTML file.
Code
<p>
Here at EarthFarm, we grow a wide variety of vegetables,
crops, and fruit, including tomatoes, pumpkins, wheat,
asparagus, peppers, squash, apples, and strawberries. We also
rear cattle, sheep, goats, and chickens, and we produce
organic honey from our beehive. We also grow flowers and
herbs, which we sell to order or in ready-tied bouquets and
wreaths.
</p>
<br>
<h2>Organic Vegetables</h2>
<ul>
<li>Pumpkins
<li>Tomatoes
<li>Potatoes
<li>Celery
<li>Beans
<li>Peppers
<li>Onions
<li>Garlic
</ul>
34

INSERT THE MISSING CODE
</body>
</html>
Answer
The <font> </font> tags are used to format text. You can also add an attribute, such as a font
face or size. To display the text "We sell only organic produce." in Arial, you enter <font face =
"arial">We sell only organic produce.</font>.
Correct answer(s):
1. <font face = "arial">We sell only organic produce.</font>
Finally, you preview the web page in your browser.

















35

Hyperlinks, Tables, and Forms
Learning Objectives
After completing this topic, you should be able to
insert hyperlinks into a web page
recognize tags used to create a table in HTML
recognize the tags that are used to create forms in HTML
1. Hyperlinks
Hyperlinks provide a clickable link between web pages on the Internet.

You can create a hyperlink that's linked to another page within the same site, to a page on
another site, or to a section of the current page.

A hyperlink can be represented by text or an image.
Graphic
The product.htm web page contains the following text: "At EarthFarm we sell only organic produce
in our farm shop. You can see our complete product list here." The word "here" is a hyperlink.
An external hyperlink links two web pages.
Try It
You want to view the HTML for the external hyperlink.
To complete the task
1. Select View - Source
Using keyboard: The keyboard alternative is Alt+V, C.
The HTML for the external hyperlink displays.
The HTML for the link is displayed. You scroll through it to view the link at the bottom of the
page.
Graphic
This code is highlighted: <a href="produce_list.htm">here</a>
36

Code
approach to farming means that in addition to making
vegetables,
fruit, meat, and honey available to you, we can offer dairy products
including goats cheese and yogurt and also preserves and relishes
made in our farm kitchen.</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="2">At EarthFarm
we sell only organic produce in our farm shop. You can see our complete
produce list <a href="produce_list.htm">here</a>.</font></p>
<!-- #EndEditable --></td>
</tr>
</table>
</td>
<td height="380" width="160" align="left" valign="top"> <!--
#BeginEditable "info1" -->
<table width="160" border="0" height="600" align="right"
bordercolor="#000000">
<tr>
<td align="center" valign="top" height="40">&nbsp; </td>
</tr>
<tr>
<td align="center" valign="top" height="196">
<div align="left">
<p align="center"><a href="recipes.htm"><img src="assets/eggplant.jpg"
width="133"height="133" border="0"></a>
<p/>
In HTML, you should have the following elements within an external link:
Code
<a href="produce_list.htm">here</a>
anchor tags
The anchor tags <a> </a> surround the text or image that represents the link on the web page.
hypertext reference attribute
The hypertext reference attribute, or href attribute, identifies the file or Uniform Resource
Locator, also known as URL, that the anchor text or image links to.

You place the href attribute within the first anchor tag followed by the equals sign and the page
that you want to link to.
file or URL, and
37

You can link to a file, a fully qualified URL, or a partial URL. You can also link to another anchor
on the current page. In this case, you link to a page in the same folder as the page with the
anchor called "produce_list.htm".
text for the link
The text for this link is the word "here." On the EarthFarm web page, it's underlined and in a
different color to the rest of the text. When you move your mouse over it, the pointer changes to a
hand so you know it can be clicked.
You can also create hyperlinks using an image as the clickable anchor.

The file that the image links to is homepage.htm. The image is held in the assets folder of the
web site and is called "ef_workers.jpg".
Graphic
The sample image-based hyperlink is <a href="homepage.htm"><img src="assets/ef_workers.jpg"
width="130" height="130" border="0"></a></p>
Code
<p align="center"><font size="2"
face="Arial, Helvetica, sans-serif">
<a href="recipes.htm">Visit
our recipes page
</a></font></p>

</div>

</td>

</tr>

<tr>

<td align="left" valign="top">

<p align="center"><a href="homepage.htm">
<img src="assets/ef_workers.jpg"
width="130" height="130" border="0"></a></p>

<p align="center"><font size="2"
face="Arial, Helvetica, sans-serif">
<a href="homepage.htm">Details

about our Farm</a></font></p>
38


</td>
You select File - Exit to close the Notepad file that shows the HTML.
Try It
You want to view the hyperlink's target page.
To complete the task
1. Click the here hyperlink
The hyperlink's target page downloads.
The produce_list.htm page contains a number of internal links. You use internal links to jump to
other parts of the same document without having to scroll.
Graphic
There are a number of headings at the top of the page that are also hyperlinks. They are "Organic
Food", "Organic Vegetables", "Organic Fruit", "Organic Meat", and "Flowers and Herbs".
Try It
You want to move to other parts of the HTML document without having to scroll.
To complete the task
1. Click the Organic Vegetables link
The Organic Vegetables section of the page displays.
You select View - Source to view the HTML code for the produce_list.htm page.
Keyboard Sequence
The keyboard alternative is Alt+V, C.
You scroll through the source and locate the link for Organic Vegetables in the HTML.
Code
39

<td height="36" colspan="3">
<font face="Arial, Helvetica, sans-serif" size="2">
<b>
<a href="#OrganicFood">Organic Food</a>&nbsp;&nbsp;
<a href="#OrganicVegetables">Organic
Vegetables</a>&nbsp;&nbsp;
<a href="#OrganicFruit">Organic Fruit</a>&nbsp;&nbsp;
<a href="#OrganicMeat">Organic Meat</a>&nbsp;&nbsp;
<a href="#FlowersandHerbs">Flowers and Herbs</a>
</b>
</font>
</td>
In this case, you first create a named anchor for the Organic Vegetables area.
Code
<a name="OrganicVegetables">Organic Vegetables</a>
Then you create the link used to jump to the anchor you just created. Within the link's code, the
first instance of the words represents the newly-created anchor name, and the second instance
represents the link text used to access the target.
Code
<td height="36" colspan="3">
<font face="Arial, Helvetica, sans-serif" size="2">
<b>
<a href="#OrganicFood">Organic Food</a>&nbsp;&nbsp;
<a href="#OrganicVegetables">Organic
Vegetables</a>&nbsp;&nbsp;
<a href="#OrganicFruit">Organic Fruit</a>&nbsp;&nbsp;
<a href="#OrganicMeat">Organic Meat</a>&nbsp;&nbsp;
<a href="#FlowersandHerbs">Flowers and Herbs</a>
</b>
</font>
</td>
The value for the href attribute includes the hash (#) symbol before the target text. The hash
symbol tells the browser to search for the text within the page. If you omit the symbol, the link
doesn't work.
Code
40

<td height="36" colspan="3">
<font face="Arial, Helvetica, sans-serif" size="2">
<b>
<a href="#OrganicFood">Organic Food</a>&nbsp;&nbsp;
<a href="#OrganicVegetables">Organic
Vegetables</a>&nbsp;&nbsp;
<a href="#OrganicFruit">Organic Fruit</a>&nbsp;&nbsp;
<a href="#OrganicMeat">Organic Meat</a>&nbsp;&nbsp;
<a href="#FlowersandHerbs">Flowers and Herbs</a>
</b>
</font>
</td>
Question
Type the opening anchor tag and attributes for the link to a page called frameset.htm.
Code
<head>
<title> </title>
</head>
<body>
INSERT THE MISSING CODE
Answer
You type <a href="frameset.htm"> to create the opening tag and attributes.
Correct answer(s):
1. <a href="frameset.htm">
2. Tables
Tables have a number of functions. They can display tabular data and you can use them to align
text and images on a web page.
Graphic
The table lists a number of foodstuffs and their prices at given quantities. The table does not display
any borders.
To view the HTML code for the Organic Food table, you select View - Source.
Keyboard Sequence
41

The keyboard alternative is Alt+V, C.
Some of the HTML tags used to create a table are
Code
<table>
<caption>
Organic Food
</caption>
<tr>
<th>Food</th>
<th>Quantity</th>
<th>Price</th>
</tr>
<tr>
<td>Flour</td>
<td>2 lbs</td>
<td>$3</td>
</tr>
<tr>
<td>Soft Cheese</td>
<td>1 lb</td>
<td>$3</td>
</tr>
<tr>
<td>Sugar</td>
<td>1 lb</td>
<td>$8</td>
</tr>
</table>
<table> </table>
The <table> </table> container tags are the main tags for a table, and all other tags are
contained within them. These tags are required elements.
<caption> </caption>
<tr> </tr>
The <tr> </tr> tags are used to signify the start and end of a table row.
<td> </td>, and
Table data <td> </td> tags define the beginning and end of each cell in a row.
<th> </th>
42

The <th> </th> tags define the table heading and mark the beginning and the end of the
heading text. Heading text is usually placed in the top row or the first column as it defines the
data that comes after it. This tag is not mandatory because not all tables require heading text.
Question
Which table elements define the beginning and end of each row in a table?
Options:
1. <table> </table>
2. <td> </td>
3. <tr> </tr>
Answer
Option 1: Incorrect. The <table> </table> tags mark the beginning and end of the entire table.
Option 2: Incorrect. The <td> </td> tags mark the beginning and end of each cell within a row.
Option 3: Correct. The <tr> </tr> tags are used to define the beginning and end of each row in
a table.
Correct answer(s):
3. <tr> </tr>
Your web browser doesn't show table borders unless specified in the HTML. It makes decisions
on how to show other table elements such as text alignment and table width.

You can also specify how your table looks in a browser by manipulating the HTML.
Graphic
The table lists a number of foodstuffs and their prices at given quantities. The table includes a
border.
Note
Tables with the same settings may not look identical in different browsers.
You view the HTML code for the Organic Food table with borders.
43

Graphic
The View menu is open, with Source selected.
The HTML code of the Organic Food table with borders is displayed.
Code
<body>
<table width="80%" border="5" bgcolor="white"
height="600" cellspacing="1" cellpadding="10"
align="center" bordercolor="#000000">
<tr>
<th colspan="3">
<font face ="Arial" size="4">Organic Vegetables </font>
</th>
</tr>
<tr>
<th>Food</th>
<th>Quantity </th>
<th>Price </th>
</tr>
<tr>
<td>Honey</td>
<td>1 jar</td>
<td>$8</td>
</tr>
<tr>
<td>Eggs</td>
<td>6</td>
<td>$2</td>
</tr>
<tr>
<td>Flour</td>
<td>2 lbs</td>
You can change the appearance of rows, columns, or the entire table using the following basic
attributes:
Code
<body>
<table width="80%" border="5" bgcolor="white"
height="600" cellspacing="1" cellpadding="10"
align="center" bordercolor="#000000">
44

<tr>
<th colspan="3">
<font face ="Arial" size="4">Organic Vegetables </font>
</th>
</tr>
<tr>
<th>Food</th>
<th>Quantity </th>
<th>Price </th>
</tr>
<tr>
<td>Honey</td>
<td>1 jar</td>
<td>$8</td>
</tr>
<tr>
<td>Eggs</td>
<td>6</td>
<td>$2</td>
</tr>
<tr>
<td>Flour</td>
<td>2 lbs</td>
width
The width attribute describes the intended table width, either in pixels, or as a percentage of
screen width. For example, you use this code to specify that the table takes up 80% of the
screen. Specifying the table width in pixels may result in the table being wider than the screen.
This attribute can also be applied to cells in a table.
border
Table borders are not displayed in browser windows unless specified. To show borders around all
cells within tables, you use the border attribute. To draw a border of 5 pixels around all the cells
in the table, you use this code.
bgcolor
You use the bgcolor attribute to specify the background color for the table. The attribute goes in
the <table> tag, in the <tr> tag, in the <td> tag, or in the <th> tag depending on the table
element you wish to color. In this case, the background color is in the <table> tag and specified
as white.
height
The height attribute works in the same way as the width attribute except it is used to specify the
height of a table, row, or cell.
cellpadding and cellspacing, and
45

You control the white space between the border and the text in the cell using the cellpadding
attribute. To prescribe a space of 10 pixels between the cell border and its contents, you use this
code.

The white space between cells can be controlled using the cellspacing attribute. To ensure
there is a one pixel space between cells in a table, you use this code.
rowspan and colspan
The attributes rowspan and colspan when placed within the <th> or <td> tags enable you
to span a heading across the rows or columns of your table respectively. To create the heading
"Organic Vegetables" in an Arial font and size 4 spanning across three columns, you use this
code.
You view the source for a web page on the EarthFarm site.
The page comprises a table.
Code
<table width="160" border="0"
height="600" align="right" bordercolor="#000000">
<tr>
<td align="center" valign="top"
height="40">&nbsp; </td>
</tr>
<tr>
<td align="center"
valign="top" height="196">
<div align="left">
<p align="center"><a href="recipes.htm">
<img src="assets/eggplant.jpg" width="133"
height="133" border="0"></a>
</p>
<p align="center"><font size="2"
face="Arial, Helvetica, sans-serif">
<a href="recipes.htm">Visit
our recipes page</a>
</font></p>
</div>
</td>
</tr>
<tr>
There are a number of alignment attribute options available to you when using tables to display
data.
46

align
You can place the align attribute within the <table> tags, the <caption> tags, the <tr> tags,
the <td> tags, or the <th> tags to align the table or parts of it to the left, right, or center.

For example, <table align="right"> horizontally aligns the entire table to the right.
valign
The valign attribute vertically aligns text within a row or cell. Its values are top, middle, and
bottom. The valign attribute is generally used with the <tr>, <td>, and <th> tags.
halign
The halign attribute horizontally aligns text within a row or cell. Its values are left, center, and
right. The halign attribute is commonly used with the <tr>, <td>, and <th> tags.
Question
Insert the opening tag for a table that's 200 pixels wide. Specify that it's centrally aligned and has a
border width of 1.
Code
<head>
<title> </title>
</head>
<body>
INSERT THE MISSING CODE
Answer
You type <table width="200" align="center" border="1"> to create a table that is 200
pixels wide and centrally aligned with a border width of 1.
Correct answer(s):
1. <table width="200" align="center" border="1">
3. Forms
Forms are used in HTML pages to collect user input and forward it to a web server.

Forms are widely used in online surveys, online banking, online shopping, information requests,
and for site registration purposes.
You can enter and submit data by using controls such as checkboxes, radio buttons, text fields,
and submit buttons.

47

Data is processed using Common Gateway Interface, or CGI, scripts located at the web server
or client-side scripts that are run by the client's browser.
The <form> </form> tags are used in an HTML document to signify the beginning and end of
a form.

Various attributes need to be added to the <form> tag to ensure the form works correctly.
These include method, action, and enctype.
Graphic
In the sample HTML page, the code that defines the beginning of a form is:
<form name="survey" method="post"
action="survey.php" enctype="text/plain">

The code that defines the end of the form is:
</form>
Code
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type"
content="text/html">
</head>
<body>
<form name="survey" method="post"
action="survey.php" enctype="text/plain">

<strong>Quick survey:</strong><br>
<br>
We are considering adding
carrots to our list of organic vegetables.<br>
<br>
Do you like carrots?
<br>
<br>
<input name="like_carrots"
type="radio" value="Y"> Yes.
<br>
<input name="like_carrots"
type="radio" value="N"> No.
<br>
<input name="submit" type="submit" value="SUBMIT">
48

<input name="reset" type="reset" value="RESET FORM">
</form>
The method attribute specifies which method the browser uses to send form data to a web
server. You can use the get or post value with this attribute.
Graphic
In the sample HTML page, the code that defines the method, action, and enctype attributes of a
form is: <form name="survey" method="post"
action="survey.php" enctype="text/plain">
Code
<form name="survey" method="post"
action="survey.php" enctype="text/plain">
<strong>Quick survey:</strong><br>
<br>
We are considering adding
carrots to our list of organic vegetables.<br>
<br>
Do you like carrots?
<br>
<br>
<input name="like_carrots"
type="radio" value="Y"> Yes.
<br>
<input name="like_carrots"
type="radio" value="N"> No.
<br>
<input name="submit" type="submit" value="SUBMIT">
<input name="reset" type="reset" value="RESET FORM">
</form>
</body>
</html>
The get value specifies that the form data is appended to the URL for use in a query string.

The post value specifies that the form data is posted to the URL, which is specified by the
action attribute. The action attribute specifies the name and location of the CGI script used
to process the form.
The enctype attribute sets a MIME type for the data being sent to the web server. In this case,
the value for the enctype attribute is "text/plain".
49

When creating a form, you can use a number of tags to create fields.
Code
<form name="survey" method="post"
action="survey.php" enctype="text/plain">
Do you like carrots?
<br>
<br>
<input name="like_carrots"
type="radio" value="Y"> Yes.<br>
<input name="like_carrots"
type="radio" value="N"> No.<br>
<br>
What are your favorite vegetables?<br>
<br>
<select name="favorite_veg"
size="6" multiple>
<option value="Beans">Beans</option>
<option value="Broccoli">Broccoli</option>
<option value="Celery">Celery</option>
<option value="Peppers">Peppers</option>
<option value="Potatoes">Potatoes</option>
<option value="Tomatoes">Tomatoes</option>
</select><br>
<br>
Do you like any other vegetables? If so, please specify:<br>
<br>
<textarea name="notes" cols="50" rows="8"></textarea><br>
<br>
< input name="like_carrots"
type="radio" value="Y"> Yes.<br>
< input name="like_carrots"
type="radio" value="N"> No.
Most controls are added to a form using the <input> tag. The <input> tag is an empty tag. The
type of control that is displayed is decided using the type attribute. You can specify various
types of control by using this attribute.
< select name="favorite_veg"
size="6" multiple>
<option value="Beans">Beans</option>
<option value="Broccoli">Broccoli</option>
<option value="Celery">Celery</option>
<option value="Peppers">Peppers</option>
<option value="Potatoes">Potatoes</option>
50

<option value="Tomatoes">Tomatoes</option>
</select>
The <select> </select> tags are used to define the start and end of a select list in a form.
Various attributes can be used with the <select> tag. The name attribute is used to name the
list. The multiple attribute is used to specify whether multiple options can be selected from the
list. The display of each option in the list requires further HTML coding using <option>
</option> tags.
< textarea name="notes" cols="50" rows="8"></textarea>
The <textarea> </textarea> tags enable the insertion of a multiline text input area into a
form. These are commonly used for lengthy user input such as comments in a survey. Various
attributes are added to the <textarea> tag to identify it and control how it is displayed. These
attributes include name, rows, and cols. The name attribute gives the data entered into the text
area a name, rows is used to specify the height of the text area in rows, and cols is used to
specify the character width of the text area.
You can preview the form to check that its displaying correctly.
Some of the more common type attribute controls include
text
The text attribute is used to display a text field. Additional attributes such as name and value
can be added to a text input to give it a name, recognizable by a CGI script, and a default value.

For example, you can create a text field called "identity", with a default value of "Do you like any
other vegetables?"
checkbox
The checkbox attribute will display the input as a small box that can be checked or unchecked.
When checked, the value attribute of the checkbox is activated.

To ensure that a checkbox is checked by default, you can use the checked attribute.

For example, you can create a checkbox called "maillist" with a value of "Yes" that is checked by
default.
radio
Radio buttons are round option buttons in a group of two or more that are mutually exclusive
options. Radio buttons are useful for getting a response to a multiple choice question in a form.

When creating a group of radio buttons, you must ensure that they have the same value in the
name attribute.

For example, you can create a radio button group called "survey" that enables a user to either
select Yes or No as an option.
51

submit
If the type attribute is set to submit, a Submit button is displayed in the form. Submit buttons
are used to send the form data to the relevant CGI script on the web server for processing.

You set the text that appears on the button by using the value attribute. This element is
displayed by default.
reset, and
If the type attribute is set to reset, a Reset button is displayed in the form. Reset buttons are
used to set all of the form inputs to the default or blank values.

This is a useful way for the user to clear the form if a mistake is made during data input.
hidden
Hidden inputs are used to include a value in the form that the user does not need to see. The
hidden input is named using the name attribute and has its value added to it by using the value
attribute.

For example, you can add a hidden input called "action", with a value of delete.
Each option in the select list needs to be given a value and text to identify it. This is done by
adding the value attribute to the <option> tag.

The text used to identify the option in the list is entered between the <option> </option>
tags.
Code
<select name="fruit">
<option value="apples">Apples</option>
<option value="pears">Pears</option>
</select>
Question
You are creating an HTML form and wish to place a user input on the screen called "comments" that
enables the user to enter multiple lines of text.

Identify the correct code to enable this.
Options:
1. <textarea name="comments"> </textarea>
2. <input type="text" name="comments">
3. <input type="radio" name="comments">
52

Answer
Option 1: Correct. You can also specify the size of the text input area using rows which specifies
the height of the text area in rows and cols which specifies the character width of the text area
attributes.
Option 2: Incorrect. The code <input type="text" name="comments"> creates a text field
with only one line.
Option 3: Incorrect. The code <input type="radio" name="comments"> creates a radio
button called comments.
Correct answer(s):
1. <textarea name="comments"> </textarea>
Question
Match each tag to its description.
Options:
A. <input>
B. <select>
C. <textarea>
Targets:
1. An empty tag where the type of control displayed depends on the type attribute specified
2. A container tag that creates select lists
3. A tag that creates text area spaces
Answer
The <input> tag is used to create text boxes, checkboxes, radio buttons, and the Submit and
Reset buttons.
The <select> tag also creates multiple select lists.
The <textarea> tag is a container tag.
Correct answer(s):
Target 1 = Option A
53

Target 2 = Option B
Target 3 = Option C
Question
You want to create a form that is used by web site visitors to submit data to a CGI script called
"sendmail.php".

Modify the opening <form> tag by adding the attribute and value that specifies this.
Code
<head>
<title> </title>
</head>
<body>
<form method="get"INSERT THE MISSING CODE
Answer
The tag <form action="sendmail.php"> helps to create a form that is used by web site
visitors to submit data to a CGI script called "sendmail.php".
Correct answer(s):
1. action="sendmail.php"
Summary
Hyperlinks connect web pages both within sites and across the Internet. External links are
hyperlinks to other web pages. Internal links are hyperlinks within the same web page.

Tables can be used to neatly display data in rows and columns. There are a number of HTML
elements within a table, including the <table> tag and the <td> tag. You can also change a
number of table defaults including alignment and color.

Forms are used in web pages to collect data from users and forward it to a CGI script for
processing.The form element is associated with three attributes method, action, and
enctype. You can use various tags to create fields in forms. These are <input>, <select>,
and <textarea> tags.



54

Image Maps and Style Sheets
Learning Objectives
After completing this topic, you should be able to
recognize how to use image maps in web pages
recognize how to apply style sheets to web pages
identify the functions of Cascading Style Sheets
1. Image maps
You can define areas on graphics that a user can click or roll over to trigger an event.

An image map is a set of coordinates that creates a region on a particular image called a hot
spot. Each of these hot spots acts as a hyperlink.
Image maps call either a client-side or a server-side set of coordinates to determine how to
process the user's mouse action.
Server
Server-side image maps require Common Gateway Interfaces, or CGIs, to define their
coordinates.
Client
The coordinates for client-side image maps are embedded in HTML code.
This example of an image map is on a web site that has a montage of vegetables and farmyard
animals on its opening page.

Each of the highlighted areas of the image is defined in the HTML code and references a
specific hyperlink, which usually links to a page related to the subject matter of the image. For
example, you can define an image map, so that it links an image of a carrot to a site with a
recipe for carrot cake.

The image of fruit displayed on the EarthFarm site links to pages about bananas, grapes, and
peaches.
Graphic
The EarthFarm web page has a photograph of a number of pieces of fruit including a bunch of
bananas, a bunch of grapes, and a number of peaches.
Try It
55

You want to view the HTML for the image map.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional/
/EN">
<html><head><title>EarthFarm Produce</title><!
#BeginTemplate "Templates/Earthfarm.dwt" -->
<!-- #BeginEditable "doctitle" --><!-- #EndEditable -->
<meta http-equiv=Content-Type
content="text/html; charset=iso-8859-1">
<SCRIPT language=JavaScript>

<!--

function MM_swapImgRestore() { //v3.0

var i,x,a=document.MM_sr; for(i=0;a&&I
<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

var i,j=d.MM_p.length,a=MM_
preloadImages.arguments; for(i=0; i<a.length; i++)

if (a[i].indexOf("#")!=0){ d.MM_p[j]=
new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.0

var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
To complete the task
1. Select View - Source
Using keyboard: The keyboard alternative is Alt+V, C.
56

The source code is displayed.
You scroll down the page and view the relevant code. All of the image maps are contained
within the <map> tags.
Code
<p><img src="assets/fruit.gif" width="300"
height="245" align="middle" usemap="#earthfarm"
border="0" vspace="0" hspace="75"></p>
<map name="earthfarm">
<area shape="rect" href="banana.html"
coords="11,34,98,180"/>
<area shape="poly"
href="grape.html"
coords="178,165,50,189,81,212,153,211"/>
<area shape="circ"
href="peach.html" coords="227,159,48"/>
</map>
The <area> tag is used to define an area inside the image map. The first image referenced in
the code is of a banana shape. It is defined as a rectangle by using the shape attribute.

The href attribute links the image to a location - in this case, a web page called banana.html.

The coords attribute defines the dimensions of the rectangle within the image based on pixels.
Graphic
The highlighted code for the banana image is as follows:

<area shape="rect" href="banana.html" coords="11,34,98,180">
Code
<p><img src="assets/fruit.gif" width="300"
height="245" align="middle" usemap="#earthfarm"
border="0" vspace="0" hspace="75"></p>
<map name="earthfarm">
<area shape="rect" href="banana.html"
coords="11,34,98,180">
<area shape="poly"
href="grape.html"
coords="178,165,50,189,81,212,153,211">
<area shape="circ"
57

href="peach.html" coords="227,159,48">
</map>
Question
You want to create a client-side image map called "Products".

Type the opening tag.
Code
INSERT THE MISSING CODE
Answer
You type <map name="Products"> to create the opening tag of a client-side image map called
"Products".
Correct answer(s):
1. <map name="Products">
Question
Identify the features of image maps.
Options:
1. Image maps call either a client-side or a server-side set of coordinates
2. Server-side image maps require CGIs to define their coordinates
3. The coordinate system used to define an image map is based on millimeters
4. The shape of an image map is defined using the <map> tag
Answer
Option 1: Correct. Image maps call either the client-side or server-side to determine how to process
the user's mouse action.
Option 2: Correct. The coordinates for client-side image maps are embedded in HTML code.
Option 3: Incorrect. The coordinate system used to define an image map is based on pixels.
Option 4: Incorrect. The shape of an image tag is defined in the <area> tag within the <map> tag.
Correct answer(s):
58

1. Image maps call either a client-side or a server-side set of coordinates
2. Server-side image maps require CGIs to define their coordinates
2. Style sheets
Cascading Style Sheets, also known as CSS, are lists of formatting instructions used to
customize your web page.

You can use style sheets to override some or all of the default properties presented by HTML
elements. The strict flavor of HTML requires you to use only style sheets to impose layout for
your pages.
A CSS style rule has two parts - a selector and one or more declarations.

The selector references the element you want to apply the style to.
Code
h1 {color:green; font-size:10px;}
A declaration contains an attribute and a value to specify the style you want to apply.
Code
h1 {color:green; font-size:10px;}
For administrative purposes, style sheets make site development easier because you can make
design changes to a number of pages centrally.
Style rules can be included directly within an HTML document or grouped within a separate CSS
file which can be attached to the HTML document. External CSS files have the .css file
extension.

There are three standards for CSS CSS1, CSS2, and CSS3. Full support for CSS2 is
widespread with partial support for CSS3.
There are four different implementations of style sheets:
linked style sheets
Linked style sheets are external style sheets that are attached to web pages with the style
definitions held in a separate .css file.

It's a lot quicker to use linked style sheets to reformat an entire web site than it is to alter each
59

web page manually. The style sheet is linked to the web pages that use the style elements from
the style sheet.
imported style sheets
You can import an external .css style sheet file to an HTML document using an import statement.
embedded style sheets, and
You can embed CSS styles within a document. An embedded style sheet is useful when a style is
unique to a particular document. Embedded style rules override any style rules for the same
elements in an imported or linked style sheet.
inline styles
Inline styles are coded into the tag of the element that is affected. Inline styles override any
embedded style rules or imported or linked style rules that may exist for the element. This is why
style sheets are described as "cascading".
Question
Identify the functions of CSS.
Options:
1. Cascading Style Sheets use HTML elements to define the style of a web page
2. You can apply a style rule to a single element, a single page, or a group of documents
3. An embedded style is placed directly within an HTML document
4. The use of style sheets increases administrative load
Answer
Option 1: Incorrect. Cascading Style Sheets use rules, and not HTML elements, to define the style
of a web page. A rule defines the style of an element in a web page such as text.
Option 2: Correct. CSS rules can be applied to entire sites, to a single page or a single element.
Option 3: Correct. The style information is specified by inserting <style> tags between the
<head> tags in a document.
Option 4: Incorrect. You can make changes centrally, so the administrative overhead is actually
diminished.
Correct answer(s):
2. You can apply a style rule to a single element, a single page, or a group of documents
3. An embedded style is placed directly within an HTML document
60

3. Applying style sheets to web pages
An HTML document inherits all changes made to its style sheets.

You can develop two different style sheets to attach to the same HTML document. For example,
you can create a style sheet that deals with applying a serif font and another style sheet that
deals with the colors of the font. The elements of both style sheets are inherited by the HTML
document.
Drill Down Home Page
You can implement style sheet rules using four different methods, each coded in different ways.
Page 1 of 3: Linked style sheets
Linked style sheets control the style elements of multiple pages, which saves space on the web
server. This also means that it takes less time to download pages in a browser.

This is the code of a sample css file.
Code
table { font-family: "Times New Roman", Times, serif; font-
size: small; font-style: normal; color: black; text-
decoration: none}
Page 2 of 3: Linked style sheets
This code is typical of that contained in a web document that links to a style sheet.

The rel attribute defines the relationship between the HTML document and the style sheet,
which is represented by the stylesheet attribute.
Code
<title>Welcome to EarthFarm</title>
<link rel="stylesheet" type="text/css"
href="earthfarmstyle.css">
Page 3 of 3: Linked style sheets
The type attribute defines the Multipurpose Internet Mail Extensions, or MIME, type and the
href attribute indicates the file you're referencing in this case earthfarmstyle.css.
61

Code
<title>Welcome to EarthFarm</title>
<link rel="stylesheet" type="text/css"
href="earthfarmstyle.css">
Page 1 of 1: Imported style sheets
You can combine an imported style sheet with other style sheets. To do this, you create a main
sheet containing declarations that apply to the entire site and partial sheets containing
declarations that apply to specific elements or documents.

To import a style sheet, you include the @import notation between the opening and closing
<style> tags.
Code
<link rel="stylesheet" href="main.css" type="text/css">
<style type="text /css">
@import url(http://www.and.so.on.partial1.css);
@import url(http://www.and.so.on.partial2.css);
</style>
Page 1 of 1: Embedded style sheets
In an embedded style sheet, the style information is specified by inserting the css rules between
<style> tags which are inserted between the <head> tags in the HTML document. Coded
directly into the HTML, the <style> tag allows you to change the formatting of a single web
page.
Code
<head>
<style type="text/css">P{
text-indent: 10px;
}
</style>
</head>
Page 1 of 1: Inline style sheets
Inline styles are entered directly into the element you want to apply the rule to.

For example, to apply a style to a range of text, you can use the style attribute within the
62

<span> and </span> container tags.

These tags encompass the area of text that you want to impose the style on, and set the style
attribute within the <span> tag. This method applies not just to tables but to the formatting of
any text.
Code
<span style="color: red; background:white; font-family: sans-serif; font-
size: 24 px;">Welcome to Earthfarm</span>
Question
Match each type of style sheet implementation to its description.
Options:
A. Embedded style sheet
B. Inline style
C. Linked style sheet
Targets:
1. Styles are applied directly to an element using the style attribute within the tag of the element that is
affected
2. Coded into the web page through HTML, it allows you to change the formatting of a single web page
3. Suited to global design, the style definitions are held in a separate file
Answer
The inline style method is the most specific way of applying style.
Embedded style sheets are suited to formatting individual web pages.
The linked style sheet is linked to web pages that use the style elements from the style sheet.
Correct answer(s):
Target 1 = Option B
Target 2 = Option A
Target 3 = Option C
63

Question
You want to apply a style to a page using a link tag.

When implementing a linked style sheet, between which tags in an HTML page should the <link>
tag be situated?
Options:
1. <body> and </body>
2. <head> and </head>
3. <style> and </style>
Answer
Option 1: Incorrect. The <body> </body> pair of tags define the start and end of the body of a
document.
Option 2: Correct. The <head> </head> pair of tags element can contain information about the
document. This is the location where the <link> tag would be used to link a style sheet to the
document.
Option 3: Incorrect. The <style> </style> pair of tags are used to define styles within the
HTML document to define styles that can be applied to any element within the page.
Correct answer(s):
2. <head> and </head>
Summary
An image map is part of an image or web page that the user can click or roll over to trigger an
event. The area on which the event is triggered is called a hot spot. Image maps are defined in
HTML by their shape and can be linked to other web pages.

CSS are lists of formatting instructions used to customize a web page. You can use them to
apply styles that take priority over some or all of the default properties presented by HTML
elements.

You can apply two or more style sheets to the same HTML document. You can implement style
sheet rules using four different methods - linked style sheets, inline style sheets, imported style
sheets, and embedded style sheets. Linked and imported style sheets reduce overheads
because you can apply them to many web pages.
64

Enhancing Web Pages
Learning Objective
After completing this topic, you should be able to
use advanced HTML elements to enhance a web page
Exercise overview
In this exercise, you're required to create a web page that contains a table, a form, and an
image map and link it to a style sheet.
This involves the following tasks:
adding elements to a table
adding elements to a form
defining image maps, and
linking a Cascading Style Sheet
You want to create a number of web pages with a table, a form, and an image map and link it to
a style sheet for the company EarthFarm.
Task 1: Adding elements to a table
You've added a table to a web page listing some of your company's products. Now you want to
improve the appearance of the table and add some interactive elements.
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitiona;//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table>
Question
You want to add a caption to the table.

Type the opening tag that allows you to do this.
65

Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table>
INSERT THE MISSING CODE
Answer
You type <caption> to open the caption tag.
Correct answer(s):
1. <caption>
You create your caption, which is "Organic Food."
Graphic
This code is referenced:

<table>
<caption>
Organic Food
</caption>
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table>
<caption>
Organic Food
</caption>
<tr>
66

Question
You now want to create a border for the table.

Enter the attribute that enables you to create a border for the table within the table tag and set the
value of this attribute to two.
Code
<body>
<table INSERT THE MISSING CODE>
<caption>
Answer
You type border="2" to create a border for the table and set the value of this attribute to two.
Correct answer(s):
1. border="2"
You add width and cellpadding attributes.
Graphic
The code for this is:
<table width="60%" border="2" cellpadding="5">
Code
<body>
<table width="60%" border="2" cellpadding="5">
<caption>
Organic Food
</caption>
Question
For each product listed in the table, you want to provide a link to a separate page about that
product.

Start by adding the tag that creates a link from the text "Honey" to the web page "honey.html".
Code
<tr>
67

<td>INSERT THE MISSING CODEHoney</td>
<td>1 jar</td>
<td>$8</td>
</tr>
Answer
You type <a href="honey.html"> to begin the process of linking to the honey.html page.
Correct answer(s):
1. <a href="honey.html">
You add the closing anchor tag to create the link.
Code
<tr>
<td><a href="honey.html">Honey</a></td>
<td>1 jar</td>
<td>$8</td>
</tr>
You view the table in your web browser.
Graphic
The table titled Organic Food lists a number of food items, and their prices at given quantities.
Task 2: Adding elements to a form
You've added a form to a page, so that users can submit answers about products that aren't
listed in the table. You need to add some more elements to the form.
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="survey">
68

Question
Specify that this form will be used to submit data by adding the appropriate attribute and value.
Code
<form name="survey" INSERT THE MISSING CODE action="survey.php"
enctype="text/plain">
Answer
You type method="post" to specify that this form will be used to submit data.
Correct answer(s):
1. method="post"
Question
You create your form and you scroll to the bottom of the page to create a text area.

Complete the missing code to add a text area called "notes" to the form.
Code
<br>
Do you like any other vegetables? If so, please specify:<br>
<br>
<INSERT THE MISSING CODE cols="50" rows="8"></textarea><br>
<br>
Answer
You type textarea name="notes" to add a text area called "notes" to the form.
Correct answer(s):
1. textarea name="notes"
Question
Complete the code to add a radio button to the form.
Code
Do you like carrots?
<br>
69

<br>
<input name="like_carrots" INSERT THE MISSING CODE value="Y"> Yes.<br>
Answer
You type type="radio" to add a radio button to the form.
Correct answer(s):
1. type="radio"
You add a second radio button to the form.
Code
Do you like carrots?
<br>
<br>
<input name="like_carrots" type="radio" value="Y"> Yes.<br>
<input name="like_carrots" type="radio" value="N"> No.<br>
<br>
You complete the form.
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="survey" method="post" action="survey.php"
enctype="text/plain">

<strong>Quick survey:</strong><br>
<br>
We are considering adding carrots to our list of organic
vegetables.<br>
<br>
Do you like carrots?
<br>
<br>
<input name="like_carrots" type="radio" value="Y"> Yes.<br>
70

<input name="like_carrots" type="radio" value="N"> No.<br>
<br>
What are your favorite vegetables?<br>
<br>
<select name="favourite_veg" size="6" multiple>
<option value="Beans">Beans</option>
You view the form in your web browser.
Graphic
The form has Yes/No radio buttons asking the question "Do you like carrots?" There is also a select
list on the form asking "What are your favorite vegetables?" The list has the following vegetables:
Beans, Broccoli, Celery, Peppers, Potatoes, and Tomatoes. Following this is a text box asking the
user to specify what other vegetables they like.
Task 3: Defining image maps
One of the pages on EarthFarm's site contains an image that you want to use as an image map.
It will contain links to different parts of the site. You've added the code for the image map, but it's
missing some elements.
Question
You view the HTML code for the web page that contains the image.

Enter the value and attribute that link the image map "earthfarm" to the image.
Code
<P>
<img src="assets/fruit.gif" width="300" height="245"
align="middle" INSERT THE MISSING CODE border="0"
vspace="0" hspace="75">
</P>
Answer
You type usemap="#earthfarm" to attach the image map "earthfarm" to the image.
Correct answer(s):
1. usemap="#earthfarm"
Question
71

The tag that defines the shape and coordinates for the hot spot is missing some elements.

Enter the code that enables you to define the shape and coordinates.
Code
<map name="earthfarm">
INSERT THE MISSING CODE="rect" href="banana.html"
coords="11,34,98,180">
Answer
You type <area shape to define the shape.
Correct answer(s):
1. <area shape
You create other image maps using the rest of the image.
Code
<map name="earthfarm">
<area shape="rect" href="banana.html"
coords="11,34,98,180"/>
<area shape="poly" href="grape.html"
coords="178,165,50,189,81,212,153,211"/>
<area shape="circ" href="peach.html"
coords="227,159,48"/>
Question
Enter the closing tag for the image map.
Code
<map name="earthfarm">
<area shape="rect" href="banana.html"
coords="11,34,98,180"/>
<area shape="poly" href="grape.html"
coords="178,165,50,189,81,212,153,211"/>
<area shape="circ" href="peach.html"
coords="227,159,48"/>
INSERT THE MISSING CODE
Answer
72

You type </map> to add the closing tag to the image map.
Correct answer(s):
1. </map>
You view the image map in your web browser.
Graphic
The EarthFarm web page contains a picture with a number of items of fruit including a bunch of
bananas, a bunch of grapes, and a number of peaches.
Task 4: Linking a style sheet
You've decided to use a linked style sheet to give your site a consistent look and feel. You've
added the relevant code to the home page but some elements are missing.
Code
<title>Welcome to EarthFarm</title>
rel="stylesheet" type="text/css"

<script language="JavaScript">
Question
Enter the tag for applying a linked style sheet to the web page.
Code
<title>Welcome to EarthFarm</title>
INSERT THE MISSING CODE rel="stylesheet" type="text/css"

<script language="JavaScript">
Answer
You type <link> to apply a linked style sheet to the web page.
Correct answer(s):
1. <link>
73

Question
Complete the <link> tag by entering a hypertext reference to the style sheet "earthfarmstyle.css".
Code
<title>Welcome to EarthFarm</title>
<link rel="stylesheet" type="text/css"
INSERT THE MISSING CODE
<script language="JavaScript">
Answer
You add a hypertext reference by typing href="earthfarmstyle.css"
Correct answer(s):
1. href="earthfarmstyle.css"
You view the web page in your browser. The style sheet has been applied to the web page.












74

Client-side and Server-side Scripts
Learning Objectives
After completing this topic, you should be able to
distinguish between client-side and server-side scripting
identify the common scripting and programming languages
1. Client-side and server-side scripting
HTML is ideal for displaying images and text in a page on the Web. However, it doesn't provide
the functionality or support for more advanced web applications such as e-commerce or online
collaborations.

Scripting is used to add this functionality. The term scripting is used to indicate that a computer
language will react to, control, or "script" a series of events. Scripts are program statements that
perform tasks independently of other programming languages. They allow programmers to
extend the basic functionality of HTML.
Developers use scripts to add active content, such as clocks and hit counters, to web pages.
They can also be used to identify browsers and customize web pages.
Scripts can be classified as
server-side or
Server-side scripts are executed on the server.
client-side
Client-side scripts are executed at the client computer.
A server-side script is a compilation of commands and functions that are executed when called
on the server. It enables you to perform a series of functions before creating dynamic HTML
pages containing resulting output from the script. These pages are then sent to the browser.

Such scripts are executed using a Common Gateway Interface, or CGI. This standard allows the
web server to pass scripts to programs running outside of the web server service, and which
process the scripts.

Some of the commonly used server-side scripting languages and application frameworks are
ASP.NET, PHP, and JSP.
Animation
75

In this example of server-side scripting, a remote client sends a query across the Internet to a
server. The server executes a server-side script, and sends back its response.
Server-side scripting is commonly used for connections to databases, database processing,
session management, and dynamic generation of HTML files.

These scripts aren't dependent on browser type. They can be used to detect the type of browser
and then output a particular version of a web page that is fully compatible with it.
Client-side scripts execute after a web page has downloaded to a client computer. They are
executed by the client's browser to create active or dynamic content, such as displaying the
current date and time.

They embed instructions for active content in simple HTML files. These instructions are usually
written using client-side scripting languages such as JavaScript and VBScript.

These scripts can be used for various functions for example, validating data inputted into a
form before it's sent to the server for processing.
Client-side scripting leaves the web server free to process requests from a larger number of
clients by getting the client to perform certain functions. However, the embedded scripts
increase the size of web pages, so they can marginally increase download times.

A client-side script's functionality depends on the type of browser. For these scripts to run,
scripting must be enabled in the browser and the browser must be able to support the particular
language.
Certain functions may be compatible with one type of browser but not with another. To ensure
that the script functions properly on all browsers, developers use a technique called cross-
browser scripting. This enables them to detect the browser type and version and run a version of
the script that is suited to it.
Question
What are the potential disadvantages of client-side scripting?
Options:
1. It is browser dependent
2. It places a strain on the server
3. It can't access databases
4. It increases HTML page size
Answer
76

Option 1: Correct. Scripting needs to be enabled in the browsers and some browsers may not
support certain scripts. A technique called cross-browser scripting can be used to overcome some
of these limitations.
Option 2: Incorrect. Client-side scripting is carried out on the client so these scripts place no
processing load placed on the server.
Option 3: Correct. Databases are stored on the server and server-side scripting is required to
access them.
Option 4: Correct. The client-side scripting code added to HTML pages will increase the page file
sizes by varying amounts depending on the amount of code used.
Correct answer(s):
1. It is browser dependent
3. It can't access databases
4. It increases HTML page size
2. Scripting and programming languages
JavaScript is one of the most popular client-side scripting languages. It was designed to add
interactivity to HTML pages.

There are several versions of JavaScript and the various browsers support these differently. To
get around this issue, you can add version-specific sections of the code, which will only be
executed by browsers that support each version.

JavaScript can exist on its own in .js text files or it can be incorporated directly into HTML pages
with these tags.
Graphic
The tags are
<script language="JavaScript">
and
</script>
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Displaying the date using Javascript</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
77

</head>

<body>
<script language="JavaScript">

var today = new Date();

document.write(today);

</script>
</body>
</html>
VBScript, or the Microsoft Visual Basic Scripting Edition language, is an offshoot from the Visual
Basic programming language. It was developed by Microsoft and it's used to develop client-side
and server-side scripts.

VBScript provides an easy-to-use web development language for developers who know Visual
Basic. It is incorporated into HTML documents to make them more dynamic.
Code
<html>

<head>

<title></title>

</head>

<body>

<script type="text/vbscript">
document.write("Hello World")
</script>

</body>

</html>
ASP.NET is a web application framework that has been developed by Microsoft so that
programmers are able to create dynamic web sites, web applications, and web services.
ASP.NET was created along with the .NET framework, and is the successor to ASP. It uses the
CLR so that programmers can use any supported code for writing code.
Code
78

<html>

<head>

<title></title>

</head>

<body>

<%
response.write("Hello World")
%>

</body>

</html>
ASP.NET is browser independent, which means that all code is processed on the server and
then sent back to the browser as HTML. Using ASP.NET you can combine many .NET services
from different sources.

ASP.NET supports combining many .NET services from different sources, as well as creating
reusable components through the creation of user controls. When you use ASP.NET, you can
add your own properties, methods, and event handlers, and you can also build custom controls
for ASP.NET applications.
Code
<html>

<head>

<title></title>

</head>

<body>

<%
response.write("Hello World")
%>

</body>

</html>
79

Some of the other scripting and programming languages are
the C languages
The C languages include C++ and C#. C++ is a middle-level language that is a statically typed,
free-form, multi-paradigm, compiled, and general-purpose.

C# is a strongly typed object-oriented language in the Microsoft .NET Framework designed to
give the best combination of simplicity, expressiveness, and performance. It's intended to be a
simple, modern, general-purpose, object-oriented programming language.
Visual Basic
Visual Basic is a natural language with a case-insensitive approach that supports optional
parameters. It is part of the .NET Framework. A benefit of Visual Basic is simpler event handling.
Java
Java is a powerful programming language used to build Internet applications. It's designed to be
independent of the operating system and the computer on which it runs. It can be used to develop
applications and applets.

Applications are standalone programs that can be launched independently of other programs and
which have access to the host system. Applets are programs that need an applet viewer or a web
browser to run them and they don't have access to the host system.
JSP
JSP stands for JavaServer Pages. It provides a way to dynamically generate web pages and
simplifies the process of developing web-based applications.

JSP-enabled pages use a combination of HTML, XML, and short Java scripts that, when
compiled, make up servlets. Servlets are small programs which run on servers. JSP-enabled
pages are similar in form and function to pages containing PHP or ASP.NET. JSP uses the
<%....%> tags to contain the script in an HTML file.
Perl, and
Perl stands for Practical Extraction and Report Language. It is a programming language that
combines syntax from several UNIX utilities and languages.
PHP
Question
Match each scripting language to its description.
Options:
A. JavaScript
B. VBScript
80

C. ASP
D. Java
Targets:
1. A client-side script with the .js file extension
2. An offshoot of a Microsoft programming language
3. A Microsoft server-side based scripting environment
4. A powerful programming language used to build Internet applications
Answer
JavaScript is one of the most popular client-side scripting languages. JavaScript was designed to
add interactivity to HTML pages.
VBScript is a scripting language offshoot from VB, developed by Microsoft, which is used to develop
client-side and server-side scripts.
ASP extends standard HTML by adding built-in objects and server-side scripting, and by allowing
access to databases and other server-side ActiveX components.
Java is designed to be independent of the operating system and the computer on which it is run.
Java can be used to develop applications and applets.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Summary
Scripts are used to extend the functionality of applications and to make HTML pages dynamic.
Client-side scripts are run on the client computer and execute after a web page has downloaded
to a client computer. Server-side scripts are run on a server when web pages are accessed on
the server.

There are many scripting and programming languages used today for web development and for
building applications. JavaScript is an example of a client-side scripting language and ASP.NET
is a server-side scripting environment. VBScript can be used to write client-side or server-side
scripts.
81

Advanced Markup Languages
Learning Objectives
After completing this topic, you should be able to
define DHTML and the DOM
recognize how XHTML relates to XML and HTML
identify the characteristics of XML
identify common platforms for delivering web content to wireless devices
1. Understanding DHTML and the DOM
Dynamic HTML, known as DHTML, is a combination of technologies that enable you to create
advanced interactive web sites. Although HTML is used to create static web elements, the
addition of scripting languages such as JavaScript provide enhanced functionality and enable
elements on web pages to be used dynamically.

The technologies most commonly used to create dynamic web sites include HTML, JavaScript,
and Cascading Style Sheets or CSS.

One example of dynamic HTML elements is having the color of a text heading change when a
user passes their mouse over it. Another is allowing a user to "drag and drop" an image to
another place on a web page.
DHTML works in conjunction with event handlers. These enable a web page to react to user
input without having to send requests to the web server, reload, or refresh the page.

Different browsers handle events differently so DHTML code will differ slightly from one browser
to the other.
In a web page, each page element is viewed as an object. Elements can include a division or
section, heading, paragraph, image, and list. The Document Object Model or DOM lists and
gives you access to every object in a document. It defines what attributes are associated with
each object, and how the objects and attributes can be manipulated.
The DOM is designed to be vendor-neutral to help standardize the methods for creating
dynamic content. However, it is not implemented identically in all browsers.

The DOM helps to dynamically change formatting. It can also be used to control the size of the
browser window and turn on and off toolbars and menu bars.
Question
Identify the features of the DOM.
82

Options:
1. It allows the browser window to be resized and toolbars and menu bars to be turned on and off
2. It represents all the objects in a web page
3. It is implemented identically by all browsers
4. It only applies to Microsoft web browsers
Answer
Option 1: Correct. The DOM can be used to manipulate certain browser applications.
Option 2: Correct. Each web page element is considered to be an object and the DOM represents
all the objects in a web page.
Option 3: Incorrect. DOM is not implemented exactly the same way in each browser. Each browser
implements its own version of the DOM.
Option 4: Incorrect. The DOM is intended as a vendor-neutral specification, making it applicable in
all browsers.
Correct answer(s):
1. It allows the browser window to be resized and toolbars and menu bars to be turned on and off
2. It represents all the objects in a web page
2. Understanding XML and XHTML
Extensible Markup Language, known as XML, is a text-based language that describes the
structure of documents. It's a specification developed by the World Wide Web Consortium,
known as W3C, to separate the structure of data from its format.

XML doesn't format data it describes it. As with HTML, XML uses markup tags, but has itself
no predefined sets of tags. It allows you to define your own tags, which is what is meant by the
term "extensible." The tags are used to describe data.
XML is a pared-down version of the Standardized General Markup Language, or SGML, and it's
designed especially for web documents. XML has the functionality of SGML but is not as
complex.
XML documents need to include a Document Type Definition, or DTD. This defines the validity,
meaning, and function of every tag used in the XML document. Without it, the XML document
won't function.

The DTD can be placed in the XML document or in a separate file. If a DTD is in a separate file,
it can be linked to all XML documents of the type defined in the DTD.
83

XML developers try to achieve certain design goals.

XML should
be easy to use on the Internet
Ease of use on the Internet was XML's first design goal and was achieved by developing XML to
use existing Internet protocols. XML has been simplified to the degree that Internet applications
can process it as quickly as they would process HTML.
support a wide variety of applications
XML should support a wide variety of applications. This will allow applications that work outside
the World Wide Web, such as databases and word processors, to be developed to support XML.
be compatible with SGML
XML should be compatible with SGML. This gives it the flexibility of a generalized markup
language and ensures that it conforms to a widely accepted standard.
keep optional features to a minimum
XML should keep the number of optional features to an ideal minimum of zero. Optional features
would lead to compatibility problems when documents are shared. Having no optional features
results in greater compatibility between users.
be fully legible and reasonably clear, and
XML documents should be fully legible and reasonably clear. They also have definable tags that
enable developers to use meaningful names for tags. So you should be able to read XML code
with a text editor rather than a browser.
consist of plain ASCII text
XML documents should consist of plain ASCII text like HTML so that anyone can create or
edit them in a text editor.
Question
Identify the features of XML.
Options:
1. An XML document requires a DTD to function
2. It allows you to create your own tags
3. XML is a simplified version of SGML
4. Documents do not have to be well formed
Answer
84

Option 1: Correct. The DTD describes the meaning and function of each tag in an XML document.
The XML document will not function without it.
Option 2: Correct. XML is extensible, which means that you can define your own tags for describing
data.
Option 3: Correct. XML is a less complex version of SGML that was developed for the web.
Option 4: Incorrect. Documents must be well formed with tags closed, elements correctly nested,
and elements and attributes in lower case.
Correct answer(s):
1. An XML document requires a DTD to function
2. It allows you to create your own tags
3. XML is a simplified version of SGML
Extensible HTML, known as XHTML, is a combination of HTML and XML. It takes the features
of HTML and combines them with the data description abilities of XML. It is written using XML
and is designed to replace HTML. XHTML documents have to be very well-formed. This means
that, unlike HTML, XHTML documents can be parsed using standard XML parsers.
The basic structure of an XHTML page includes a Document Type Declaration, or DOCTYPE.
This validates the document as a valid XHTML document through a Document Type Definition,
or DTD.
This is an example of the structure of a DOCTYPE. The first line is an XML declaration, which
includes the version of XML being used, the encoding scheme, and the DTD location. The DTD
follows the XML declaration, and the DTD is followed by the namespace.
Code
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>An XHTML 1.0 Strict standard template</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
</head>
<body>
<p> ... Your HTML content here ... </p>
</body>
</html>
85

The namespace uniquely identifies duplicate elements that have differing values, or can be used
to identify different languages used in the document. The namespace is followed by the
character data, or CDATA, which is the content. If the content is code, it is referred to as parsed
character data, or PCDATA.
Finally, after the CDATA and PCDATA, the document contains white space. XHTML ignores
white space in much the same way that HTML does, except that white space is included when
inserted within quotation marks.
3. Web content for wireless devices
Wireless Application Protocol, known as WAP, is an open specification designed to enable
mobile devices to access the Internet. Such devices include cellular phones, personal digital
assistants, known as PDAs, and pagers.

Using WAP means that these devices can be used to read and send e-mail and access web
sites. However, viewable content may be reduced due to hardware limitations in many mobile
devices.
WAP 2.0 was released in 2002 and is a reworked version of WAP that uses a cut-down version
of the XHTML that has end-to-end HTTP.

Mobile devices make use of XHTML Mobile Profile, known as XHTML MP, which is the markup
language as defined by WAP 2.0.
The Wireless Markup Language is the language that was initially used to allow a WAP browser
to display text sections of web pages on cell phones and PDAs via wireless access. Referred to
more commonly as WML, it is based on XML and is used to specify user interface and content
for all narrowband, WAP-enabled devices. WML is an industry standard that has been optimized
for small displays.
However, WML has some disadvantages:
limited computational power
WML's limited computational power is a problem. WMLScript was developed to address this
issue and is based on JavaScript technology. When integrated with WML, it creates a more
powerful programming interface. However, when compared with other languages, WML and
WMLScript are still limited in computational power.
constrained by device limitations, and
Small display size is a major constraint of wireless devices. The development of WML may be
hindered by the limitations of the wireless devices available.
slow connection speeds
86

The slow download times can lead to prohibitively expensive call charges, which can effect the
uptake of WAP services.
WML is now not widely used and has largely been replaced by XHTML Mobile Profile code. This
is an improvement on HTML and WML that contains some attributes of both preceding
languages. This code contains a start tag, such as an element name and its attributes, then the
element attributes, and finally a closing tag.
Code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.1//EN"
"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>XHTML MP Example</title>
</head>
<body>
<p>Example of an XHTML MP document.</p>
</body>
</html>
This is the syntax for using XHTML MP code.
Code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.1//EN"
"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>XHTML MP Example</title>
</head>
<body>
<p>Example of an XHTML MP document.</p>
</body>
</html>
Syntax
<element attribute="value">element content</element>
XHTML MP contains support for many modules, including text, hypertext, list, forms, basic
tables, image, objects, meta information, scripting, style sheet, style attribute, link, and base.
Partial support is available for presentations, intrinsic events, and legacy.
87

XHTML MP also has a module known as Text Input Modes that deals with all the different kinds
of input available when using mobile devices.
Many HTML module elements are supported within XHTML MP. However, tables should be
used minimally because support for them in mobile browsers is not good.
Some important points to remember when writing XHTML MP code are that
documents must be well formed
tags must be closed
elements must be properly nested
elements and attributes must be in lowercase
attribute values must be enclosed with quotes
attributes can't be minimized, and
XHTML entities must be handled properly
Question
What are the advantages of XHTML MP?
Options:
1. Many HTML module elements are supported
2. Partial support is available for presentations
3. Partial support is available for hypertext
4. It has limited computational power
Answer
Option 1: Correct. Most HTML module elements are supported by XHTML MP, although tables can
be tricky and should be used sparingly.
Option 2: Correct. XHTML MP provides partial support for presentations, intrinsic events, and
legacy.
Option 3: Incorrect. XHTML MP provides full support for hypertext.
Option 4: Incorrect. Limited computational power is a disadvantage of WML.
Correct answer(s):
88

1. Many HTML module elements are supported
2. Partial support is available for presentations
Summary
DHTML combines HTML, CSS, and DOM to create dynamic and interactive web content. The
DOM lists and gives you access to every object in a document.

XML is a text-based language that describes the structure of digital documents. It's a light
version of SGML. XML documents need to include a DTD. XHTML is a combination of HTML
and XML. It takes the features of HTML and combines them with the data description abilities of
XML.

WAP is an open specification designed to enable mobile devices to access the Internet. WAP
2.0 was released in 2002 and is a reworked version of WAP. XHTML MP, which is the markup
language as defined by WAP 2.0, is an improvement on HTML and WML that contains some
attributes of both preceding languages.














89

Managing and Connecting to Databases
Learning Objectives
After completing this topic, you should be able to
recognize the characteristics of common database models
identify the function of a database management system (DBMS)
recognize the standards and technologies that facilitate database connectivity
1. Database management systems
A database management system, known as a DBMS, is software that allows you to store,
access, and edit data in an organized and secure way. It also allows you to regulate
simultaneous database entries by multiple users.

DBMSs are distributed systems, which means they can be dispersed or replicated among
different computers in a network.
Databases can be non-relational, relational, or object-oriented.
Non-relational
A non-relational, or flat-file, database organizes data in a single table.
Relational
A relational database organizes data in multiple, related tables, each of which may use a different
format for its entries.
Object-oriented
An object-oriented database supports the modeling and creation of data as objects.
DBMSs allow you to work with both hierarchical and network database types.
Hierarchical database
In a hierarchical database, such as a mainframe, one record contains physical links to another.
This means that only one user at a time can access the records.
Network database
In a network database, records are linked to each other in such a way that multiple users can
access records simultaneously.
You manage relational databases using a relational DBMS, known as an RDBMS.

You manage object-oriented databases using an object DBMS, known as an ODBMS.
90

These database management systems work in different ways.
RDBMS
An RDBMS uses Structured Query Language, known as SQL, to construct database queries.
Examples of RDBMS products are Microsoft Access, Oracle 8, the IBM DB2 family, Sun
NetDynamics server, InterBase InterServer, InterClient, d-BASE, Paradox, and Microsoft SQL
Server.
ODBMS
An ODBMS uses Object Query Language, known as OQL, to construct database queries. You
can use it to bridge DBMS and RDBMS solutions.

ODBMSs support Java and allow you to use a custom interface with familiar command structures.
They are also faster, simpler to search, and easier to maintain than database and relational
database management systems. And they provide better recovery from errors.
Question
Which statements accurately describe how database systems work?
Options:
1. An RDBMS uses SQL to construct database queries
2. In a hierarchical database, multiple users can access records simultaneously
3. In a network database, only one user at a time can access records
4. An ODBMS supports Java and allows you to use a custom interface
Answer
Option 1: Correct. RDBMSs use some form of SQL to make requests to the database server for
information retrieval and updates.
Option 2: Incorrect. Because each record contains physical links to another in a hierarchical
database, access to a record is locked to other users while it is being accessed by one user.
Option 3: Incorrect. Instead of using a single-parent tree hierarchy, the network model allows child
records to have more than one parent, enabling it to support many-to-many relationships.
Option 4: Correct. You use Object Query Language, or OQL, to construct database queries.
ODBMSs are faster, easier to maintain, simpler to search, and provide better recovery from errors
than DBMSs and RDBMSs.
Correct answer(s):
91

1. An RDBMS uses SQL to construct database queries
4. An ODBMS supports Java and allows you to use a custom interface
2. Database model characteristics
Most transactions over an intranet, extranet, or the Internet involve accessing or modifying the
contents of a database. Apart from the actual database, database-driven web sites require
various other components.
In addition to data storage, you require a query language or other method of accessing and
retrieving data from a database. This access method is called the process logic.

You also need a user interface that provides access to run process logic and present the
returned data in a well-organized and readable form.
The distribution of the data storage, process logic, and user interface elements of a database is
often organized according to four database models.
1-tier
The 1-tier database model is the classic model for database access.

In this model, one computer is responsible for the user interface, process logic, and data storage
functions.
2-tier
The 2-tier database model divides the database management functions between the server and
the client. In this model, the server is responsible for data storage and the client is responsible for
the user interface.

The process logic can run on either computer.
3-tier
In the 3-tier database model, the user interface runs on the client. The process logic runs on an
application server, and the database resides on a database server.

The thin client solution is an example of a 3-tier model. In this solution, the web browser accesses
a database server via a web server.

The 3-tier model is useful in environments where the stored data is sensitive. The database can
be stored behind a firewall with access from external sources limited to a single web server.
n-tier
The n-tier database model is one where the application program is distributed among three or
more separate computers in a distributed network.

92

The first tier consists of the user interface software, usually called the front end. The data servers,
often referred to as the back end, make up the third tier. The second tier is where the business
logic is handled. Additional tiers in the application are usually added between the web server and
that data server. These tiers are referred to as middleware.
Because the n-tier model uses multiple computers to manage the process logic, the system load
remains balanced. This means that no computers become overloaded with requests for
database access.

The n-tier model also leads to performance enhancement because each service runs on a
system dedicated to performing that function. There is always a computer available to manage
the process logic if one of the other computers fails.
Graphic
The diagram of an n-tier database model shows a computer connected through the Internet to three
web servers. These, in turn, are connected to a database server.
Question
Your database access solution consists of a database server, multiple clients that each provide a
user interface, and an application server that performs the process logic.

What kind of database model have you implemented?
Options:
1. 1-tier
2. 3-tier
3. 2-tier
Answer
Option 1: Incorrect. A 1-tier model comprises a single computer that is responsible for the user
interface, process logic, and data storage functions.
Option 2: Correct. The 3-tier model consists of one or more clients as the first tier, an application
server for the second tier, and a database server as the third tier.
Option 3: Incorrect. The 2-tier model consists of a client and a server. The server is responsible for
data storage and the client is responsible for the user interface.
Correct answer(s):
93

2. 3-tier
3. Database connectivity standards
To access a data store, you need to create a data access application that includes data query
statements and you need to implement a database application programming interface, or API.
You can use different APIs to access data stores. These include Open Database Connectivity,
known as ODBC, Object Linking and Embedding Database, referred to as OLE DB, and Java
Database Connectivity, known as JDBC.
The ODBC standard was developed by Microsoft. Its main purpose is to provide a consistent
application programming interface, known as an API, to many different types of RDBMS
applications.

ODBC resides between the RDBMS and the application being used to access and manipulate
data. A driver for the RDBMS must be installed and registered with the operating system in
order for an ODBC-compliant application to interact with it.
The ODBC driver receives instructions from applications. These requests are translated into a
form that the database understands before being issued to it.
OLE DB was developed by Microsoft and is similar to ODBC except that it can access data
sources other than databases.
The JDBC standard was developed by JavaSoft, a subsidiary of Sun Microsystems. It helps the
database to understand and reply to the client's data requests. Unlike ODBC, which is largely
related to Microsoft operating systems, JDBC is platform independent.
Methods to enable database access and data management include
ColdFusion
ColdFusion was developed to facilitate server-end database access. It uses its own proprietary
language, ColdFusion Markup Language, which is known as CFML. ColdFusion files are called
templates and use the .cfm extension.

The main advantage of ColdFusion is its simplicity. Whereas many scripting languages are
derived from difficult programming languages, ColdFusion uses the syntax of HTML tags, so it's
easy for non-programmers to use. The tags, all starting with the letters CF, are parsed and
executed by the server before the page is returned to the client.
ADO.NET
ADO.NET is the Microsoft standard for accessing data sources such as SQL Server and XML.
Active Server Pages, or ASP.NET, works with ADO.NET to provide web sites with data access
capabilities.
scripting languages, and
94

Scripting languages play an important role in web database interfacing. Their strengths lie in their
portability and ease of use. CGI programming with Perl is one of the most common methods for
accessing and displaying data from a relational database on the Web. Perl stands for Practical
Extraction and Report Language. Other scripts include PHP and MySQL.
save as HTML
Many current database products allow you to save a database as an HTML file. As a result, you
can publish the database tables directly to a web server as HTML. This method is limited and
does not offer much functionality.
ADO.NET distinguishes between data access and data manipulation so that they can be used
separately or together. It includes .NET framework data providers that can connect to databases
and execute commands as well as retrieve results.

Different providers can be used with ADO.NET to access SQL Server or Oracle data sources or
sources exposed by ODBC, or OLE DB.
It's possible for Perl scripts to retrieve database information indirectly from a text file. However,
it's more efficient to employ Perl extension products to gain dynamic database access.

PHP, or Hypertext Preprocessor, is another popular language for building dynamic web pages. It
is widely regarded as a more efficient language than Perl for making your HTML pages
communicate with a database. A common database that is used with PHP is MySQL. In
combination, MySQL and PHP are often used for blogs, bulletin boards, and calendar
applications.
Question
Which technologies can be used to connect to a database?
Options:
1. ADO.NET
2. ColdFusion
3. PHP
4. XML
Answer
Option 1: Correct. ADO.NET is the Microsoft standard for accessing databases. ASP.NET works
with ADO.NET to provide web sites with data access capabilities.
Option 2: Correct. ColdFusion was developed to facilitate server-end database access. It uses its
own proprietary language known as CFML.
95

Option 3: Correct. PHP is commonly used to access MySQL data.
Option 4: Incorrect. A data source can be in XML format and can be accessed using a data access
technology and a data provider such as OLE DB.
Correct answer(s):
1. ADO.NET
2. ColdFusion
3. PHP
Summary
Most transactions over an intranet, an extranet, or the Internet involve accessing or modifying a
database. Databases can be non-relational, relational, or object-oriented.

Database systems may be organized in a 1-tier, 2-tier, 3-tier, or n-tier model. DBMS is software
that allows you to store, access, and edit data in an organized and secure way. It allows you to
work with hierarchical and network database types. You manage relational and object-oriented
databases using RDBMS and ODBMS.

You manage object-oriented databases using an object database. Two standards govern these
forms of access. They are the ODBC and the JDBC standard. You can use several methods
and applications for database access and management.










96

Understanding Advanced Web Techniques
Learning Objective
After completing this topic, you should be able to
distinguish between different scripting languages and database technologies
Exercise overview
In this exercise, you're required to distinguish between different scripting languages and
database technologies.
This involves the following tasks:
choosing a scripting language and
choosing a database model
You're a network administrator working for EarthFarm LLC. The company is planning a new
database-driven web site. The management team is not familiar with scripting languages or
database models, so you've been asked to research and write a report on the implementation
options available to them.
Task 1: Choosing a scripting language
Your first task is to explain why server-side scripting is more suited to the company's needs than
client-side scripting.
Question
Why should server-side scripting be used?
Options:
1. Client-side scripts connect directly to a database to process queries
2. It facilitates dynamic site content
3. It is required to query a database and provide feedback to users
4. It allows the client process information independently of the server
Answer
Option 1: Incorrect. A browser can only process client-side scripts, which are limited in their
functionality and can't connect directly to a database to process queries.
97

Option 2: Correct. Server-side scripting can build HTML pages dynamically from database content
and send the pages to the user's computer.
Option 3: Correct. Server-side scripting allows users to access a database and to send the relevant
data back to the user's computers.
Option 4: Incorrect. Server-side scripting is always carried out on the server. The client uses client-
side scripting to process information independently of the server.
Correct answer(s):
2. It facilitates dynamic site content
3. It is required to query a database and provide feedback to users
Question
Now you need to specify some of the scripting languages that EarthFarm could use.

What are the scripting languages or application frameworks that you could use?
Options:
1. ASP.NET
2. JavaScript
3. HTML
4. PHP
Answer
Option 1: Correct. ASP.NET is a server-side application framework developed by Microsoft. It
allows access to databases as part of Microsoft's .NET Framework.
Option 2: Incorrect. JavaScript is incorporated in HTML files or stored in separate .js text files. It is a
client-side script, which is processed by the browser.
Option 3: Incorrect. HTML is a markup language that presents text and images for display in the
browser software of a client machine.
Option 4: Correct. PHP is a powerful open-source, server-side scripting language.
Correct answer(s):
1. ASP.NET
4. PHP
98

Question
You've decided to recommend a specific scripting language for EarthFarm to use. This language
should always run on the server, natively support connections to several different types of
databases, and be open-source software.

Which scripting language would you recommend?
Options:
1. ASP.NET
2. HTML
3. PHP
4. VBScript
Answer
Option 1: Incorrect. ASP.NET is a server-side scripting language developed by Microsoft.
Option 2: Incorrect. HTML is a markup language and doesn't provide database connectivity.
Option 3: Correct. PHP is a server-side scripting language. It is open source, which means anyone
can contribute to its development. It supports connections to many types of databases but it is most
often used with the free database MySQL.
Option 4: Incorrect. VBScript is a scripting language offshoot from the Visual Basic programming
language. It is used to write client-side and server-side scripts.
Correct answer(s):
3. PHP
Task 2: Choosing a database model
In your report, you want to talk about the different types of management systems and database
models that exist.
Question
In your report, you explain the multitiered computing models.

Match the 3-tier components with their descriptions.
Options:
99

A. Application server
B. Client
C. Database server
Targets:
1. Runs the user interface
2. Runs the process logic
3. Manages data storage
Answer
The user interface programming is carried out at the client.
The application server uses rules to determine how user requests for data are communicated to the
database server.
The database server contains the database and the services that control access to the data.
Correct answer(s):
Target 1 = Option B
Target 2 = Option A
Target 3 = Option C
You decide to recommend an RDBMS for EarthFarm.
Question
Identify the features of a relational database.
Options:
1. A single database can be spread across several tables
2. It is managed using an ODBMS
3. Data is stored in a single table
4. It is easy to extend
Answer
Option 1: Correct. Relational databases are different to flat-file databases, in which each database
is self-contained in a single table.
100

Option 2: Incorrect. Relational databases are managed using an RDBMS. Object-oriented
databases are managed using an ODBMS.
Option 3: Incorrect. Data is stored in multiple tables so that it can be accessed or reassembled in
many different ways without having to reorganize the database tables.
Option 4: Correct. You can add new data categories to relational databases without requiring that
all existing applications be modified.
Correct answer(s):
1. A single database can be spread across several tables
4. It is easy to extend
Question
Which language is used to access the records in an RDBMS?
Options:
1. OQL
2. JavaScript
3. PHP
4. SQL
Answer
Option 1: Incorrect. An ODBMS, rather than an RDBMS, uses OQL to construct database queries.
Option 2: Incorrect. JavaScript is a client-side scripting language. JavaScript does not possess the
required functionality to connect to or query a database.
Option 3: Incorrect. PHP is a server-side scripting language that builds HTML pages from database
content. Functions exist within PHP to send SQL queries to, and receive result sets from, a
database.
Option 4: Correct. SQL, which stands for Structured Query Language, is used to query information
in the tables of a relational database.
Correct answer(s):
4. SQL

101

EXCEL

Opening an Excel 2010 Workbook
Learning Objectives
After completing this topic, you should be able to
start Excel 2010 and open an existing workbook
identify the features of spreadsheets
1. Worksheets in Excel
Microsoft Excel 2010 is a powerful application that you can use to work with several kinds of
worksheets such as budgets, expense requests, or time sheets. You can use Excel to
organize, manage, compare, and view data. It also assists you with financial calculations and
generating graphs.
Graphic
Some sample Excel worksheets are budgets, outlining the estimated and actual expenditure, time
sheets, and graphs such as pie charts to show the actual cost breakdown, for example.
In the past, accountants used paper-based ledgers to record data and perform calculations.
These days, spreadsheet applications like Excel 2010 enable you to work with data in an
electronic form.
Like traditional ledgers, electronic spreadsheets consist of rows, columns, and cells into which
you can enter information.
Select each spreadsheet element to learn more about it.
Graphic
The Expense Budget December spreadsheet is open in Excel. The Excel interface includes several
default elements a mini toolbar, a Ribbon containing more commands, and a formula bar. The
spreadsheet itself appears below those elements.
Row
A row is a horizontal arrangement of cells. In Excel, rows are distinguished by numbers.
In this case, row 7, displaying the Retirement fund budget and actual expenses, has been
selected.
102

Column
A column is a vertical arrangement of cells. In Excel, these are distinguished by letters of the
alphabet.
In this case, column F, showing the difference between the budget and actual expenses for
different expenses has been selected.
Cell
A cell is a box into which you can enter data either numbers, text, or formulas. Each cell is an
intersection of a row and a column, and is identified by the column letter and the row number.
Column D of the spreadsheet, containing the sums budgeted for different expenses, is
highlighted, as is Row 10. The selected cell is D10.
Active cell
The active cell is the currently selected cell. The cell's coordinates, as well as the data within the
cell, are displayed in the Name Box and the Formula Bar.
The active cell is C7 and column C and row 7 are highlighted.
Cell range
A cell range is a selected group of cells.
The cells in the selected range are where Row 5, which is highlighted, intersects with each of the
highlighted columns D, E, F, and G.
Cell coordinate
The cells in a spreadsheet are identified by their coordinates. Rows have numbers and columns
have letters. A cell's coordinates consist of the column letter followed by the row number. For
example, a cell in column F, row 7 of a spreadsheet is called F7.
In Excel, a tabbed page is called a "worksheet."
Graphic
The current workbook contains three tabs: Expenses, Income, and Summary. The Expenses tabbed
page is currently displaying.
A collection of more than one worksheet is called a "workbook."
Question
Which statements accurately describe the elements of spreadsheets?
Options:
1. Cells are named according to their column letter and row number
2. Columns refer to diagonally arranged data
3. Rows refer to horizontally arranged data
103

4. Columns refer to vertically arranged data
5. Cells are named according to their contents
6. A cell is where a column and a row intersect
Answer
Option 1: Correct. Cells are identified by their coordinates written as the column letter followed by
the row number.
Option 2: Incorrect. Columns refer to vertically arranged data, not diagonally arranged data.
Option 3: Correct. A row refers to a horizontal arrangement of cells.
Option 4: Correct. A column refers to a vertical arrangement of cells.
Option 5: Incorrect. Cells are named according to their column and row numbers, not their contents.
Option 6: Correct. A cell refers to the intersection of a row and a column.
Correct answer(s):
1. Cells are named according to their column letter and row number
3. Rows refer to horizontally arranged data
4. Columns refer to vertically arranged data
6. A cell is where a column and a row intersect
2. Workbooks in Excel
To open Excel, you use the Windows Start menu.
Graphic
The Windows Start menu is open. It contains an All Programs menu.
Alternatively, you can use the Start menu's search function to find the Excel link.
Graphic
The Windows Start menu is open and the word "Excel" is typed into the search field.
By default, when you open Excel, the program displays a blank workbook consisting of three
worksheets. The first worksheet is open, but you can access the other worksheets in the
workbook by clicking the tabs.
104

Graphic
A blank workbook is displayed and three tabs are available. They're named Sheet1, Sheet2, and
Sheet3.
Try It
Now you can practice opening Excel using the Windows Start menu.
The Windows desktop is displayed.
To complete the task
1. Click Start
2. Select All Programs
3. Select Microsoft Office
4. Select Microsoft Excel 2010
You have successfully opened Excel using the Windows Start menu.
With the workbook open, you can use the main elements of the interface namely the Ribbon,
the Quick Access Toolbar, and the Backstage view to perform several functions.
Select each interface element to learn more about what you can use it for.
Ribbon
The Ribbon, which consists of eight tabs, gives you convenient access to important commands
you may need to perform. The commands are grouped logically into each tab.
The Ribbon's tabs are File, Home, Insert, Page Layout, Formulas, Data, Review, and View. The
Home tab displays by default.
Quick Access Toolbar
The Quick Access Toolbar is a handy way to access Excel's save, undo, and redo functions
which you may need regularly when working with data.
The Quick Access Toolbar includes commands such as Undo and Save.
File tab
You click the File tab on the Ribbon to gain access to Backstage view, where you'll find common
file-level commands such as saving, printing, closing, sharing, and publishing workbooks. You
can also access a list of the most recently used workbooks.
105

3. Opening an existing workbook
Within Excel, there are two main ways to open an existing workbook that's saved to your hard
drive or to a network location. You first select the File tab, which opens Backstage view. Then
you either use the Open command or access the Recent tabbed page to open your workbook.
The method you use depends on whether or not you have accessed the file recently.
Graphic
Backstage view contains a panel that has Quick Commands, such as Open, and tabs, which include
Recent.
Select each method to find out when you would use it.
Open command
The Open command in Backstage view lets you navigate your computer to find the file you want
to work with. You would use the Open command if the workbook doesn't appear in your list of
most recently opened workbooks.
Recent tabbed page
The Recent tabbed page, which is open by default in Backstage view, displays a list of recently
opened files and their locations. It provides you with quick access to a workbook that you've
worked on recently. You would also use this page if you've forgotten where you stored the file or
if you accidentally saved the file somewhere other than the desired location.
The Recent tabbed page displays two columns: "Recent Workbooks" displays a list of workbooks
that have been opened recently, while "Recent Places" displays a list of folder locations that have
been accessed recently.
Alternatively, if you don't have Excel open, you can simply use Windows Explorer to browse to
the workbook location, then double-click the file to open it.
Graphic
In the Documents library in Windows Explorer, a list of Excel files display.
The Open dialog box contains several elements, including the Address Bar, View pane,
Navigation pane, and File name drop-down list box.
Graphic
Clicking Open in Backstage view launches the Open dialog box. It displays the Document library by
default.
106

Select each element of the interface to learn more about it.
Address bar
The Address bar identifies your current location and includes a trail of the open folder's parent
folders, if applicable.
The Address bar currently displays the path of Libraries - Documents.
View pane
The View pane displays the contents of the file location you are currently browsing.
The contents of the Document library display by default.
Navigation pane
You can use the Navigation pane to quickly gain access to the locations and folders that are
commonly used to save files.
The Navigation pane lists the following locations: Favorites, Libraries, and Computer. The
Favorites folder includes the links Desktop, Downloads, and Recent Places. The Libraries folder
includes the links Documents, Music, Pictures, and Videos.
File name drop-down list box
You can type in the name of the file you want to open into the File name drop-down list box.
When you select a file from the View pane, the name of the file will appear here. You can also
filter files in the current folder by using the drop-down list.
Say you want to open a sales report which is saved in a folder named "Sales records" in your
Documents library. You follow these steps:
Graphic
The Open dialog box appears, with the Computer link selected in the Navigation pane. The View
pane is currently empty.
1. you select the Documents library from the Navigation pane
The Documents link is selected in the Navigation pane. The View pane now shows four folders, one of
which is titled Sales records.
2. you double-click the relevant folder in the View pane to open it
The Sales records folder is clicked.
3. you open the file either by double-clicking it, or by selecting it and then clicking the Open button, and
The Sales Seattle December file is selected and the Open button is clicked.
4. your file will now be displayed
The Sales Seattle December workbook is opened in Excel.
The next time you access the Recent tabbed page, the file will be listed as one of your recent
documents.
107

Graphic
Backstage view displays the Sales Seattle December file in the Recent Workbooks column.
Try It
Now you try to open a file using Backstage view's Open command.
A blank workbook is displayed.
To complete the task
1. Click File
2. Click Open
3. Select Documents, then double-click Timesheets
4. Select Week47 Timesheet RLawrence and then click Open
You have opened a file using Backstage view's Open command.
Question
You want to open a financial workbook, "NovemberSalaries.xls," which you were working on earlier
in the day. Unfortunately, you don't remember where you saved the workbook.

Which is the best way of accessing the file in Excel 2010?
Options:
1. Use the Quick Access Toolbar to browse to the file
2. Use Backstage view's Recent tabbed page
3. Use Backstage view's Open command
4. Use the Ribbon's View tab to open the file
Answer
Option 1: Incorrect. By default, you can use the Quick Access Toolbar to save a file, undo actions,
and redo actions. If you want to use the Toolbar to open files, you have to customize it.
Option 2: Correct. The Recent tabbed page gives you quick access to workbooks that you've
worked on recently. Because you don't need to remember where you saved the file, this method is
ideal for this situation.
Option 3: Incorrect. You use the Open command to navigate to the location of the file you want to
work with. Because you don't know the location of this file, this method is not ideal.
108

Option 4: Incorrect. The View tab gives you options regarding how you see the data you're working
with. You can't use these options to open a file.
Correct answer(s):
2. Use Backstage view's Recent tabbed page
Summary
Workbooks have many practical uses, including budgeting, record-keeping, and financial
analysis. In Excel 2010, you can create and use workbooks to manage your data efficiently.

The main elements of the Excel interface are the Ribbon, the Quick Access Toolbar, and the
Backstage view each performing important functions.

Within Excel, you can access workbooks by using the Open command to navigate to them, or
from the Recent tabbed page in Backstage view.

















109

Introducing the Excel 2010 Interface
Learning Objective
After completing this topic, you should be able to
recognize the functions of key Excel 2010 interface elements
1. The Ribbon
Microsoft Excel 2010 has an efficient and user-friendly layout. The Ribbon contains seven main
command tabs that contain the most commonly used commands the Home, Insert, Page
Layout, Formulas, Data, Review, and View tabs. You can also select the File tab to access
Backstage view, where you'll find commands to manage files themselves.
Graphic
As you select each tab on the Ribbon, the set of commands that displays changes. The File tab
opens Backstage view, which consists of a panel of commands and tabs. By default, the Info tabbed
page displays.
The Quick Access Toolbar provides you with shortcuts to the most commonly used controls
such as the Save and Undo commands. You can view your document in different ways using
the page layout views such as Normal, Page Layout and Page Break Preview. Also, you
can zoom in to the spreadsheet to view it in greater detail or zoom out to get a more complete
view of what the document looks like. View and zoom options are available in the View tab on
the Ribbon or on the status bar.
Graphic
The three default commands on the Quick Access Toolbar are Save, Undo, and Redo. The status
bar includes the page layout buttons.. As you click each page layout button, the layout of the
worksheet as well as the zoom changes. For example, when you click Page Break view, the zoom
changes to 60 percent. You can also change the zoom using the Zoom In and Zoom Out buttons, as
well as a Zoom slider
The Ribbon includes several command tabs. Each tab is divided into groups of commands,
according to the kind of task those commands relate to. For example, the Font group in the
Home tab contains options for formatting text.
Graphic
The main tabs are Home, Insert, Page Layout, Formulas, Data, Review, and View.
You can access the tabs on the Ribbon by clicking them.
110

Keyboard Sequence
You can also press the Alt key together with the tab's shortcut key to open the tab.
Select each tab to find out what tasks you can use it to perform.
Home
When you open Excel, the Home tab displays by default. You can use the commands in this tab
to manipulate your work by moving, cutting, copying or formatting groups of cells or the data
within them.

For example, you could change the style, size, or color of text by using the options in the Font
group. Or you could align your column headers so they display in the center of a cell.
The Home tab includes the Clipboard, Font, Alignment, Number, and Styles groups.
Insert
The Insert tab contains commands that enable you to insert data from different sources and in
various ways. For instance, you could use the options in the Illustrations group to navigate to a
photograph saved in another location.
The Insert tab includes the Tables, Illustrations, Charts, Sparklines, Filter, and Links groups.
Page Layout
The groups in the Page Layout tab contain commands that enable you to change the way your
worksheet is presented on screen.

If you want to give your worksheet a background, you could do this by clicking the Background
button in the Page Setup group and navigating to the image you want.
The Page Layout tab includes the Themes, Page Setup, Scale to Fit, and Sheet Options groups.
Formulas
The Formulas tab includes commands you can use to calculate or insert formulas. These
commands are particularly useful when you want to insert a pre-existing formula into a cell. The
Function Library group includes a number of such formulas.
The groups included in the Formulas tab are, amongst others, Function Library, Defined Names,
and Formula Auditing.
Data
The commands in the Data tab enable you to manipulate data, audit information, and analyze
trends in a worksheet. For instance, if you want to alphabetize your data, you would use the Sort
command in the Sort & Filter group.
The Data tab includes the Get External Data, Connections, Sort & Filter, and Data Tools groups.
Review
You can proofread and edit your worksheet by using the commands in the Review tab. You can
also add comments to a worksheet, protect a workbook so it can't be edited by unauthorized
111

persons, share a workbook so multiple people can work on it at the same time, and track any
changes made to the workbook.
The groups on the Review tab include Proofing, Language, Comments, and Changes.
View
The View tab contains commands you use to view elements of a worksheet in different ways. For
example, you can view several worksheets in tile form by clicking the Arrange All button in the
Window group and selecting the appropriate radio button from the dialog box.
The View tab includes the groups Workbook Views, Show, Zoom, and Window.
The Ribbon displays contextual tabs in addition to the main command tabs. A contextual tab is
specific to the content of your worksheet and is displayed automatically when you're working on
an object, like a table, chart, or picture. For example, you're working in a worksheet that contains
an image. When you select that image, the Picture Tools contextual tab which you can use to
adjust the settings of the image appears in the Ribbon.
Graphic
The Picture Tools tab has a Format tab, containing several groups, such as Adjust and Picture
Styles.
Several groups within a tab have dialog box launchers. You can click this launcher to open a
dialog box containing all the commands and options associated with that group.
Graphic
On the Home tab, the Clipboard, Font, Alignment, and Number groups all have launchers.
You access the dialog box for a group to view all commands related to it. For example, if you
want to apply a strikethrough effect to text, you launch the dialog box from the Font group to
access that command.
Graphic
The Format Cells dialog box opens when the launcher in the Font group is selected. It opens on the
Font tabbed page, which contains a number of fonts, sizes, colors, themes, and effects options.
Other tabs in the dialog box include Number, Alignment, and Border.
You can also customize the Ribbon by right-clicking it and selecting Customize the Ribbon.
You can then choose to display the commands you use most often. To do so, you select a
program and then click the Add or Remove buttons.
Graphic
112

The Excel Options dialog box opens on the Customize Ribbon tabbed page. It has two panes. One
includes a list of popular commands that you can add to or remove from the Ribbon. The other pane
lists the commands currently on the Ribbon, grouped under the tabs.
You can click the Minimize the Ribbon button to hide the command tabs so more of your
workbook is displayed on screen.
Keyboard Sequence
You can also press Ctrl+F1 to minimize the Ribbon.
You can still select a tab, but when you click away, the tab will be hidden again.
Graphic
In this case, the Data tab is selected.
You can restore it by clicking the Expand the Ribbon button, which appears when the Ribbon is
minimized.
Keyboard Sequence
You can also press Ctrl+F1 again to restore the Ribbon.
Question
What types of functions can you perform using the commands available directly within the Ribbon
tab groups?
Options:
1. Insert tables, picture, or charts
2. Alphabetize data
3. Format text in cells
4. Save a document
5. Undo an action
Answer
Option 1: Correct. If you want to insert tables, pictures, or charts into your worksheet, you can use
the commands in the Table group on the Ribbon's Insert tab.
113

Option 2: Correct. You can alphabetize your data by accessing the Data tab and selecting the
command from the Sort & Filter group.
Option 3: Correct. You can use the options within the Font group on the Home tab to format the
text in cells.
Option 4: Incorrect. You can't save a document by using a command within a group on a Ribbon
tab. If you want to save a document, you use the Quick Access Toolbar or access the option in the
File tab.
Option 5: Incorrect. You can't undo an action from the options on the Ribbon. If you want to undo
an action, you use the Quick Access Toolbar.
Correct answer(s):
1. Insert tables, picture, or charts
2. Alphabetize data
3. Format text in cells
2. The Backstage view
The File tab differs from the other command tabs on the Ribbon. Whereas you'd use commands
in the rest of the Ribbon to work within a workbook, you use the File tab to access Backstage
view, where you'll find commands for working with the workbook itself. For example, you'd
access Backstage view to save or print a file.
Graphic
The Wireless Tech Conference worksheet is open in Excel. Clicking the File tab opens Backstage
view on the Info tabbed page. The panel in Backstage view contains commands that include Save
and Save As, and tabs such as Print.
You can also use Backstage view to examine contextual information about your file. For
example, because Excel keeps the different versions of your files as you save, you can keep
track of the changes made to your workbook.
Graphic
In the Versions section of the Info tabbed page, it states that the open workbook was saved Today,
9:42 AM (autosave). This section also includes a Manage Versions button.
The Backstage panel contains four Quick Commands Save, Save As, Open, and Close.
Selecting any of these commands launches a dialog box that enables you to complete the task
you want to perform.
114

Additional commands are contained in Backstage view. Select each command to find out more
about its associated tabbed page.
Info
The Info tabbed page includes commands that allow you to manage the permissions on your
document, the sharing settings, and your version history. It also provides you with information
about the file, such as its properties, related dates, and related people.

For example, if you want to make sure no-one can change your document but still want to allow
people to view it, you can specify these settings in the Info tabbed page.
The Info tabbed page is organized into three sections including Permissions, Prepare for Sharing,
and Versions. It also presents a preview of your document with all its information.
Recent
The Recent tabbed page contains a list of recently accessed files as well as the locations those
files were accessed from. You could use this page to navigate quickly to files you're currently
working on.
The Recent tabbed page is divided into two panels: Recent Workbooks and Recent Places.
New
To create a new workbook from a template, you can access the New tabbed page and then
select the kind of document you want to create. The page provides you with templates that have
been stored in Excel or on Office.com, as well as any templates that you've created and saved. If
you don't want to use a template, you select Blank workbook.
The New tabbed page includes a menu of Available Templates and a preview of whichever
template is selected. The Blank workbook option is selected by default.
Print
The Print tabbed page lets you set several options before you print your document. You can
specify the number of pages per sheet, the number of copies you want to print, and the size of
the margins, to name a few examples.

You can also view what the worksheet would look like when printed given the options you've
selected in the Preview section. For example, if you want to scale a worksheet to fit a page but
aren't sure how it will look, you can view a preview of it first to make sure it will print as you want it
to.
The sections on the Print tabbed page include Print, Printer, and Settings.
Save & Send
The Save & Send tabbed page provides you with different ways to send your saved file. You have
the option to send your documents using e-mail, via the Web, or to a shared network. For
example, if you want to post your file on a web site, you can use the Save to Web command.

The Save & Send tabbed page also allows you to specify a file type for your file. You can also
convert it to a PDF or XPS document.
The Save & Send tabbed page is divided into the Save & Send, File Types, and Send Using E-
115

mail sections. The Save & Send section includes the Send Using E-mail, Save to Web, and Save
to SharePoint commands. The File Types sections contains the Change File Type and the Create
PDF/XPS Document commands. The Send Using E-mail section includes the Send as
Attachment, Send a Link, and Send as PDF commands.
Help
The Help tabbed page provides you with assistance with Excel. You could use the Getting
Started guide or Microsoft Office Help. If you can't find what you're searching for, you can follow
the links for the Microsoft Office support site from the Help tabbed page.

In the Tools for Working With Office section, you can customize program settings or update your
help information by using the Check for Updates command.
The Help page is organized into Support and Tools for Working With Office sections. It also
provides all the published information, such as the version and product ID.
Clicking the Options command in the Backstage panel launches the Excel Options dialog box,
which you can use to change several interface settings. For example, you can access the
Customize the Ribbon tabbed page.
Graphic
The Excel Options dialog box has several tabs, including General, Formulas, Proofing, Language,
and Customize Ribbon.
Backstage view also has an Exit command and when selected, it closes Excel.
Question
What tasks can you perform using Backstage view?
Options:
1. Upload your worksheet to a web site
2. Protect your file from being altered by others
3. Use a template to create a new worksheet
4. Zoom in on your worksheet
5. View several worksheets in tile format
Answer
Option 1: Correct. You can upload your worksheet to a web site by accessing the Save & Send
tabbed page from the Backstage panel.
116

Option 2: Correct. You can select options from the Protect Workbook drop-down menu in the Info
tabbed page to control who has access to the file.
Option 3: Correct. To create a new document, you can access the New tabbed page, which lets
you create a new page using a template.
Option 4: Incorrect. The Zoom command can't be accessed from the Backstage panel. To zoom in
or out on a worksheet you access the Zoom group options from the View tab or use the Zoom slider
on the status bar.
Option 5: Incorrect. You can't change your view from Backstage view. If you want to access several
worksheets in tile format, you can use options in the Page Setup group on the Page Layout tab on
the Ribbon.
Correct answer(s):
1. Upload your worksheet to a web site
2. Protect your file from being altered by others
3. Use a template to create a new worksheet
3. The Quick Access Toolbar
The Quick Access Toolbar provides you with shortcuts to any of the commands in Backstage
view or on the Ribbon. The default setting pins only the Save, Undo and Redo command
buttons to the Quick Access Toolbar.
The commands that are already pinned to the Quick Access Toolbar are three of the most
commonly used commands in Excel.
You can click Save regularly to make sure any changes you make to your file are kept.
You can use the Undo and Redo commands to correct a mistake, instead of having to retype
the data. You can access lists of your actions by clicking the drop-down buttons.
Question
What commands are available by default on the Quick Access Toolbar?
Options:
1. Save
2. Undo
3. Redo
4. Print
5. Open
117

Answer
Save, Undo, and Redo are pinned to the Quick Access Toolbar by default. You can customize the
Quick Access Toolbar to remove these commands or add others.
Option 1:
Option 2:
Option 3:
Option 4:
Option 5:
Correct answer(s):
1. Save
2. Undo
3. Redo
You can add or remove buttons on the Quick Access Toolbar to suit your own needs. You can
access a list of commonly used commands by clicking the Customize Quick Access Toolbar
button.
Graphic
Options in the Customize Quick Access Toolbar drop-down list include New, Open, Save, E-mail,
Quick Print, Print Preview and Print, Spelling, Undo, Redo, Sort Ascending, Sort Descending, and
Open Recent File. It also includes the options More Commands and Show Below the Ribbon.
To add buttons to the Quick Access Toolbar, you can select the commands from the list. For
example, you can add Quick Print by clicking it.
Then the list closes automatically and the command you selected appears on the Quick Access
Toolbar.
To remove buttons from the Quick Access Toolbar, you can select the command again. The list
closes automatically and the command is no longer on the Quick Access Toolbar.
As well as adding or removing some of the most commonly used commands, you can also
access more commands to choose from or reposition the Quick Access Toolbar.
Graphic
118

The More Commands and Show Below the Ribbon options are highlighted.
Select the options to find out how to customize the Quick Access Toolbar.
More Commands
You can access the Customize Quick Access Toolbar tabbed page of the Excel Options dialog
box by selecting More Commands from the drop-down list. The dialog box contains many more
options and commands you can choose from to customize the Toolbar.
Show Below the Ribbon
You can reposition the Quick Access Toolbar by selecting Show Below the Ribbon from the
drop-down list.
Try It
Now you try customizing the Quick Access Toolbar.

You want to add the Spelling button, and reposition the Quick Access Toolbar below the Ribbon.
To complete the task
1. Click Customize Quick Access Toolbar and select Spelling
2. Click Customize Quick Access Toolbar and select Show Below the Ribbon
You've added the Spelling button to the Quick Access Toolbar and repositioned it below the
Ribbon.
4. The description bars
The Formula Bar displays the data within a cell, such as text, numbers, or formulas. You can
use this bar to enter data into the worksheet or to edit existing data. The bar displays whatever
data was entered into the worksheet originally and doesn't reflect changes in formatting.
Graphic
In the sample spreadsheet containing data relating to the actual and estimated values for an event
budget, when cell B3 is selected, the Formula Bar displays its value, namely 2,300. When the value
is updated to 2,500 in the Formula Bar, the value updates in the cell too. When the cell B7 is
selected, a formula displays in the Formula Bar, namely =SUM(B3:B6).
The Name Box displays the coordinates of a selected cell. For example, if the cell is in column
B, row 5, the coordinates that display in the Name Box are B5. The coordinates help you avoid
confusion when creating large and complicated worksheets. You can enter coordinates into the
Name Box to navigate to a particular cell.
119

Graphic
The Wireless Tech Conference worksheet is open in Excel. It contains the actual and estimated
budget figures for various items required for the conference. Below the Ribbon, the Name box and
Formula Bar display.
You can use the status bar to monitor the status of your worksheet. If you're able to work in the
worksheet, the status "Ready" displays.
If you double-click a cell, the status "Enter" displays. You can then enter data into the cell.
Graphic
For example, the blank cell B10 is selected.
If you double-click a cell that already has data in it, the status "Edit" displays, which means you
can change or add to the data in the selected cell.
Graphic
For example, the cell B5 containing the data Venue hire has been selected.
The status bar also includes several layout options the Layout selector, the Zoom buttons and
slider, and the built-in functions. You can use these to change the way you view your worksheet
or to monitor the worksheet.
Graphic
For example, clicking the Zoom In button can increase the zoom to 110% and then clicking Zoom
Out reduces it back to 100%.
Select each component of the status bar for more information about it.
Built-in functions
The status bar includes built-in functions. For example, when you select two or more cells, the
built-in functions display the Average, Count, and Sum of the numbers in the cells. Average is the
average numeric value of all the selected cells, Count provides you with the number of cells
selected, and Sum automatically adds the values of the selected cells.
In this case, the Average is $1,500, the Count is 5, and the Sum is $7,500.
Layout selector
Three layout buttons are positioned on the status bar. You can click Normal the default view
to display the worksheet as a simple grid. You click Page Layout to view the worksheet as it
120

would appear on a printed page and Page Break Preview to view the page breaks on the
worksheet.
Zoom level
The Zoom level button displays the percentage of zoom level. The default view is 100%. As well
as using the Zoom buttons and slider, you can also click the Zoom level button to launch the
Zoom dialog box and select the zoom level.
The available options in the Zoom dialog box are 200%, 100%, 75%, 50%, 25%, Fit selection,
and Custom.
Zoom buttons and slider
You can zoom in and out of your worksheet, changing how large the worksheet appears on
screen. You can either use the Zoom slider or click the Zoom In and Zoom Out buttons to do so.
You can customize the status bar by right-clicking it and selecting an additional command from
the Customize Status Bar list.
Graphic
Items that appear on the status bar are selected and a checkmark is displayed with each item on the
Customize Status Bar menu.
You can also unpin options by selecting the option again, which deselects it. For example, you
can choose whether or not to include the Count option.
Graphic
The Count option is selected on the Customize Status Bar menu.
Each worksheet in a workbook is tabbed. These tabs appear just above the status bar, and you
use them to navigate between worksheets.
Graphic
In this workbook, there are three tabs Expenses, Income, and Summary.
Question
What tasks can you can perform using the status bar?
Options:
1. Switch to Page Break Preview layout
2. Increase and decrease the zoom
121

3. View page number
4. View the average of a selected number of cells
5. Change font color
6. View associated people
Answer
Option 1: Correct. Page Break Preview is one of three layout buttons on the status bar that you
can use to change the view of your worksheet.
Option 2: Correct. The status bar includes the Zoom in and Zoom out buttons and the Zoom
slider. You can use them to find your preferred view.
Option 3: Correct. You can customize the status bar to display the page number of the page you're
working on.
Option 4: Correct. The Average function calculates the numerical average of the selected cells.
You can choose not to display this function by selecting the option from the Customize Status Bar
list.
Option 5: Incorrect. You can't change the font color by using options on the status bar. Instead, you
would do so using the Font group on the Home tab.
Option 6: Incorrect. The status bar doesn't give you the option of viewing the workbook's associated
people. You can access this information from Backstage view.
Correct answer(s):
1. Switch to Page Break Preview layout
2. Increase and decrease the zoom
3. View page number
4. View the average of a selected number of cells
Summary
In Excel 2010, you can access most options by using the seven command tabs on the Ribbon.

The File tab enables you to access Backstage view which provides you with information about
the file and enables you to manage the file itself.

You can use the Quick Access Toolbar for the most commonly used commands. You can also
customize it to suit your requirements.

The description bars help you organize and keep track of your work. These include the Name
Box, Formula Bar, and status bar.
122

Creating a New Excel 2010 Workbook and Entering Data
Learning Objectives
After completing this topic, you should be able to
create a new workbook
enter data in a given scenario
1. Excel data types
Excel 2010 comes with several ready-made templates, including calendars, expense reports,
and time sheets. You can use worksheets and templates to manage different types of data, such
as text, numbers, or dates and times. And, although you'll enter much of your data manually,
when it comes to certain common data series, you can type in an entry and then use Excel's
AutoFill feature to complete the rest of the series.
Graphic
For example, in a time sheet template, you can type the name of a client, as well as the scheduled
date and start and stop times of an appointment. You can use the AutoFil feature by entering Sun in
a row, and the rest of the days of the week are added automatically.
Excel's three basic data types are text, numbers, and dates and times.
Select each data type to learn more about how Excel interprets it.
Text
You use text when you want to enter words, names, labels, or codes. Excel defines text as either
letters of the alphabet alone, or combinations of letters and numbers, spaces, and certain
symbols.
Numbers
Excel doesn't recognize an entry as a number if it includes any spaces, but it can include
common symbols used for numbers such as commas, periods, plus signs, minus signs, currency
symbols, and percentage signs.
Dates and times
You use dates and times to record specific periods such as a day of the year, or a time of day.
You can customize the format you use for dates and times to suit your needs.

These entries are made up of numbers. For dates, these numbers are punctuated with forward
slashes or dashes, but for times of day they're punctuated with colons.
123

Excel aligns data types in different ways by default:
Graphic
The section of a worksheet displaying Anticipated Expenses is open. It has columns named Type of
expense, Description of expense, Daily expenses, Number of days, and Total expenses, with data
listed in each column.
text entries are aligned to the left-hand side of a cell
In this example, Food and miscellaneous, under the Description of expense column, is left aligned.
number entries are aligned to the right-hand side of a cell, and
The number 2, in the Number of days column, is right aligned.
dates and times are considered a kind of number, so they're aligned to the right-hand side of a cell
The date 11/15/2010, in a section above the Anticipated Expenses section, is right aligned.
Because Excel ignores text entries when performing calculations, it's useful to know these
alignment differences so you can easily spot when you've made a mistake with an entry.
Graphic
A timesheet displays an employee's times in and out of the office, as well as the totals, for each day
of the working week. It also displays the total hours worked for the week.
For example, if you use a space to separate hours from minutes when you enter a time, Excel
will interpret your entry as text.
Graphic
All the time entries in a timesheet use colons to separate the hours from the minutes, for example 8
colon 55. These entries are all right aligned. The user's entry of the time 17 20 is aligned to the left
because of the space between 17 and 20.
As a result, you can encounter calculation errors, because the text entry will not be used in
calculations.
Graphic
The Incorrect Time Format dialog displays the note "Time should be entered in the following format:
12:00 AM." The Total and the Total hours worked cells now contain the error message #VALUE!.
Question
124

Match each data type with its correct representation in Excel 2010.
Options:
A. Time
B. Numbers
C. Dates
D. Text
Targets:
1. A set of numbers separated by a colon
2. Numbers and symbols aligned to the right of a cell
3. Comprises numbers separated by dashes or forward slashes
4. Comprises letters or combinations of letters aligned to the left of a cell
Answer
Times are represented by numbers punctuated with colons.
Numbers are represented by numerical values and are aligned to the right of a cell.
Dates are represented by numbers, punctuated with dashes or forward slashes.
Text is represented by letters alone, or combinations of letters and numbers, spaces, and certain
symbols. It's aligned to the left of a cell.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
2. Creating a new workbook
When you open Excel, a new blank workbook is created by default. However, there may be
times when you'll want to create a new workbook yourself. You can either create a new blank
workbook or create a new workbook based on a template.
Graphic
125

For example, you can create a Sales worksheet using the Sales template that includes specific
column and row headers, as well as a color scheme.
You create a new blank workbook by selecting the New tab in Excel's Backstage view.
By default, the Blank workbook template is selected.
Graphic
The New tabbed page contains two sections of templates: Available Templates and Office.com
Templates. At present, the Blank workbook template is selected in the Available Templates section.
To create a new workbook based on a template, you either double-click the template option, or
select it and then click the Create button.
Try It
Now you practice creating a new blank workbook using Backstage view.
A blank workbook is open.
To complete the task
1. Click File
2. Click New
3. Ensure that Blank workbook is selected, then click Create
You've created a new blank workbook using Backstage view.
In Excel, a template is a ready-made workbook that already contains the layout and formatting
to fulfill specific purposes such as creating budgets or invoices.
Graphic
An Expense report1 template is displayed. The template contains various sections for you to enter
information, such as employee information, which is left blank. It also contains a table where you
can enter expenditure details.
Because these templates are preformatted, you can begin entering data immediately, without
having to apply formatting.
Graphic
126

For example, the fields Name, Department, Position, and Manager are populated with actual data.
R. Lawrence displays in the Name field, R&D in the Department field, Research Associate in the
Position field, A. Alford in the Manager field.
Excel contains a number of templates that are useful for common business and personal
purposes. Those in the Available Templates section are included with Excel 2010.
Graphic
The New tabbed page in Backstage view displays. The Available Templates section contains these
templates options: Blank workbook, Recent templates, Sample templates, My templates, and New
from existing.
The Available Templates section contains templates that you can access from your local
computer.

Select each category of template to find out more about it.
Blank workbook
Selecting Blank workbook opens an empty workbook without any formatting applied to it.
Recent templates
Selecting Recent templates opens a list of the templates that you've accessed most recently.
Sample templates
Selecting Sample templates opens a list of a few basic templates for purposes such as expense
reporting, time keeping, and personal budgeting.
My templates
The My templates folder contains personal templates that you have created.
New from existing
Selecting New from existing opens a new workbook based on an existing workbook.
While some templates can be accessed from your local computer, you'll need to be connected
to the Internet to access the full range of Excel templates from the Office.com web site.
Graphic
The Office.com Templates sections contains many categories of templates, including Agendas,
Budgets, Calendars, Databases, Diagrams, and Expense reports.
To access one of these templates, you first select the template category.
127

Graphic
The Receipts category is selected.
This opens a new page, which gives you a range of different templates in the selected category.
Graphic
The Receipts category is displayed. It contains numerous templates, including a Donation receipt,
Sales receipt (Simple Blue design), and a Sales receipt (Blue Gradient design).
Once you've chosen a template, you download it from Office.com before you can use it.
Graphic
The template is selected and the Download button is clicked.
Try It
Here's your chance to practice opening a template from Office.com.

Open the Credit memo (Simple Blue design) template, which appears in the Memos category.
In Backstage view, the New tabbed page is open.
To complete the task
1. Select Memos
2. Select Credit memo (Simple Blue design)
3. Click Download
You have successfully downloaded a template from Office.com.
When the template opens, you'll find that some text has already been entered for you, and some
sections are already formatted. This saves you the time of setting up the worksheet yourself.
Graphic
A new Credit Memo workbook is displayed, with sections for you to fill in as required. You can enter
the name of the company and its logo, as well as other fields, such Credit #, Customer ID, and
customer address.
You can then customize the worksheet to suit your specific requirements.
128

Graphic
Diallonics has been filled into the [Your Company Name] field.
3. Entering data in Excel
To manually enter data in a cell, you simply select the cell and begin typing. As you type, your
input also appears in the Formula Bar. Alternatively, you can type directly into the Formula Bar.
This is useful if you're typing lengthy text, such as long numbers or phrases. You can then click
the Enter button the checkmark icon to confirm your entry, or click the Cancel button the
cross icon to reject it.
Graphic
A Travel Advance request worksheet displays, containing information such as the date of
submission, the details of the traveler, as well as the purpose and dates of travel. The date of travel
is entered directly into the relevant cell but a lengthy description of the purpose of the travel is typed
into the Formula Bar and then the Enter button is clicked.
If you're using the Formula Bar and you want to move to the next line of the worksheet, you
activate the next cell by clicking it.
Graphic
The selection moves from cell C12, which contains the description of the purpose of travel, to cell
C13 in this case.
If you're using the Formula Bar or typing directly in a cell, you can move to the cell below by
clicking it or by pressing Enter on the keyboard.
To edit data that's already entered into a cell, you need to do several things.
Graphic
The Sales Seattle December worksheet displays.
First you select the cell.
Graphic
Cell G8, containing a salesperson's name Heather Denfries, is selected.
Next, in the cell or using the Formula Bar, you delete some or all of the data.
129

Graphic
In the Formula Bar, the last four letters of the name Denfries are deleted.
You then type the new data in the desired position.
Graphic
In the same cell's formula bar, the letters i e l d are typed so that the name is Denfield.
Finally, you accept the edit by pressing Enter if you're typing directly into the cell or clicking the
checkmark icon if you're using the Formula Bar.
Note
If you're using the Formula Bar or typing directly in a cell, you can move to the cell below by clicking
it or by pressing Enter on the keyboard.
The data in the cell will now be edited.
Graphic
G8 now reads Heather Denfield.
Although you'll enter most data into a worksheet manually, Excel also includes two automatic
data entry features AutoFill and AutoComplete. These features make it faster and easier for
you to enter data into a worksheet.
Select each feature to learn about it.
AutoFill
You can use the AutoFill feature to complete common series of data, such as the days of the
week, months of the year, multiples of certain numbers, and predictable number series such as
even numbers like 2,4,6,8, and so on.
AutoComplete
You use the AutoComplete feature to complete words that have previously been entered into
other cells in the column you're working in. For example, if you're entering a client's name for the
second time in a column, you need to enter only the first few letters of the name. AutoComplete
can fill in the rest for you.
Question
130

Which of these series of data could you use Excel's AutoFill feature to complete?
Options:
1. 2, 4, 6, 8, 10...
2. Monday, Tuesday, Wednesday...
3. 15, 15, 15, 15...
4. 1, 3, 5, 9, 13...
Answer
Option 1: Correct. AutoFill automatically completes predictable number series, such as even
numbers.
Option 2: Correct. AutoFill automatically completes common series of data, such as days of the
week.
Option 3: Correct. AutoFill automatically completes predictable number series, such as repetition of
a single number.
Option 4: Incorrect. AutoFill does not complete number sequences that have no common pattern or
predictable sequence.
Correct answer(s):
1. 2, 4, 6, 8, 10...
2. Monday, Tuesday, Wednesday...
3. 15, 15, 15, 15...
Say you want to type the word "Installation" in column D. You start typing the word, but, because
the word already appears in the column, Excel remembers it and fills in the rest for you.
Graphic
The Sales Seattle December workbook displays. One column lists the sales items Cell phone,
Landline, and Internet as well as sub-items for each of these. The user has typed the letters "I n s"
in D17 and Excel's AutoFill feature has suggested that the word be completed with the letters
"tallation." So the complete word reads "Installation."
If you want to accept the word, you can either press Enter or navigate away from the cell by
using the arrow keys on your keyboard or clicking away from the cell.
Graphic
The word "Installation" now appears in D17.
131

However, you don't have to accept the AutoComplete suggestion. If you want to type another
word, which starts with the same letters you've already entered, you simply keep typing.
Graphic
The words Institutional setup rather than "Installation" appear in the cell the user was typing in.
To use the AutoFill feature, you begin by typing in the series. In the case of a series such as
days of the week or a simple number series, you only need to type the first entry. You can also
type two entries to enable Excel to recognize and fill a more complex series such as number
values increasing by 2.
Graphic
A weekly time sheet is displayed, containing columns for the days of the week. Monday has been
typed into cell F7 and the cells has been selected.
Note
By default, Excel treats the entry Monday, or the entry January as the first in a series of days of the
week or months of the year. In the case of numbers, Excel treats the first entry as the first of a
repeating series. If you want to reverse this default behavior, for instance to have Monday treated as
the first of a repeating series of Monday entries, or 1 as the first in an increasing number series,
1,2,3..., you simply press the Ctrl key when you drag the fill handle. You can also drag a fill handle
to the left or upwards to fill previous cells with a series in reverse order.
You then hover your mouse over the bottom right-hand corner of the cell you last entered data
into. The cursor changes to a thin black cross icon, known as the fill handle.
Graphic
The cursor is positioned in the corner of the selected cell. It appears as a thin, black cross.
You then drag the fill handle to the last cell in the cell range you want to fill.
Graphic
After the fill handle is dragged across the adjacent cells then released, the adjacent cells now
display the remaining days of the week: Tuesday, Wednesday, Thursday, and Friday.
As soon as you start autofilling a series, the AutoFill Options icon appears.
Graphic
132

The icon is positioned at the end of the series.
You can click it to access a range of fill options, which vary according to the type of data you
entered. These options allow you to edit the content or the formatting of the series that has been
or is being filled.
Graphic
For a series of days of the week, the available AutoFill Options are Copy Cells, Fill Series, Fill
Formatting Only, Fill Without Formatting, Fill Days, and Fill Weekdays. The Fill Series radio button is
selected.
In this case, the options relate to the days of the week. Select each option to learn what it does.
Copy Cells
You can select Copy Cells to replicate your initial entries, along with their formatting, in the
selected cells. This option does not continue the series.
Fill Series
Selecting Fill Series automatically fills the adjacent cells with the rest of the series. This option
replicates the formatting you used for your initial entries.
Fill Formatting Only
Selecting Fill Formatting Only copies only your initial entries' formatting style to the adjacent
cells, but does not fill the adjacent cells with any data.
Fill Without Formatting
You can select Fill Without Formatting to automatically fill the adjacent cells with the rest of the
series. This option does not replicate the formatting you used for your initial entries.
Fill Days
You can select Fill Days to fill the adjacent cells with the current series, which is days of the
week. This option replicates the formatting you used for your initial entries.
Fill Weekdays
You can select Fill Weekdays to automatically fill the adjacent cells with the current series of
days but excluding weekends. This option replicates the formatting you used for your initial
entries.
Other AutoFill options include Fill Months and Fill Years, which become available in the
AutoFill Options list when your initial entries consist of months or years.
Graphic
The worksheet displays the months January to June.
133

Try It
Now you practice using the AutoFill feature.

You're entering performance data for the months January to June. Type the label for the first month
manually, then use AutoFill to complete the labels for the remaining five months.
A worksheet reflects sales figures for six months of a year. No month titles have been filled in yet.
Cell D6, which is the column header for the month of January, is already selected.
To complete the task
1. Type January, then click cell E6
2. Select D6 and drag the fill handle across cells D6 to I6
You have used AutoFill to complete a data series.
Summary
Excel 2010's three basic data types text, numbers, and dates and times are aligned
differently within cells.

In Excel, you can create a new blank workbook or create a workbook based on a template.

You can enter data directly into a worksheet cell, or using the Formula Bar. You can also enter
data quickly and easily by using Excel's AutoFill and AutoComplete features.











134

Opening Workbooks and Entering Data in Excel 2010
Learning Objectives
After completing this topic, you should be able to
open a workbook based on an existing template
open an Excel workbook
enter data into an Excel workbook
Exercise overview
This topic teaches you how to perform tasks using Excel 2010, simulating the application
interface and guiding you through the tasks. The instructions for completing the exercise are
presented on screen.
In this exercise, you're required to perform various tasks in Microsoft Excel 2010.
This involves the following tasks:
creating a new workbook based on an existing template
opening an existing Excel workbook, and
entering data into an Excel workbook
Task 1: Creating a new workbook based on an existing template
You manage a team of sales agents and you track various aspects of their performance using
Excel workbooks. You now want to open Excel and create a new workbook to fill in a sales
forecast. You want to base the workbook on a workbook which you've used in the past.
First open Excel by navigating the Windows Start menu. Then use Excel's File tab to create a
new workbook based on the existing "Sales Predictions" workbook.
Steps list
Instructions
1. Click Start - All Programs - Microsoft Office, and select Microsoft Excel 2010
2. Click File
3. Click New
4. Click New from existing
135

Steps list
Instructions
5. Select the Sales Predictions worksheet, then click Create New
Task 2: Opening an existing Excel workbook
Next you want to open a timesheet for one of the sales agents.
Use Backstage view's Open command to open the workbook "Week45 Timesheet TChavis,"
which is located in the Timesheets folder of your Documents library.
Steps list
Instructions
1. Click File
2. Click Open
3. Double-click Timesheets
4. Select the workbook Week45 Timesheet TChavis, then click Open
Task 3: Entering data into an Excel workbook
The timesheet for T. Chavis is not yet complete, because the days of the week have not been
filled in. You want to complete this timesheet by entering the days of the week.
Type Monday in cell F7 and then use Excel's AutoFill feature to fill in the remaining weekdays in
cells G7, H7, I7, and J7.
Steps list
Instructions
1. Click cell F7
2. Type Monday, then drag the fill handle across cells G7, H7, I7, and J7
136

Excel has been opened and a new workbook was created based on an existing template. The
File tab's Open method has been used to open a workbook and Excel's AutoFill feature has
been used to complete a series of data in this workbook.





















137

Formatting Text and Cells in Excel 2010
Learning Objectives
After completing this topic, you should be able to
apply basic text formatting
apply and copy cell formatting
1. Changing fonts
In Microsoft Excel 2010, you can format the content of spreadsheets in a variety of ways. In
other words, you can change the appearance of various aspects of a worksheet. You might do
this to draw attention to certain information, improve readability, and generally enhance a
worksheet's visual appeal. For example, you could change the font, font size, or font color of
column headings to make them stand out.
Graphic
In a sample Expense Budget worksheet, the heading Expense Budget is selected and the font size
is increased and the font color changed. In addition, a row of column headings are selected, the text
is formatted in bold and the cells are shaded a light gray.
As well as changing the appearance of data within cells, you can use Excel to format the cells
themselves. You can add borders in a variety of colors. Or you can use background colors and
patterns to make a cell or a range of cells stand out from the rest of the data in a worksheet. To
save time, you can also use the Format Painter to copy the formatting in existing cells and apply
it directly to new cells.
Graphic
In the same worksheet, in addition to the column header row, the backgrounds of next two rows of
cells are changed. This formatting of three rows is then copied to another set of three rows in the
worksheet.
To apply basic formatting to a worksheet, you can use options in the Font group on the Home
tab of the Ribbon.
Graphic
The Week 47 Timesheet RLawrence worksheet is open in Excel.The Excel interface includes
several default elements a mini toolbar of frequently used commands, a Ribbon containing several
tabs of commands, and a formula bar. The spreadsheet appears below these elements.
138

Select each option in the Font group for more information about it.
Font
From the Font drop-down list, you can choose different font types to apply to text. Each font type
displays characters in a different style. Because some font types are easier to read than others,
it's important to use fonts that are appropriate for your purpose.
The Font drop-down list currently displays Tahoma.
Font Size
You can use options in the Font Size drop-down list to adjust the size of the font you apply to cell
entries. The size of a font is measured in points.
The Font Size drop-down list currently displays 12.
Bold
You can click the Bold button to add thickness and weight to the font in selected cells.
Italic
You can click the Italic button to make the font slant to one side in the selected cells.
Underline
Clicking the Underline button adds a line beneath the entries in selected cells. You can also
choose to apply a single or a double line by selecting the relevant options from the Underline
drop-down list.
Increase Font Size and Decrease Font Size
You can use the Increase Font Size and Decrease Font Size buttons to alter the font size of the
entries in selected cells by predefined increments.
Borders
Clicking the Borders button adds a default border around selected cells. The Borders drop-down
menu contains different border styles that you can choose to apply.
Fill Color
Clicking the Fill Color button applies a background color to selected cells. You can expand the
Fill Color drop-down list to choose a fill color from a range of colors.
Font Color
Clicking the Font Color button changes the color of the entries in selected cells from the default
black to the font color that was last chosen. To choose a text color, you click the Font Color
drop-down button.
Try It
Now you try formatting the text in a selected cell by changing its font and font size, applying bold,
and changing the font color.
Cell G1, containing the text Timesheet, is selected.
139

To complete the task
1. Select Segoe UI from the Font drop-down list
The Font drop-down list lists various fonts in alphabetical order.
2. Select 14 from the Font Size drop-down list
The Font Size drop-down list contains various font sizes, listed as numbers. The text was in 12-point.
3. Click Bold
4. Select Orange from the Recent Colors section of the Font Color gallery
The Font Color gallery is divided into Theme Colors, Standard Colors, and Recent Colors. There is also
a More Colors option. In this case Orange is the first color in the Recent Colors section.
You've formatted text so that it displays in the Segoe UI font at a size of 14 points, in bold, and in an
orange color.
Some options in the Font group are also available on the Mini Toolbar. This is a smaller,
undocked toolbar that includes only text-formatting options.
Graphic
The Mini Toolbar displays alongside the selected cell G1. It includes options for changing the font
type, size, and color, as well as other common formatting commands such as Bold and Italics.
The Mini Toolbar appears when you select text. It remains faded though, until you move your
cursor over it. You can use the Mini Toolbar to select a font, font size, or font color, and to make
text display in bold or italics.
Question
Which are examples of ways you can format worksheet entries using options in the Font group?
Options:
1. You can italicize numbers and text
2. You can change the font color to red
3. You can increase the font size of headings
4. You can rotate the text so it runs diagonally across a cell
5. You can cut and paste data from one cell to another
Answer
Option 1: Correct. You can use the Italics button in the Font group to italicize data in one or more
selected cells.
Option 2: Correct. You can use the Font Color button to change the font color in selected cells to a
default color, which you can select from the Font Color drop-down list.
140

Option 3: Correct. You can use either the Font Size drop-down list or the Increase Font Size
button to make headings or any other data you select bigger.
Option 4: Incorrect. Although Excel does enable you to rotate text, the option for doing this isn't
located in the Font group.
Option 5: Incorrect. You can copy, cut, and paste data in Excel, but this doesn't involve formatting
content and options for performing these actions aren't located in the Font group.
Correct answer(s):
1. You can italicize numbers and text
2. You can change the font color to red
3. You can increase the font size of headings
2. Applying borders and fills
Whereas most commands in the Font group apply formatting to the text within cells, two
commands apply formatting to selected cells themselves the Borders button and the Fill
Color button.
Graphic
The Home tab displays.
You can use the Borders button to apply a border around the selected cells. The default border
is whatever option you used most recently.
Graphic
In the example, the default is No Border.
Using the Borders drop-down menu, you can choose to apply a border to the cells you've
selected. This border will then become the default border shown on the Borders button.
Graphic
The Borders drop-down menu contains several border options, such as Bottom Border, Top Border,
Left Border, and Thick Box Border.
The Draw Borders menu lets you customize the color and style of the lines the borders are
drawn in, or to erase an existing border. You can also use the Draw Border or Draw Border
Grid options to apply border formatting directly to cells as you select them.
141

Graphic
In addition to these options, there are also Erase Border and Line Color options.
You can use the Fill Color button to change the background color of the active cells. Again, the
default option is whatever was selected most recently.
Graphic
The Fill Color button is available from the Font group of the Home tab.
You can choose a fill color by clicking the Fill Color drop-down button. For example, if you
wanted to give a particular range of cells a turquoise background color, you'd first select the
cells and then select the Turquoise option in the Fill Color gallery.
Graphic
The Fill Color gallery is divided into three sections Theme Colors, Standard Colors, and Recent
Colors. Each section contains sample blocks of different colors. There are also No Fill and More
Colors options.
Try It
Now you try formatting the selected cells in a worksheet by adding a bottom border to them and
changing their fill color to turquoise.
The cell range F8:J8, containing the days of the week as well as the dates, is already selected.
To complete the task
1. Select Bottom Border from the Borders drop-down menu
2. Select Turquoise from the Recent Colors section of the Fill Color gallery
You've formatted the cells by adding a bottom border and changing the background fill color to
turquoise.
3. The Format Cells dialog box
To access a wider range of formatting options, you can open the Format Cells dialog box. You
access this dialog box by clicking the Font launcher.
Graphic
142

The Format Cells dialog box has several tabs: Number, Alignment, Font, Border, Fill, and
Protection. By default, the Font tabbed page displays.
You can use the Number tabbed page to apply different formatting options to numbers.
Graphic
The Number tabbed page contains a Category list, which includes categories such as General,
Number, Date, and Time. There is also a Sample section as well as a Type list box, and a Locale
(location) drop-down list box. With the Date category selected, the Sample section contains the date
11/26/2010. In the Type list, *3/14/2001 is selected. The Locale (location) drop-down list is set to
English (U.S.).
And the Alignment tabbed page lets you alter the way text is positioned within cells.
Graphic
The Alignment tabbed page contains the Text alignment, Text control, Right-to-left, and Orientation
sections.
You use the Protection tabbed page to lock or hide certain cells.
Graphic
The Protection tabbed page has two checkboxes: Locked and Hidden. Enabling these settings has
no effect unless the worksheet is protected.
On the Font tabbed page, you can alter the font, font style, font size, and color of the text in
selected cells.
Graphic
The Font tabbed page has Font, Font style, and Size list boxes, each containing several options.
There are also Underline and Color drop-down list boxes and a Normal font checkbox. In addition,
there are two sections: Effects and Preview.
You can select different underlining effects from the Underline drop-down list.
Graphic
Options in the Underline drop-down list are None, Single, Double, Single Accounting, and Double
Accounting.
143

You can also choose to apply strikethrough, superscript, or subscript effects to text. And you can
view the effect of options you choose before applying them in the Preview pane.
Graphic
The Effects section has three checkboxes: Strikethrough, Superscript, and Subscript.
On the Border tabbed page, you can choose the style and color of a border to apply to selected
cells.
Graphic
The Border tabbed page includes a Line section with a Style pane, which displays sample line
styles, and a Color drop-down list which expands to display a gallery.
You can then choose where the border must be positioned for example, inside or outside a
cell's boundary, or only along the top or one of the sides of the cell. To do this, you can click one
of the buttons in the Presets section, click the required position inside the Border preview
window, or click one of the buttons surrounding the Border preview window.
Graphic
The Border tabbed page also contains two sections: Presets and Border. The Presets section
includes three options None, Outline, and Inside. The Border section contains a preview window
and a button for each possible placement of a border within a cell.
Using options on the Fill tabbed page, you can change the background color of selected cells to
a color you choose from the Background Color gallery.
Graphic
The Fill tabbed page includes a Background Color gallery. There are also Pattern Color and Pattern
Style drop-down lists, as well as Fill Effects and More Colors buttons.
You can also choose to add a pattern to the cells.
Graphic
You use the Pattern Color and Pattern Style drop-down list boxes for this.
You can use the Pattern Color drop-down gallery to select a pattern color. The gallery lets you
choose from colors associated with the theme currently applied to your document, from a set of
144

standard colors, or from colors you've used recently. You can also choose to access more color
options.
Graphic
The Pattern Color drop-down gallery contains the Theme Colors, Standard Colors, and Recent
Colors sections. More Colors are available and the Automatic color chip is selected.
You select the pattern itself from the Pattern Style drop-down gallery. The gallery displays each
pattern in black and white, although it will be applied in whichever color you choose from the
Pattern Color drop-down gallery.
Clicking the Fill Effects button opens the Fill Effects dialog box.
You can use this dialog box to apply a gradient, with color and a shading style you choose, as
the background color of cells.
Graphic
The Fill Effects dialog box has one tab named Gradient. It has four sections: Colors, Shading styles,
Variants, and Sample.
In the Fill Effects dialog box, the Colors section includes three options.
One color
You choose the One color option to apply a gradient consisting of a single color but with a
gradual change in shading as the background color of the selected cells.
Two colors
You can choose the Two colors option to apply a gradient in which one color gradually
transforms into a second color. For example, you can use this option to apply a background in
which white gradually changes to blue in a cell or range of cells. You can specify the two colors to
use.
Preset
You choose the Preset option to apply a gradient using the color currently set as the default.
In the Shading styles section, you can specify how the shading in the gradient you apply must
display. For example, you can set the shading to transition horizontally or vertically or from the
center of the selected cells outwards.
Graphic
The Shading styles section includes Horizontal, Vertical, Diagonal up, Diagonal down, From corner,
and From center radio buttons.
145

For the style that's currently selected, the Variants section displays additional options. For
instance, using two colors and with the Horizontal option selected in the Shading styles section,
you can choose whether the darkest shading must begin in a horizontal band at the bottom, top,
or center of the selected cells.
Also in the Fill Effects dialog box, a Sample block provides a preview of the selected options.
The Fill tabbed page also lets you apply a pattern over the background color. You can use the
Pattern Color drop-down gallery to select a pattern color.
You can then select the pattern itself from the Pattern Style drop-down gallery.
Try It
Now you try formatting the selected cells using the Format Cells dialog box. You want to add a two-
color gradient as a fill effect and to add a thick bottom border to the cells.
The cell range C12:G12 column headers is selected in the Expense Budget December
worksheet.
To complete the task
1. Click the Font launcher, click the Fill tab, and click the Fill Effects button
2. Select Olive Green, Accent 3, Lighter 40% which is the fourth option in the seventh column from
the Color 1 drop-down gallery, select White which is the first option in the first column from the Color
2 drop-down gallery, and click OK
3. Click the Border tab and select the Thick Line option which is the second-last option on the right
from the Style gallery
4. Select Olive Green, Accent 3, Lighter 40% the fourth option in the seventh column from the Color
gallery and then click the Bottom Line button in the Border preview section
5. Click OK
You've formatted the cells to include a two-color gradient fill and a thick line bottom border.
4. Using the Format Painter
If you've made several changes to the formatting of a group of cells and want to apply these
same changes to other cells, you can save a lot of time by using the Format Painter to copy and
apply all the formatting settings.
To use the tool, you first select the cells with the formatting you want to copy and click the
Format Painter button in the Clipboard group.
Graphic
146

The Expense Budget December worksheet is open in Excel. A row of headings is selected.
The cursor changes to show that you can apply the selected formatting.
Graphic
The cursor displays as a white plus sign next to a paintbrush.
You can then simply select a cell to apply the new formatting to the same number of cells you
originally selected. For example, if you copied the formatting in cells C4 to G4, and wanted to
apply it to cells C12 to G12, you'd select only cell C12 to apply the formatting.
SkillCheck
You want to apply formatting to the headings in your worksheet so it looks more professional.
You've already selected cells D8 to F8.

Use the options in the Font group to set the headings in the selected cells to display in the Segoe UI
font at a size of 12 points, in bold, and with the background color setting of Orange, Accent 6,
Lighter 80% which is the second option in the tenth row of the gallery. Finally, use the Format
Painter to copy the formatting changes to cells G8 to I8.
The Sales Seattle December worksheet displays. The column headers, including cells D8 to F8,
currently display as Segoe Script, 10.
Task:
1. Change the font style by selecting the option in the Font Style drop-down list.
2. Change the font size by selecting the option in the Font Size drop-down list.
3. Add a border by selecting an option from the Borders drop-down list.
4. Click the Fill Color drop-down button and select Orange, Accent 6, Lighter 80% from the Theme
Colors section of the gallery.
5. Copy the formatting with the Format Painter and then click the cell that requires formatting.
Answer
To complete the task
Step 1: Select Segoe UI from the Font drop-down list
Step 2: Select 12 from the Font Size drop-down list
Step 3: Click the Bold button
147

Step 4: Click the Fill Color drop-down button and select Orange, Accent 6, Lighter 80% from the
Theme Colors section of the gallery
Step 5: Click the Format Painter button in the Clipboard group and then select cell G8
Summary
Using Excel 2010, you can format cells and data to enhance the visual appeal and readability of
a worksheet.

You can use options in the Font group to change the font style, size, and color of text within
selected cells. You can also use the Mini Toolbar to do this.

You can also use Font group options to apply borders or background colors to selected cells.

The Format Cells dialog box contains all the options available in the Font group. It also lets you
apply patterns or fill effects to cells, and to change the line styles and colors of borders.

Using the Format Painter, you can easily copy formatting and apply it to additional cells.
















148

Aligning data in Excel 2010
Learning Objective
After completing this topic, you should be able to
recognize how alignment commands change the position of text
1. Alignment of data
Excel 2010 aligns data differently within worksheet cells depending on whether it's text, times,
dates, or numbers. In some cases though, you may want to change the default way data is
positioned. Depending on the type of the data, you can choose from several alignment options.
For instance, you can indent text or, if text is too long to display fully in a cell, you can set it to
wrap to a new line within that cell.
Graphic
In a worksheet detailing various expenses of salespeople, one column of data contains text items
indented in different ways. These items are selected and indented uniformly. In a row containing the
names of salespeople, the full names aren't visible in the cell because the text is too long to display
fully. Wrapping the text positions the names and surnames of the salespeople on separate lines in
the cells.
You can convert two or more adjacent cells into one, larger cell so that text like a heading will fit
in the cell. You can also use an alignment option to change the orientation of text so that it
displays vertically instead of horizontally, for example.
Graphic
In the same worksheet, four separate cells in a header row are selected and merged. The data
contained in one of the original cells now displays in the center of the merged cell. In addition,the
orientation of text in a narrow column is changed from horizontal to vertical, so that all the text is
visible.
You can control and adjust the alignment of data in an Excel 2010 worksheet using the
commands in the Alignment group on the Home tab of the Ribbon.
Graphic
The Sales Seattle December worksheet is open in Excel.The Excel interface includes several
default elements a mini toolbar of frequently used commands, a Ribbon containing several tabs
such as Home, Insert, and Page Layout, and a formula bar. The spreadsheet appears below these
elements.
149

The commands in the Alignment group are divided into three sections.
Graphic
Other groups on the Home tab include Clipboard and Font.
Select each section of the Alignment group to find out more about it.
First section
You can use the six buttons in the first section in the Alignment group to change the alignment of
entries in relation to the left or right, top or bottom, borders of their cells.
Second section
You use the three buttons in the second section of the Alignment group to control the orientation
and indentation of data in selected cells.
Third section
The two buttons in the third section of the Alignment group let you control the positioning of data
within selected cells.
The first section of the Alignment group is made up of two rows, each containing three buttons.
You use these to alter the horizontal alignment of entries in selected cells in different ways.
The first row of buttons lets you change the vertical alignment of the data in selected cells. The
Top Align button moves and positions data within a cell against the top border of that cell,
without changing its default alignment to the right or the left.
The Middle Align button moves and positions data in a cell to the center point between the
cell's top and bottom borders, without changing its default alignment to the right or the left.
The last button in the first row is the Bottom Align button. This lets you move data in a cell
against the bottom border of the cell, without changing its default alignment to the right or the
left.
You can use the second row of buttons in the first section of the Alignment group to control the
horizontal alignment of data entries in selected cells.
The Align Text Left button moves the entry in a cell against the left border of the cell, without
changing its position in relation to the cell's top and bottom borders.
The Center button adjusts data so that it's centered between the left and right borders of a cell.
The last button in this row is the Align Text Right button.
You can use this button to move data against the right border of a cell, without changing its
position in relation to the cell's top and bottom borders.
150

The three buttons that make up the second section in the Alignment group are the Orientation,
Decrease Indent, and Increase Indent buttons.
Select each button for more information about it.
Orientation
You can use the Orientation button to access options for changing the orientation of data in
selected cells. For instance, you can choose to display entries vertically instead of horizontally, or
at another angle you'd like.

Just be aware that if you've already adjusted any of the cell dimensions in a worksheet, entries
you decide to display at an angle may run into adjacent cells. You can correct this by widening
the affected row or column of data.
Decrease Indent
Indentation is useful when you want to set certain cell entries apart from others. It alters the
margin between data and either the left or right border of a cell, depending on the side to which
the data is aligned.

The Decrease Indent button decreases the margin between an entry in a cell and the border of
that cell. If text is centered or left aligned, clicking the button reduces the margin between an
entry and the left border while, if an entry is aligned to the right, it decreases the default margin
between the entry and the cell's right border.
Increase Indent
The Increase Indent button is similar to the Decrease Indent button, but is used to increase the
margin between the entry in a specific cell and the border of the cell.

For instance, if text is centered or left aligned, clicking the button will indent the text further to the
right while, if an entry is aligned to the right, clicking the button increases the default margin
between the entry and the cell's right border.
Sometimes the data in a cell doesn't display fully in a cell because it's too long to fit into the cell.
Graphic
For example the full name Bruce Oprisan doesn't display fully in the selected cell.
When this happens, you can make use of either of the two buttons on the right of the Alignment
group the Wrap Text button and the Merge & Center button.
Select each button for more information about what it does.
Wrap Text
151

The Wrap Text button wraps data in a cell onto a new line if it's too long to fit on a single line,
given the existing width of the cell. The height of the cell automatically adjusts to accommodate
more than one line of text, unless the lines fit given its existing height.
Clicking this button puts Bruce on one line and Oprisan on the next line in the same cell.
Merge & Center
The Merge & Center button combines two or more selected, adjacent cells to create a single,
larger cell. Only the entry in the top, leftmost cell is retained in the larger cell, and this entry is
aligned to the center.
The text Salesperson is now in the center of four merged cells.
Try It
Now you practice using alignment options to change the alignment of the text in cells E8 and C9.
Cell E8 is already selected.
In an Excel spreadsheet, the name Bruce Oprisan doesn't fit into cell E8. The row heading Sales
item is vertically aligned, and is read from top to bottom.
To complete the task
1. Click the Wrap Text button and then click the Align Text Left button
2. Click the Increase Indent button
3. Select cell C9 and select Rotate Text Up from the Orientation drop-down menu to make the text in the
cell face the other way
The Orientation drop-down menu options are Angle Counterclockwise, Angle Clockwise, Vertical Text,
Rotate Text Up, Rotate Text Down, and Format Cell Alignment.
You've changed the alignment of text in cells.
You can access additional options for aligning data by clicking the Alignment launcher.
Graphic
The Alignment launcher is available from the Alignment group of the Home tab on the Ribbon.
This opens the Format Cells dialog box on the Alignment tabbed page. This page includes many
of the same options as the Alignment group, as well as options for shrinking text to fit a cell and
for changing the direction of the text.
Graphic
The Alignment tabbed page includes a Text alignment section with Horizontal and Vertical drop-
down list boxes and an Indent spin box. It includes a Text control section with Wrap text, Shrink to
fit, and Merge cells checkboxes. There are also Orientation and Right-to-left sections.
152

It also lets you specify the exact angle at which to orient data within selected cells.
Graphic
There is a Text direction drop-down list box in the Right-to-left section and an Orientation pane with
a Degrees spin box in the Orientation section.
Question
Match the command from the Alignment group with the graphic depicting the way it changes text
positioning.
Options:
A. Align Center
B. Merge & Center
C. Wrap Text
D. Middle Align
Targets:
1. t6_158_sg.png
2. t6_159_sg.png
3. t6_160_sg.png
4. t6_161_sg.png
Answer
The Align Center button aligns data in a cell so that it's centered between the left and right borders
of the cell.
The Merge & Center button combines two or more adjacent cells to create a single, larger cell when
text is too long.
The Wrap Text button adds a line break to text if it's too long and has reached the right border of a
cell.
The Middle Align button moves data in a cell to the center point between the cell's top and bottom
borders.
Correct answer(s):
Target 1 = Option A
153

Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Summary
In Excel 2010, you can change the position and orientation of data within cells using the
commands in the Alignment group on the Home tab. You can change the orientation of entries
in selected cells, choose to align entries to the top, bottom, middle, left, or right of their cells, or
align entries so that they display at an angle. You can also choose to change the indent
between cell entries and the cell borders, and either wrap text or merge cells if data is too long
to fit into a cell.



















154

Formatting Numbers in Excel 2010
Learning Objectives
After completing this topic, you should be able to
apply and modify number formats
match number formats with examples
1. Using the Format Cells dialog box
In Excel 2010, you can enter numbers into a spreadsheet without formatting them and then save
time by formatting a range of cells all at once. You can also change one or a range of cells to a
wide variety of styles to show numbers refer to currency values, dates, times, scientific
formulae, or even custom-made styles.
In worksheets, numbers can represent different kinds of data. For example, a number might be
an amount in US dollars, a phone number, or a date. Using Excel's number formatting options,
you can quickly and easily distinguish between different kinds of numeric data.
Graphic
An example of a date is 11/15/2010, a phone number 206-555-4926, and currency $14.346.45.
Because number formatting options apply required formatting automatically, they help prevent
errors that can occur when you type. For example, formatting a value as a currency in Excel
2010 automatically adds a currency symbol before and two decimal spaces after the number in
the selected cell.
Graphic
The Sales Seattle December worksheet is open in Excel.The Excel interface includes several
default elements a mini toolbar of frequently used commands, a Ribbon containing several tabs of
commands, and a formula bar. The worksheet appears below these elements. It details the different
sales amounts in dollars for different salespeople.
By default, Excel will treat an entry containing any letters as text, even if it contains numbers too.
It's important to remember this if you want to use Excel to perform calculations for instance to
add a column or row of figures.
Graphic
For example, the cell F10 contains the value Dols 3726.
155

For example, if you're preparing a budget and you decide to enter "DOLS" or "EURO" instead of
the appropriate currency symbol, Excel will ignore this data when performing a calculation. This
could have far-reaching consequences, because the result of the calculation would then be
incorrect.
Graphic
In this case, the value Dols in F10, which represents a sales figure for Chadrick Powell, is not added
to the total sales in I10.
To avoid these kinds of errors, you should use the number formats Excel provides.
Graphic
The value in cell F10 is now $37,260 and is added to the total sales in I10.
Question
What are the benefits of using the number formatting options in Excel?
Options:
1. Fewer errors
2. Cells containing numbers and letters are factored into calculations
3. Faster formatting of data
4. Once you've formatted cells, letters added accidentally will be removed
Answer
Option 1: Correct. You can format numbers so they appear in a uniform manner. This makes it
easier to automate calculations in Excel.
Option 2: Incorrect. Excel will treat cells containing letters and numbers together as text and won't
factor these figures into calculations. You use the number formats to add other data, such as
currency symbols.
Option 3: Correct. You can enter data into a range of cells and then format them all at once to save
time.
Option 4: Incorrect. If you format cells before entering your data, you'll still have to be careful to
enter the correct type of data into the cells.
Correct answer(s):
156

1. Fewer errors
3. Faster formatting of data
Changing the formatting of a number changes the way it appears but doesn't alter its value.
When Excel makes calculations, it uses the data you originally typed into a cell and it's this
that continues to display in the Formula Bar.
Graphic
$37,260 in E10 appears as 37260 in the Formula Bar.
To apply formatting to numbers, you can click the Number launcher on the Home tab to open
the Format Cells dialog box.
Graphic
The Format Cells dialog box opens on the Number tabbed page.
You can select format options from this comprehensive list of number formats and customize the
format you apply to a selected cell or cell range.
Graphic
The Category list includes General, Number, Accounting, Date, Time, and Scientific.
By default, numbers you enter in an Excel worksheet have the General format. In this format,
the values are recognized as numeric and Excel automatically aligns them to the right of cells.
The General format also displays numbers too long to fit in cells or that are 12 or more digits in
exponential notation.
Graphic
With the General category selected, what appears as a currency in the worksheet $159,780
appears without formatting in the Sample section as 159780.
The Number format includes decimal places after the number. The default is two decimal
places, although you can customize this. You can also choose to add thousands separators.
Graphic
With the Number category selected, the value selected in the worksheet $159,780 appears in
the Sample section as 159,780. The Decimal places spin box is set to 0. The Use 1000 Separator (,)
checkbox is selected.
157

You can apply the Currency format to numbers that represent monetary values. This
automatically adds a currency symbol a dollar sign by default, although you can change this
as applicable. Like the Number format, it also adds two decimal points to numbers although
you can customize this. The Currency format also allows you to specify how negative numbers
display.
Graphic
With the Currency category selected, the value selected in the worksheet $159,780 appears in
the Sample section as $159,780. The Decimal places spin box is set to 0. The Symbol drop-down
list box specifies the currency as $ English (U.S.).
Like the Currency format, the Accounting format interprets numbers as currency, adds two
decimal points by default, and adds thousands separators. You can also change the currency
and the number of decimal points if you want to. The main difference between the two formats is
that the Accounting format aligns the decimal points in a column, for easier comparison of
values.
Graphic
With the Accounting category selected, the value selected in the worksheet $159,780 appears in
the Sample section of the Currency category as $159,780. The Decimal places spin box is set to 0.
The Symbol drop-down list box specifies the currency as $ English (U.S.).
Question
Match each description to its corresponding number format. A description may match to more than
one format.
Options:
A. Adds decimal places to the number
B. Adds a currency symbol
C. Aligns decimal points in a column
D. Aligns numbers to the right, but applies no other formatting
Targets:
1. Number format
2. Currency format
3. Accounting format
4. General format
Answer
158

The Number format adds two decimal places after the number by default, but you can customize
this.
The Currency format displays numbers as currency values, with currency symbols, thousands
separators, and by default two decimal places.
The Accounting format displays numbers as currency values, with currency symbols, thousands
separators, two decimal places, and aligns decimal points.
The General format aligns numbers to the right of each cell and is the default format for numeric
entries.
Correct answer(s):
Target 1 = Option A
Target 2 = Option A, Option B
Target 3 = Option A, Option B, Option C
Target 4 = Option D
The Date format interprets numbers as dates. You can select a range of different date formats,
according to local conventions. These become available depending on the location you specify.
You can specify a short date, or include the month, or day of the week.
Graphic
With the Date category selected, the value selected in the worksheet $159,780 appears in the
Sample section as 6/17/2337. The Type list box lists different date formats. The format *3/14/2001 is
selected. The Locale (location) drop-down list is set to English (U.S.).
The Time format interprets numbers as times of day. Like the Date format, the options available
will change according to the location you specify. You can choose to apply 24-hour format, or
include an AM or PM suffix.
Graphic
With the Time category selected, the value selected in the worksheet $159,780 appears in the
Sample section as 12:00:00 AM. The Type list box contains different time formats. The time
*1:30:55 PM is selected. The Locale (location) drop-down list is set to English (U.S.).
The Percentage format interprets numbers as percentages to a number of decimal places. The
default is two decimal places, but you can customize this.
159

Graphic
With the Percentage category selected, the value selected in the worksheet $159,780 appears
in the Sample section as 15978000%. The Decimal places spin box is set to 0.
The Fraction format interprets numbers as fractions of a whole. You can select the denominator
of the fraction for example, the number 8 could be interpreted as eight hundredths or eight
tenths, depending on the fraction type you've specified.
Graphic
With the Fraction category selected, the value selected in the worksheet $159,780 appears in
the Sample section as 159780. The Type list box has several formats, such as Up to one digit (1/4),
Up to two digits (21/25), and As sixteenths (8/16)..
Question
Match each description to its corresponding number format.
Options:
A. Separates numbers with colons to indicate a particular point in a day
B. Divides numbers into day, month, and year
C. Indicates proportion and includes a specified number of decimal places
D. Interprets numbers as part of a whole
Targets:
1. Time
2. Date
3. Percentage
4. Fraction
Answer
The Time format displays numbers as times, divided by colons into hours, minutes, and seconds.
The Date format displays numbers as dates, either using a combination of words and numbers or
separating the numbers representing days, months, and years with forward slashes.
The Percentage format adds a percentage symbol after numbers. You can specify the number of
decimal places that must display.
160

The Fraction format interprets numbers as part of a whole. Numbers are positioned in the middle of
cells.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
The Scientific format is useful for large numbers because it displays numbers in exponential
notation. In this notation, a number is represented by the first part of the number, rounded off,
with the formula E+n added. The number before E is multiplied by 10 to the nth degree to reach
the original number. You can choose the number of decimal places to apply.
Graphic
With the Scientific category selected, the value selected in the worksheet $159,780 appears in
the Sample section as 2.E+05. The Decimal places spin box is set to 0.
The Text format interprets whatever data is entered into the cell as text. All numbers, text, or
combinations of numbers and text appear exactly as they've been entered, and are aligned to
the left of the cell.
Graphic
With the Text category selected, the value selected in the worksheet $159,780 appears in the
Sample section as 159780.
The Special format can be used to apply additional, unique number formats to the data. The
options available change according to the location specified. For example, you could format a
number as a social security number.
Graphic
With the Special category selected, the value selected in the worksheet $159,780 appears in the
Sample section of the as 159780. The Type list contains the options Zip Code, Zip Code +4, Phone
Number, and Social Security Number. The Locale (location) drop-down is set to English (U.S.).
The Custom format option lets you to customize a number format yourself by modifying existing
number formats.
161

Graphic
With the Custom category selected, the value selected in the worksheet $159,780 appears in
the Sample section as 159780. The Type list box contains several number formats, for example,
mm:ss and dd/mm/yy.
Try It
Now you try using the Format Cells dialog box to format the numbers in cells D44 to D48 as
currency values with no decimal places. The cells have already been selected.
The Wireless Tech Conference worksheet outlines the estimated and actual cost of items for a
conference. A list of numbers in the Actual column, D44 to D48, have been selected.
To complete the task
1. Click the Number launcher
2. Select the Currency category of options
3. Click the down arrow in the Decimal places spin box twice
4. Click OK to apply the changes
You've formatted the cells D44 to D48 so the numbers are in the Currency format with no decimal
points.
Let's say you also want to format cells so they show the time in 24-hour format rather than with
the AM or PM suffix.
Graphic
A timesheet displays in Excel. The cell range F9:J9 which displays the start time in the morning
is selected. F9 contains the time 8:55:00 AM.
To do so, you access the Format Cells dialog box, select Time, and then choose the format you
want from the Type list.
Graphic
13:30 is selected from the Type list. The Sample section displays 8:55.
The numbers in the cell then display in this customized format, although the format still displays
as "Time" on the Number group.
Graphic
162

The cell F9 displays 8:55 whereas the Formula Bar displays 8:55:00 AM.
Question
Match each description to the corresponding number format.
Options:
A. Displays numbers in exponential notation
B. Aligns cell entries to the left of the cell
C. Applies unique formats, depending on your location
D. Enables you to modify pre-existing formats to suit your needs
Targets:
1. Scientific
2. Text
3. Special
4. Custom
Answer
The Scientific format displays numbers in exponential notation.
The Text format treats numbers the same way as text. Numbers are displayed in the same way as
they're entered into the cell.
The Special format includes a range of location-specific formats.
The Custom format lets you modify pre-existing formats or build a new format.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
163

2. Using the Ribbon's Number commands
The commands in the Number group on the Ribbon provide an alternative way to apply some
common number formatting changes. You can use these commands to quickly apply changes to
cells without needing to open the Format Cells dialog box.
Graphic
The Seattle Sales December worksheet displays. The Number group is on the Home tab of the
Ribbon. The cell I10, containing the value 159780, is selected in the worksheet.
Select each button in the Number group to learn more about the number format it applies.
Accounting Number Format
You use the Accounting Number Format button to apply the Accounting format to the selected
cells. As with the Accounting option in the Number format drop-down menu, numbers are
interpreted as values in the currency of your choice with two decimal places. The decimal point
places are aligned.

You can also click the Accounting Number Format drop-down list button to access some other
currency symbols. If you select More Accounting Formats, the Format Cells dialog box opens at
the Accounting option in the Number tabbed page. You can then make other currency selections
or change the number of decimal places.
$159,780 appears as $159,780.00 in cell I10.
Percent Style
You can click the Percent Style button to format the number in the selected cell as a percentage.
No decimal points are added to the number in the cell.
$159,780 appears as 15978000% in cell I10.
Comma Style
You use the Comma Style button to apply the Accounting format without a currency symbol. In
other words, a thousands separator and two decimal points are added to the numbers.
$159,780 appears as 159,780.00 in cell I10.
Increase Decimal
You can click the Increase Decimal button to increase the decimal places after the numbers in
the selected cell. Each click you make adds another decimal place to each number.
$159,780 appears as 159,780.0 in cell I10.
Decrease Decimal
You can click the Decrease Decimal button to decrease the decimal places after the numbers in
the selected cell. Each click you make removes another decimal place from each number.
$159,780 appears as 159780 in cell I10.
164

The Number format drop-down list box displays the format that has been applied to the selected
cell, which in this case is a currency. If no format has been applied, the default format General
displays.
Graphic
Cell E10 is selected $37,260 and the Number format drop-down list box displays Currency.
The commands in the Number group are mainly for devising your own accounting-related
formats. But you can access other basic number formats in the Number format drop-down list.
Graphic
Some of the options in the Number format drop-down list are General, Number, Currency,
Accounting, Short Date, Time, and Percentage.
You can choose from among a range of number formatting categories on the list. A preview of
what the number in the selected cell will look like accompanies each format option.
Graphic
The selected cell E10 contains the currency $37,260. So, in the Number format drop-down list, the
General format displays No specific format, the Number format displays as 37260.00, the
Accounting format as $37,260.00, and the Short Date format as 1/4/2002.
Selecting the More Number Formats option from the drop-down list launches the Format Cells
dialog box. Because the selected cell contains a currency, the dialog box displays the Currency
category on its Number tabbed page.
Graphic
In the dialog box, the Sample section of the Currency category displays $37,260.
Try It
Now you try applying a number format using the options on the Number group. You want to format
the cells C44 to C48 so they're in a Currency format, but without decimal places.
The Wireless Tech Conference worksheet outlines the estimated and actual cost of items for a
conference. The cells C44 to C48, containing values in the Estimated column, have been selected.
To complete the task
1. Select Currency from the drop-down list
165

2. Click the Decrease Decimal button twice
You've applied number formatting to selected cells.
SkillCheck
You're working on a timesheet for one of your employees. You'd like to format the date to reflect the
month, day, and year while using as little space as possible. You also want to change the time
format in cell J9 to a short 24-hour format to match the rest of the worksheet.

Use the Number format drop-down list to change the numbers in cells F8 to J8 to a short date form.
Then change the time in cell J9 to a short 24-hour format using the Format Cells dialog box.
A timesheet displays in Excel. The cell range F8:J8 which displays the dates for Monday to Friday
is selected. F9 contains the date 8-Nov-10. J9 displays the time as 7:50:00 AM.
Task:
1. You access the Number format drop-down list by clicking the drop-down arrow. You apply the format by
clicking the Short Date option in the list.
2. You click the cell to select it.
3. You click the Number launcher to open the Format Cells dialog box and then select the option from the
Type list.
4. You click OK to apply the format.
Answer
To complete the task
Step 1: Select Short Date from the Number format drop-down list
Step 2: Select cell J 9
Step 3: Launch the Format Cells dialog box and select 13:30 from the Type list
Step 4: Click OK
Summary
You can apply various number formats in Excel 2010 to differentiate between different types of
numeric values, such as currency values, percentages, dates, and times. This helps prevent
errors that can occur when you add formatting manually. Because you can apply formatting to
columns or rows before entering values, it also makes entering data faster.

To apply number formats, you can use the options in the Number group on the Ribbon, including
166

a drop-down list of available number formats. For a wider range of number formatting options,
you use the Number tabbed page in the Format Cells dialog box.



























167

Formatting Data in Excel 2010
Learning Objectives
After completing this topic, you should be able to
format text and cells
align text in a cell
modify and apply a number format
Exercise overview
This topic teaches you how to perform tasks using Excel 2010, simulating the application
interface and guiding you through the tasks. The instructions for completing the exercise are
presented on screen.
In this exercise, you're required to apply formatting to text, cells, and numbers in an Excel 2010
worksheet.
This involves the following tasks:
applying formatting to text and cells
changing the alignment of data in worksheet cells, and
applying number formatting
Task 1: Formatting text and cells
You've used an Excel worksheet to create a timesheet for an employee. You now want to format
some of the text in the worksheet to make it more visually appealing.
Use an option in the Font group in the Ribbon to format the heading in cell G1, which is
currently selected, in bold and to change its font color to the orange color in the top row of the
Theme Colors section of the Font Color gallery. Then change the size of the text in cell I2 to 12
points. Finally, use options in the Format Cells dialog box to change the background fill color in
cell K13 to light blue, using the fourth color in the second row of the Background Color gallery.
Steps list
Instructions
1. Click the Bold button
2. Click the Font Color drop-down button and select the orange color in the top row of the Theme Colors section of
the gallery
168

Steps list
Instructions
3. Select cell I2 and select 12 from the Font Size drop-down list
4. Select cell K13, click the Font launcher, and click the Fill tab
5. Select the fourth color in the second row of the Background Color gallery and click OK
Task 2: Aligning data
Next you want to change the alignment of the "Timesheet" heading and of the address in the
worksheet.
Use options in the Alignment group to merge cells G1 and H1 so that the heading currently in
cell G1 displays in the center of the resulting cell. Then align the address in cell D3 to the top of
the cell.
Steps list
Instructions
1. Click Merge & Center
2. Select cell D3 and click the Top Align button in the Alignment group
Task 3: Applying number formatting
Last you want to change the way the dates in cells K3 and K4 of the worksheet display.
Using the Format Cells dialog box, set the dates which are already selected to display using
the format 14-Mar-01.
Steps list
Instructions
1. Click the Number launcher
2. Select Date from the Category list
169

Steps list
Instructions
3. Select 14-Mar-01 from the Type list and click OK
Basic font and cell formatting has been applied, data has been aligned, and number formatting
has been applied in a worksheet.






















170

Introducing Formulas and References in Excel 2010
Learning Objectives
After completing this topic, you should be able to
identify elements of a formula
recognize how Excel calculates precedence in a formula
recognize examples of reference types used in Excel formulas
1. Formula elements
Excel 2010 lets you use formulas to perform calculations on data. For example, you can add
values in different cells, find average values, and calculate percentages. You can set up
formulas to perform calculations using the data in a range of adjacent cells for example, in one
column, in a set of cells that aren't adjacent, or even in cells in different worksheets.
Graphic
Some examples of formulas are =I9*H9, =SUM(H9,K9), and =SUM(L9:K17).
A formula is an equation. When you enter it in a cell, Excel 2010 calculates what's on the right
side of the equals sign and then displays the result in the cell. For example, if you enter the
simple formula =2+2 in cell A3 of a worksheet, Excel 2010 will display the resulting value of 4 in
cell A3.
Formulas can include five different elements. These are functions, references, constants,
operators, and parentheses.
Select each element for more information.
Graphic
An example formula is =SUM(A1,A2)+1.
Functions
In Excel 2010 a set of mathematical functions have already been pre-defined to help users to
carry out a range of useful mathematical operations. For example, SUM is an example of a
function that adds values you specify and returns the total.

Functions are useful for simplifying formulas, especially when the formulas must perform complex
calculations.
SUM is the function in the formula =SUM(A1,A2)+1.
171

References
A reference identifies a particular cell in a worksheet using the cell's column and row coordinates.
For example, the reference A1 refers to the cell in column 1 and row 1 of a worksheet.

In a formula, whatever value is in a referenced cell is the one that will be used. This is useful
because after you've entered a formula, you can change or correct values in the cells it
references, without having to update the formula.
A1 is an example of a cell reference.
Constants
Constants are values that don't change when a formula is calculated. An example is a number
like 1. Whereas the values of A1 and A2 change depending on what's in those cells, the number
1 doesn't refer to a cell's value and stays the same.

Expressions and the values that result from them are not constants.
In the formula =SUM(A1,A2)+1, the number 1 is an example of a constant.
Operators
Operators are signs representing particular types of calculations. Some types of operators are
basic arithmetic, mathematical, comparison, logical, and reference operators.

Examples of arithmetic operators are the signs representing addition, subtraction, multiplication,
and division.
A plus sign is an example of an operator.
Parentheses
Parentheses or brackets identify parts of a formula that must be evaluated before others. You
can use them to change the default order in which Excel performs particular calculations. In the
formula =1+2*4, for example, Excel will automatically multiply 2 by 4 before it adds 1. So the
resulting value is 9. However, the formula =(1+2)*4 equals 12, because the parentheses tell
Excel to add 1 and 2 before multiplying the result by 4.

Sets of parentheses may be nested within other sets. In this case, the part of a formula located in
the innermost set of parentheses is calculated first, followed by the part located in the next set of
parentheses, and so on, until the whole formula has been calculated.
The parentheses around A1 and A2 indicate that part of the formula should be calculated first.
Supplement
Selecting the link title opens the resource in a new browser window.
Job Aid
Access the job aid Excel 2010 Operator Types to read more about the four different types of
operators that you can use.
172

Question
Match each element to the corresponding part of the example formula.
The formula is =SUM(G1:G5)+12.
Options:
A. Function
B. Reference
C. Constant
D. Operator
Targets:
1. Create an image of the word "SUM"
2. Create an image of "G1:G5"
3. Create an image of "12"
4. Create an image of "+"
Answer
SUM is an example of a function. It tells Excel 2010 to add the values in specified cells in this
case, the values in cells G1 to G5.
G1 and G5 are examples of cell references. In the formula, G1:G5 identifies the range of cells
between column G, row 1 and column G, row 5 of a worksheet.
The number 12 is an example of a constant a value in a formula that doesn't change, even if data
referenced in the formula does.
The plus operator is an example of an arithmetic operator. It tells Excel 2010 to add the values on
either side of it.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
173

2. Calculating precedence
When Excel calculates a formula, it does so in a set order, based on fixed rules of precedence.
So within a formula, certain types of operations are always performed before others. You need
to be familiar with the rules of precedence that Excel uses to ensure that formulas you create
won't have unexpected results.
Graphic
The formula =SUM(A1,A2)+10 appears in the Formula bar.
First in the order of precedence are parentheses anything located inside parentheses is
always calculated first.
Graphic
The formula entered in this example is =SUM(A1,A2)+10. In this case (A1,A2) will be calculated
first.
Excel 2010 evaluates the parts of a formula in the following order:
1. the current values of cell references, such as A1 and B1
2. negative values, such as -A1
3. percentages, such as A1%
4. exponentiation, as in A1^2
5. multiplication and division, as in A1*B1
6. addition and subtraction, as in A1+B1
7. concatenation, as in A1&B1, and
8. comparison, as in A1<B1
If you create a formula that includes multiple multiplication and division operators, or multiple
addition and subtraction operators, Excel evaluates these from left to right.
Graphic
The formula is =A3*4+24/A7+5.
Excel also evaluates multiple sets of parentheses from left to right.
174

Graphic
The formula is =SUM(A4:A9)+25/(B6-10).
Precedence determines what the end result of a formula is. For example, in the formula
=2+4*3+1, Excel starts by multiplying 4 by 3 because multiplication has precedence over
addition. It then works from left to right, first adding 2 to the result and then adding 1. The total is
15.
In the formula =(2+4)*3+1, Excel starts by adding 2 and 4 because parentheses take
precedence over multiplication and addition. It then multiplies the result by 3 and finally adds 1,
for a total of 19.
Finally, in the formula =2+4*(3+1), Excel first adds 3 plus 1 because this is placed inside
parentheses. It then multiplies the result by 4 and finally adds 2, to end with 18.
Question
In what order does Excel 2010 evaluate the parts of this formula?
The formula is =9*B6+(12/E3).
Options:
1. It divides 12 by the value in cell E3, multiplies 9 by the value in cell B6, and then adds the two resulting
values
2. It multiplies 9 by the value in cell B6, divides 12 by the value in cell E3, and then adds the two resulting
values
3. It divides 12 by the value in cell E3, adds the resulting value to the value in cell B6, and then multiplies
that value by 9
Answer
Option 1: Correct. Excel 2010 evaluates anything inside parentheses first. Also, multiplication takes
precedence over addition.
Option 2: Incorrect. The calculation inside the parentheses will be evaluated first.
Option 3: Incorrect. Excel 2010 will start by evaluating what's in the parentheses. However, it will
then multiply 9 by the value in cell B6 because multiplication takes precedence over addition.
Correct answer(s):
1. It divides 12 by the value in cell E3, multiplies 9 by the value in cell B6, and then adds the two
resulting values
175

3. Reference types
At its most basic, cell referencing in Excel 2010 is called A1 referencing. This is the simple grid
referencing that identifies a cell using its column letter and row number. For example, A1
identifies the cell in column A, row 1.
Also using A1 referencing, you can identify a range of cells. You do this by referencing the first
cell in the range, typing a colon, and then referencing the last cell in the range.
Graphic
The formula is =SUM(D5:D10).
You can also refer to a cell in another worksheet in the same workbook. To do this, you preface
the cell reference with the name of the worksheet followed by an exclamation mark.
Graphic
The formula is =AVERAGE(Airlines1!E1:Airlines1!E17).
In the same way, you can include references to cells in other workbooks. These references are
called either links or external references.
A1 referencing can take different forms. It may be relative, absolute, or mixed. In addition, Excel
2010 supports what's known as three-dimensional referencing.
Select each referencing type for more information.
Relative
Relative cell references in a formula automatically change if the formula is moved to a different
cell, based on the relative location of the new cell.

Basic A1 references are relative. For instance, Excel automatically changes the reference A1 to
A2 if you move the formula containing it from cell B2 to cell B3.
Absolute
Absolute cell references always refer to the same cells. Unlike relative references, they don't
change if you move a formula containing them into a cell in a new location.

To create an absolute reference, you include a dollar sign before the column and row coordinates
for a cell. For example, $A$1 is an absolute reference.
Mixed
176

A mixed reference includes an absolute row reference and a relative column reference, or vice
versa. For example, $A1 includes an absolute column reference and a relative row reference,
whereas A$1 includes a relative column reference and an absolute row reference.

In a formula, the part of the reference that's absolute is fixed, whereas the part that's relative will
change automatically if you move the formula.
Three-dimensional
A three-dimensional reference identifies the worksheet in which a cell or range of cells is located.
An exclamation mark separates the name of the worksheet from the cell reference, as in the
example Sheet10!A7.

Using a three-dimensional reference, you can also reference a particular cell in more than one
worksheet, or in a range of worksheets. For example, the reference Sheet1:Sheet4!A3 identifies
cell A3 in the worksheets named Sheet1 and Sheet4, and in any worksheets located between
these.
If a formula contains a three-dimensional reference and you insert, remove, or move a
worksheet within the range of worksheets it identifies, the result of the formula will change
automatically. For example, if you copy or insert a new worksheet after Sheet1 in a workbook,
the three-dimensional reference Sheet1:Sheet4!A3 will automatically include the value in cell A3
of the added worksheet.
Graphic
For example the formula =SUM(Sheet1:Sheet4!A3) references Sheet1, Sheet2, Sheet3, and
Sheet4.
Similarly, if you delete a worksheet, the formula will exclude the cell in the worksheet you've
removed.
Graphic
For example, you can remove Sheet2.
Moving the first or last worksheet identified in a three-dimensional reference automatically
changes the range of worksheets a formula will use.
Graphic
For instance, you can add Sheet5 and Sheet6 to the range.
For example, if you move Sheet4 from its original position after Sheet3 to after Sheet5, the
reference Sheet1:Sheet4!A3 updates to include the value of cell A3 in Sheet5.
177

Question
Match each reference type to an example.
Options:
A. Absolute reference
B. Relative reference
C. Mixed reference
D. Three-dimensional reference
Targets:
1. $G$17
2. D19
3. J$23
4. Admin1:Admin7!Y133
Answer
$G$17 is an example of an absolute reference, in which the column letter and the row number are
each preceded by a dollar sign. Any formula that contains an absolute reference continues to point
to the same cell even if the formula is moved.
D19 is an example of a relative reference. If a formula containing this reference is moved to a new
cell, the reference will change automatically, based on the relative location of the new cell to the cell
that originally contained the formula.
J$23 is an example of a mixed reference in which the column reference is relative and the row
reference, which is preceded by a dollar sign, is absolute. If you copy the formula =J$23 to a
different cell in a worksheet, the referenced column will change but the referenced row number will
remain the same.
Admin1:Admin7!Y133 is an example of a three-dimensional reference. It identifies cell Y133 in the
worksheets Admin1 and Admin7, and in any worksheets currently positioned between them in the
active workbook.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
178

Target 4 = Option D
Summary
In Excel 2010, you use formulas to perform calculations. Formulas may contain functions, cell
references, operators, constant values, and parentheses.

Excel 2010 evaluates the parts of any formula using fixed rules of precedence. Elements in
parentheses are evaluated first, followed by cell references, negative values, percentages,
exponentiation, multiplication and division, addition and subtraction, concatenation, and finally
comparison.

Cell references in Excel 2010 may be relative, absolute, mixed, or three-dimensional. A relative
reference in a formula changes automatically if the formula is moved to a new cell, whereas an
absolute reference remains fixed. A mixed reference includes relative and absolute identifiers. A
three-dimensional reference identifies the same cell or cells in multiple worksheets.


















179

Inserting Formulas in Excel 2010
Learning Objectives
After completing this topic, you should be able to
create and insert formulas
use names in formulas
1. Creating and inserting formulas
Excel 2010 makes it easy to use formulas to perform calculations on data for example, to add
or subtract values in particular cells, or to find percentages or averages. Excel 2010 also lets
you name particular cells or ranges of cells in a worksheet, and then to use these names directly
in formulas. This can make formulas easier to create and interpret.
Graphic
An example of a formula is =C4+C5. You can assign a name to a cell by selecting the relevant cell
and typing its name in the cell reference field. An example of a formula in which a cell has been
assigned a name, is =Contract_T+F5. After you type a formula in the Formula bar, the selected cell
displays the result of the formula.
In Excel, you can enter a formula in a worksheet cell by typing it directly into the cell and then
pressing the Enter key. You always include an equals sign in front of a formula, to tell Excel that
your entry must be interpreted as a formula.
Graphic
A worksheet displaying sales figures for various products displays. The formula entered in I20, at
the end of a row of sales figures, is =E20+F20+G20+H20.
After you press Enter, the result of the formula displays in the cell, and the cell below it
becomes active.
Graphic
The result is $27,012.
If you select the cell, the formula displays in the Formula Bar.
Graphic
180

In the Excel interface, the Formula Bar displays beneath the Quick Access Toolbar and the Ribbon,
and just above the open worksheet.
A worksheet records the sales made by each of four sales agents in various categories. You
want to enter a formula in cell I10 to calculate the total sales of cell phone contracts. To do this,
the formula must add the sales values in cells E10, F10, G10, and H10.
Graphic
Cells E10, F10, G10, and H10 contain the dollar values of sales of cell phone contracts made by
each of the four salespersons.
You select cell I10 and type an equals sign into the cell to indicate that you're creating a formula.
Next you reference the first cell in the range you want to add. To do this, you can either type the
cell reference or select the cell. In this case, you type E10. Excel then draws a blue border
around cell E10.
You need the formula you're creating to add the values in cells E10 to H10 so you type the plus
(+) operator, which is the operator that represents addition, after the E10 cell reference. You
then select cells F10, and then repeat for G10, and H10.
As you add additional cell references to the formula, Excel highlights each relevant cell using a
border of a different color.
Note
Subsequent selections are colored green, purple, red, light green, orange, and pink. After that, the
cycle starts with blue again.
Finally you press the Enter key. The result of the formula calculation shows in the cell you
selected originally, and the cell below it becomes active.
Graphic
A dollar value displays in cell I10 and cell I11 is selected.
You can also insert a formula in a cell by selecting the cell and then typing the formula directly
into the Formula Bar.
Graphic
181

For example, the formula I10+I11+I14+I15+I17+I18+I19+I20 has been typed in the Formula Bar.
Each cell reference displays in a different color, which correspond to the borders of the relevant
cells in the worksheet.
After you press Enter, the cell you originally selected remains active.
Graphic
The selected cell displays the total sales figure for different sales people. And the colored borders
no longer display.
Next you want to enter a formula in cell E25. The formula must calculate Bruce Oprisan's
commission, which is a fixed percentage of his total sales. To do this, it must multiply the total
sales in cell E22 by the fixed percentage, which is specified in cell E24.
Graphic
Cell E24 contains the value 5%.
You select cell E25 and type an equals sign in the Formula Bar. The Formula Bar becomes
active and Enter and Cancel buttons display.
Next you type E22 after the = sign. Excel then draws a blue border around cell E22 in the
worksheet.
The formula you're creating must multiply the value in cell E22 by the value in cell E24. The first
cell reference is displayed in blue and its cell is outlined in a blue border with square corners
while the second cell reference is displayed in green with its cell outlined in a green border with
square corners.
Graphic
The completed entry in the Formula Bar is =E22*E24.
Note
Cells for named ranges are similarly outlined but without square corners.
Finally, you can either press the Enter key on your keyboard or click the Enter button on the
Formula Bar.
Cell E25, which remains selected, displays the result of the calculation, while the Formula Bar
displays the formula.
182

Graphic
Cell E25 displays a dollar value.
Try It
Now you try using the Formula Bar to insert a formula in cell H12 that calculates Tonya Chavis's
total cell phone sales. Use uppercase when typing the cell references.
In the open worksheet, the sales figures for Tonya Chavis appear in cells H10 and H11. They are
$37,260 and $7,846 respectively.
To complete the task
1. Select cell H12 in the worksheet
2. Type =H10+H11 in the Formula Bar and click the Enter button
You've inserted a formula using the Formula Bar in Excel 2010.
Now say you want to use the same formula to calculate the total cell phone sales for other
employees. You can use the AutoFill feature to copy the formula from cell H12 into cells G12,
F12, and E12.
Graphic
With H12 selected, the Formula Bar displays =H10+H11, and H12 displays a dollar value. The cells
G12, F12, and E12 are blank.
You hover your cursor over the bottom right corner of cell H12 until it changes to a Fill handle.
You then use your mouse to drag the Fill handle across from cell H12 to cell E12.
Excel 2010 automatically adjusts the cell references in formulas based on which cells you enter
them in. For instance, if you select cell E12, the formula =E10+E11 displays in the Formula Bar,
although =H10+H11 is the formula you copied from cell H12.
Excel then places the formula in the selected cells, which display the results.
The adjustments Excel makes are possible because Excel uses relative referencing by default.
When you enter a formula, you enter specific cell references. Behind the scenes, Excel
translates those references into positions relative to the result cell.
183

Most of the time, this is what you would want. However, there may be times when you need to
stop Excel from updating cell references when you copy formulas. Sometimes relative
referencing can result in a copied formula that generates zero results.
In these situations, you can use absolute cell references. To create an absolute cell reference,
you include a dollar sign before each of a cell's coordinates.
Graphic
For example, H12, which displays Tonya Chavis's cell phone sales' total, contains the formula
=H11*$E$24.
Say you want to calculate the percentage of total sales made by each of the four sales agents.
The same total sales figure, which is in cell I22, must be used in each of the calculations. So you
need to divide each agent's sales by the same total sales figure from cell I22.
To start, you enter the formula for calculating the proportion of total sales Bruce Oprisan made
in cell E24. In the formula, you use an absolute reference to cell I22.
Graphic
The formula in cell E24 is =E22/$I$22.
Now when you use Autofill to copy the formula in cell E24 to cells F24, G24, and H24, the
absolute reference stays the same.
Try It
Now you try using the Formula Bar to create a formula that uses an absolute reference. The formula
must calculate the proportion of Chadrick Powell's total sales that can be attributed to contract sales.
So it must divide the contract sales figure in cell F10 by the total sales figure in cell F22. Use
uppercase when typing the cell references.
The bottom part of the December worksheet displays and contains sales figures.
To complete the task
1. Select cell F24 in the worksheet
2. Type =F10/$F$22 in the Formula Bar and click the Enter button
You've inserted a formula containing an absolute reference in Excel 2010.
Cell F24 contains the formula =F10/$F$22. You now copy this formula into cell F25 to calculate
the proportion of Chadrick Powell's total sales that can be attributed to his prepaid sales. When
you do this, the absolute cell reference in the formula remains unchanged.
184

Graphic
The formula copied into cell F25 is =F11/$F$22.
In Excel 2010 formulas, you can include references to cells in other worksheets. This type of
reference is called a 3-D reference. It consists of the name of a worksheet, an exclamation
mark, and then the coordinates of the relevant cell.
Graphic
The example in the Formula Bar is =Income!H8-Expenses!D9.
Suppose you want to subtract the total expenses for a conference from the total income it
generated and the relevant values are in separate worksheets. You want the result to display in
cell D61 of the Expenses worksheet, so you start by selecting this cell and typing an equals
sign.
You click the Income tab to open the Income worksheet and then select cell H31, which
contains the total income value. The 3-D reference Income!H31 is then automatically added to
the formula you started typing in cell D61 of the Expenses worksheet.
Graphic
The Formula Bar displays the entry =Income!H31.
Next you return to the Expenses worksheet. You add a minus sign to the formula and type
Expenses! to begin creating a 3-D reference to a cell in the Expenses worksheet.
You select cell D60, which contains the total actual expenses figure, to complete the formula.
You press Enter and the result of the formula displays in cell D61.
You can also add a 3-D reference simply by typing it into a formula, in a cell or in the Formula
Bar.
Graphic
For example, =Income!H displays in the Formula Bar.
Try It
Now you practice using the Formula Bar to insert a formula that uses 3-D references. The formula
must add the value in cell K19 of the active June worksheet to the value in cell K19 in the December
185

worksheet. Both values show the total bonus values for all sales agents. Use uppercase when
typing the cell references.
To complete the task
1. Type =K19+December!K19 in the Formula Bar and click the Enter button
You've inserted a formula containing a value in another worksheet.
Question
A worksheet details the sales each of the four sales agents for a telecommunications company have
made. You want to insert a formula that will calculate the total sales using an absolute reference for
cells E22 and F22.

Which formula would you use?
A worksheet containing sales data displays. Cell E22 contains the total sales made by Bruce
Oprisan and cell F22 contains the total sales made by Chadrick Powell. Cell G22 contains the total
sales made by Heather Denfield and cell H22 contains the total sales made by Tonya Chavis.
Options:
1. =E!22+F!22+G22+H22
2. $E$22+$F$22+G22+H22
3. =$E$22+$F$22+G22+H22
Answer
Option 1: Incorrect. The correct operator for an absolute cell reference is a dollar sign before each
cell coordinate. The correct formula is =$E$22+$F$22+G22+H22.
Option 2: Incorrect. A formula must always begin with an equals sign. The correct formula is
=$E$22+$F$22+G22+H22.
Option 3: Correct. This formula calculates the total sales by adding the sales made by all four
employees.
Correct answer(s):
3. =$E$22+$F$22+G22+H22
186

2. Using names in formulas
In Excel 2010, you can give a descriptive name to a particular cell or cell range, or even to a set
of non-adjacent cells. In formulas, you can then use the name you've assigned instead of typing
in cell references. This can make formulas much easier to enter, and to understand and
maintain. You can also easily update and manage all the names you assign in a workbook.
Graphic
In a worksheet displaying sales figures for cellphone contracts and prepaid phone in different
months, the cell C4, for example, containing the sales figure for contracts in January, can be
renamed Contract_Jan. Similarly, instead of referring to D4 and D5 in a formula, you can use
Contract_Feb+Prepaid_Feb instead.
You can define a name for a cell, range of cells, formula, or constant value.
Graphic
A worksheet outlining sales data of different products over different months is open. The cell J8, in
the Goal per Month column, displays the value $100,000 and instead of J8, the cell reference
displays as Contract_Goal.
In addition, Excel 2010 automatically names tables and you can choose to alter the default
table names it assigns.
Graphic
In the Properties group of the Table Tools - Design tab of the Ribbon, the Table Name text box
displays Table1, in this case.
To assign a name to a cell or range of cells, you first select the cell or cell range.
Graphic
In an example worksheet, cell H20 is selected. It contains a formula for adding predicted sales
values for 2015, contained in cells H8 to H18.
You can then simply type a name in the Name Box on the Formula Bar and press Enter. A
name must begin with a letter and can be up to 255 characters in length. In this case, the cell
selected is named TotalPredictedSales2015.
Graphic
187

The name is entered in the Name Box. The Formula Bar displays =SUM(H8:H18).
A name you assign in this way is automatically available throughout a workbook. So you'll be
able to use it instead of a cell or cell range reference in formulas you enter in any worksheet in
the workbook.
You can also use the Define Name button, which is on the Formulas tab of the Ribbon, to
create names in Excel 2010.
Graphic
On the Formulas tab, the Define Name button is located in the Defined Names group.
Clicking the button opens the New Name dialog box, which provides various options.
Select each option in the New Name dialog box to learn more about it.
Name text box
You use the Name text box to specify a name for the selected cell or cell range.
Scope drop-down list
You use the Scope drop-down list to specify the scope of the name. You can choose to make a
name available in all the worksheets in the current workbook which is the default option or
only in a worksheet you specify.
The Scope drop-down list includes a Workbook option, which is selected by default, and an
option for each of the worksheets in a workbook.
Comment text box
You can choose to use the Comment text box to enter a comment for example, describing the
content of a cell you name. The text box accepts up to 255 characters.
Refers to text box and button
You can use the Refers to text box to alter the cell or cell range to which the name you assign
refers. If you click the button alongside the text box, the New Name dialog box collapses to
display the text box only and you can select one or more cells directly from the worksheet.
Try It
Now you try using the Define Name button to assign the name "csales2011_15" to cells D8 to H8 in
the current worksheet.
A worksheet displaying annual sales figure projections is open. On the Ribbon, the Home tab is
open.
188

To complete the task
1. Select the cell range D8:H8 in the worksheet
2. Click the Formulas tab and click the Define Name button
3. Type csales2011_15 in the Name text box and, to apply the name only for the current worksheet,
select 2011-2015 from the Scope drop-down list
4. Click OK
You've assigned a name to the cell range.
Another way you can create names in Excel 2010 is by using the Create from Selection button
on the Formulas tab. This lets you convert existing row or column headings into names.
Graphic
The Create from Selection button can be found in the Defined Names group of the Formulas tab.
To use this option, you first select the cell or range of cells you want to name, together with the
row or column label you want to assign as the name.
Graphic
In an example worksheet, row 9 is selected. Cell B9 contains the name Chavis_Tonya in the
Salesperson column. The remaining cells contain Tonya Chavis's employment details, the dollar
value of her sales, and a bonus percentage and dollar value.
Then you click Create from Selection.
In the Create Names from Selection dialog box, you can specify whether the entry in the top or
bottom row, or in the left or right column, of the selected range should be assigned as the name.
Once you've chosen the appropriate option, you click OK.
Graphic
The Create Names from Selection dialog box contains Top row, Left column, Bottom row, and Right
column checkboxes. In this case, Left column is selected.
Now when you select the cell range you've named, the Name Box on the Formula Bar displays
its name. Note that this name identifies all the cells in the specified range you can't use it to
reference only one cell in that range.
Graphic
In this example, the Name Box displays the name Chavis_Tonya.
189

Try It
Now you try naming a cell range which is already selected using the Create from Selection
command.
In the worksheet displaying product sales over different months, cells D6 to D18 are selected. Cell
D6 contains the column heading "January." The Formulas tab is open on the Ribbon.
To complete the task
1. Click Create from Selection
2. Accept the default selection of the Top Row checkbox in the Create Names from Selection dialog box
and click OK
You've named a cell range using the Create from Selection command.
Once you've assigned names to selected cells or cell ranges, you can use them in formulas.
One way of doing this is to click the Use in Formula drop-down button and select the required
name from the associated menu.
Graphic
The Use in Formula drop-down menu lists all the names available to the current worksheet, such as
csales2011_15. A Paste Names option is also available.
If the name is the first part of a formula, Excel 2010 will automatically add an equals sign, as
well as the name you selected, to the Formula Bar.
Graphic
In this case, the Formula Bar displays =csales2011_15.
Alternatively, you can start typing the name of a cell or cell range directly into the Formula Bar.
After you've typed a few letters, Excel 2010 displays any matching names and you can add the
relevant one to the formula by double-clicking it.
Graphic
The formula =I20+cs displays in the Formula Bar. The option =csales2011_15 displays below the
Formula Bar.
Try It
190

Now you try using the Use in Formula command. You want to enter a formula in cell E20 to add the
value in the cell named "January" to the total sales value in cell E19. Use uppercase when typing
the cell reference.
A worksheet displaying product sales over different months displays.
To complete the task
1. Select cell E20
2. Click the Use in Formula drop-down button and select January
3. Type +E19 and click the Enter button on the Formula Bar
You've added the name to the formula using the Use in Formula command.
You can track and manage all the names you've assigned to cells or cell ranges in a workbook.
To do this, you first click the Name Manager button.
Graphic
The Name Manager button is in the Defined Names group on the Formulas tab.
This opens the Name Manager dialog box, which you can use to create new names, delete
existing names, or edit names and their associated details.
Graphic
The Name Manager dialog box contains New, Edit, Delete, and Filter buttons. It contains a pane
with Name, Value, Scope, Refers To, and Comment columns. Below the pane, a Refers to text box
with a Collapse Dialog button references a selected cell.
You need to be careful when you delete names. Once you've deleted a name, any formulas
you've entered using the name will display errors.
Graphic
A cell containing a formula that uses a deleted name contains the entry #NAME?.
Try It
Now you try using the Name Manager to delete the name "March."
A worksheet displaying product sales over different months displays. The Formulas tab displays on
the Ribbon.
191

To complete the task
1. Click Name Manager on the Formulas tab
2. Select March
3. Click the Delete button and click OK
4. Click the Close button
You've deleted a name using Name Manager.
Summary
In Excel 2010, you can enter a formula by typing it directly into a cell or by using the Formula
Bar. Once you have entered a formula you can use the Autofill option to copy it to other cells.
Excel 2010 makes use of four kinds of references relative, absolute, mixed, and 3-D
references.

Excel 2010 also enables you to name a particular cell or cell range in order to describe its
content. You can use the Name Box, Define Name button, and Create from Selection command,
which uses existing row and column labels, to create names. You can then use these names in
formulas by selecting the Use in Formula command, and manage and update them using the
Name Manager.















192

Editing and Correcting Common Formula Errors
Learning Objectives
After completing this topic, you should be able to
correct common error values
edit formulas
1. Avoiding errors in formulas
Errors in formulas can have disastrous consequences for example, giving you inaccurate
results in a budget calculation or when you're calculating employee bonuses. Excel 2010 detects
many common types of errors automatically. However, it can't recognize every possible type of
error.
Graphic
An error in a formula can be displayed in a cell as #VALUE!
So although formulas are extremely useful for performing calculations, you need to be especially
careful not to make mistakes when entering them.
Graphic
A worksheet displaying product sales for different salespeople is open in Excel.The Excel interface
includes the Quick Access Toolbar and the Ribbon, and just above the open worksheet. Beneath
these features is the Formula Bar and the open worksheet. An example of a formula, in this case, is
E22+F22+G22+H22.
You can avoid formula errors by following a set of guidelines. These guidelines specify the
requirement that you start formulas with an equals sign, match opening and closing
parentheses, indicate a range using a colon, nest no more than 64 functions, place an
exclamation mark after a worksheet name, avoid dividing by zero, and use the correct types of
arguments.
Select each guideline to learn more about it.
Start with an equals sign
You need to remember to start any formula with an equals sign to stop Excel from interpreting it
as a text string or date. For example, if you enter SUM(D6:H6) in a cell, Excel will display the text
"SUM(D6:H6)" instead of calculating the formula.
Match opening and closing parentheses
193

You should ensure that opening and closing parentheses are always paired. For example, the
formula =SUM(A4+A5)*2) is incorrect because it includes only one opening parenthesis but two
closing parentheses. The correct formula is =SUM((A4+A5)*2).
Indicate a range using a colon
When you reference a range of cells in a formula, you need to use a colon to separate the
coordinates for the first and last cells in the range. An example is F11:F17 in the formula
=F11:F17*2.
Nest no more than 64 functions
You can nest no more than 64 levels of functions within another function. Nesting refers to using
functions within the calculations performed by other functions. In the formula
=SUM(SQRT(9+7)), for example, the SQRT function is nested inside the SUM function.
Place an exclamation mark after a worksheet name
In formulas, you need to place an exclamation mark after any worksheet name. For example,
you'd refer to cell B3 in the Annual Sales worksheet using the reference Annual Sales!B3.
Avoid dividing by zero
You should be careful to avoid dividing a cell by another cell that contains either a value of zero
or no value. Because values aren't divisible by zero, this will generate an error.
Use the correct types of arguments
It's important to use the correct types of arguments in your formula. Some worksheet functions
require numeric arguments, while others require text values. If you use the wrong type of data as
an argument, Excel might return an unexpected result or display an error.
Question
Which guidelines can help you avoid errors in Excel formulas?
Options:
1. Avoid dividing by zero
2. Remember always to start with an equals sign
3. Use an exclamation mark between the first and last cell references when you identify a cell range
4. Use the correct types of arguments
5. Always place a colon after a worksheet name
Answer
Option 1: Correct. Values aren't divisible by zero, so you need to be careful that when you're using
cell references in formulas, you don't accidentally divide the value in one cell by a zero or null value
in another cell.
194

Option 2: Correct. You need to precede any formula with an equals sign so that Excel 2010 will
interpret it as a formula.
Option 3: Incorrect. You need to use a colon to separate references to the first and last cells in a
cell range.
Option 4: Correct. Excel functions may require arguments of particular types.
Option 5: Incorrect. This will result in an error. You need to place an exclamation mark after a
worksheet name in a formula.
Correct answer(s):
1. Avoid dividing by zero
2. Remember always to start with an equals sign
4. Use the correct types of arguments
2. Correcting common errors
By default, Excel 2010 runs a background error check to check for errors in the data you enter in
cells. In this way, it automatically detects several types of common mistakes in formulas. For
each of the error types it recognizes, it displays a particular error value.
Select each error value to find out what it indicates.
#####
The ##### error value displays if a column isn't wide enough to display the characters in the cell.
You can then increase the width of the column or it may be sufficient to decrease the font size
of the cell's content.

The same error value displays if a cell contains a negative date or time value. If this occurs, you
need to correct the formatting of the value.
#DIV/0!
The #DIV/0! error value displays if the formula in a cell instructs Excel to divide a number by zero
or by a cell that contains no value. To correct the error, you need to alter the formula.
#N/A
The #N/A error value displays if a value isn't available to a function or formula. The error most
commonly occurs when an incorrect value is given for the Lookup function. You can correct this
error by ensuring that the argument you entered in the Lookup function is of the correct type and
value.
#NAME?
195

The #NAME? error value displays when Excel doesn't recognize text in a formula. You can
correct this error by ensuring that you use only names that have been defined for cells or cell
ranges, and that you spell those names correctly.
#NULL!
The #NULL! error value displays if you specify the intersection of two ranges that don't actually
intersect. An intersection is the point at which two cell ranges overlap. You can correct this
problem by changing the reference so that the ranges intersect, or by using a different operator.
The operator that indicates an intersecting range is a space character between two cell
references, for example =A1:D11 C1:C8.
#NUM!
The #NUM! error value displays if you include an invalid number in a formula. An invalid number
may take the form of a negative number when a positive number is required, a non-numeric value
when a numeric value is required, or a number that results in a value that is too large or too small
for Excel to handle.
#REF!
The #REF! error value displays if a formula contains an invalid cell reference. You can correct this
error by ensuring you haven't deleted or moved cells referenced by other formulas.
#VALUE!
The #VALUE! error value displays if you use the wrong type of argument or operand, which is a
value on either side of an operator. You can avoid this type of error by ensuring you haven't
entered text when a formula requires a number or logical value. You should also check that you
haven't supplied a range to an operator or function that requires a single value.
Question
Match each error value to its cause.
Options:
A. #DIV/0!
B. #####
C. #VALUE!
D. #N/A
E. #NUM!
Targets:
1. A formula produces a result too wide to fit in a cell
2. A formula attempts to divide a value by zero
3. A formula can't find a value it has been told to find
196

4. A formula uses an invalid number
5. A formula contains or references an invalid data type
Answer
The ##### error value displays when a formula produces a result that's too wide to display in a cell,
given the width of the column in which it's located. It also displays if a cell contains a negative date
or time value.
The #DIV/0! error value displays when a formula in a cell attempts to divide a value by zero or when
the referenced divisor cell is empty.
The #N/A error value displays when a value isn't available to a function or formula, such as when
the formula can't find the value it has been told to find using the Lookup function.
The #NUM! error value displays when a formula contains an invalid value, such as a negative
number when a positive number is required.
The #VALUE! error value displays when a formula or function is supplied with an invalid data type
for example, if a text value is supplied when a numeric value is required.
Correct answer(s):
Target 1 = Option B
Target 2 = Option A
Target 3 = Option D
Target 4 = Option E
Target 5 = Option C
When Excel 2010 detects an error in a formula, it doesn't only display an error value in the cell
containing the formula. It also displays an Error Indicator button beside the cell when you
select the cell.
Graphic
In the Sales Predictions worksheet, #VALUE! displays in the Total column for predicted prepaid cell
phone sales over the years 2011 to 2015.
Clicking the button expands a menu. The menu options are context sensitive they differ
depending on which error value displays. For example, six options display for a cell containing a
#VALUE! error.
197

Graphic
The options are Error in Value, Help on this error, Show Calculation Steps, Ignore Error, Edit in
Formula Bar, and Error Checking Options.
Select each option on the menu to find out more about it.
Error in Value
The first option tells you what kind of error you're dealing with in this case, a #VALUE! error.
Help on this error
You use the Help on this error option to access information specific to the error type in the Excel
Help dialog box. You can use the dialog box to read suggested articles or browse through related
Help topics.
Show Calculation Steps
You use the Show Calculation Steps option to open the Evaluate dialog box, which lists all
steps leading to the error. This is useful for isolating errors in complex formulas.
Ignore Error
You use the Ignore Error option to accept the formula as entered, without Excel displaying the
Error Indicator button.
Edit in Formula Bar
The Edit in Formula Bar option lets you edit the formula that's generating the error in the
Formula Bar.
Error Checking Options
The Error Checking Options option opens the Options dialog box on the Formulas page. This
page contains numerous options that you can use to customize your error checking.
In an example, the #VALUE! error displays in cell I9 because the formula in that cell references
cell C9, which contains a text value instead of a numeric value.
Graphic
The formula is =C9+D9+E9+F9+G9+H9. Cell C9 contains the row heading "Prepaid." The remaining
cells contain the predicted sales values for the years 2011 to 2015.
To edit the formula using the Formula Bar, you click the Error Indicator button and select Edit
in Formula Bar.
198

The Formula Bar is automatically selected and the cursor is placed at the end of the formula.
The Enter and Cancel buttons also become active.
Graphic
In the Formula Bar, each cell reference is color-coded, to match the border around each relevant
cell in the formula.
You can then correct the formula in the Formula Bar by either clicking the Enter button on the
Formula Toolbar or by pressing the Return key on your keyboard.
Graphic
The reference to cell C9, which contained the text Prepaid, is removed from the formula.
The correct value now displays in cell I9.
Graphic
I9 now displays the total sales predicted for prepaid cell phones.
Try It
Now you try using the Formula Bar to correct the error in cell I16 in the Sales Predictions worksheet.
Use uppercase when typing the cell references.
In this case, I16 displays #VALUE! instead of the total Bluetooth sales for the years 2011 to 2015.
To complete the task
1. Click the Error Indicator button beside the error
2. Select the Edit in Formula Bar option
=C16+D16+E8+F16+G16+H16 displays in the Formula Bar.
3. Replace the incorrect formula by typing =D16+E16+F16+G16+H16 in the Formula Bar and click Enter
You've corrected the error using the Formula Bar.
3. Editing formulas
As well as editing formulas to update or correct them, you can delete formulas, or cut or copy
and then paste them into new locations.
Graphic
199

Deleting a formula deletes the content of the entire cell.
To delete a formula, you first select the cell in which it's located.
Graphic
D15 is selected.
You can then remove the formula by deleting it either from the cell or from the Formula Bar.
Graphic
The formula in D15 is =SUM(D12:D14).
You can delete a formula using any one of three methods:
place the cursor at the beginning of the formula and press and hold the Delete key until the formula is
deleted
place the cursor at the end of the formula and press and hold the Backspace key until the formula is
deleted, or
select the whole formula and press the Delete key once
Question
Which methods can you use to delete a formula?
Options:
1. Place the cursor at the end of the formula and press the Backspace key until the formula is deleted
2. Highlight the formula and press the Back Arrow key
3. Place the cursor at the beginning of the formula and press the Delete key until the formula is deleted
4. Highlight the formula and press Delete once
5. Place the cursor on the Formula Bar and click the Cancel button
Answer
Option 1: Correct. You can place the cursor at the end of a formula, in a cell or in the Formula Bar,
and press Backspace until the formula is deleted.
Option 2: Incorrect. Highlighting the formula and then pressing the Back Arrow key will deselect
the formula.
200

Option 3: Correct. You can place the cursor at the beginning of a formula and press Delete until the
formula is deleted.
Option 4: Correct. You can delete a formula by selecting it either in its cell or in the Formula Bar
and pressing Delete once.
Option 5: Incorrect. Clicking the Cancel button deactivates the Formula Bar and returns you to the
previously selected cell in the worksheet.
Correct answer(s):
1. Place the cursor at the end of the formula and press the Backspace key until the formula is
deleted
3. Place the cursor at the beginning of the formula and press the Delete key until the formula is
deleted
4. Highlight the formula and press Delete once
To move formulas, you can use the Cut, Copy, and Paste buttons in the Clipboard group on the
Home tab.
When you copy and paste a formula, the original formula remains in the cell it was created in.
When you cut and paste a formula, however, the original formula is cut from the original cell,
leaving it empty.
To paste a formula, first you click the Paste drop-down button in the Clipboard group on the
Home tab.
You then select the Formulas option from the drop-down menu.
Graphic
The Paste drop-down menu is divided into three sections. The Paste section allows you to paste
items, including formulas, with different format specifications, such as pasting with no borders and
keeping the source cells column width. The Paste Values section allows you to paste values by
themselves, with number formatting or with source formatting. The Other Paste Options section
contains options that allow you to paste formatting, links, pictures, and linked pictures. Finally, there
is a Paste Special option, which launches the Paste Special dialog box.
Try It
Now you try copying the formula in cell I10 and pasting it into cell I11 in a worksheet.
201

In a worksheet displaying the sales figures for various salespeople,I10 contains the total contract
cell phone sales of four salespersons. I11 will contain the total prepaid cell phone sales of the same
four salespersons. The Home tab is open on the Ribbon.
To complete the task
1. Select cell I10
2. Click Copy in the Clipboard group
3. Select cell I11
4. Click the Paste drop-down button and select Formulas
You've copied a formula and pasted it into a different cell.
When you copy and paste a formula, Excel 2010 automatically updates all relative cell
references. If a copied formula contains absolute cell references, however, these references
aren't changed in the duplicate formulas.
Graphic
For example, a formula copied from I10 to I11displays as =SUM(E11:H11) in cell I11.
Summary
You can avoid formula errors by following a set of guidelines, these include starting a formula
with an equals sign, matching opening and closing parentheses, indicating a range using a
colon, nesting 64 functions or less, placing an exclamation mark after a worksheet name,
avoiding dividing by zero, and using the correct types of arguments.

Excel 2010 automatically detects certain types of errors in formulas and displays error values in
cells to identify these. It also provides options that make it easier to diagnose and correct
identified errors.

Excel 2010 also makes it easy to delete formulas, and to cut or copy formulas and paste them
into new locations.






202

Entering a Formula and Using References in Excel 2010
Learning Objectives
After completing this topic, you should be able to
create a formula
define a name reference and use it in a formula
copy and paste a formula between cells
Exercise overview
This topic teaches you how to perform tasks using Excel 2010, simulating the application
interface and guiding you through the tasks. The instructions for completing the exercise are
presented on screen.
In this exercise, you're required to use formulas in Excel 2010.
This involves the following tasks:
entering a formula
copying and pasting the formula, and
defining a name for a cell and using it in a formula
Task 1: Creating a formula
You're determining your employees' bonuses, which are calculated as a specified percentage of
each employee's sales, for the month of June.
Enter a formula in cell K9 that calculates Tonya Chavis's bonus. Use the value of her Dollar
sales given in H9 and ensure you use a relative reference to identify I9, the cell containing the
bonus percentage she's been assigned according to her sales. To enter the formula, use a
button rather than pressing a key.
Steps list
Instructions
1. Select cell K9 in the June worksheet
2. Type =H9*I9 in the Formula Bar and click the Enter button
203

Task 2: Copying and pasting a formula
Next you want to use the same formula you used to determine Tonya Chavis' bonus to
determine Ralph Hecht's bonus.
Copy the formula you entered in cell K9 and paste it into cell K13.
Steps list
Instructions
1. Select cell K9
2. Click Copy on the Home tab
3. Select cell K13
4. Click the Paste drop-down button and select Formulas
Task 3: Defining a name
You now want to name the worksheet cell containing a total sales value so that you can use this
name in formulas you create.
Use a dialog box to assign the name "Total_Sales" to cell H19, which is currently selected,
ensuring that the name applies only in the June worksheet. Then use this name in a formula you
enter in cell L19 to add the value in the cell it identifies to the value in cell K19. To add the name
to the formula, select it from a list of available names. To enter the formula, use a button rather
than pressing a key.
Steps list
Instructions
1. Click Define Name on the Formulas tab
2. Type Total_Sales in the Name text box, select June from the Scope drop-down list, and click OK
3. Select cell L19 and click Use in Formula on the Formulas tab
4. Select Total_Sales from the drop-down list
204

Steps list
Instructions
5. Type +K19 in the Formula Bar and click the Enter button
A formula has been entered and copied into a different cell, and a name has been assigned to a
cell and used in a formula.






















205

Using Tables and Applying Table Styles in Excel 2010
Learning Objectives
After completing this topic, you should be able to
format data as a table
sort and filter table data in a given scenario
1. Formatting data as a table
Tables are a useful feature of Excel they let you manipulate the data they contain without
affecting other data in the worksheet. For example, you can sort the data in a table column in
ascending or descending alphabetical order, or by color. You can filter the data so that only the
information you need displays, or perform calculations. You can also choose to export the
contents of a table, without the rest of the worksheet in which it appears.
You can apply different formats such as headers, colors, or banded rows to a table to
change its look and presentation. You can choose a pre-existing set of formatting styles from the
Table Styles gallery, or create your own customized table style.
To convert a range of data in a worksheet into a table, you begin by selecting the cells you want
the table to include.
Graphic
A worksheet, listing employees as well as their sales and bonuses, is open in Excel.The Excel
interface includes several default elements a mini toolbar of frequently used commands, a Ribbon
containing several tabs of commands, and a formula bar. The worksheet appears below these
elements.In this case, the rows 8 to 13 have been selected.
You can use one of two ways to create a table of the data you selected. These are situated on
the Home and Insert tabs.
To create a table using the default style, you use the Table command on the Insert tab.
Graphic
The Tables group on the Insert tab of the Ribbon contains PivotTable and Table, which is selected.
This launches the Create Table dialog box, which lists the coordinates of the cell range you
selected and lets you adjust this range if necessary. It also allows you to specify whether or not
your table contains data that should be used as headers. This option, which is enabled by
default, converts the top row of the selected range into column headers.
206

Graphic
The Create Table dialog box includes the "Where is the data for your table" field as well as the My
table has headers checkbox. In this case, the field displays =$B$8:$H$13, and the checkbox is
selected by default.
A table in the default style includes bold column headings in a header row, and banded rows,
which alternate in color.
Graphic
The formatted table stretches from row 8 to 13.
Each column header includes a drop-down menu you can use to sort and filter data in the
column.
Graphic
For example, the sort and filter menu for the Salesperson column header contains the options Sort
A to Z, Sort Z to A, Sort by Color, Clear Filter From "Salesperson," Filter by Color, and Text Filters.
A Search text box and a checkbox list containing the names of the salespersons in the table also
display.
Try It
Now you try creating a table in a worksheet. You want to use the default data range and apply the
default table style but add table headers to it. Although the table headers option is initially enabled
by default, you can assume that it was de-selected when a previous table was created, and you
need to ensure that it's selected now.
A worksheet displays six columns with the headers Salesperson, Office, Date of employment, Sales
$, Bonus %, and Bonus $. Cell B8 Salesperson is selected. The Ribbon displays the Insert tab.
To complete the task
1. Click Table in the Tables group
2. Accept the default data range and select the My table has headers checkbox
The Create Table dialog box appears and the Where is the data for your table? field contains
=$B$8:$I$17 and the My table has headers checkbox is empty.
3. Click OK
The My table has headers checkbox is ticked.
You've formatted a cell range as a table.
207

If you need to create a table with a style other than the default style, you select the cell range
and use the Format as Table command in the Styles group on the Home tab. This launches the
Table Style gallery.
Graphic
The Table Style gallery includes formatting options under the sections Light and Medium.
Some table styles have column headers and banded rows in different colors. Other styles are
simpler, with fewer variations in color. You can preview what the table in your worksheet will
look like by hovering your mouse pointer over options in the gallery.
Graphic
In this case, you hover over a style from the Light section of the Table Style gallery, and the
worksheet colors change accordingly.
Using the gallery, you can choose from many pre-existing table styles. These are arranged by
color scheme and divided into three sections Light, Medium, and Dark. You can scroll down to
view all of the available options. You then simply click on a style to create a table using that style
or to apply the style to an existing selected table.
No matter which way you create your table, when you select a cell within the table, then Table
Tools - Design contextual tab appears on the Ribbon. You can use it to make changes to the
table.
Graphic
The Table Tools - Design contextual tab includes the groups Properties, Tools, External Table Data,
and Table Style Options.
If you click outside the table in the worksheet, the Design tab disappears from the Ribbon.
Graphic
For example, you click on cell D4, which is located outside the table.
If you want the Design tab to reappear so you can make changes to the table, you simply click
anywhere on the table.
Graphic
For example, you click on cell B8, which is inside the table.
208

It's easy to change the look of your table by selecting or clearing the checkboxes in the Table
Style Options group on the Table Tools - Design contextual tab.
Graphic
The Table Style Options group contains the checkboxes Header Row, Total Row, Banded Rows,
First Column, Last Column, and Banded Columns.
The checkboxes in the Table Style Options group let you customize the visual style of your table
at any time.

Select each style option to find out more about it.
Header Row
You can select the Header Row checkbox to turn the top row of your table into a header.
Total Row
Selecting the Total Row checkbox adds a row to the bottom of a table. From cells in this row, you
can perform various calculations using the data in the table. By default, the first cell in this row
has the text "Total" and the last cell includes the numeric total of the data in the last column of the
table.
Banded Rows
You can select the Banded Rows checkbox to add rows in alternating shades of the same color.
This makes it easier to read data in tables with many rows.
First Column
You can select the First Column checkbox to bold the data in your table's first column and to
format the cells in a single color rather than in banded colors.
Last Column
You can use the Last Column checkbox to bold the content of your table's last column and to
format the cells in a single color rather than in banded colors.
Banded Columns
You can use the Banded Columns checkbox to display columns in alternating shades of the
same color, making them easier to differentiate.
While some table styles are directly accessible within the Table Styles group, you can also
access the complete Table Styles gallery from the Table Tools - Design contextual tab by
clicking the More button in the Table Styles group.
Note
209

You can scroll through the gallery a row at a time from the Table Styles group.
You can append new data to a table by simply adding the data beneath the final row of the
table.
You need to disable the Total Row option to do this if it is enabled.
Graphic
The Total Row checkbox is located in the Table Style Options group in the Table Tools - Design
contextual tab.
If you want to include additional existing worksheet data in your table, you can do so by
increasing its cell range. To increase cell range, you drag the table border to include the
additional data. The table formatting is now applied to the additional data, which then becomes
part of the table.
Graphic
In this case, you drag the border to include an additional four rows in the table.
If you're adding numerical values and you select the Total Row checkbox, a Total row displays
at the bottom of the table.
Graphic
For example, in a table displaying several salespeople's individual bonus totals in dollars, a row is
added that totals up all the bonuses in dollars.
Try It
Now you try adding a Total row to the Bonus Calculations worksheet table and then change the
table style.
A worksheet displaying bonuses for salespeople is open and cell E4 is selected. The Home tab of
the Ribbon is visible.
To complete the task
1. Select cell B8, then select the Table Tools - Design contextual tab and select the Total Row checkbox
2. Expand the Table Styles gallery by clicking the More button in the Table Styles group
The total row displays with the 1,180,530 under the total $ column.
3. Select the first style of the first row of the Medium section in the gallery
The table style menu is open and the default style is selected.
210

You've added a Total row and changed the table style.
If you no longer require the table, you can delete it by selecting the entire table and pressing the
Delete key. This will completely remove the table and the data it contains.
If you want to remove the table but retain the information it holds, however, you can convert the
table back into a data range. To do this, you first click anywhere in the table, then click Convert
to Range in the Tools group on the Table Tools - Design contextual tab.
Graphic
Once Convert to Range is selected, the Microsoft Excel information dialog box asks "Do you want to
convert the table to a normal range?" There are two buttons: Yes and No. In this case, the Yes
button is selected.
This will remove the table for example the drop-down buttons no longer display. However, all
the formatting stays in place, including colors and bold text. The data displays the same way it
did as when it was in a table.
If you have removed a table structure, and want to remove the formatting, you can select the
cells and select Clear Formats from the Clear drop-down menu in the Editing group on the
Home tab.
Graphic
The Clear drop-down list contains the options Clear All, Clear Formats, Clear Contents, Clear
Comments, and Clear Hyperlinks.
You can also use this option in an existing table to remove all table formatting.
This leaves your data in a table, but strips it of all formatting and previously chosen table styles.
Graphic
The default formatting styles are now applied to the table.
Question
In which situations is it inappropriate to use the Table command on the Insert tab of the Ribbon?
Options:
1. You want to filter and sort the data in a table
2. You want to use the default table style for the table
211

3. You want to apply a particular table style to your table as you are creating it
4. You want your table to have headers
Answer
Option 1: Incorrect. To create a table in order to sort and filter data, you would either use the Table
command on the Insert tab, or the Format as Table command on the Home tab.
Option 2: Incorrect. To create a table with the default style, you would use Table command on the
Insert tab.
Option 3: Correct. You select the style when you use the Format as Table command, and would
need to change to your chosen style afterwards if you inserted a table from the Insert tab.
Option 4: Incorrect. To create a table with headers, you ensure that the My table has headers
checkbox is selected after you click the Table command on the Insert tab.
Correct answer(s):
3. You want to apply a particular table style to your table as you are creating it
2. Sorting and filtering data
One reason tables are useful is that you can use them to sort and filter specific data in a
worksheet. Each column header has a drop-down menu associated with it. This menu contains
options to sort and filter data according to various criteria, which you can specify.
Graphic
For example, you can sort the data alphabetically in ascending or descending order.
You can also sort and filter table data using commands in the Sort & Filter drop-down menu on
the Home tab. This gives you a number of criteria by which to arrange your data.
Graphic
The sort and filter drop down menu contains the options Sort A to Z, Sort Z to A, Custom Sort, Filter,
Clear, and Reapply.
Note
212

Excel lets you apply the Sort & Filter command to a column even if it hasn't been formatted as a
table. Select the data you wish to sort and choose the appropriate option. Excel warns you if the
selected column is linked to other data in rows that make up that column.
Once a column has been sorted, the drop-down menu button in that column's header cell will
change.
Graphic
For example, after the Salesperson column is sorted alphabetically in descending order, the drop-
down menu button has another arrow added to it to indicate descending order.
Select each option in the Sort & Filter drop-down menu to find out more about it.
Sort A to Z
You can select Sort A to Z to sort a range of textual data alphabetically from A to Z. If you have a
range of dates, the option changes to Sort Oldest to Newest and if you have a numerical range,
the option becomes Sort Smallest to Largest.
Sort Z to A
You can select Sort Z to A to sort text alphabetically from Z to A. For a range of dates, this option
changes to Sort Newest to Oldest, and for a numerical range, it becomes Sort Largest to
Smallest.
Custom Sort
You select Custom Sort to launch the Sort dialog box, which you can use to sort according to
various criteria. For example, you can sort according to row or column numbers, and cell or font
color, for example.
Filter
The Filter option is used to enable or disable filtering in a table. When filtering is enabled in a
table which it is, by default, you can use the column headers to specify one or more filters to
display only cells that meet certain criteria. For example, you could filter a column of figures to
only display those that fall above the average value. The first column header's drop-down menu
then lets you access and stipulate the criteria of the filter.
Clear
You can use the Clear command to remove any sorting or filtering that has been applied to a
column.
Reapply
You can use the Reapply option to apply the appropriate sort or filter to new data that's located in
a column that already has a sort or filter applied to it. In other words, if you sort or filter a column
213

and later update it, the new data won't have the sort or filter applied to it. Once you reapply the
sort or filter to the appropriate column, though, the new data will be included in the sort or filter,
and display in the correct place.
You can also use the Filter command on the Data tab to enable filtering for a table. This can be
applied to text or numbers.
Graphic
The Filter button is selected in the Sort & Filter group on the Data tab.
You can then click on the drop-down arrow in a column header to determine the parameters of
your filter. Available options enable you to select criteria, a cell value, color, or font color to filter
data. Filtering can be applied to text or numbers.
Graphic
For a column containing numerals, the Sort and filter menu contains the options Sort Smallest to
Largest, Sort Largest to Smallest, Sort by Color, Clear Filter From "Sales $", Filter by Color, and
Number Filters, and a Search text box. . It also includes the Select All checkbox and checkboxes for
each value in the column, including 54,455, 70,543, 90,016. All the checkboxes are selected by
default.
For example, say you wanted to filter a column of office locations so that only those names that
start with the letter S display.
Graphic
For the column displaying office locations, the Sort and filter menu contains the options Sort A to Z,
Sort Z to A, Sort by Color, Clear Filter From "Office", Filter by Color, and Text Filters, and a Search
text box. It also includes the Select All checkbox and checkboxes for each office name in the
column, including Los Angeles, New York, San Francisco, and Seattle. All the checkboxes are
selected by default.
You first select Text Filters - Begins With from the Office drop-down menu.
Graphic
The submenu options that display when Text Filters is selected in the Sort and Filter drop-down
menu are Equals, Does Not Equal, Begins With, Ends With, Contains, Does Not Contain, and
Custom Filter.
Next you can enter "s" in the Office begins with drop-down list box of the Custom AutoFilter
dialog box and click OK.
214

Graphic
In this case, only the salespeople in the Seattle and San Francisco offices are now displayed.
Once you've applied filter criteria to a column, that column's drop-down menu button displays a
filter icon.
To clear the filter for a single column, you first click the Filter button on the column header.
Graphic
This opens the Sort and filter menu for the Office column in this case. It contains the options ort A to
Z, Sort Z to A, Sort by Color, Clear Filter from "Office," Filter by Color, and Text Filters. All the
checkboxes for the various offices are unchecked.
You then select Clear Filter from "Office".
You can clear all filters in a table by clicking Clear or Filter in the Sort & Filter group on the Data
tab or in the Editing group on the Home tab. Clicking Clear will clear the filters but filtering will
remain enabled while clicking Filter will also disable filtering in the table.
Say you want to filter a list of employee names according to each person's sales figures. To
display the top ten sellers, you enable a filter on the Sales column by selecting Number Filters -
Top 10 from the column's Filter drop-down menu.
Graphic
The Sort and filter menu contains the options Sort Smallest to Largest, Sort Largest to Smallest,
Sort by Color, Clear Filter From "Sales $", Filter by Color, and Number Filters. All the checkboxes
are selected by default. The Number Filters option has been expanded and Top 10 selected.
You can customize the number of names that display in the resulting Top 10 AutoFilter dialog
box by specifying a figure in the relevant spin box and clicking OK.
Graphic
The Top 10 AutoFilter dialog box has a Show section, consisting of a drop-down list box set to Top,
a spin box set to 6, and another drop-down list box set to Items.
You can make the filter criteria even more specific and apply additional filtering to the column.
You can use the filter on the Sales column which now lists your top six salespeople to refine
your results.
215

To display only above-average figures, you select Number Filters - Above Average from the
menu.
Then only those sales figures above the column average display.
Graphic
In this case, now only five salespeople are displayed.
Try It
Now you try applying a filter.

You want to filter the data in the Sales $ column so that only above-average sales figures display.
Then you want to filter the entire table so it only displays the data relating to Karen Johannsen.
In the worksheet displaying the sales and bonus figures of salespeople, Cell B4 is selected and the
Data tab displays. The Sales $ column is F. All Salespersons are listed in column B.
To complete the task
1. Click the arrow in the column header in F8, mouse over the Number Filters option and select Above
Average
2. Click the arrow in the column header in B8, mouse over the Text Filters option and select Begins With
The table has been filtered down to display only the above average sales $ figures.
3. Enter j in the text box next to the begins with filter option and click OK
The Custom AutoFilter dialog box is open, and the begins with input field is empty.
You've filtered the table to display only above average figures and then filtered it to display Karen
Johannsen's sales.
SkillCheck
You want to format a table with the last style of the second row of the Light style section and then
sort the data in the first column so that it is presented in alphabetical order.

Select the first column to format the table, and use the commands in the Home tab and the column
drop-down menu to do so.
A worksheet displaying the sales and bonus figures of salespeople is open on the Home tab, and
cell D6 is selected. The column of salespeople's names is in B8 to B17.
Task:
1. Use commands in the Styles group to format the table.
216

2. Select the table style from the gallery.
3. Access the correct sort command from the column header's drop-down menu.
Answer
To complete the task
Step 1: Select cell B8, and click Format as Table
Step 2: Select the last style in the second row of the Table Styles gallery
Format as table is selected and the table style menu is open.
Step 3: Select Sort A to Z from the drop-down menu in cell B8
The table's visual style has been changed.
Summary
You can use tables in Excel to format data separately from the rest of the worksheet so you can
manipulate it without affecting the worksheet's layout. Tables can also be formatted with
different visual styles, including various colors, headers, and bolded items, to make them easier
to read.

You can apply sorting and filter options to data presented in columns using Excel 2010. Data
can be sorted according to alphabetical, numerical, or color-based criteria, so the order of
presentation changes or entries that fail to meet the specified criteria are hidden.












217

Applying Conditional Formats in Excel 2010
Learning Objectives
After completing this topic, you should be able to
apply conditional formatting rules
recognize when to use specific conditional formats
1. Conditional formatting
Using conditional formatting in Excel you can make a worksheet quicker and easier to analyze
by drawing attention to specific data. You can make certain cells stand out by applying
conditional rules for example, to highlight cells with specific text, or with duplicated data, or
with data above or below a specified value.
The appearance of the cells that meet these rules change so that they stand out. You can use
the conditional formatting tools to compare data within a worksheet using data bars or color
scales, or you can use icon sets to identify the highest and lowest values, or averages.
You might want to highlight certain cells for a number of reasons. For example, you might want
to highlight the values in a cell range that are above average.
Graphic
A worksheet, listing employees as well as their sales and bonuses, is open in Excel.The Excel
interface includes several default elements a mini toolbar of frequently used commands, a Ribbon
containing several tabs of commands, and a formula bar. The worksheet appears below these
elements. In the Styles Group on the Home tab on the Ribbon, Conditional Formatting - Highlight
Cells Rules - Greater Than is selected.
The Conditional Formatting drop-down menu is comprehensive and easy to use. There are a
number of rule categories available in Excel 2010 that you can choose from. Each of these
categories contain a variety of options that you can apply to cells, depending on what you want
to highlight.
Graphic
.The Conditional Formatting drop-down menu contains the options Highlight Cells Rules,
Top/Bottom Rules, Data Bars, Color Scales, Icon Sets, New Rules, Clear Rules, and Manage Rules.
Select each option on the Conditional Formatting menu for more information about it.
Highlight Cells Rules
218

You can use the different options in Highlight Cells Rules to draw attention to cells that meet
certain conditions. For example, you can specify that only cells that include specific text, that
contain numbers over a certain amount, or that contain duplicate values are highlighted. You can
then set the color these cells will be highlighted in.

For example, you may want to draw attention to certain columns or rows in a worksheet by
highlighting their headers. You'd specify the text that should be contained within a cell in order for
the cell to be highlighted. Or you may want to highlight all the sales values above $100,000 to
do so you'd select the rule, specify the value, and also choose the format to apply.
The Highlight Cell Rules submenu contains these options: Greater Than, Less Than, Between,
Equal To, Text that Contains, A Date Occurring, and Duplicate Values.
Top/Bottom Rules
The Top/Bottom Rules option lets you set different rules to highlight the highest or lowest set of
values. You can also choose to highlight the set of values above or below the average.

For example, you might use the Top 10 rule to identify the top seven sales figures.
The Top/Bottom Rules submenu displays these options: Top 10 Items, Top 10 %, Bottom 10
Items, Bottom 10 %, Above Average, and Below Average.
Data Bars
The Data Bars option lets you compare cells in a selected range to one another. The cell with the
highest value will have a full data bar and all others will be measured in proportion to it.
The Data Bars submenu contains the Gradient Fill and Solid Fill galleries.
Color Scales
You can use the Color Scales menu to display a group of values with different colors in a
gradient of a certain theme. For example, if you selected the green, yellow, red color scale, Excel
highlights the value of each cell in a specific color depending on the value. The highest values will
be green, the average values will be yellow, and the lowest values will be red.
Icon Sets
You can use the Icon Sets to assign icons representing the lowest, average, and highest values
to cells in a range. You can choose from a range of different icon sets. If you choose the 3
Arrows (Colored) set, for example, the highest values will be represented with a green arrow
pointing up, the average values will be represented by a horizontal yellow arrow, and the lowest
values will be represented by a red arrow pointing down.
The Icon Sets submenu includes options grouped into sections, such as Directional.
Three additional commands in the Conditional Formatting menu help you manage the rules you
apply to your worksheet. The New Rule command opens a dialog box where you can create
your own rule by assigning a rule type, colors to use, and so on.
Graphic
219

The three additional commands are New Rule, Clear Rules, and Manage Rules. Selecting New Rule
opens the New Formatting Rule dialog box. It contains the Select a Rule Type list and a section
named Edit the Rule Description. Examples of rule types are Format all cells based on their values
and Format only values that are above or below average.
The Clear Rules option lets you clear any rules that you might have set from selected cells, the
entire sheet, or from a table.
Graphic
The Clear Rules option on the Conditional Formatting submenu displays a submenu with these
options: Clear Rules from Selected Cells, Clear Rules from Entire Sheet, Clear Rules from This
Table, and Clear Rules from This PivotTable.
When you select the Manage Rules option, the Conditional Formatting Rules Manager dialog
box opens, showing you all the rules that have already been applied and their details. You can
also use it to edit or delete existing rules.
Graphic
The Conditional Formatting Rules Manager dialog box contains the Show formatting rules for drop-
down list, which is currently set to This Table. It also includes the New Rule, Edit Rule, Delete Rule,
Move Rule Up, and Move Rule Down buttons. It also lists the conditional formatting rules under the
columns Rule (applied in order shown), Format, Applies to, and Stop if True.
Question
Match the conditional formatting rule with the situation in which you would use it.
Options:
A. Greater Than
B. Text that Contains
C. Top 10 Items
D. Data Bars
E. Icon Sets
Targets:
1. Highlight sales that exceed a specific target
2. Indicate the customers who are offered a "Special discount"
3. Highlight the best selling products
4. Compare net income across four quarters
5. Categorize your employees performances into low, average, and high
220

Answer
The Greater Than rule lets you highlight cells above an amount that you specify.
The Text that Contains rule lets you highlight cells that contain a specific text.
The Top 10 Items rule enables you to highlight the top number of items in your selected cells.
Applying the Data Bars option to a set of cells lets you compare them to each other.
Icon Sets enable you to identify the highest values, average values, and the lowest values in a
graphical way.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
2. Applying conditional formats
You can apply rules using conditional formatting by first selecting the range of cells that you
want to apply the rules to.
Graphic
For example, you select the cells in a column in a table.
To highlight cells greater than a certain value, for example, first you highlight the cells and then
click the Conditional Formatting button in the Styles group on the Home tab. Then you select
the Highlight Cells Rules category and choose the Greater Than option.
Graphic
A column of sales figures has been selected in the open worksheet.
You can then either enter the value or select the cell containing the figure you want to compare
the others to in the Greater Than dialog box. Once you've specified your value, you can click
OK.
221

Graphic
In the Greater Than dialog box, the Format cells that are GREATER THAN text box contains the cell
reference =$E$6, in this example. The associated drop-down list box is set to the default Light Red
Fill with Dark Red Text.
All the cells containing values above the one you specified will be highlighted in a different
format.
Graphic
In this case, the cells containing values above the value in cell E6 are formatted with a light red fill
and the dark red font color.
Try It
Now you try applying a rule to the worksheet by adapting the Top 10 Items rule.
E9:E17 is already selected in the open worksheet, and contains sales figures.
To complete the task
1. Click the Conditional Formatting drop-down button and select Top/Bottom Rules
2. Select Top 10 Items
3. Use the spin box arrow to change the number of top items from 10 to 7
4. Select Green Fill with Dark Green Text from the drop-down menu and click OK
The Green Fill with Dark Green text is the third options in the drop-down list.
You've adapted the Top 10 Items rule and applied it to the worksheet.
If you want to categorize data or rate all data values in a range against all other values in that
range, you can choose between the Data Bars, Icon Sets, and Color Scales conditional
formatting features in Excel to make and visually represent the comparison.
You can add data bars to compare your data by first selecting the cells and then clicking the
Conditional Formatting drop-down button.
Graphic
The Conditional Formatting drop-down menu contains the options Highlight Cells Rules, Top/Bottom
Rules, Data Bars, Color Scales, Icon Sets, New Rules, Clear Rules, and Manage Rules.
You select the Data Bars option and then choose the type of Fill you want to apply from the
menu.
222

Graphic
The Data Bars submenu contains a gallery of data bar formats categorized under Gradient Fill and
Solid Fill.
The data bars appear in each cell in the selected range so that you can compare them. The cell
with the fullest bar is the one with the highest value.
Graphic
For example, in a column of sales figures, the highest number in the range 156,895 has a full
bar of color, whereas the lowest number in the range 54,455 has a color bar that's less than half
the length of the cell.
To use color scales to compare your data, you first select the cells you want to compare. You
can then open the Conditional Formatting drop-down menu and select Color Scales.
Graphic
The Color Scales submenu contains a gallery of different conditional formatting styles. In this case,
a range of figures in column G have been selected.
Then you choose the color scale you want to use by clicking it. You can use a color scale of
either two or three colors.
When a color scale is applied, the cells are color coded according to their value. For example, if
you select the first Color Scale style the cells with the highest figures will be shown in green, the
cells with average values in yellow, and the cells with the lowest values in red.
Graphic
For example, the highest number 20,396 display in green and the lowest number 0 displays
in red. Numbers in between the highest and lowest display in various shades of green, yellow, and
yellowish-red.
Sometimes you may want to use more than one rule to highlight your cells. Excel's Conditional
Formatting tools allow you to set more than one conditional format at a time.
Graphic
For example. you can apply both an icon set and a data bar to a range of cells.
223

You can use icon sets to determine the highest, lowest, and average values. To apply an icon
set you first select the cells and open the Conditional Formatting drop-down menu.
Graphic
In this example, a column of sales figures to which data bars have already been applied, is selected.
The Conditional Formatting drop-down menu contains the options Highlight Cells Rules, Top/Bottom
Rules, Data Bars, Color Scales, Icon Sets, New Rules, Clear Rules, and Manage Rules.
When you hover over the Icon Sets command, a submenu appears with a list of the different
sets of icons you can apply to the cells.
Graphic
There are a range of icons you can choose under sections named Directional, Shapes, Indicators,
and Ratings.
When you select the icon set you want by clicking it, the menu automatically closes and the
icons appear in the cells.
Graphic
In this example, a Directional option has been selected. The cells now have both data bars and
different colored arrows indicating their relative values.
You can clear the whole sheet of rules, or just selected cells. To clear rules that you have
previously set, you first select the cells that the rule is applied to. Then you open the Conditional
Formatting drop-down menu.
Graphic
For example, the G column of the table, that has color scales applied to it, has been selected.
You can hover your mouse over Clear Rules to access more detailed options. For example, you
can click Clear Rules from Selected Cells.
Graphic
Options that appear when you hover over Clear Rules in the Conditional Formatting menu include,
Clear Rules from Selected Cells, Clear Rules from Entire Sheet, Clear Rules from This Table, and
Clear Rules from This PivotTable.
The menu will automatically close, and the rules will be cleared on the cells you selected.
224

Graphic
The selected range of cells now have no color conditional formatting applied to them.
SkillCheck
You've formatted a worksheet, and now want to apply a conditional format to make it easier to read.

Clear the rules from the already selected cell range H9:H17, which contains the sum of each
salesperson's salary and bonus. Then add Green Solid Fill data bars the second option in the
Solid Fill section of the Data Bars menu.
In the worksheet displaying bonus calculations of salespeople, the Home tab displays and the
selected cell range already has color scales formatting applied to it.
Task:
1. Select the cells you want to remove the rules from, and access the clear options.
2. Clear the rules from the selected cells.
3. Access the Data Bar rules.
4. Apply the data bar rule in solid green.
Answer
To complete the task
Step 1: Click the Conditional Formatting drop-down button
Step 2: Select Clear Rules, and select Clear Rules from Selected Cells
Step 3: Click the Conditional Formatting drop-down button and hover over Data Bars
Step 4: Select the Green Solid Fill option in the Data Bars menu
Summary
With conditional formatting you can compare and categorize data to highlight certain cells.
Drawing attention to certain cells visually makes it easier to analyze your worksheets. You
highlight cells by applying certain rules to the worksheet, or by applying data bars, color scales,
or icon sets to a number of cells.

You can find the conditional formatting features and rules in the Styles group on the Home tab.
For example, you could use the Greater Than rule to highlight cells over a certain value. Or you
225

may want to compare and color-code your data to see the lowest, average, and highest values
using the Color Scale feature.



























226

Using Sparklines in Excel 2010
Learning Objectives
After completing this topic, you should be able to
use sparklines to show data trends
format sparklines
1. Showing data trends with sparklines
Sparklines are a new feature in Excel 2010 that can be used to visualize data trends for a series
of values. They are miniature charts that display the fluctuations in a range of cells for
instance, the monthly sales figures for a company over a fiscal year but presented in a single
cell. They can be used to show seasonal increases, decreases, or financial cycles, and highlight
both minimum and maximum values.
The biggest benefit of sparklines is that you can show patterns that aren't apparent at first
glance. Visually representing a decline in sales can have a bigger impact than a set of numbers.
You can add sparklines to a worksheet by using commands on the Insert tab.
Graphic
A worksheet, listing product sales over different months, is open in Excel.The Excel interface
includes several default elements a mini toolbar of frequently used commands, a Ribbon
containing several tabs of commands, and a formula bar. The worksheet appears below these
elements. The Sparklines group on the Insert tab contains the options Line, Column, and Win/Loss.
Each sparkline type is best suited to showing particular types of data trends.

Select each option in the Tools group to find out more about it.
Line
The Line sparkline is a line graph connecting points that represent the individual values in the
range. It can be customized to show various colored markers, such as the highest and lowest
values, and you can change the colors of the line or markers.
Column
The Column sparkline looks like a bar graph. Each value in the cell range is represented by a
column, where lower values have smaller columns and vice versa. You can change the colors of
the bars, but you can't add markers.
Win/Loss
227

The Win/Loss sparkline is a kind of bar graph where columns originate from a horizontal axis that
bisects the cell. Win/Loss columns are all the same height and appear above or below the axis,
depending on whether the values they represent are negative or positive.
Say you're examining a worksheet of sales figures. You want to create an individual sparkline for
the data representing the difference between your sales goal and the actual sales per month.
You first select cell K13.
Graphic
The table in consists of columns seven columns under the headings Product, Mar-10, April-10, May-
19, Jun-10, Goal per month, and Trend. The rows display the sales amounts for each month for
each product and the target sales amount in the Goal per month column. The Trend column for
each product is currently blank, and the selected cell, K13, is located in this column.
You then select the required Sparkline option in this case a Column sparkline.
This displays the Create Sparklines dialog box.
Graphic
The Create Sparklines dialog box contains the Data Range and Location Range text boxes. Each
text box has an associated Collapse Dialog button. In this case, the Location Range is set to $K$13.
To insert a sparkline you need to specify the data range and location for the sparkline. You can
either type in the data range or drag a selection, which will reflect in the Data Range text box in
the Create Sparklines dialog box.
Graphic
In this case, the Data Range text box displays C30:I30.
You can specify a new location for your sparkline or retain the previously selected location.
Graphic
The Location Range displays $K$13, which is the selected cell.
If you don't specify a new location, the sparkline will appear in your previously selected cell.
Graphic
A line sparkline appears in selected cell K13.
228

If you have a data range selected before you choose to insert a sparkline, Excel will use the
selection as the data to be displayed.
Graphic
Cells D29 to I29 are selected and the Column sparklines option is selected.
The selected range then appears in the Data Range text box. You then need to enter or select a
cell location.
Graphic
The Create Sparklines dialog box is open and D29:I29 displays in the Data Range text box. The
Location Range text box is blank.
You can click the Collapse Dialog button beside the Data Range or Location text boxes to more
easily select a range or location. This collapses the Create Sparklines dialog box to a single text
field.
Graphic
Clicking Collapse Dialog in the Location text box, reduced the Create Sparklines dialog box to one
field, and the Collapse Dialog button changes to the Expand Dialog button.
Note
Even if you haven't already chosen to collapse the dialog box, it collapses automatically, if you begin
to select a cell range and expands once the selection is complete.
You then select the target range or cell and click the Expand Dialog button to expand the dialog
box.
Graphic
Cell K12 is selected and $K$12 appears in the field of the Create Sparklines dialog box.
The coordinates of the selected range or cell appear in the relevant text box. When you have
inserted a data range and location, you click OK.
Graphic
The Create Sparklines dialog box now displays both the Data Range and Location Range text boxes
with the associated settings that are specified.
229

The sparkline appears in the cell you selected and the Sparkline Tools - Design contextual tab
opens on the Ribbon.
Graphic
A Sparkline for the specified range is displayed in cell K12.
Say you wish to create a group of column sparklines for a set of monthly sales figures. To do so,
you select the data range and insert column sparklines by clicking the Column button in the
Sparklines group.
Graphic
The cell range F8:I18 has been selected. The data in the cells in this range contain dollar values.
The Create Sparklines dialog box opens with the selected range in the Data Range text box.
You then select the location of the sparklines and click OK.
Graphic
The Create Sparklines dialog box displays D8:I18 in the Data Range text box. The Location Range
text box contains the data range $K$8:$K$18.
The new sparklines appear grouped, and can be edited together by simply selecting a single line
within the group.
Graphic
Column sparklines appear in cells K8 to K18.
SkillCheck
You want to use sparklines to show the difference between your sales goals and the actual sales
figures for the July to December period. You've already selected the data range D25:I26.

Add Line sparklines to display the trend in cell phone sales using the options on the Ribbon.
Manually collapse the dialog to select the range for the sparklines' location, which is K8:K9 and then
expand the dialog again and confirm the selection. To select the range of cells, click cell K8 and
drag to cell K9 without releasing the mouse button.
A worksheet, listing product sales over different months, is open in Excel. The Insert tab displays.
Task:
230

1. Use the Sparklines group to insert a Line sparkline.
2. Select the cell range.
3. Confirm your selection.
Answer
To complete the task
Step 1: Click the Line sparkline button
Step 2: Click the Collapse Dialog button, select cells K8 to K9, and click the Expand Dialog button
Step 3: Click OK
2. Formatting sparklines
When you create a sparkline, or select a cell with one inserted, Excel opens the Sparkline
Tools - Design contextual tab. You can use this tab to format and edit sparklines.
Graphic
The Sparkline Tools contextual tab includes the Sparkline, Type, Show, and Style groups.
You can edit the data used to create a sparkline by selecting options in the Edit Data drop-down
menu in the Sparklines group.
Graphic
Edit Group Location & Data displays in the Edit Data drop-down menu. Other options are Edit Single
Sparkline's Data, Hidden & Empty Cells, and Switch Row/Column.
In the Edit Sparklines dialog box, you can change the data range or location range by manually
entering the data and selecting the cells.
Graphic
The Edit Sparklines dialog box is identical to the Create Sparklines dialog box and contains the Data
Range D25:I35 and the Location Range $K$8:$K$18, in this case.
If a cell has no value but is included in the cell range, by default this displays on the sparkline as
a gap.
Graphic
231

In this example, cell I18 is blank, and it appears in the sparkline as a blank space.
You can select Hidden & Empty Cells from the Edit Data drop-down menu to choose the way
Excel displays missing data.
Graphic
The option Hidden & Empty Cells is selected in the Edit Data drop-down list menu.
The dialog box offers different ways to represent empty cells.
Graphic
The Hidden and Empty Cell Settings dialog box has three radio buttons in the Show empty cells as
section: Gaps, Zero, and Connect data points with line. There is also a Show data in hidden rows
and columns checkbox, which is not selected.
If you change your mind about the sort of sparkline you want to use, you can simply make
another selection from the Type group.
Graphic
Win/Loss is selected from the Type group. Other options are Line and Column.
Try It
Now you try editing the data range for a sparkline.

The currently selected sparklines in K11:K13 take their data from an incorrect data range. Edit the
sparklines so the data range comes from D11:I11. To select the range of cells, click cell D11 and
drag to cell I13 without releasing the mouse button.
A worksheet, listing product sales over different months, is open in Excel and a column sparkline
displays alongside the table data. The Sparkline Tools - Design tab is open.
To complete the task
1. Click Edit Data, then select Edit Group Location & Data, and click the Collapse Dialog button next to
the Data Range text box
2. Drag the selection from cell D11 around the cells from January to April to cell I13, then click the Expand
Dialog button
3. Click OK
You've altered a sparkline so that it uses a different data range for its data.
232

3. Customizing sparklines
You can customize sparklines to best illustrate data trends by using the checkboxes in the Show
group on the Sparkline Tools - Design contextual tab. You can show negative or positive
values, high and low points, or a combination of settings.
Graphic
For example, you can mark the different points in the Sparkline with different colors, such as green
for the highest value, blue for above average values, orange for below average values, and red for
the lowest value.
The Show group consists of six checkboxes that let you add color coded identifiers to points on
your sparklines.

Select each option to find out more about it.
Graphic
The worksheet has a group of line sparklines from cell K8 to K18. Cell K8 is selected.
High Point
When you select the High Point checkbox, the highest point on the sparkline is highlighted.
Low Point
When you select the Low Point checkbox, the lowest point on the sparkline is highlighted.
Negative Points
The Negative Points command highlights any negative points on the sparkline. If there are no
negative values, nothing will be displayed.
First Point
The First Point command highlights the first value on the sparkline.
Last Point
The Last Point command highlights the last value on the sparkline.
Markers
You can select the Markers checkbox to add a point to every value on the sparkline, but only on
Line sparklines. For other sparkline types, the Markers checkbox is unavailable.
The Style group contains a range of predefined color themes that you can apply to a sparkline.
233

Graphic
The Style group includes the Style gallery and the Sparkline Color drop-down menu, which contains
the Theme Colors, Standard Colors, Recent Colors galleries. It also contains the More Colors and
Weight options.
You can use the More button to open the Styles gallery.
Graphic
This displays a gallery containing a number of predefined sparkline styles. They are all line
sparklines, as this is the currently selected sparkline.
Once you make a selection, both the color of the sparkline and the markers change to the new
style.
Using the Marker Color drop-down menu, you can customize the color of a sparkline's markers
by changing the color of the different points.
Graphic
The Marker Color drop-down menu in the Style group contains the options Negative Points,
Markers, High Point, Low Point, First Point, and Last Point.
Say you decide to pick a new color for the highest point of each line. You simply select the new
color from the High Point color gallery.
Graphic
The High Point color gallery includes the Theme Colors, Standard Colors, Recent Colors galleries,
as well as the More Colors. When you select a color swatch, the gallery closes and the color is
applied to the highest points of the selected sparkline.
You can also modify the color of the sparkline without affecting the points by opening the color
palette from the Sparkline Color button in the Style group.
Try It
Now you try changing the color of sparkline and customizing the markers on a line sparkline in cell
K8, which is already selected. You've already specified that the sparklines show high and low points.
A worksheet, listing product sales over different months, is open in Excel and a line sparkline
displays alongside the table data. The Sparkline Tools - Design tab is open.
234

To complete the task
1. Click Sparkline Color and select Orange, the third option in the Standard Colors section of the gallery
2. Click Marker Color, roll over High Point, and select the second color in the fourth column of the Theme
Colors section of the gallery
The sparkline line color has been changed.
3. Click Marker Color, roll over Low Point, and select the last color in the Standard Colors section of the
gallery
You've added markers for the high and low points of the sparkline, and changed the colors of the
line, and the high and low points.
4. Grouping sparklines
You can use commands in the Group group to edit a number of sparklines at once. For
example, you can change the axis settings to highlight trends or to create a visual comparison
across the group.
The Group, Ungroup, and Clear commands in the Group group let you control your sparklines
collectively.
Graphic
The Group group can be found on the Sparkline Tools - Design tab.
Select each group related command to find out more about it.
Group
The Group command lets you group several sparklines in a cell range. You can then format their
scale and appearance. If the sparklines are already grouped, this option will be unavailable.
Ungroup
You can use the Ungroup command to split a collection of sparklines if they're all selected. If a
single line in a group is selected, Ungroup will remove that line from the group.
Clear
You can access the Clear Selected Sparklines option and the Clear Selected Sparkline
Groups option from the Clear drop-down menu. Clear Selected Sparklines will remove any
sparklines currently selected, even if they're removed from within a group. Clear Selected
Sparkline Groups clears whole selected groups of sparklines, and you need select only a single
sparkline in a group for this option to affect them all.
You can also access the Axis drop-down menu from this group to alter how the horizontal and
vertical axes display.
235

Graphic
The Axis drop-down menu contains three sections: Horizontal Axis Options, Vertical Axis Minimum
Value Options, and Vertical Axis Maximum Value Options. The Horizontal Axis Options section
includes the options General Axis Type, Date Axis Type, Show Axis, Plot Data Right-to-Left. The
Vertical Axis Minimum Value Options section includes the options Automatic for Each Sparkline,
Same for All Sparklines, and Custom Value. The Vertical Axis Maximum Value Options section
includes the options Automatic for Each Sparkline, Same for All Sparklines, and Custom Value.
When you select Date Axis Type from the Axis drop-down menu, the sparkline will display
according to dates within the data range, and show missing months in a chronological
sequence. This allows you to view trends within a chronological context.
You specify the range containing the dates you wish to use for the new axis. The range will be
accepted only if the data is not formatted as a table.
Graphic
In the Sparkline Date Range dialog box, the Select the range that contains the date values for the
Sparkline data text box contains the cell range D6:J6.
You can then change the sparkline type to Column to view the data with gaps added to indicate
any missing dates.
Graphic
The Column option is selected in the Type group of the Sparkline Tools - Design tab..
You can choose to use the same minimum or maximum vertical axis for all sparklines in the
group. By default, the vertical axis for each sparkline is derived from the individual range.
Graphic
The Same for All Sparklines option is selected in the Vertical Axis Minimum Value Options section of
the Axis drop-down menu.
If the group of sparklines display with the same minimum value, you get a more accurate picture
of changing trends across the entire range.
Whether you choose to use the same maximum or minimum axis depends on the data range. It
can be difficult to spot differences if there's a huge gap between the maximum and minimum
figures.
236

Graphic
The Same for All Sparklines option is selected in the Vertical Axis Maximum Value Options section
of the Axis drop-down menu.
You can also specify the minimum or maximum axis values using the Custom Value options.
Graphic
Custom Value is selected in the Vertical Axis Minimum Value Options section of the Axis drop-down
menu.
For example, you can specify a very low minimum value for the vertical axis to highlight the
lowest figures in a data range.
Graphic
The Sparkline Vertical Axis Setting dialog box displays. It contains the Enter the minimum value for
the vertical axis text box, which in this case, in contains the value 10.
By choosing this option, most columns in the sparkline group now appear similar in height, but
the lowest values are more apparent.
Try It
Now you try changing the axis settings for a group of sparklines.

You want to display the sales figures for a specified period of time, showing gaps for the missing
months. You also want to change the vertical axis to use the same minimum values for all sparklines
in the group. Use uppercase when typing cell references.
A worksheet, listing product sales over different months, is open in Excel and column sparklines
displays alongside the table data. The Sparkline Tools - Design tab displays on the Ribbon.
To complete the task
1. Click Axis and select Date Axis Type
2. Enter D6:J6 into the Sparkline Date Range dialog box text input field and click OK
The Sparkline Date Range dialog box appears with an empty text input field.
3. Click Axis and select Same for All Sparklines from Vertical Axis Minimum Value Options
You've changed the sparklines to use a Date Type axis for the horizontal axis, and to use the same
minimum value for the vertical axis.
237

Question
You've created a Column-type sparkline.

In which ways can you format sparklines using the Design tab in the Sparkline Tools contextual
tab?
Options:
1. You can change the sparkline to display as a line
2. You can edit the data range
3. You can highlight high points and low points on the sparkline
4. You can include markers and change their color
5. You can change the sparkline color
6. You can superimpose a line sparkline over the column sparkline
Answer
Option 1: Correct. You can choose between Line, Column, and Win/Loss type for your sparkline
in the Type group.
Option 2: Correct. You can edit both the data range displayed by the sparkline and the location of
the sparkline from the Sparkline group.
Option 3: Correct. In the Show group, you can choose which points you want the sparkline to
display.
Option 4: Incorrect. Markers are only available for Line-type sparklines.
Option 5: Correct. The Sparkline Color gallery is accessible from the Style group.
Option 6: Incorrect. Only one sparkline can be inserted into a cell.
Correct answer(s):
1. You can change the sparkline to display as a line
2. You can edit the data range
3. You can highlight high points and low points on the sparkline
5. You can change the sparkline color
Summary
Sparklines are a new Excel feature. They are mini-graphs displayed in single cells that highlight
trends in data ranges.
238


They can be formatted in a number of ways to display as a bar graph, a line graph, or to show
both positive and negative values.

You can customize sparklines to highlight certain points and change the colors of both a
sparkline and its markers.

Sparklines can also be grouped and edited together. The axes can be edited to alter the way the
sparklines display.























239

Using Tables, Conditional Formatting, and Sparklines
Learning Objectives
After completing this topic, you should be able to
sort and filter table data
use conditional formats to highlight data
use sparklines to highlight trends in data
Exercise overview
This topic teaches you how to perform tasks using Excel 2010, simulating the application
interface and guiding you through the tasks. The instructions for completing the exercise are
presented on screen.
In this exercise, you're required to format a range of data as a table and then use this to sort and
filter the data, use conditional formats to highlight specific data, and identify trends in the data by
using sparklines.
This involves the following tasks:
formatting the data as a table, and sorting and filtering the data
using conditional formats to highlight data, and
using sparklines to highlight trends in data
Task 1: Formatting a table, and Sort and Filter options
You want to format certain data in a worksheet of bonus calculations as a table.
Convert the selected data to a table, then add a table style using the Medium Navy format, the
second option in the Medium section of the gallery. Remove the banded rows and insert banded
columns. Then use the Total column's drop-down list to filter the data to show the top seven
items, and sort the data to go from smallest to largest.
Steps list
Instructions
1. Select Format as Table
2. Select the Medium Navy format and click OK
3. Clear the Banded Rows checkbox and select the Banded Columns checkbox instead
240

Steps list
Instructions
4. Click the drop-down button on the Total $ column, select Number Filters, then select Top 10
5. Click the down arrow in the spin box three times to show the top 7 items and click OK
6. Select Sort Smallest to Largest from the drop-down menu on the Total $ column
Task 2: Using conditional formats
You now want to add conditional formatting to the worksheet to highlight top performers.
Use the options in the Styles group to highlight the selected data in the Sales $ column above
$115,000 in the default color. Enter the amount using the format, 115,000, in the rule. Highlight
the above-average figures in the Bonus $ column, cells G9 to G17, using a green fill with dark
green text. Finally, in the Total $ column, cells H9 to H17, show the figures using orange data
bars the fourth option in the Solid fills section of the menu and the three-colored arrow icon
set, which is the first option in the menu.
Steps list
Instructions
1. Click the Conditional Formatting drop-down button, select Highlight Cells Rules, and select Greater Than
2. Enter 115,000 and click OK
3. Highlight cell G9 to cell G17
4. Click the Conditional Formatting drop-down button, select Top/Bottom Rules, and select Above Average
5. Select Green Fill with Dark Green Text from the drop-down list and click OK
6. Highlight cell H9 to cell H17
7. Click the Conditional Formatting drop-down button, select Orange Solid Fill from the Data Bars menu
8. Select Icon Sets from the Conditional Formatting drop-down menu and select the 3 arrow (color) icon set
241

Task 3: Using sparklines
You have now opened the Seattle Sales Comparison worksheet. You want to illustrate the sales
trends from January to June for all products, using sparklines.
You've already selected the data from columns C8 to H13. Add Column-type sparklines in
column J by using commands on the Ribbon and by selecting the cells in column J. Manually
collapse the dialog to select the range for the sparklines' location, which is J8:J13, and then
expand the dialog again and confirm the selection. Configure the sparkline to highlight the
highest and lowest points. You want the sparklines to be in blue, red, and green, which is the
second option in the sixth row of the Style drop-down gallery.
Steps list
Instructions
1. Click the Insert tab and select Column from the Sparklines group
2. Click the Collapse Dialog button
3. Select cells J8 to J13
4. Click the Expand Dialog button
5. Click OK
6. Select the High Point and Low Point checkboxes from the Show group
7. Select the blue, green, and red style from the Style drop-down menu
Data has been formatted as a table showing the top seven items and sorted from Smallest to
Largest. Cells higher than a certain amount and cells higher than average have been
highlighted, and data bars and icon sets have been applied to a range of data. Column
sparklines have been added to the Seattle Sales Comparison worksheet.




242

Operating Systems

UNIX Philosophy and History
Learning Objectives
After completing this topic, you should be able to
recognize the basic principles of UNIX
describe the historical development of UNIX
1. The basic principles of UNIX
UNIX is a powerful operating system, widely used by major corporations and institutions since
its initial development in 1969.
Its popularity stems from its flexibility, power, and versatility, which it draws from its basic design
principles.
Three design principles encompass much of the UNIX philosophy.
Simplicity
UNIX tries to keep every task simple. Rather than being made up of a few complex applications,
UNIX consists of a large number of very simple applications. This increases overall efficiency
because each program does one thing well, resulting in fewer wasted system resources.
Reusability
UNIX's simplicity extends to reusability. UNIX's large number of small, efficiently written programs
allows for faster development of new applications, because you can use existing programs in
your code.
Portability
Because UNIX is written entirely in C, it is easier for developers to port the OS to new and
different hardware. The open source nature of UNIX means that this porting has already been
done for many, many hardware architectures already.
One of the features that makes UNIX so powerful is that most of its file formats are open,
making them easily accessible. Most UNIX configuration files follow an open standard, so simple
text editors can be used to configure the system.
American Standard Code for Information Interchange, or ASCII, files are plain text files. These
files use 8-bit codes from 0-255 for printable and non-printable characters.
243

Specifically, ASCII uses codes 48-122 for the alphanumeric characters 0-9, a-z, and A-Z. All text
readers or editors can read ASCII format.
Question
What are the basic principles of UNIX?
Options:
1. It's an open source operating system
2. You can reuse existing programs to develop new applications
3. It aids simplicity by using a few powerful applications
4. Most of its file formats are restricted to prevent unnecessary editing
Answer
Option 1: Correct. Because UNIX is open source, it has been ported to run on many different
hardware architectures.
Option 2: Correct. The numerous programs included with the operating system make developing
new applications faster, because you can use existing programs in your code.
Option 3: Incorrect. UNIX consists of a large number of very simple applications rather than a few
complex applications.
Option 4: Incorrect. A feature that makes UNIX so powerful is that most of its file formats are open,
which makes them easily accessible and editable.
Correct answer(s):
1. It's an open source operating system
2. You can reuse existing programs to develop new applications
2. The history of UNIX
The first computer operating systems in the early 1960s allowed only one user at any given time
to run a single program. Users had to schedule time on the system, and would have to wait for
one computer task to finish before they could start another.
This led to a number of businesses and educational institutions coming together to create a
prototype system to support several users simultaneously. Known as the Multics project, it was
only partially successful and was eventually discontinued in the late 1960s.
244

UNIX was created in the laboratories of AT&T Bell Labs in 1969 and used a number of Multics
principles. It was initially developed by Ken Thompson and several other ex-Multics
programmers, including Dennis Ritchie, M. D. McIlroy, and J. F. Ossanna.
They designed UNIX so a game they had developed on Multics could work on a PDP-7
computer system they had access to. The result was a workable multiuser, multitasking
operating system.
The significance of UNIX became apparent when its portability was demonstrated. This came
about when AT&T upgraded Thompson's hardware to a PDP-11, which was not backward-
compatible with the PDP-7 Thompson had been working with.
Thompson and his colleagues now had to move their project to a completely new environment.
Normally, this would have required recoding from scratch. However, they had already written
UNIX in the new C language recently developed by Ritchie.
This meant that for the first time, an operating system could be transported in its entirety to a
completely different platform and be recompiled without having to rewrite it. All that was required
was a C compiler written for the destination system.
Thompson began to distribute copies of the UNIX source code in C to friends and colleagues. In
this way, UNIX quickly became a community development project.

Programmers could write and distribute code that could run on a wide variety of hardware
platforms.
Although AT&T still owned the code, they'd been involved in regulatory difficulties and had been
forbidden to sell software commercially. Instead, over the next decade or so, AT&T liberally
assigned licenses to universities and businesses.
UNIX therefore became the established teaching medium for operating system design. Because
C is much easier to read than machine code, students could study the source code, learn from
it, and readily adapt it.
Today UNIX is one of the most widely used operating systems in the world, existing in both
commercial and open source forms. In fact, the majority of Internet servers run on a variant of
UNIX.
Question
What was it that made UNIX so useful?
Options:
1. It was written in C, which allowed it to be moved to new systems without having to be recoded
2. Based on Multics' principles, it allowed more than one user to use multiple programs at a time
245

3. It was written in COBOL, which allowed for easy distribution, so it quickly grew into a community
development project
4. UNIX could be fully transported to a completely different system and be recompiled as long as there was
a BASIC interpreter on the destination system
Answer
Option 1: Correct. UNIX could be transported in its entirety to a completely different platform and be
recompiled as long as there was a C compiler written for the destination system.
Option 2: Correct. UNIX was the first workable multiuser, multitasking operating system.
Option 3: Incorrect. It was coded and distributed in C, which allowed programmers to easily write
and pass along their code.
Option 4: Incorrect. Because it was rewritten in C, any new system would need a C compiler on it to
allow UNIX to run.
Correct answer(s):
1. It was written in C, which allowed it to be moved to new systems without having to be recoded
2. Based on Multics' principles, it allowed more than one user to use multiple programs at a time
3. Further UNIX development
In the early 1980s, the Bell network of companies was broken up, leaving AT&T free to pursue
UNIX commercially. They restricted their source and developed a proprietary version of UNIX.
At this point, there were two main UNIX camps.
AT&T System V
AT&T System V was the first commercial distribution of UNIX. It was a standard package, lacking
many of the more exciting features of its counterparts, and it came without source code.
However, System V came with backup and customer support, which are important concerns for
businesses.
Berkeley Software Distribution
Berkeley Software Distribution, or BSD UNIX was a raw and vibrant ongoing development that
came with source code. While it wasn't commercially supported, its open source nature meant
that new tools were constantly being invented for it.

Features of BSD UNIX included screen editing capabilities, and the now famous C shell a
command environment customized for C programmers. BSD is also credited with inventing the
TCP/IP stack, on which the Internet is now based.
246

BSD UNIX belongs to the University of California, Berkeley. It was initially based on a lot of
AT&T code, so users of BSD required an expensive AT&T license. To counter this, Berkeley
rewrote their UNIX without any AT&T code and released it under an open source license.
AT&T sued Berkeley for copyright infringement and disclosing trade secrets. Berkeley counter-
sued because AT&T included the TCP/IP stack invented by Berkeley, without acknowledging its
open source origins.
The AT&T versus BSD legal battle marked the beginning of what has become known as the
UNIX wars, which continued until 1993 when AT&T sold its rights to UNIX to Novell and left the
arena.
A number of software developers have developed and sold custom versions of UNIX based on
the innovations of the open source version.
In the commercial sector, the dominant versions of UNIX are Oracle's Solaris, SGI's IRIX, IBM's
AIX, and Hewlett-Packard's HP-UX and Tru64 UNIX.
In the open source sector, BSD is still a major player and exists in several forms, notably
FreeBSD, NetBSD, and OpenBSD.
In 1991, a student at the University of Helsinki named Linus Torvalds announced he'd
developed a UNIX kernel specifically for Intel processors. He dubbed the kernel Linux and
released it under a free license.
This meant Linux source code was freely available and could be shared between users and
machines. The open source nature of Linux allowed users to modify the functionality of source
code as they desired.
Because of this, Linux could react to developments in the computing world as they took place. It
rapidly took off as an operating system development project firmly rooted in the open source
community.
The Linux audience would grow to include many technical users worldwide. These users
created new source code that they added to the operating system to optimize its performance,
fix code errors, and provide support for numerous hardware platforms.
Today Linux comes in many different distributions - or distros as they're called - and is used in
all types of computers, from desktops to supercomputers.
Question
Which events serve as milestones in the evolution of UNIX?
Options:
247

1. AT&T gave out numerous free UNIX licences to learning institutions, because it was not legally allowed
to sell software
2. Linux was a development of the UNIX kernel for use on PC systems
3. AT&T BSD UNIX was the first commercial distribution of UNIX
4. The University of California, Berkeley, paid royalties to AT&T for rights to redistribute UNIX
Answer
Option 1: Correct. While AT&T owned the UNIX source code, they'd been involved in regulatory
difficulties and had been forbidden to sell software commercially.
Option 2: Correct. In 1991, Linus Torvalds announced he'd developed a UNIX kernel specifically for
PC processors, which he named Linux.
Option 3: Incorrect. AT&T System V was the first commercial distribution of UNIX, although it
lacked a number of features, and it came with no source code.
Option 4: Incorrect. The university rewrote their UNIX, called BSD, without any AT&T code and
released it under an open source license.
Correct answer(s):
1. AT&T gave out numerous free UNIX licences to learning institutions, because it was not legally
allowed to sell software
2. Linux was a development of the UNIX kernel for use on PC systems
Summary
UNIX design is based on the concepts of simplicity, reusability, and portability. Rather than
featuring a small number of complex utilities, UNIX has a large number of simple programs,
each of which does one thing well.

Ken Thompson and Dennis Ritchie created UNIX in 1969, at AT&T's Bell Labs. Because it was
written in C, it could be easily ported to other hardware platforms something that had never
been achieved before.

UNIX development took place in two camps commercial development by AT&T and open
source development at the University of Berkeley, California. Initially, this resulted in the
splintering of UNIX, but it was later reunified by a UNIX variant called Linux.



248

UNIX Portability and Standards
Learning Objective
After completing this topic, you should be able to
describe UNIX standards
1. UNIX and the open source model
The early development of UNIX wasn't commissioned or planned. It was an experiment by a
team of operating system programmers who were trying to get a game they had designed on a
different operating system to work on their current hardware.
Because it was a collaborative experiment, there wasn't any secrecy surrounding the source
code. And when the UNIX kernel was rewritten in C for its first major port, the programmers
passed around the source code to their friends, asking for additions, feedback, and bug fixes.
Programmers exchanged UNIX source code freely in its early days as it was, to a large extent,
relatively unencumbered by licensing and copyright issues.
Sharing code was also a good way for programmers to learn from each other, and it allowed for
faster development. A lot of time was saved because one programmer could use code that
another programmer had already written.
Developing code faster by drawing on the knowledge and work of others was the underlying
concept in the early days of UNIX programming. It was also considered fair practice to share
your knowledge when you made use of other people's knowledge.
Much of UNIX as we know it today is built on these early ideals, and many of UNIX's innovations
have been created by open source movements.
Open source means that the source code is available to anyone. This allows any user to modify
or improve it, and then recompile the code.
Open source is often confused with meaning free freely available is a better way of describing
it. This is because there are also commercial versions of UNIX, so depending on which version
you want, that particular version may not actually be free of charge.
Nonetheless, the commercialization of UNIX led to further innovations. When AT&T's rising
licence prices began to discourage early developers from using the platform, Richard Stallman
founded the GNU's Not Unix project. This was a completely open source version of UNIX
without any AT&T code.
These days GNU, now combined with a UNIX kernel, is one of the most widely used forms of
UNIX, and is still available free of charge.
249

Question
Why did early UNIX programmers consider it important to share code?
Options:
1. To share knowledge
2. To develop code faster
3. To save on costs for hiring coders
4. To circumvent licensing and copyright issues
Answer
Option 1: Correct. Sharing code is a good way for programmers to learn from each other, and it
allows for faster development.
Option 2: Correct. The underlying principle in the early days of UNIX programming was to draw on
the knowledge and work of others to develop code faster.
Option 3: Incorrect. The driving force behind sharing UNIX code was for programmers to learn from
each other, and the fact that code is developed faster if more people are working on it.
Option 4: Incorrect. UNIX source code was freely distributed in its early days, because it was
relatively unencumbered by licensing and copyright issues.
Correct answer(s):
1. To share knowledge
2. To develop code faster
2. UNIX software portability
Because it was largely written in C, UNIX became the first portable operating system.
Portability means that software, UNIX for example, can be converted, or ported, with relative
ease to a number of different hardware platforms.
PC architecture, such as the Intel x86 series, is a platform. So are IBM RISC System/6000 and
Apple Macintosh architectures.
The emphasis on coding quickly became focused on reusability over efficiency. The advantage
of not having to rewrite code for new hardware platforms was seen as more important than the
gain in performance speed obtained from writing code in machine language.
250

The ability to move code was a revolution in how code was distributed. Before this, it had been
necessary to circulate large, bulky binary files. Now you could pass around just the source code.
Consider an application written in C on a Solaris system based on Intel hardware. To move it to
a FreeBSD system, also based on Intel hardware, you'd simply need to ensure there's base
kernel compatibility and that the APIs needed are present on both systems.
The simplest way of moving the application across is to copy the source to the FreeBSD system,
and use a C compiler on that system to recompile the code.
The resulting executable is automatically tailored for the new host environment. Because C
compilers were readily available, copying and recompiling the source was deemed to be the
most efficient way to transport large applications.
The era of software portability also led to changes in how software was organized. For software
to be reusable, it needed to be broken down into its component parts and organized into
libraries.
Users began to create application programming interfaces, or APIs. These were collections of
related C programs that could be called when you were writing a program.
You therefore wouldn't need to write functionality for printing, for example. You could instead call
an API that already had the functionality. Before long, a few standard libraries emerged that
were used by everyone.
The programmers in charge of development came up with a standard UNIX file and directory
structure that allowed APIs to be stored within a system.
With the APIs in a predictable place on every version of UNIX, code portability was increased.
Programmers could rely on those APIs being there, and could use them to write shorter code.
Question
What is portability?
Options:
1. Software can easily be converted to run on different hardware platforms
2. Different hardware platforms can be adapted to accept a standard type of software
3. Large binary files could easily be passed around
Answer
Option 1: Correct. Portability means that software, operating systems or applications, can be
converted with relative ease to a number of hardware platforms.
251

Option 2: Incorrect. Portability relates to the ease with which a piece of software can be converted
to a different hardware platform.
Option 3: Incorrect. Portability means that source code can be passed around instead of large
binary files.
Correct answer(s):
1. Software can easily be converted to run on different hardware platforms
3. UNIX standards
The evolution of the UNIX operating system has also been steered by standards. Features
developed for a specific UNIX variation can become adopted as part of the standards process.
Different versions of UNIX can include a compliant version of a feature once it has been
standardized.
Application developers wanting to create programs for a range of computer systems running
UNIX experienced problems because there were different versions of UNIX without a single
standard.
Various standards have been developed to help solve these problems by defining the
characteristics a UNIX system should have.
Applications can then be created to work on any system that conforms to the standard.
AT&T published the System V Interface Definition, or SVID, in 1983. It specifies how an
operating system needs to behave to comply with the System V standard. SVID compliance
could be checked by running the AT&T System V Verification Suite.
Programs could be developed that were guaranteed to work on any platform running an SVID-
compliant version of the UNIX System.
SVID also specified certain features that were guaranteed not to change in future releases to
ensure applications would run on all releases of UNIX System V.
In 1981, the by/usr/group initiated an independent effort to define a standard operating system
environment. They wanted to ensure the portability of applications and published a standard in
1984.
Because of the size of the workload, in 1985 they merged with a similar undertaking - Project
1003 - being run by the Institute for Electrical
and Electronics Engineers, or IEEE.
252

The standards being established by Project 1003, or P1003, are called the Portable Operating
System Interface for Unix, or POSIX for short.
POSIX is a family of standards defining the way applications interact with an operating system
and assures code portability between systems. It includes areas such as system calls,
interfaces, security, tools, libraries, verification and testing, and real-time features.
There are four POSIX standards.
P1003.1
P1003.1, also known as POSIX.1, defines the system interface.
P1003.2
P1003.2, also known as POSIX.2, deals with shells and utilities.
P1003.3
P1003.3 deals with testing methods
for POSIX compliance.
P1003.4
P1003.4 deals with real-time extensions.
The National Institute of Standards and Technology has endorsed POSIX as part of the Federal
Information Processing Standard, or FIPS. This standard must be met by computers purchased
by the US federal government.
Once programmers started relying on the existence of APIs in UNIX, the need for a standard
way of dealing with system files became apparent.
The Filesystem Hierarchy Standard, or FHS, defines both the location and names of critical
system files and directories.
FHS is maintained by the Linux Foundation. They've declared it their policy to maintain FHS
compliance, because most Linux distributions follow the FHS.
A number of other organizations have contributed to UNIX standards.
Open Software Foundation
Open Software Foundation, or OSF, was created in 1988 by a group of computer companies that
included IBM, HP, and DEC. Its initial purpose was to develop a version of UNIX called OSF/1 to
compete with UNIX System V Release 4. While the operating system itself wasnt widely adopted,
OSFs GUI, called MOTIF, was. OSF merged with X/OPEN in 1996 to create the Open Group.
X/Open Consortium
The X/Open Consortium was established in 1984 to set standards for competing versions of
UNIX. These standards defined what specifications an operating system had to meet to be a
253

UNIX system, their main goal being to standardize software interfaces. To do this, X/Open
published their Common Applications Environment, or CAE, based on the SVID and containing
the POSIX standards.
Common Open Software Environment consortium
Established in 1993 by some of the major UNIX vendors, the Common Open Software
Environment consortium, or COSE, was created to define industry standards for UNIX systems.
COSE would begin work on the COMMON Desktop Environment, or CDE. This was to be the
industry-standard graphical user interface for use with UNIX systems. This work was taken over
by the OSF when COSE later disbanded.
Open Group
Formed in 1996 through a merger of the OSF and X/OPEN, the Open Group currently owns the
rights to the UNIX brand name. They've drawn up a list of features based on open standards and
global interoperability that a distribution of UNIX must have in order to carry the UNIX stamp. This
is to ensure that more software will run on a wider range of UNIX platforms.
Other UNIX standards include X/Open API and Single UNIX Specification Version 2.
X/Open API
In 1993, to help with porting software products to different versions of UNIX, X/Open took over
the responsibility for managing the development of a common API specification. This allowed
UNIX system software vendors to create applications that would work on all UNIX platforms
supporting the specification. It was initially called Spec 1170 because it originally contained 1,170
different APIs. This specification would define what is now known as the Single UNIX
Specification.
Single UNIX Specification Version 2
The Open Group developed an enhanced version of the Single UNIX Specification in 1997.
Called Version 2, it was developed to maintain UNIX's place as the best platform for high-
performance graphical applications, and mission-critical enterprise systems. Version 2 updates
the original specification with new standards and advances made by developers. It contains 1,434
APIs over the original 1,170.
Question
Match the UNIX standards with their descriptions.
Options:
A. POSIX
B. FHS
C. SVID
D. Single UNIX Specification Version 2
254

Targets:
1. Defines the way applications interact with an operating system
2. Defines the location and names of critical system files and directories
3. Specifies how an operating system needs to behave in order to be considered part of the standard
4. Developed to maintain UNIX's status as the best platform for mission-critical enterprise systems
Answer
POSIX is a group of standards defining the way applications interact with an operating system, and
include areas such as interfaces, real-time features, tools, and libraries.
FHS is a standard developed once programmers started relying on the existence of APIs in UNIX,
and needed to know where they were located.
The SVID standard defines how an operating system has to behave to comply with the System V
standard.
The Single UNIX Specification Version 2 updates the original specification with new standards and
advances made by developers.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Summary
UNIX is based on the long-standing principle of source code sharing, which allows programmers
to learn from one another and develop new code faster.

The development of the C language allowed software to be independent of the hardware
running it. Programmers could now easily swap source code and compile it on their own
systems.

UNIX development was fracturing in too many directions, giving rise to the need for standards.
UNIX standards are maintained by the IEEE, the Open Group, and the Linux Foundation.


255

UNIX Distributions
Learning Objectives
After completing this topic, you should be able to
recognize the advantages of UNIX as a server
describe the differences between UNIX's commercial and open source distributions
1. Using UNIX as a server
The Linux variant of UNIX is rapidly gaining ground as a desktop operating system. However
UNIX's multi-user capabilities make it ideally suited for a server role.
When implemented as a web or database server, a properly configured UNIX system provides
unparalleled periods of uptime, requiring little maintenance.
UNIX's multi-user capabilities make it highly resistant to attack. It's designed in such a way that
even if a malicious party did gain access to the system, their activities would be restricted to the
user account they had access to, leaving them unable to damage critical system resources.
For this reason, there are very few viruses that target UNIX systems, and even fewer that pose
any real threat. In fact, most UNIX virus scanners for example, those running on mail servers
do most of their work removing viruses intended for other operating systems, to which they are
immune.
UNIX is also cost-effective in the long term because it's independent of the hardware it runs on.
Naturally, it runs faster on more powerful hardware, but it doesn't require powerful hardware to
begin with. This means that existing computers will have a longer useful life.
The structure of UNIX means that in the case of a hardware failure, sections of the file system
can be taken offline, replaced and brought back online without shutting down the system. This
makes UNIX a good choice for mission-critical applications.
Question
What are some of the advantages of UNIX as a server?
Options:
1. It is quite resistant to attacks from malicious code
2. It requires specialized computer systems
3. It is structured to minimize impact if compromised
4. It safely shuts down the entire network in case of a hardware failure in one section of a data structure
256

Answer
Option 1: Correct. The UNIX architecture is designed to be resistant to attacks from malicious code.
If an attack occurs, it is restricted to the user account that was attacked and system resources are
not affected.
Option 2: Incorrect. The design of UNIX makes it independent of the hardware it runs on, so it can
run on virtually any type of computer.
Option 3: Correct. UNIX is designed in such a way that even if a malicious party did gain access to
the system, their activities would be restricted to the user account they had access to, leaving them
unable to damage critical system resources.
Option 4: Incorrect. In case of hardware failure in one data structure, UNIX can isolate that section
until it is repaired.
Correct answer(s):
1. It is quite resistant to attacks from malicious code
3. It is structured to minimize impact if compromised
2. Differences between UNIX distributions
UNIX distributions come in two main variants commercial and open source. Each has its own
distinct features and advantages that need to be carefully considered when choosing which
product is right for your environment.
Commercial UNIX has the distinct advantage of having IT vendor support. When something
goes wrong with the system, there's usually someone you can call who will help you with the
problem you're experiencing.
Commercial distributions often adhere to established standards, so chances are high that the
software you need will run reliably on your system. Commercial UNIX often uses proprietary
code to ensure that the system is as stable as possible.
Some distributors write commercial UNIX specifically for a particular set of hardware. The
advantage of this approach is that the software can be highly optimized for that hardware, giving
maximum performance and a greater level of stability.
Examples of this include Oracle's Solaris for their SPARC systems. Solaris was created and
owned by Sun until 2010, when the company was acquired by Oracle. Another example of
commercial UNIX is IBM's AIX for the IBM RS/6000, Hewlett-Packard's HP-UX, and other
hardware platforms. Apple's Mac OSX also uses UNIX as its base.
257

Using commercial UNIX with proprietary code might mean that the software will be scalable and
compatible, but it also means you may be locked into a particular upgrade path and can only
use hardware from one specific company.
Open source UNIX is a rapidly growing technology. Because the code is open and available,
you can compile UNIX for just about any hardware. It is free of charge because open source
UNIX is distributed under the GNU General Public License, or GPL.
The GPL allows you to make any modifications you see fit to the code in order to improve on
system components, provided you make your changes available to the rest of the open source
community under the same license, and provide them with the modified source. GPL software
has no warranty of any kind.
FreeBSD, a widely used open source version of UNIX, works a little differently. The bulk of its
code is covered by the GPL, but FreeBSD incorporates functionality from several proprietary
modules, including some from the original version of BSD. So FreeBSD is covered by the GNU
GPL, the BSD copyright, and has restrictions on the redistribution of several proprietary
components. Ultimately, this makes FreeBSD a bit of a hybrid.
Linux, the UNIX clone created by Linus Torvalds, is an extremely popular UNIX variant. It is
particularly interesting in that it has been ported to many different platforms, from desktop
computers to laptops, tablet PCs and smartphones. Using UNIX desktop environments similar to
Windows and Mac OSX, such as Gnome and KDE, Linux has made inroads in the desktop
computing market as well.
The Android operating system created by Google is based on the Linux operating system.
You can download open source versions of UNIX, including FreeBSD and Linux, without paying
for them. But because of the terms of the GPL, you usually cannot get support for such
distributions.
However, because of the wide user base, you can get support for open source versions of UNIX
by turning to the Web, where there is a wealth of documentation and user group expertise to
draw from. Alternatively, you can choose to buy commercial support from a company that
specializes in supporting open source UNIX.
Also, the flexibility to compile code for any processor doesn't guarantee that the software will be
compatible with other hardware in your system, such as a particular brand of graphics card, a
printer, or network router. However, if you search the Internet, you'll often find there's a driver
project underway by others who have encountered the same difficulty.
Question
Match the feature of each type of UNIX to its distribution method.

Options may be used more than once.
258

Options:
A. Is supported by the vendor
B. Adheres to established standards
C. Is free of charge
D. Its code can be modified by any user
E. Can limit you to using hardware from a single vendor
F. May be incompatible with hardware components in your system
Targets:
1. Commercial UNIX
2. Open source UNIX
Answer
Commercial UNIX is usually well supported by the vendor of the brand you use. It also adheres to
established standards, however it may limit your upgrade options and lock you into using specific
hardware.
Open source UNIX is distributed free under the terms of the GPL. Its code is freely modifiable by
anyone who wants to. One of its limitations is that certain hardware components in your computer
system may not be supported in the free versions of UNIX.
Correct answer(s):
Target 1 = Option A, Option B, Option E
Target 2 = Option C, Option D, Option F
Some of the most famous and widely used brands of UNIX include Oracle's Solaris and Hewlett-
Packard's HP-UX.
Solaris is a binary-compatible operating system, which means that Oracle has gone to some
lengths to ensure that their version of UNIX will run on all its hardware. Solaris also features
integrated Java support, although Java can be downloaded for any UNIX distribution.
Oracle makes UNIX for Intel hardware as well as their own proprietary hardware.
By comparison, HP manufactures multiple versions of its operating system, each fine-tuned for a
specific purpose. Hewlett-Packard's UNIX variants all support both RISC architecture and Intel's
Itanium architecture.
Other commercial UNIX variants include IBM's AIX and Silicon Graphics' IRIX system.
259

There are an increasingly large number of offshoots of open source UNIX. However, two
significant names are BSD and Linux.
BSD UNIX is one of the oldest forms of UNIX and pioneered such technologies as the TCP/IP
stack and virtual memory. It's widely in use across the Internet as a web server.
Linux is a port of the UNIX kernel to Intel x86 architecture and is one of the fastest growing and
most widespread versions of UNIX in use today.
In fact, some hardware vendors who traditionally developed proprietary UNIX systems offer the
choice of shipping their hardware with Linux installed. For example, even though IBM have their
own proprietary UNIX, they offer the option of shipping their xSeries servers with Linux pre-
installed.
Question
Match each brand of UNIX to its distribution type.

Options may be used more than once.
Options:
A. Solaris
B. HP-UX
C. Linux
D. FreeBSD
Targets:
1. Commercial UNIX
2. Open source UNIX
Answer
Commercial UNIX variants include Oracle's Solaris and Hewlett-Packard's HP-UX. Commercial
UNIXes usually offer good vendor support.
Open-source UNIX distributions include FreeBSD and Linux. These open source distributions are
usually free but there is no real vendor support available.
Correct answer(s):
Target 1 = Option A, Option B
Target 2 = Option C, Option D
260

Summary
Even though the Linux variants of the UNIX operating system are becoming popular as desktop
operating systems, the multi-user features of UNIX make it highly suitable for use in a server
environment. When used as a server, UNIX is very resistant to attacks by malicious code,
minimal maintenance is required by the system, and if a machine is compromised, the attacker
is limited to the user account they had access to, leaving them unable to damage critical system
resources.

UNIX comes in two main flavors commercial and open source. The strength of commercial
UNIX lies in its support and stability, while open source's strength lies in innovation and
portability. Well-known commercial UNIX variants include Oracle's Solaris and Hewlett-
Packard's HP-UX. Well-known open source UNIX variants include BSD and Linux.




















261

Choosing a UNIX Distribution
Learning Objective
After completing this topic, you should be able to
choose a UNIX distribution, given a scenario
Exercise overview
In this exercise, you are required to answer questions relating to UNIX distribution methods.
Choosing a UNIX distribution
You can choose from many different variants of UNIX depending on your needs.
Question
Match each feature of a UNIX distribution to its distribution type.
Options:
A. It has full vendor support
B. It is optimized for the hardware it will run on
C. It limits your upgrade options
D. It is usually distributed free under the GPL
E. It can be modified and re-distributed
F. It may not be compatible with some hardware components in your computer
Targets:
1. Commercial UNIX
2. Open source UNIX
Answer
Commercial UNIX is normally fully supported by the vendor and it is designed to work with the
specific hardware it will run on. However, upgrade options are limited because you are committed to
specific hardware.
Open source UNIX is usually available for free under the terms of the GPL. It can be freely modified
and distributed, however certain hardware components may not function with all variants of open
source UNIX.
262

Correct answer(s):
Target 1 = Option A, Option B, Option C
Target 2 = Option D, Option E, Option F
Question
Match each UNIX variant to its distribution method.

Options may be re-used.
Options:
A. Solaris
B. HP-UX
C. FreeBSD
D. Linux
E. AIX
Targets:
1. Open source
2. Commercial
Answer
FreeBSD and Linux are open source distributions of Linux.
Solaris, HP-UX, and AIX are all commercial distributions of UNIX.
Correct answer(s):
Target 1 = Option C, Option D
Target 2 = Option A, Option B, Option E
Question
What are the benefits of using a commercial distribution of UNIX instead of an open source
distribution?
Options:
1. It is supported by the vendor
263

2. It is optimized for the hardware in your computer system
3. It is available for free
4. It can be freely modified and distributed by anybody
Answer
Option 1: Correct. Commercial distributions of UNIX are well supported by the vendor. Open source
UNIXes are not generally supported officially.
Option 2: Correct. A commercial UNIX distribution is normally optimized for the hardware it will run
on. This ensures that all hardware components in the computer will work with the operating system.
Option 3: Incorrect. Commercial distributions of UNIX have to be purchased from a vendor. Open
source distributions are available for free.
Option 4: Incorrect. Commercial distributions are created and licensed by software vendors,
therefore they can't be redistributed as open source UNIX.
Correct answer(s):
1. It is supported by the vendor
2. It is optimized for the hardware in your computer system
Question
Which variants of UNIX are commercial distributions?
Options:
1. FreeBSD
2. Linux
3. HP-UX
4. Solaris
5. AIX
Answer
Option 1: Incorrect. FreeBSD is an open source distribution of UNIX. Open source UNIX can be
modified by any user.
Option 2: Incorrect. Linux is an open source version of UNIX. Open source Unix can be freely
distributed.
264

Option 3: Correct. HP-UX is a commercial distribution of UNIX. Commercial distributions usually
have full vendor support.
Option 4: Correct. Solaris is a commercial distribution of UNIX. Commercial distributions are
normally very stable.
Option 5: Correct. AIX is a commercial distribution of UNIX. Commercial distributions adhere to
established standards.
Correct answer(s):
3. HP-UX
4. Solaris
5. AIX
Question
You have purchased a new computer but don't want to pay for a proprietary operating system.

Select the variant of open source UNIX that is suited to being a desktop OS.
Options:
1. Linux
2. AIX
3. Solaris
Answer
Option 1: Correct. Linux is growing in popularity as a desktop operating system. It is free to use and
distribute.
Option 2: Incorrect. AIX is not suitable as standalone desktop operating system.
Option 3: Incorrect. Solaris is an example of a commercial UNIX operating system.
Correct answer(s):
1. Linux
Question
What are the benefits of using an open source distribution of UNIX instead of a commercial
distribution?
265

Options:
1. It is usually free
2. It will always be compatible with all hardware components
3. It can be modified to suit your requirements
4. It comes with support from the vendor
Answer
Option 1: Correct. Open source distributions of UNIX are usually free to download and are
distributed under the terms of the GPL.
Option 2: Incorrect. Because open source UNIX is not standardized, there may be situations in
which certain hardware components may not function as expected.
Option 3: Correct. Open source UNIX can be customized to suit your requirements. However you
can't charge for any improvements that you make.
Option 4: Incorrect. Open source UNIX is not typically not supported by any vendor, unless you
purchase their hardware and take out a support contract.
Correct answer(s):
1. It is usually free
3. It can be modified to suit your requirements
You should now be able to choose a version of UNIX to suit your requirements.











266

UNIX Implementations
Learning Objectives
After completing this topic, you should be able to
distinguish between UNIX implementations in network environments
describe UNIX's implementation on standalone computers
1. UNIX network implementation
Various UNIX operating systems are in use on a wide range of computers, including tablets and
smartphones, home PCs and high-end network and Internet servers.
UNIX is well suited to network environments because networking has been an integral aspect of
UNIX throughout its development. UNIX was developed during a time where computers were
large decentralized systems. This approach to systems is found in UNIX, which makes it a good
platform on which to build distributed network systems.
Unix is widely used in academic and institutional networks as well as in the corporate world.
UNIX servers are often used to provide infrastructure and services on networks and the Internet.
For example, they can provide services such as the domain name system, or DNS, and
Dynamic Host Configuration Protocol, or DHCP. They can be used as routers, file servers, and
FTP servers.
The Internet is a particularly common area of application for UNIX computers. The majority of
the world's web servers run on some variant of UNIX, including those that power Yahoo's search
engine and Apache's official web site.
There are many ways of deploying UNIX networks, depending on how centralized the network is
and on what hardware its computers are running. The client-server structure of UNIX daemons
and services allows a group of computers to provide services to each other over a network. In a
small network, you could use a group of similar computers, each linked to all the others and
providing network services.
Drill Down Home Page
A typical UNIX network might consist of servers, X terminals, diskless clients, and Windows
clients.
267

Page 1 of 4: Servers
In larger networks it's more common to concentrate the services on a group of powerful server
computers that users access from less powerful workstations or terminals. This model
centralizes administration and shares resources, making it more efficient and economical.
For example, large user directories are often stored on a server. Users then mount these
directories from their workstations. This allows them to access the data easily even though it's
stored on the server. Therefore, their workstations don't need large amounts of hard disk space.
Page 2 of 4: Servers
Taking the concept further, users can log in to servers remotely. In such cases, they run
processes on the server using the server's CPU. This centralization of processing makes it
easier to administer processing load and reduces the need for fast processors on users'
workstations.
Page 3 of 4: Servers
You can access UNIX servers and workstations directly using a console or terminal. This is the
simplest way of accessing UNIX and requires only a keyboard and monitor. Consoles provide a
text-only command-line interface to accept and parse input.
Page 4 of 4: Servers
If your requirements include graphical interfaces, you can install the X Window System on
servers and workstations. You can install more fully featured graphical desktop environments
over the X Window System.
Page 1 of 2: X terminals
If you are running UNIX on a central high-spec computer and connecting to it from a group of
less powerful terminals as is the case with mainframe systems you can install the X Window
System on the terminals.
This allows the terminals to access the central computer and run applications on it. It provides
terminal users with a graphical interface they can use to interact with these applications.
Page 2 of 2: X terminals
Because X terminals don't need to run any applications apart from the basic UNIX operating
system, the X Window System, and basic utilities, they don't need to have large amounts of
memory and hard disk space.
268

Therefore, they're a good way of reusing obsolete PCs. For example, a computer with a 486
processor, 16 MB of memory, and 200 MB of disk space would be an adequate X terminal.
Page 1 of 2: Diskless clients
Taking the terminal concept still further, you can implement technology that allows terminals to
boot from a server over the network. In these deployments, the UNIX operating system and the
X Window System download into the client's RAM from a network server.
The client doesn't need to have a disk and can consist of a basic processor and motherboard
with a network card and a small amount of memory. The network card needs to support the Boot
Protocol, also known as BOOTP, and DHCP so that the client can obtain an IP address from the
boot server.
Page 2 of 2: Diskless clients
This solution is the most centralized, and the least expensive, of the UNIX deployment options.
However, server hardware needs to be able to cope with the processing load of all the diskless
clients at the same time.
Page 1 of 1: Windows clients
The computers accessing a central UNIX computer don't necessarily need to run UNIX
themselves. It's possible for users on Windows computers to connect to UNIX computers using
a Telnet session. They can then execute UNIX commands and programs in a command-line
environment.

This is especially useful in mixed deployments where users are working on Windows computers
but they occasionally need to access UNIX servers that are performing essential network
functions.
Question
Match each UNIX implementation example to its associated computer type.
Options:
A. UNIX network services are typically hosted on this computer
B. This computer boots from a local disk, and runs applications from the server
C. This computer boots off the server using BOOTP
D. This computer uses a proprietary operating system
Targets:
1. Server
269

2. X terminal
3. Diskless client
4. Windows client
Answer
You can host core services on a UNIX server, and users can access them from their workstations.
You can also manage a server remotely using an X terminal computer.
You can reduce client requirements by having their operating systems boot off a server.
You can connect UNIX servers to clients running proprietary operating systems, such as Windows.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
You can test your network connection to a particular UNIX system using the ping command in
the command line interface. You can specify the destination using an IP address or URL and
then press Enter.
Code
# ping Computer023.domain1.easynomadtravel.com
Packets are sent to the destination. You can press Ctrl+C to stop sending packets and to show
the summary data.
Code
# ping Computer023.domain1.easynomadtravel.com
PING Computer023.domain1.easynomadtravel.com (190.100.20.4): 56 data
bytes
64 bytes from 190.100.20.4: icmp_seq=0 ttl=128 time=0.983 ms
64 bytes from 190.100.20.4: icmp_seq=1 ttl=128 time=0.400 ms
64 bytes from 190.100.20.4: icmp_seq=2 ttl=128 time=0.870 ms
--- Computer023.domain1.easynomadtravel.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
270

round-trip min/avg/max/std-dev = 0.400/0.751/0.983/0.252 ms
#
The round trip time in milliseconds for each packet shows the speed at which the connection is
performing. You can also check how many packets were lost. A 0.0% packet loss shows that
the network is performing adequately.
Code
# ping Computer023.domain1.easynomadtravel.com
PING Computer023.domain1.easynomadtravel.com (190.100.20.4): 56 data
bytes
64 bytes from 190.100.20.4: icmp_seq=0 ttl=128 time=0.983 ms
64 bytes from 190.100.20.4: icmp_seq=1 ttl=128 time=0.400 ms
64 bytes from 190.100.20.4: icmp_seq=2 ttl=128 time=0.870 ms
--- Computer023.domain1.easynomadtravel.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.400/0.751/0.983/0.252 ms
#
2. Standalone UNIX implementation
Although networking is one of the main strengths of the UNIX operating system, you can also
use UNIX systems as standalone computers.
However, you need to host the entire system on the single computer rather than separating
parts of the system across a number of computers. This means you need to install larger
implementations of UNIX that provide full user functionality.
For example, you could set up UNIX on a home PC and use it in much the same way as a home
PC running Windows. For example, you can use it to watch local videos and listen to sound
files, watch media streamed from the Internet, as well as occasionally surf the Internet and
check e-mail messages.
Some flavors of UNIX are better suited to this functionality than others, with Linux being
particularly popular.
The requirements of home users tend to differ from those of academics and IT administrators
home users usually require more graphical interaction and user-friendly tools and applications.
To provide a more attractive and comfortable feel for the user, several GUIs have been created
for UNIX. These include desktop environments, graphical configuration tools, and applications
for work and entertainment similar to those found in Mac OS and Windows environments.
271

The most popular UNIX GUIs are the Common Desktop Environment, or CDE, Gnome, and the
K Desktop Environment, or KDE.
Because these GUI environments require processor and memory resources in order to run
smoothly, you should avoid installing them on computers that also perform a server role. These
computers may need to dedicate maximum processing power to the services they provide.
Question
What are some of the features of a UNIX implementation on a standalone computer?
Options:
1. Graphical user interface
2. User friendly applications
3. Provides DNS
4. Computers do not need large hard disks
Answer
Option 1: Correct. Standalone UNIX computers often use a GUI for home users.
Option 2: Correct. The GUI provides applications that are more user-friendly than a console
interface.
Option 3: Incorrect. UNIX implementation on a network of computers can include a computer that
provides Domain Name Services, or DNS.
Option 4: Incorrect. Standalone computers need larger hard disks than networked computers to
host the OS, GUI and applications.
Correct answer(s):
1. Graphical user interface
2. User friendly applications
Summary
UNIX systems are frequently used to provide infrastructure and services on networks. They are
in widespread use as web servers. You can deploy UNIX networks with differing degrees of
centralization. Small networks don't need much centralization, but in larger networks users
usually access a few powerful servers from less powerful workstations. The servers provide
centralized storage and processing. X terminals and diskless clients allow further centralization,
with most of their processing and resources located on the server.
272


Standalone UNIX deployments especially of Linux are useful for home users. UNIX GUIs
such as Gnome and KDE provide the user-friendly graphical environment that has become
popular for end-user interaction.


























273

The Basics of Using UNIX
Learning Objective
After completing this topic, you should be able to
perform the basics of using a UNIX system
1. From command line to GUI
When video terminals were first developed, they replaced hard-copy terminals that accepted
input from a typewriter-like keyboard and printed output onto paper one line at a time. Like
monitors, terminals displayed input as well as output, acting as the interface between the user
and the processor.
Like hard-copy terminals, video terminals process input commands one line at a time. Already
processed input and output scrolls upward, and users can enter further commands at the
command prompt.
This type of interface is known as a command-line interface, or CLI. It's also known as the
command-line shell and is still used on UNIX terminals and in UNIX consoles, which emulate a
terminal interface.
The traditional UNIX CLI is limited compared to graphic user interfaces, or GUIs, in that it can't
show graphic output or accept mouse input. Instead, it relies on typed commands and
combinations of keystrokes.
The commands and keystrokes that UNIX uses are often cryptic abbreviations. For this reason,
it takes practice to learn how to use the operating system effectively.
However, an experienced user only needs a few keystrokes to complete tasks that would take
much longer in a graphical user environment.
The simplicity of the CLI also means that its resource requirements are very low. For example,
you can run several command-line sessions on a busy server without taking up much memory
or processing time.
As they became more widespread, the need grew for computers to become easier to use
because the people using them were no longer trained IT professionals. As a result, it became
necessary to create graphical user interfaces, or GUIs, which were more user-friendly and
easier to learn than the command-line interface.
Developed at MIT in the late 1980s, the X Window System was the first UNIX GUI. It's a basic
GUI that allows users to run processes in separate windows and to multitask between them.
This means you can initiate a process in one window and then perform a different task in a
different window while the first task is executing.
274

Each window is still essentially a command-line interface, but the X Window System allows you
to monitor and interact with several such interfaces simultaneously. In effect the graphical user
interface is itself simply an interface between the command line and the user.
The X Window System provides the basic functionality that allows users to view processes
graphically and use a mouse for input.
But, on its own, it doesn't provide any menus, buttons, icons, or toolbars. Its focus is on making
processing power available to a number of users in a networked time-sharing setup.
Several more complex and user-friendly desktop environments were developed during the
1990s. They consisted of tools and interfaces with a standardized look and feel. However, they
all still relied on the X Window System to provide the underlying graphical system.
The most common UNIX desktop GUIs are Gnome and K Desktop Environment, or KDE.
Gnome
The Gnome desktop began as a simple but effective tool for managing multiple processes in a
graphical environment and today offers a desktop environment similar to Windows in functionality
while requiring less system resources than other UNIX GUIs like KDE. It provides a graphical
desktop with clickable icons and a control panel from which menus and applications can be
launched.
KDE
The KDE desktop is a visually rich GUI that provides an interface similar to Microsoft Windows. It
also provides a graphical desktop with clickable icons and a control panel from which menus and
applications can be launched.
Question
What are the advantages of CLIs over GUIs?
Options:
1. A CLI can be quicker to use than a GUI
2. A CLI caters to inexperienced users better than GUIs
3. A CLI incorporates graphics and widgets
4. A CLI uses fewer resources than a GUI
Answer
Option 1: Correct. For an experienced user who is familiar with the various keystroke combinations,
using a CLI is quicker than making multiple point-and-click gestures within a graphical user
275

interface. Indeed, many experienced users prefer the control and freedom afforded by CLIs over
GUIs.
Option 2: Incorrect. GUIs were developed to cater to users who didn't want to learn a plethora of
keyboard commands and arcane syntax. Unskilled users find it more intuitive to use the menus,
buttons, and drop-down option lists presented to them by modern GUIs.
Option 3: Incorrect. CLIs don't use graphics. This means the screen is not cluttered with imagery
and allows you to focus on the current command line. Each time you press Return, a previous
command vanishes off the top of the screen.
Option 4: Correct. Graphics are notoriously heavy on processor and memory resources. Because
CLIs don't employ graphics, there is a very low memory overhead all commands are in textual
format which can easily be processed by a server.
Correct answer(s):
1. A CLI can be quicker to use than a GUI
4. A CLI uses fewer resources than a GUI
2. The X Window System
The X Window System, also called X11, is a program that performs the basic functions of a GUI.
It translates information between the operating system and the user environment.
Although you can use the X Window System on a free-standing computer, it was designed for
use on networks. It uses a client-server model to allow multiple users to remotely access
applications.
In a networked environment, the X system is divided into servers and clients. However, both
roles can be hosted on a single computer. In this sense, a client is a requesting application and
a server is the responding application.
An X client accepts instructions from an application about how to display output graphically and
it sends feedback to a server application about user input such as mouse clicks or keystrokes.
An X client runs applications that send their input to an X server. The client application then
receives feedback from the X server.
A network running the X Window System requires a powerful computer to run X server
applications as well as act as its own X client. Less powerful workstations can access these
applications but they need to be set up as X clients.
To use the X Window System, you need to run an X client process on your terminal or
workstation. The computer that runs the applications you are accessing whether it's the local
client computer or a remote computer needs to run an X server process.
276

Question
Which functions does the X Window System provide?
Options:
1. Standardized desktop controls
2. Standardized window behavior
3. Translation between applications and the graphical user environment
4. Translation between the operating system and the graphical user environment
Answer
Option 1: Incorrect. To use standard desktop controls, such as buttons and menus, you must install
one of the many available UNIX GUIs, such as Gnome or KDE, over your X Window installation.
Option 2: Incorrect. The X Window System itself is not concerned with graphical presentation. Each
X Window is little more than a CLI, and each group of X Windows interacts within itself. As a
developer, you can use standard APIs to control the look and feel of your X Windows.
Option 3: Correct. Keystrokes and commands are translated to actions on specific parts of an
application. The X client process need not be running on the same machine as the application. For
example, a networked client might run on a powerful mainframe.
Option 4: Correct. The server controls the display directly, and is responsible for all input/output via
the keyboard, mouse, or display. The clients, on the other hand, do not access the screen directly -
they communicate with the server, which handles all input and output.
Correct answer(s):
3. Translation between applications and the graphical user environment
4. Translation between the operating system and the graphical user environment
You use window managers to control the way windows look and behave. Window managers run
on top of the X Window System and interpret its display directions, superimposing their
graphical elements on the simple windows that X creates.
There are many window managers for the X Window System, including Blackbox, Sawfish, and
WindowMaker. Each window manager gives the X Window System a characteristic look and
feel.
The distinctions between the various window managers are demonstrated by their differing use
of focus policy. Some window managers require the user to click in a window in order to make it
active. Others move the focus to whichever window underlies the mouse pointer.
277

Note
Focus policy determines the way a GUI decides which of the open windows is currently active.
The elements of a UNIX GUI are called widgets. Buttons, icons, and drop-down lists are
examples of widgets.
Each window manager includes its own set of widgets, so that buttons and lists may appear
different and behave differently in different window managers.
Application developers can also give their application interface its own distinctive widget style.
However, using the existing libraries helps ensure a standard look-and-feel across the desktop.
Each window manager has its own methods of configuration. Some provide GUI tools for
configuration, whereas others require you to edit configuration files manually.
Complete UNIX desktop environments, such as Gnome and KDE, include their own window
managers. These control widgets and window behavior, and then superimpose window output
on the desktop background and controls.
3. Beginning to use UNIX
To start using a UNIX system, you need to log in with user credentials. This makes your files
available and ties your activities to your identity.
You can access a UNIX system using one of three methods:
local login
With local login, you access a UNIX computer directly. When you start the operating system, it
presents you with a login screen. Logging in initiates a command-line session.
client-server login, and
Client-server login is accessing a UNIX computer from another UNIX computer by mounting
shared file systems. You don't need to log in to the server that hosts the file systems, but you do
need to have appropriate permissions.
remote login
Remote login involves logging in to a UNIX from another computer using programs such as rlogin
and telnet. Once you connect to the UNIX system, it presents you with a login screen. After that,
the process is exactly the same as for a local login.
Whether you connect to a UNIX system directly or over a network, it presents you with a login
screen similar to this.
278

Code
FreeBSD/i386 (easynomad2.easynomad.com) (ttyp1)

login: gregl
You type your username at the login prompt on the second row of text, and then press Enter.
Graphic
You type gregl at the login prompt.
Question
Now complete the command required to log in using the jgold username.
Code
FreeBSD/i386 (easynomad2.easynomad.com) (ttyp1)

login: INSERT THE MISSING CODE
Answer
You enter jgold to log in using the jgold username.
Correct answer(s):
1. jgold
Next you are prompted to provide your password. On most systems, you won't see asterisks or
any other characters appearing as you type your password. Once you've typed your password,
you can press Enter.
Code
FreeBSD/i386 (easynomad2.easynomad.com) (ttyp1)

login: gregl
Password:
Question
Now complete the command required to log in using the word secret as the password.
279

Code
FreeBSD/i386 (easynomad2.easynomad.com) (ttyp1)

login: gregl
Password: INSERT THE MISSING CODE
Answer
You enter secret to log in using a password.
Correct answer(s):
1. secret
Assuming you entered your credentials correctly, the computer opens a command-line shell and
presents you with the shell prompt. This example shows the Bash shell.
Code
bash-2.05a$
You can now enter UNIX shell commands. The ls command displays the contents of the
current directory.
Code
bash-2.05a$ ls
The output of the ls -a command lists all the files and directories contained in the current
directory. The -a tag specifies that hidden files should also be listed.
Code
bash-2.05a$ ls -a
. .Xauthority .kderc
.. .bash_history .login
.DCOPserver__:0 .cshrc .login_conf
.DCOPserver___0 .gtkrc-kde .mail_aliases
.ICEauthority .kde .mailrc
bash-02.05a$
Question
280

Complete the command required to list all files in the current directory that are not hidden files.
Code
bash-2.05a$ INSERT THE MISSING CODE
Answer
You enter ls to list all files in the current directory that are not hidden.
Correct answer(s):
1. ls
The output for the ls command lists all the files that are not hidden in the current directory.
Code
bash-2.05a$ ls
EntryLog Permissions
Restricted Permitted
bash-02.05a$
The cat command lists the contents of a text file.
Code
bash-02.05a$ cat
So, to view the contents of the usernames file, you can type cat usernames.
Code
bash-02.05a$ cat usernames
Syntax
bash-02.05a$ cat argument
The resulting output shows the contents of the file.
Code
281

bash-02.05a$ cat usernames
danielb Daniel Baker
deboraw Debora Wade
gregl Greg Logan
nickn Nicholas Novak
samo Sam Oswald
tanyas Tanya Strother
bash-02.05a$
It's common when showing syntax for a command-line interface like the UNIX shell to use the
angled brackets to indicate the argument. For example, the cat name command consists of the
command cat and the argument name. This command will return the contents of the file called
name.
Code
bash-02.05a$ cat name
Syntax
bash-02.05a$ cat argument
The display goes to the screen by default, although you can redirect it to the printer. The
displayed version is read-only and you must manually pause and continue the output if the
contents exceed the screen size.
Question
Complete the command required to open the file named clients.
Code
bash-02.05a$ INSERT THE MISSING CODE
Answer
You enter cat clients to open the file called clients.
Correct answer(s):
1. cat clients
When you're finished using a UNIX computer, you need to log off. This closes the session that
was opened using your username and password. If you don't log off, another user of the
computer might be able to use your credentials and access your files.
282

Code
bash-02.05a$
You can end the session using the keyword logout.
Code
bash-02.05a$ logout
Note
Alternatively, you can enter exit, logoff, or you can press Ctrl+D. This may vary depending on
the UNIX version used.
The display returns to the login prompt, allowing another user to log in.
Code
FreeBSD/i386 (easynomad2.easynomad.com) (ttyp1)

login:
Question
Complete the command required to log off this session.
Code
bash-02.05a$ INSERT THE MISSING CODE
Answer
You enter logout or exit to log off this session.
Correct answer(s):
1. logout
2. exit
3. logoff
283

Summary
The original UNIX user interface was a command-line interface used on terminals. This interface
is still useful, but it's now possible to access UNIX systems using the X Window System a
basic graphical user interface as well as more advanced desktop GUIs such as Gnome and
KDE.

The X Window System translates information between the operating system and a graphical
interface. It uses a client-server model. X servers interpret display information sent to them by X
clients, and they return user input information to the X clients. Window managers control the
appearance and behavior of the windows created by the X Window System.

Whether you connect to a UNIX system locally or remotely, you need to log in by entering your
username and password. This opens a command-line shell in which you can execute shell
commands.


















284

Getting Started with a UNIX System
Learning Objectives
After completing this topic, you should be able to
log into a UNIX system
perform basic UNIX file tasks
log out of a UNIX system
Exercise overview
In this exercise, you need to use the basic UNIX functions.
This involves the following tasks:
logging on
finding and opening a file, and
logging off
Logging on
Question
Complete the command required to log in using noneill as the username.
Code
FreeBSD/i386 <easynamad2.easynomad.com> <ttyp1>

Login: INSERT THE MISSING CODE
Answer
To start the logon process, you enter noneill.
Correct answer(s):
1. noneill
Question
Complete the logon process by entering N O'Neill's password, which is token.
285

Code
FreeBSD/i386 <easynamad2.easynomad.com> <ttyp1>

Login: noneill
Password: INSERT THE MISSING CODE
Answer
To complete the logon process, you enter token.
Correct answer(s):
1. token
Finding and opening a file
Question
You are looking for a particular file called suppliers. Complete the command required to show all
the files in the current directory.
Code
FreeBSD/i386 <easynamad2.easynomad.com> <ttyp1>

Login: noneill
Password:

bash-2.05a$ INSERT THE MISSING CODE
Answer
You enter ls to list all the files in the current directory.
Correct answer(s):
1. ls
Question
You have found the suppliers file. Now complete the command required to open it.
Code
FreeBSD/i386 <easynamad2.easynomad.com> <ttyp1>

286

Login: noneill
Password:

bash-2.05a$ ls
customers suppliers employees
bash-2.05a$ INSERT THE MISSING CODE
Answer
You enter cat suppliers to open the file.
Correct answer(s):
1. cat suppliers
Logging off
Question
Having examined the suppliers file, you have finished working with the UNIX system and you now
want to end your session. Complete the command required to do this.
Code
bash-2.05a$ cat suppliers
Ayana Boyd
472 Barcel Court
Northglenn, CO 80233
Tel: 303-555-8173
Fax: 303-555-8194
Grace Bergman
7863 Scarsdale Heights Freeway
St. Petersburg, FL 3370
Tel: 813-555-8214
Fax: 813-555-8254
Nick Burns
682 Nashby St South
Atlanta, GA 39903
Tel: 404-555-3729
Fax: 404-555-3731
Zack Jacobs
405 Oakwood Parkway
Boise, ID 83799-3210
Tel: 208-555-8465
Fax: 208-555-8466
bash-2.05a$ INSERT THE MISSING CODE
287

Answer
You enter logout, exit, or logoff to end the UNIX session.
Correct answer(s):
1. logoff
2. exit
3. logout
When you log out, the system returns to the logon screen.
Code
FreeBSD/i386 <easynamad2.easynomad.com> <ttyp1>

Login:
A UNIX system has been logged on to, a file found and opened, and the user has been logged
off of the system.















288

Understanding UNIX Shell Scripts
Learning Objectives
After completing this topic, you should be able to
recognize examples of how the UNIX shell processes using expansion and substitution
group commands on a command line
recognize how commands are stored in scripts
1. How the UNIX shell processes
The UNIX shell is a command-line interpreter that processes each command or combination of
commands on a command line when you press Enter.
You can combine multiple commands on the same command line by creating a composite
command.
You can use a number of special characters in the command line. A semicolon, for example,
allows you to place more than one command statement in the same command line. The shell
executes a command preceding a semicolon only when it reaches the semicolon. This doesn't
mean that the command preceding a semicolon will complete before the command following the
semicolon, only that it will start first.
There are several special characters you can use to manipulate commands in the command
line:
backslash
greater than
Show >
less than
Show <
pipe, and
ampersand
The backslash character prevents the shell from treating the following character as a special
character through a process called backslash escaping.
Code
289

#$ echo Long pieces of text may not always fit onto a single \
> line of the command line interface, so it becomes \
> necessary to split them across multiple lines using \
> backslashes.
This allows you to split a command statement across multiple lines. When you insert the
backslash at the end of a line and then press Enter, you can continue the statement on the next
line. The backslash prevents the shell from treating the Enter keystroke or new line character
as a special character. For example, you might need to write an echo statement carried across
three lines.
Another example of special characters is the greater than character, which is used when you
need to send the output of the ls command to a file called userdirs.
Code
#$ ls -l /usr/home > userdirs
The greater than character allows you to direct the standard output of a command to a file or a
device such as a printer instead of to the terminal screen. For example, you may need to write a
command that will send the output of the ls command to a file called userdirs in order to store a
directory listing at a certain time.
The less than character allows you to send the contents of a file to a command as its standard
input. For example, you need to send input from a file called list to the sort command.
Code
#$ sort -d < list
The pipe character allows you to direct the output of one command to the input of another
command. For example, you can pipe the output from the cat command as input to the grep
command for further processing.
Code
#$ cat EasyNomad | grep 'South America'
An ampersand character at the end of a command statement allows you to run commands in the
background. For example, you can use the find command to run a long search process in the
background.
Code
290

#$ find 'EasyNomad' &
[1] 48748
$ EasyNomad
If you want to use special characters in command-line text without the shell recognizing them as
special characters, you have to enclose them in quotes or precede them with a backslash.
Code
#$ echo Tours \& Accommodation
Tours & Accommodation
$
For example, you can use an echo command in which the echo text contains an ampersand.
The backslash in front of the ampersand prevents the shell from treating it as a special
character.
Code
#$ echo Tours "& Accommodation
Tours & Accommodation"
$
When you execute a command line, the shell looks for spaces and special characters and splits
the command line into segments wherever these characters occur. It then processes each
segment in sequence.
Code
$ find 'EasyNomad' &

$
find
'EasyNomad'
&
The segments into which the shell divides a command line are called tokens. To execute a
command line, the shell processes the first token and then each subsequent token in sequence.

To begin processing a token, the shell checks whether it's a keyword, an alias, or an ordinary
word.
If the token is a keyword that opens a substructure such as a function, conditional statement, or
bracketed group of commands, the shell processes the substructure before moving on to the
next token.
291

Code
$ find 'EasyNomad' &

$
find
'EasyNomad'
&
If a token is an alias, the shell replaces it with the command to which the alias is mapped.
If a token is an ordinary word, such as a command or a filename, the shell processes it directly.
After comparing a token against the list of known keywords and aliases, the shell processes it
using several stages of expansion and substitution.
Expansion and substitution takes place in the following sequence:
brace expansion
In brace expansion, the shell looks for braces or curly brackets in the token. If braces are
present, it expands their contents.

For example, this token expands into ball book.
The token is show b{all,ook}.
tilde expansion
In tilde expansion, the shell looks for tildes in the token. If a tilde is present, it replaces the tilde
with the location of the current user's home directory.

For example, depending on the system configuration, this token might expand into
/usr/home/vincep/file2.
The token is ~vincep/file2.
parameter substitution
In parameter substitution, the shell checks whether the token is a variable, that is, preceded by a
dollar sign. If it is, the shell replaces the token with the current value of the corresponding
variable.

For example, if the value of the variable SHELL is /bin/ksh, this token is replaced with /bin/ksh.
The token is $SHELL.
command substitution
In command substitution, the shell checks whether the token is a command enclosed in brackets
and preceded by a dollar sign. If it is, the shell processes the command and replaces the token
with the command's output.

292

For example, this token might be replaced with vincep.
The token is $(type username).
arithmetic substitution
In arithmetic substitution, the shell checks whether the token is an arithmetic expression enclosed
in double brackets and preceded by a dollar sign. If it is, the shell evaluates the expression and
replaces the token with the result.

For example, the shell replaces this token with the result of dividing 72 by 9, which is 8.
The token is $((72/9)).
word splitting, and
In word splitting, the shell examines those parts of the command line that have resulted from
previous stages of expansion and substitution. If any of these contain spaces or special
characters, it splits them into tokens for processing.
pathname substitution
In pathname substitution, the shell looks for wildcard characters in the token. If it finds asterisks,
question marks, or double slashes, it searches the current directory for filenames that match
these wildcards and substitutes them for the token.

For example, depending on the files in the current directory, this token might expand into fares.txt
flights.txt funding.txt.
The token is f*.txt.
After performing expansion and substitution, the shell processes subsequent tokens until it
reaches the end of a command, denoted by a semicolon or a new line character.
Code
$ find 'EasyNomad' &

$
find
'EasyNomad'
&
Then it matches the command against its list of known functions, built-in commands, and
pathnames. Once the shell has identified which command it needs to execute, it executes the
command to produce output. It then moves on to the next command, processing its tokens in the
same way.
Question
Which character prevents the shell from treating another character as a special character?
293

Options:
1. Backslash ( \ )
2. Greater than ( > )
3. Less than ( < )
4. Pipe ( | )
Answer
Option 1: Correct. The backslash character allows you to split a command statement across
multiple lines.
Option 2: Incorrect. The greater than character allows you to direct the standard output of a
command to a file or a device.
Option 3: Incorrect. The less than character allows you to send the contents of a file to a command
as its standard input.
Option 4: Incorrect. The pipe character allows you to direct the output of one command to the input
of another command
Correct answer(s):
1. Backslash ( \ )
Question
Match each expansion and substitution method to an example of how it works.
Options:
A. Command substitution
B. parameter substitution
C. arithmetic substitution
D. word splitting
Targets:
1. The shell checks whether the token is a command enclosed in brackets and preceded by a dollar sign
2. The shell checks whether the token is a variable name preceded by a dollar sign
3. The shell checks whether the token is a mathematical expression enclosed in double brackets and
preceded by a dollar sign
4. The shell examines those parts of the command line that have resulted from previous stages of
expansion and substitution
294

Answer
If the token is a command enclosed in brackets and preceded by a dollar sign, the shell processes
the command and replaces the token with the command's output.
If the token is a variable name preceded by a dollar sign, the shell replaces the token with the
current value of the corresponding variable.
If the token is a mathematical expression enclosed in double brackets and preceded by a dollar
sign, the shell evaluates the expression and replaces the token with the result.
If any of these contain spaces or special characters, it splits them into tokens for processing.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
2. Grouping commands on a command line
You can join commands on a command line in such a way that the second command executes
only if the first command has executed successfully.

For example, you can use a command to check whether a file exists and then, if the file exists,
use a second command to perform an operation on it.
To make one command conditional on another, you join the commands using a double
ampersand. The command after the double ampersand executes only if the command before
the double ampersand produces a zero exit status in other words, if it executes successfully.
In this example, the ls command checks whether the userlist file exists. Because it does exist,
the ls command executes without errors, so its exit state is zero. This causes the sort
command to execute.
Code
#$ ls userlist && sort userlist
userlist
BAKER, Daniel
CARUSO, Maria
GARZA, Teresa
295

LOGAN, Greg
MANEROWSKI, Sarah
NOVAK, Nicholas
NOVIALLO, Glen
OSWALD, Sam
PASCUCCI, Vince
REILLY, Molly
STROTHER, Tanya
WADE, Debora$
If you delete the userlist file and run the command again, the ls command encounters an error
so its exit state is non-zero. Because the sort command is conditional on the ls command, the
shell doesn't attempt to execute it.
Code
#$ ls userlist && sort userlist
ls: userlist: No such file or directory
$
You use a double pipe to make a command conditional on the unsuccessful execution of the
previous command.
In such a case, the second command executes only if the first command has a non-zero exit
state.

In this example, the ls command looks for a file called userlist. If it fails to find the file, the
touch command creates it.
Code
#$ ls userlist || touch userlist
ls: userlist: No such file or directory
$
If the ls command executes successfully, this means the file already exists. In this case, the
touch command doesn't execute.
Code
#$ ls userlist || touch userlist
userlist
$
296

You can group commands using braces. The shell treats any command block enclosed in
braces as if it were a single command. This allows you to redirect input and output to and from a
group of commands. In this example, the braces group the sort and grep commands into a
command block so that the shell sorts input and then extracts any lines containing the word
"Mexico".
Code
#$ {sort | grep 'Mexico'}
You can redirect input and output to and from the command block as if it were a single
command. In this example, the code specifies the flights file as input and the mex_flights file as
output.
Code
#$ {sort | grep 'Mexico'} < flights > mex_flights
$
You can group commands using round brackets instead of braces. This causes the shell to
spawn a subshell and execute the command block in the subshell.
Code
#$ (sort | grep 'Mexico') < massivefile > mex_info
$
Commands that execute in a subshell don't affect what's happening in the main shell. This
allows you to define variables that exist only for the lifetime of the subshell, and to change the
working directory within the subshell without affecting the parent shell.
Code
#$ (sort | grep 'Mexico') < massivefile > mex_info
$
Question
Which character can you use to make one command conditional on another completing
successfully?
Options:
1. Double ampersand ( && )
297

2. Braces ( {} )
3. Double pipe ( || )
Answer
Option 1: Correct. Double ampersand allows you to run the command after the double ampersand
only if the command before the double ampersand runs successfully.
Option 2: Incorrect. Braces allow you to redirect input and output to and from a group of
commands.
Option 3: Incorrect. Double pipe works if the command before the double pipe fails.
Correct answer(s):
1. Double ampersand ( && )
Question
You want to create a file named hostname, containing the text easy1.easynomad.com. However,
you don't want to overwrite any existing file by that name.

Which line of code will enable you to do this?
Options:
1. cat hostname || echo easy1.easynomad.com > hostname
2. cat hostname && echo easy1.easynomad.com > hostname
3. cat hostname | echo easy1.easynomad.com > hostname
Answer
Option 1: Correct. You use the double pipe to make a command conditional on the unsuccessful
execution of a previous command.
Option 2: Incorrect. The && conditional execution symbol ensures that if the attempt to list the
hostname file succeeds, it will get overwritten.
Option 3: Incorrect. The I symbol pipes the output from one command into another command as
input.
Correct answer(s):
1. cat hostname || echo easy1.easynomad.com > hostname
298

3. Storing commands in scripts
Command grouping is useful for executing relatively short commands that you need to run only
once.
Code
$ echo Long pieces of text may not always fit onto a single \
> line of the command line interface, so it becomes \
> necessary to split them across multiple lines using \
> backslashes.
However, you may need to run larger commands that include several lines or to use the same
command many times. In such cases, it can be advantageous to store the command in a file.
You can store blocks of shell commands in shell scripts. The contents of shell scripts are stored
as ordinary ASCII text. Unlike ordinary ASCII text files, shell scripts contain commands, are
executable, and have an introductory line of code that defines them as scripts.
Code
#! /bin/sh

clear
rm /temp
You can read and edit ordinary text files, but you can't execute them. However, you need to be
able to execute shell scripts. Therefore, you have to assign executable permissions on script
files.
The first line in any shell script has to be a special line of code that specifies the particular shell
program in which the script must run. This is necessary because some commands run
differently in different shell programs.
The shell identifier at the beginning of a shell script consists of a hash followed by an
exclamation point commonly called a shebang and the absolute pathname of the shell
program.
Code
#! /bin/ksh
299

For example, you can create a script that tests whether the directory /usr/shared/tours exists. If
the directory doesn't exist, the script creates it. Then it creates a file called tourlist inside this
directory and returns a message.
Code
#! /bin/ksh
ls /usr/shared/tours || mkdir /usr/shared/tours
touch /usr/shared/tours/tourlist
echo tour directory and tourlist file created
Once you've created a script and made it executable, you can use it as many times as you like.
You can execute it directly from the command line or you can invoke it from inside other scripts.
Code
#! /bin/ksh
ls /usr/shared/tours || mkdir /usr/shared/tours
touch /usr/shared/tours/tourlist
echo tour directory and tourlist file created
Shell scripts are ASCII text files that need to have executable permissions set. The first line of a
shell script identifies the command interpreter. Since these scripts are simple ASCII text files,
you can easily create them in a text editor such as vi or Emacs.
Code
#! /bin/ksh
ls /usr/shared/tours || mkdir /usr/shared/tours
touch /usr/shared/tours/tourlist
echo tour directory and tourlist file created
They're interpreted by the command interpreter, so they don't contain binary code and aren't
compiled. For shell scripts to run, either one or more of the owner, group, or other executable
permissions must be set.
Code
#
The first line of a shell script consists of a hash symbol followed by an exclamation mark and the
absolute path to the command interpreter that will be used to execute the script.
Code
300

#!/bin/bash.
Question
Identify the statements that correctly describe shell scripts.
Options:
1. Shell scripts are ASCII text files
2. Shell scripts need to be compiled prior to execution
3. Shell scripts don't require executable permissions set
4. The first line of a shell script is used to identify the command interpreter
Answer
Option 1: Correct. Shell scripts are ASCII text files, which can be made using text editors.
Option 2: Incorrect. Shell scripts don't contain binary code and aren't compiled because they are
interpreted by the command interpreter.
Option 3: Incorrect. When shell scripts are executed, the various executable permissions must be
set.
Option 4: Correct. The first line of a shell script is made up of a hash symbol, an exclamation mark,
and the absolute path to the command interpreter. The command interpreter will be used to run the
script.
Correct answer(s):
1. Shell scripts are ASCII text files

4. The first line of a shell script is used to identify the command interpreter
Summary
You can use special characters to join commands on a single command line, to redirect input
and output, to run commands in the background, and to continue a command over multiple
lines. You can prevent the shell from recognizing a special character by preceding it with a
backslash. When you execute a command line, the shell splits it into tokens and processes each
token in turn.

You can group commands using braces or brackets, which cause the shell to treat the
commands as a single command. You can join two commands so that the second command will
execute only if the first command executes successfully or only if it executes unsuccessfully.
301


You can store blocks of commands in a text file called a shell script and make this file
executable. You can execute shell scripts directly from the command line and reuse them as
often as necessary.


























302

Choosing UNIX Shells
Learning Objective
After completing this topic, you should be able to
choose UNIX shells
1. The UNIX shell families
UNIX is a command-line based operating system and you use a shell interface to issue
commands to UNIX and Linux systems. When you enter a command, the system processes the
command and performs the task, and displays any results in the open shell.
There are different shell families you can use with UNIX and Linux systems, and different
distributions come standard with each shell. Each shell family offers the same basic functions,
but each has its own enhancements.
sh
The sh shell is the original UNIX shell and is also known as the Bourne shell after its creator
Steven Bourne. It enables basic shell scripting, which allows you to create a whole program built
from script commands. It comes standard with all UNIX distributions but lacks some of the
enhancements of the other shells. For example sh doesn't support a command history feature,
and is generally only used for basic commands.
csh
The csh shell - commonly called C Shell - was based on the syntax of the C programming
language and provides more support for shell-scripting development. It introduced the concepts
of aliases, job control, and the command history list, which you access by using the up and down
directional keys in an open shell. A common shortcoming is its incompatibility with scripts written
in the sh shell. It also doesn't handle long and complex shell scripts very well.
tcsh
The tcsh shell was developed from csh, but addressed some of its shortcomings. It allows you to
edit command lines and has a command history feature that allows you to access previously
written commands. Another feature that improves on csh is command-line completion. When you
enter a command, the shell can automatically complete the command. However, it doesn't
support scripts created using the original Bourne shell.
ksh
The ksh or the Korn shell named after its developer David Korn was developed by AT&T Bell
Laboratories. It was developed to combine the best of both sh and csh shells. It also includes
features for command history, job control, aliases, and command-line editing. It comes standard
on some UNIX distributions and is freely available for download under a Common Public License.
bash
303

The Bourne Again Shell or bash, is a new version of the sh shell and is part of the GNU project.
It's backwards compatible with sh shell and is an extension of ksh. It also includes some of the
functionality of the tcsh shell such as shell script programming. It's the default shell distributed
with Linux distributions and, in many UNIX distributions, you can open bash by running the sh
command.
There are a few less popular UNIX shells. The rc shell is similar to the sh shell but the syntax
has been simplified, and uses C-like control structures.

The pdksh shell is the public-domain version of the Korn shell, and zsh shell further extends the
bash shell and includes a spell checker.
You can check which shells are included in your UNIX distribution by checking the main pages
for a particular shell, or checking the list of shells included in /etc/shells. You can run this
command to display the contents of the file.
Code
# cat /etc/shells
/bin/sh
/bin/csh
/bin/ksh
#
Question
Match the shell families with their descriptions.
Options:
A. sh
B. csh
C. ksh
D. bash
Targets:
1. The original UNIX shell that allows basic shell scripting
2. Uses C syntax and introduced features such as job control and the command history list
3. Combines the best features of two earlier shells and includes functions to edit command lines and
access command history
4. Is part of the GNU project, and comes default for Linux distributions
Answer
304

The sh shell was the original UNIX shell and allowed basic UNIX scripting, but lacked the more
complex features of later shells.
The csh shell is built to use C syntax and introduced the job control and command history features.
The later tcsh version also allowed you to edit command lines.
The ksh shell was developed by David Korn and combines the best features of sh and csh. It
includes features for job control and aliases, and you can also view command history.
The bash shell is an updated version of the sh shell and is backwards compatible with it. It extends
the ksh shell and provides some of the tsh functionality.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
2. Choosing UNIX shells
Every account on a UNIX system can have its own default shell, which loads when you start the
computer and then allows you to log on to the system.
The name of the shell you use is stored in an environment variable named SHELL. You can use
this command to see which shell is installed for your account.
Code
# echo $SHELL
The system returns the name of the shell, which in this case, is the Korn shell or ksh.
Code
/bin/ksh
#
You can temporarily change your current shell by entering its name in the command line. So for
example, you can enter this command to temporarily change your shell to csh.
Code
305

# csh
You can change back to your default shell by entering exit in the command line, or pressing
the ctrl+d key combination. When you log out of your UNIX session, the original shell will also
be restored the next time you log in.
Code
# exit
You can find the full path name for your default shell by entering the which command. You can
also use this command to see the absolute path for other utilities or programs, by substituting
the shell name with the name of the utility or program name.
Code
# which ksh
In this case, the ksh shell is stored in the /bin/ directory.
Code
/bin/ksh
#
You use this absolute path when you want to change the default shell for your account. To do
this, you can use the chsh and the passwd commands available in UNIX.
You use the chsh command with the -s switch and specify the path to the default shell you
want to change to.
Code
# chsh -s /bin/csh
#
If you get an error message when using the chsh command, you can use the passwd
command instead. The passwd command is normally used to change your login password, but
when you add the -s switch, you can use it to change your default shell. You can also point the
command to the path location of the shell you want to use.
Code
306

# passwd -s /bin/csh
#
Question
You want to change your default shell from csh but first want to find out the full path name of the
shell. Complete the command that will perform this operation.
Code
# INSERT THE MISSING CODE csh
Answer
You use the which command followed by the name of the current shell, to find the full path name of
the shell.
Correct answer(s):
1. which
Question
You've found the shell to be located in the /bin/csh directory, and you want to change the default
shell to be ksh. Complete the command that performs this operation.
Code
# INSERT THE MISSING CODE
Answer
You use the chsh command with the -s switch and the full path name of the shell you want to use,
to change the default UNIX shell.
Correct answer(s):
1. chsh -s /bin/ksh
Question
The chsh command didn't work on your last attempt and you now want to try an alternative method
to change the default UNIX shell. Which other command can you use to change the default shell?
307

Code
# INSERT THE MISSING CODE
Options:
1. passwd -s /bin/ksh
2. passwd /bin/ksh
3. passwd -sh /bin/ksh
Answer
Option 1: Correct. You use the passwd command while using the -s switch, and specifying the full
path to the default shell you want to switch to.
Option 2: Incorrect. You add the -s switch to this command line to change the default UNIX shell
using the passwd command.
Option 3: Incorrect. The switch you use to change the default UNIX shell is -s.
Correct answer(s):
1. passwd -s /bin/ksh
Summary
You can use different shell families to enter commands in UNIX. Some of these shells support
complex scripting procedures using C syntax, while others are best used for simple operations.
Newer shells support command-line editing, job control, and enable you to view lists of
command history.

Each UNIX account can have separate shells to work with. Once logged in, you can temporarily
change the shell you're using, or you can make the change permanent. To make a permanent
change, you use the chsh or passwd commands.







308

Creating and Running an Executable File in UNIX
Learning Objectives
After completing this topic, you should be able to
create a shell script
run a shell script
1. Creating a shell script
UNIX shell scripts can be written in any text-based editor and then executed by the UNIX shell.
To create a shell script, you open a text file in a text editor such as vi, emacs, or pico.
For example, you decide to write a shell script for the Korn shell that automates the repetitive
task of creating a file and folder structure for a new travel package.
You open a new text file in vi and in this case, name it add_pkg_files. You need to invoke the
Korn shell at the start of the script and you use this command to do this.
Code
# /bin/ksh
The names you use for the new files and directories will depend on the names of the travel
packages. Therefore, the shell script needs to prompt the user to supply the package name,
read the name, and store it as a variable.
Code
# /bin/ksh
clear
echo "Please enter the name of the new travel package: "
read PNAME
You want to create a directory for the new package in /usr/shared, and create "bookings" and
"info" subdirectories in the package directory. To do this, you use a series of mkdir statements.
Code
ls /usr/shared/$PNAME || mkdir /usr/shared/$PNAME
cd /usr/shared/$PNAME
mkdir bookings
mkdir info
309

You also want to create three empty text files in the new folder hierarchy one for flights,
accommodation, and booking respectively.
You use a series of touch statements to create the empty text files.
Code
# /bin/ksh
clear
echo "Please enter the name of the new travel package: "
read PNAME
ls /usr/shared/$PNAME && mkdir /usr/shared/$PNAME
cd /usr/shared/$PNAME
mkdir bookings
mkdir info
touch /bookings/$PNAME_bookings
touch /info/$PNAME_accom
touch /info/$PNAME_flights
You also add a command to display a message to the user that confirms that the files and
folders have been created successfully.
Code
echo "Files and folders for $PNAME created in /usr/shared."
When you've saved and closed the text file containing your new script, you can confirm its
existence using this command.
Code
# ls -l
The results show the file exists but doesn't have execute permissions set, and can't be run as a
script command.
Code
# ls -l
total 2
-rw-r--r-- 1 vincep vincep 326 Aug 10 11:56 add_pkg_files
#
When you specify a set of permissions, you need to specify the permissions that apply to
310

the file's owner
users in the file owner's group, and
everyone else
You can specify permissions in either symbolic or numeric form. When you specify it in symbolic
form, you use the letters r, w, and x to denote read, write, and execute permissions,
respectively.
You use this command to make a script executable using symbolic form, and specify the +x
switch to add the execute permissions.
Code
# chmod +x add_pkg_files
#
This can also be done using the numeric form by specify permissions using a three-digit octal
code. The numbers from 0 to 7 represent increasingly open permissions, with 0 specifying no
access and 7 specifying read, write, and execute permissions.
Graphic
The table shown lists the numerical permission codes and its text equivalent. For octal digit 0, the
text equivalent is ---; for 1 the text equivalent is --x; for 2, the text equivalent is -w-; for 3, the text
equivalent is -wx; for 4, the text equivalent is r--; for 5, the text equivalent is r-x; for 6, the text
equivalent is rw-; and for 7, the text equivalent is rwx.
In the three-digit code, the first digit applies to the file's owner, the second to the owner's group,
and the third to all other users.

For example, you want to allow everyone to execute a script, but you don't want anyone else to
be able to write to the script.
You do this by specifying the script's permissions as 755.
Code
# chmod 755 add_pkg_files
#
Say you're a member of a group and you want other members of the group to be able to edit
your script. You don't, however, want general users to be able to use the script at all. In this
case, you can specify the script's permissions as 770.
311

Code
# chmod 770 add_pkg_files
#
You can run this command again to check the file permissions, and it reveals that the script file
is now executable.
Code
# ls -l
total 2
-rwxrwx--- 1 vincep vincep 326 Aug 10 11:56 add_pkg_files
#
Question Set
You're working for a temporary employment agency and the consultants create new files for each of
the new temp workers they recruit. You want to write a UNIX script that will automate the creation of
the directory structure and files.
Question 1 of 4
Question
You want the script to be executed using the Korn shell, and you want to load the shell in the first
line of code.

Select the option that does this.
Options:
1. #/bin/ksh
2. #/ksh
3. #/bin/korn
Answer
Option 1: Correct. You load the Korn shell using this command.
Option 2: Incorrect. You also need to specify the /bin/ directory that stores the ksh file.
Option 3: Incorrect. The correct usage to load the Korn shell is ksh.
312

Correct answer(s):
1. #/bin/ksh
Question 2 of 4
Question
At this stage the script reads the name of the worker from the screen, and then proceeds to check if
a directory by that name already exists.

If it doesn't, you should create a new directory of that name. Complete the code to create the
directory.
Code
# /bin/ksh
clear
echo "Please enter the name of the new worker: "
read WNAME
ls /usr/shared/$WNAME && INSERT THE MISSING CODE /usr/shared/$WNAME
Answer
You use the mkdir command to make a new directory.
Correct answer(s):
1. mkdir
Question 3 of 4
Question
The script makes the necessary directories and you now want to create the blank text files that will
store the information.

Select the command that performs this operation.
Code
# /bin/ksh
clear
echo "Please enter the name of the new worker: "
read WNAME
ls /usr/shared/$WNAME && mkdir /usr/shared/$WNAME
cd /usr/shared/$WNAME
313

mkdir info
mkdir skills
INSERT THE MISSING CODE /info/$WNAME_contact
Options:
1. touch
2. echo
3. ls
Answer
Option 1: Correct. You can use the touch command to create a new blank instance of the
specified file.
Option 2: Incorrect. You use the touch command to create a new blank file.
Option 3: Incorrect. You use the touch command to create a blank instance of a file.
Correct answer(s):
1. touch
Question 4 of 4
Question
You now want to use the chmod command to set the execute permissions of the new file. Complete
the command that provides full read, write, and execute access to the file owner, but restricts other
users to read and execute only.
Code
# chmod INSERT THE MISSING CODE add_worker_info
Options:
1. 755
2. 700
3. 775
Answer
Option 1: Correct. You use 7 to assign full permissions to the owner, and 5 to give read and
execute permissions only to other users.
314

Option 2: Incorrect. 700 assigns full permissions to the owner but prevents other users from using
the file at all.
Option 3: Incorrect. 775 gives full permissions to the owner and the group, and r and x
permissions to other users.
Correct answer(s):
1. 755
2. Running a shell script
You can execute a shell script by
Code
# ./add_pkg_files

# /bin/ksh add_pkg_files

# add_pkg_files
executing it directly
Executing a script directly is the simplest way to execute a script. You navigate to the directory in
which the script is stored and type its name at the shell prompt, preceded by ./. Instead of
navigating to the script's directory, you can also specify its full file path.

When you run this command, the shell spawns a child shell process, also called a subshell. The
script executes in the subshell, which returns you to the main shell once the script has finished
running. You can also run the script in the background by including the & character at the end of
the command. This allows you to use the main shell while the subshell executes the script.
The relevant code is # ./add_pkg_files.
invoking the shell, and
Invoking the shell to execute a script involves running an instance of the shell, and specifying the
path to the script as well as the script name. This allows you to specify shell options as part of the
command.

You can run the script by invoking the shell. To do this in the Korn shell, for example, you use this
command. As with direct execution, the script runs in a subshell.
The relevant code is # /bin/ksh add_pkg_files.
using your environment
Using your environment to execute a script requires that the script is located in a directory that's
found in the $PATH environmental variable. This allows you to execute the script by simply typing
315

its name, regardless of your current working directory.

If you've added your script directory to the $PATH statement in your .profile file, you don't need to
use ./ or the shell to run the script. In this case, you only need to type the name of the script.
This causes the script to run in a subshell.
The relevant code is:
# add_pkg_files
If you don't want to run the script in a subshell, you can precede it with the keyword source.
This causes the current main shell to run each command of the script in sequence.
Code
# source add_pkg_files
When you do this, you won't be able to do anything else with the main shell while the script is
executing. In some UNIX shells, the keyword source is replaced by a period.
Code
# . add_pkg_files
Question
You have logged in as gregl and navigated to /home/gregl/bin, which contains a shell script named
addfile.sh. You want to run the script in the current shell.

Which command should you use?
Code
# INSERT THE MISSING CODE
Options:
1. source addfile.sh
2. addfile.sh
3. ./addfile.sh
4. /bin/bash addfile.sh
Answer
Option 1: Correct. You use the source keyword to execute a script in the current shell.
316

Option 2: Incorrect. This method executes the script in a subshell, and you use it when the location
of the addfile.sh file is listed in the $PATH variable.
Option 3: Incorrect. The ./ syntax only allows you to execute the addfile.sh file in a subshell, and
you use it when the location of the file is not listed in the $PATH variable.
Option 4: Incorrect. This method launches a subshell in which the script is executed, and you can
use it if you need to set options for the subshell.
Correct answer(s):
1. source addfile.sh
You may not want to execute a script immediately and you can use shell commands to run a
script at a specified future time, at regular specified intervals, or whenever system load levels
are low.
You can use the at command to run a script at a specified future time. In this example, you
specify that the script must run at 6:00 p.m. on October, 12.
Code
# at 6pm Oct 12 add_pkg_files
You can also use a variety of formats, including keywords such as "noon" and "today".
You can use the cron command to run a script at regular intervals. You make an entry in the
/etc/crontab file, specifying the name of the script and the interval at which to run it.
For example, suppose you want to schedule a script to run Monday to Friday at 6:00 a.m. The
first two digits specify the minute and the hour of the day the script is to run. The next two
characters specify the day of the month and month, which in this case is the wildcard character.
This means that the script should be executed every day and month. You also specify the days
of the week on which the script is executed, which in this case is Monday to Friday or 1-5.
Finally, you add the path to the script.
Code
0 6 * * 1-5 add_pkg_files
You can then run the cron command, which starts a process that checks the /etc/crontabs file
each minute, and executes any jobs scheduled for the current minute.
Code
317

# cron
You can also use the batch command to run a script as soon as system load levels are low.
When you run a script this way, the shell queues it as a pending job until the system load
average falls below a specific amount. This amount varies depending on the UNIX system being
used.
Code
# batch add_pkg_files
Question
You have created a script and are evaluating the possible methods of executing it. Match these
commands to their descriptions.
Options:
A. at
B. batch
C. cron
Targets:
1. Runs scripts when system resource usage is low
2. Runs scripts at a specified time
3. Runs scripts at a specified interval
Answer
You run the batch command if you want to run scripts at times when they won't interfere with
system performance. It runs commands or scripts when system load levels drop below a specific
amount. The amount will vary according to your system.
You use the at command to run commands at a date and time you specify.
You use the cron command to specify the interval at which a command will repeat. It can be set to
recognize minutes, hours, days of the week, days of the month, or specific months.
Correct answer(s):
Target 1 = Option B
Target 2 = Option A
318

Target 3 = Option C
Question
You want to run the run_tasks script but you don't want it to run right away, but to execute at a
later stage.

Match the descriptions to the script examples.
Options:
A. Run this script when the system resource usage is low
B. Run this script after a specified interval
C. Run this script at a specified time
Targets:
1. batch run_tasks
2. place 0 6 * * 1-5 run_tasks in crontab file and then run cron
3. at now + 1 month run_task
4. ./run_tasks
Answer
You use the batch command when you want a scrip to run when more resources are available on
the system.
You open the crontab file and write a line of code that specifies when the task should be run. You
then run the cron command to open the file, which will execute the script at the specified time.
You use the at command to run a command at the time specified in the command.
When you run this command, the script will run right away in a new subshell.
Correct answer(s):
Target 1 = Option A
Target 2 = Option C
Target 3 = Option B
Target 4 =No Option Specified.
319

Summary
You can create a file script using UNIX text editors. You enter the commands in the file and if
these are specific to a particular shell, your first entry in the script will switch to the correct shell.
When you create a script. you might need to check and set the appropriate file permissions. You
can assign read, write, and execute permissions to the file owner, the group they belong to, and
all users. You can use symbolic or numeric methods to set these file permissions.

You can run a shell script by invoking it directly or through the shell. Both these processes
cause it to run in a subshell. Alternatively, you can run a script in the main shell using the
source keyword. If you include your script directory in the $PATH statement of the .profile file,
you can run a script simply by typing its name at the command prompt. You can also run a script
after a specified interval, script a schedule, or wait until the load on system resources is low.
















320


Choosing UNIX Shells and Running Scripts
Learning Objectives
After completing this topic, you should be able to
choose UNIX shells
create a shell script
run shell scripts
Exercise overview
In this exercise you're required to use the UNIX shell to switch between shells, and create and
run scripts.
This involves the following tasks:
choosing a default UNIX shell
creating a shell script, and
running a shell script
Choosing a default UNIX shell
You have set up a new UNIX system, which is using sh as the default shell. While you can
perform all basic tasks using sh, you want to switch the default shell to the bash shell.
Question
To change the default shell, you first need to find the full path name of the shell on the system. Type
the command that will return this value.
Code
# INSERT THE MISSING CODE
Answer
You use the which command and specify the sh shell as parameter to return the full path name.
Correct answer(s):
1. which sh
321

Question
The which command returns the value of /bin/sh, and you now want to change the default shell
to bash. Identify the command required to perform this operation.
Code
# INSERT THE MISSING CODE
Options:
1. chsh -s /bin/bash
2. chsh /bin/bash
3. chsh -s bash
Answer
Option 1: Correct. You use the chsh command along with the -s switch and the full path name to
change the default sell.
Option 2: Incorrect. You also include the -s parameter in the chsh command line to change the
shell.
Option 3: Incorrect. You specify the full path name, which is /bin/bash, to change the default
UNIX shell.
Correct answer(s):
1. chsh -s /bin/bash
Question
The chsh command returned an error and you now want to use an alternative method to change to
using the bash shell. Complete the command to perform this operation.
Code
# INSERT THE MISSING CODE
Answer
You use the passwd command along with the -s switch and specify the full path name, to perform
this operation.
Correct answer(s):
322

1. passwd -s /bin/bash
Creating a shell script
You work for a small retailer and the products buyer has asked you to create a UNIX script that
will read the name of a new product. The script should use this to create a basic file structure
that will contain product information, and some blank text files that will be used to store product
information.
Question
You want the script to run in the ksh shell. Complete the first line of the script that opens a ksh
subshell instance.
Code
# INSERT THE MISSING CODE
Answer
You open the Korn shell by using the ksh command in the /bin/ directory.
Correct answer(s):
1. /bin/ksh
Question
By now your script reads the product name and then checks if a directory for the product already
exists. Complete the command following the conditional operator that will create the directory if it's
not already present.
Code
# /bin/ksh
clear
echo "Please enter the product name: "
read PRODNAME
ls /home/products/$PRODNAME || INSERT THE MISSING CODE
Answer
You use the mkdir command followed by the directory path you want to be created.
Correct answer(s):
323

1. mkdir /home/products/$PRODNAME
Question
You now want to create a blank instance of a text file named description that can be used to
enter product information.

Complete the command to do so.
Code
# /bin/ksh
clear
echo "Please enter the product name: "
read PRODNAME
ls /home/products/$PRODNAME || mkdir /home/products/$PRODNAME
INSERT THE MISSING CODE /home/products/$PRODNAME/description
Answer
You use the touch command to create blank instances of files.
Correct answer(s):
1. touch
Question
You've named the shell script add_prod and after checking its access permissions, want to change it
so you're the only person that has write permissions on it. All other users should be able to read and
execute the script.

Type the command that will change the script's access permissions.
Code
# INSERT THE MISSING CODE
Answer
You use the chmod command with the 755 numerical indicator to change the script's access
permissions.
Correct answer(s):
1. chmod 755 add_prod
324

Running shell scripts
Question
You have created a shell script called quickscript, which you want to execute in the current shell.
Type the command that performs this operation.
Code
# INSERT THE MISSING CODE
Answer
You use the source command followed by the script name to run the script in the current shell.
Correct answer(s):
1. source quickscript
Question
You've written a script called check_script, which you want to run once at 1:00 p.m. on the August,
10. Type the command that will perform this operation.
Code
# INSERT THE MISSING CODE
Answer
You use the at keyword followed by the time, date, and the script name, to run the script at the
specified data and time.
Correct answer(s):
1. at 1PM Aug 10 check_script
Question
You've added some code to a file that represents a schedule when the specified script should run.
Enter the command that will read this file and execute the script according to the contents of the file.
Code
# INSERT THE MISSING CODE
325

Answer
You use the cron command that will read the crontab file to execute the commands listed within at
the specified time and date.
Correct answer(s):
1. cron
Question
You've created a script called update_db that will take up a large percentage of the system
resources when it runs.

You want the script to run when most of the resources become available. Type the command that
performs this operation.
Code
# INSERT THE MISSING CODE
Answer
You use the batch command followed by the script file to run a script when the system load drops
below a specific amount.
Correct answer(s):
1. batch update_db
A UNIX shell has been chosen and a script created. Scripts were also executed at different
intervals, in accordance with specific requirements.








326

UNIX Command Execution
Learning Objectives
After completing this topic, you should be able to
recognize how characters are used in commands
use conditional execution
group commands
1. Using the command line
In UNIX, shell programs provide an interface between users and the UNIX kernel, which is the
core of the operating system.
You interact with the kernel by entering commands at the shell prompt. When you need to enter
several commands at once, you separate the commands with a semicolon.
This command redirects the output of the ls command to a file called listing, and then uses
the cat command to display the contents of the file. These two commands are separated by a
semicolon and will run consecutively.
Code
# ls -l /home > listing ; cat listing
lrwxrwxrwx 1 root wheel 9 Oct 30 13:53 /home -> /usr/home
#
You can end a line of code with a backslash (\) to improve the readability of commands. When
you press Enter after a backslash, the prompt moves to a new line and allows you to continue
entering commands. You can continue to do this over multiple lines.
When you run the commands, the shell executes your code as if it were one long line, ignoring
the backslash characters.
Code
# echo This is a very long line of \
> text, wrapped with a backslash
This is a very long line of text, wrapped with a backslash
#
327

Most shell commands behave as filters and can take data as input, process it, and provide
output. Because of this behavior, you can chain commands together by piping the output of one
command into the input of another command.
You do this using the pipe character (|). For example, you can use this command to pipe the
output of ls as input to the less command.
Code
# ls -l | less
You can also run commands in the background. This is useful when you want to execute a
command that's likely to take a long time to complete.
Background commands use only idle CPU time, which gives priority to all other commands. You
use the ampersand character to run a command in the background. This code will run a script
called myscript.sh in the background.
Code
# ./myscript.sh &
[1] 34030
#
Question
Match each code sample with the effect the specified command-line character will have on the
execution of the code statements.
Options:
A. The semicolon in
# ls -l /usr > companyusers ; cat companyusers
B. The pipe in
# cd /home | ls -l userlist
C. The backslash in
# echo Please ensure\
> all backups are made\
> before COB
D. The forward slash in
# ls -l /usr/admin
Targets:
1. Separates the two statements
328

2. Chains commands together
3. Continues the command on the next line
4. Used to distinguish between folders
Answer
You can use a semicolon in a single command line to execute two or more commands on the same
line.
You use the pipe character to chain two or more commands together, so the result of the first
command is used as input for the second command.
You can use a backslash to write commands over two or more lines in the shell for readability. They
are executed as if written in one line.
You use the forward slash character to identify directories and subdirectories.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
2. Using conditional execution
Conditional execution means that actions are contingent on the outcome of an initial operation.
For example, you can create a shell script that checks the size of a log file and then backs it up
only if it's larger than a certain size.
Regardless of their type or function, most UNIX commands return an exit status number to the
shell when execution is complete. The exit status indicates whether the command executed
successfully.
When a command executes successfully, it returns a value of zero (0) to the shell. Any values
greater than zero indicate that an error of some sort has occurred.
Although exit statuses aren't displayed at the shell prompt, you can use them to include
conditional decisions in your shell scripts.
Most UNIX shells provide at least the following two pairs of operators for performing conditional
execution based on exit status values:
329

double pipe (||) and
When you separate two commands with two pipe characters, the second command executes only
if the first command returns a non-zero exit status. This indicates an error.
double ampersand (&&)
When you separate two commands with two ampersand characters, the second command
executes only if the first command returns a zero exit status. This indicates that the command
executed successfully with no error.
You can combine conditional execution operators to produce complex commands. In this
example, the second command executes only if the first command fails. And if the second
command fails, the third command won't run.
Syntax
command 1 || command 2 && command 3
Question
You want to create a command to check for the existence of a log file. If a file exists, the log file
should be copied to a backup directory. But if the copy operation fails, the system should send an e-
mail to the root user.

Type the operator you'd use to back up a log file if it exists.
Code
# ls -l /var/log/mylog INSERT THE MISSING CODE cp /var/log/mylog
/backup/mylog \
...
Answer
You use the && operator to run the cp /var/log/mylog /backup/mylog command if the ls
/var/log/mylog command locates a log file.
Correct answer(s):
1. &&
Question
If the copy operation fails, a notification is sent to the root user. Enter the conditional execution
operator you'd use to complete the code.
330

The code is:

# ls -l /var/log/mylog && cp /var/log/mylog /backup/mylog \
> MISSING CODE mail -s "Error" root
Answer
Correct answer(s):
1. ||
3. Using group commands
Conditional execution operations are based on the exit status value of a single command. This
means you can't have more than one command on either side of a conditional operator.
While this is sufficient for simple tasks, you might want to base conditional execution on the
result of a series of commands. You achieve this using grouping.
You can enclose a series of commands in brackets to create a code block, which allows you to
create far more complex commands and shell scripts.
The shell treats a command block as if it were a single command. It then returns one exit status
value for the entire block, rather than for each command the block contains.
You can group commands using two types of brackets:
parentheses, and
You can use parentheses to create blocks of code that execute in a subshell, which is a new shell
program spawned from the shell that you're running.
braces
You use braces to create blocks of code that execute in the current shell.
The advantage of running commands in a subshell, by grouping them using parentheses, is that
subshells have their own environment variables. As a result, any environment changes that take
place during the running of a code block don't affect the shell you started with.
Question
You want to group a number of commands into a command block. Which operators do you use to
do this?
Options:
331

1. Parentheses
2. Braces
3. Brackets
4. Semicolons
Answer
Option 1: Correct. Parentheses group commands into a code block that is executed in a subshell.
For instance, you can use this if you want to avoid altering environment variables in your current
shell.
Option 2: Correct. Braces group commands into a single code block for execution in the current
shell.
Option 3: Incorrect. Brackets are used by the shell in pattern matching operations to specify
character ranges.
Option 4: Incorrect. Semicolons are used to enter multiple commands on the same line. However,
the commands are executed in sequence, not as a code block.
Correct answer(s):
1. Parentheses
2. Braces
Question
You're in /home/gregl and you want to execute the command that looks for a specific log file. If
the file exists a message is displayed to reflect this.

In which working directory will the shell be when it has finished executing?
Code
# ( cd /var/log ; ls mylog ) /
&& echo "Found the log file."
Options:
1. /usr/home
2. /home/gregl
3. /var/log
Answer
332

Option 1: Incorrect. The /usr/home directory is not used in this code, so neither the current
working shell or the subshell will change to this directory.
Option 2: Correct. To change the working directory to /var/log you'd enclose the code block in
braces. Because this example uses parentheses, the command will be executed in a subshell and
the working directory will remain /home/gregl.
Option 3: Incorrect. The command that changes the directory to /var/logs runs in a subshell
because it's wrapped in parentheses. To run the code in the current shell and change the working
directory, you'd remove the parentheses from the command or use braces.
Correct answer(s):
2. /home/gregl
Question
Select the statement that accurately describes how the command is executed.
Code
# {cd /home ; rm filename} && ls
Options:
1. The code in braces executes as a separate process
2. The ls command will list the contents of the directory that was selected prior to running this code
3. The ls command will list the contents of the /home directory
Answer
Option 1: Incorrect. The command within braces is run in the current shell.
Option 2: Incorrect. Because it is run in the current shell, the command in braces will change to the
/home directory and the ls command will list its contents.
Option 3: Correct. The command will list the contents of the /home directory because the ls
command is executed in the current shell because braces have been used.
Correct answer(s):
3. The ls command will list the contents of the /home directory
333

Summary
The shell's command line provides an interface between users and the UNIX kernel. You can
separate commands using a semicolon, continue them on new lines using a backslash, and plug
them into each other using a pipe.

You can use conditional operators to specify that commands execute based on the exit status of
other commands. You use two ampersand characters to specify that a command should run
only if a previous command is successful. You use two pipe characters to specify that a
command should run only if a previous command failed to execute correctly.

You can group commands into code blocks to specify that the shell should return one exit status
for the entire block. You use braces to specify that code should execute in the current shell and
parentheses to specify that code should execute in a subshell.



















334

Redirection in UNIX
Learning Objectives
After completing this topic, you should be able to
use standard I/O redirection
perform file redirection
script with redirection
1. Using standard I/O redirection
Most UNIX commands behave as filters. This means they can take input, process it in some
way, and provide output. A UNIX shell usually sends this output to the screen, but you can
redirect it to provide advanced functionality.
A common example of redirection is the use of the pipe operator to plug the output of one
command directly into the input of another command. However, redirection most often involves
writing to and reading from files.
You can perform redirection with files by preceding a filename with operators:
greater than
You use the greater than operator with a filename to redirect the output of a command to a file. If
the file doesn't exist, the shell will create it. If it exists, the shell will overwrite it.
less than, or
You use the less than operator with a filename to redirect standard input from a file. For example,
when using the mail command to send e-mail, you can redirect input from a file you have
previously prepared, rather than having to type your message at the shell prompt.
two greater than symbols
You use two greater than symbols with a filename to redirect the output of a command to a file,
appending the new data if the file already exists. This is useful for creating log files.
If you use a lot of file redirection in your scripts, it's quite easy to overwrite existing files
accidentally. To prevent this, most shells implement the noclobber environment variable.
When set, noclobber prevents file overwriting through redirection but not through the
execution of commands such as cp or rm. You enable noclobber by entering this command.
Code
$ set -o noclobber
$
335

When you want to overwrite output files protected by noclobber, you can use the >| operator.
When you send a mail, as in this example, the shell reads the e-mail body from the text file
you've specified.
Code
$ mail s "Guess what" vincep@localhost < email.txt
In this case, the shell dumps the output of the man exec command to a text file. Because you've
redirected the output, you don't see it echoed to the screen.
Code
$ man exec > exec.txt
You can use redirection to document your system by redirecting the output from commands to a
file, which, in this example, records the network interfaces configured for a system.
Code
$ ifconfig a > network.txt
Several UNIX commands accept files as input. For instance, you can redirect a text file called
report.txt to the mail utility and send it to Fred.
Code
$ mail Fred < report.txt
Appending command output to an existing file is useful for troubleshooting. You should schedule
regular execution of this command to monitor which kernel modules are loaded on a Linux
system.
Code
$ lsmod >> /var/modules.log
Question
Match the redirection operators to the descriptions of their function.
Options:
336

A. >
B. <
C. >>
Targets:
1. Used to redirect output from a command to a file
2. Used to specify a file as input for a command
3. Used to append output from a command to a file
Answer
You use the greater than operator to redirect the output from a command to a file.
You use the less than operator to use a file as input for a command.
You use the double greater than operator to append the output from a command to an existing file.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Question
You want to send e-mail to a user called vincep. You've used the vi editor to type the body of the
e-mail, and you've saved it to a file called email.txt.

Complete the code to redirect input from the email.txt file rather than from standard input.
Code
$ mail s "Guess what" vincep@localhost INSERT THE MISSING
CODE email.txt
Answer
You use the < operator to redirect input from a file rather than from standard input.
Correct answer(s):
1. <
337

Question
You're using the man command to find out about the exec command. You'd like to dump the
information to a file so that you can print it later.

Complete the command required to dump the output of the command to a file called exec.txt.
Code
$ man exec INSERT THE MISSING CODE exec.txt
Answer
You use the > operator to redirect standard output to a file rather than to the screen.
Correct answer(s):
1. >
2. File descriptors
File descriptors are files usually with numeric filenames - on disk that point to input/output (I/O)
objects, such as the keyboard, the screen, or other files. You can think of them as placeholders.
By using file descriptors, processes don't have to interact mechanically with the I/O objects that
the descriptors represent the kernel handles these mechanics.
Any running process can expect at least three default file descriptors to be available:
0
Descriptor 0 is also known as standard input. It's normally mapped to the keyboard. Processes
look to this descriptor for user input.
1
Descriptor 1 is also known as standard output. It's normally mapped to the screen, although when
UNIX was created it was mapped to a printer. Processes write command output to this descriptor,
and the output then appears on your screen.
2
Descriptor 2 is also known as standard error. It's normally mapped to the screen, but when UNIX
was invented it was mapped to a dedicated printer. Processes write error messages to this
descriptor, and the error messages then appear on your screen.
Processes can also create their own descriptors, usually for interacting with files.
Question
338

Match each standard file descriptor value to its function.
Options:
A. 0
B. 1
C. 2
Targets:
1. Processes look to this descriptor for user input
2. Processes write command output to this descriptor, and the output then appears on screen
3. Processes write error messages to this descriptor, and the messages then appear on screen
Answer
Standard input is associated with file descriptor 0, and is usually mapped to the keyboard. Typing
commands with a keyboard is the most common way of interacting with the shell.
Standard output, which is associated with file descriptor 1, is usually mapped to the screen. Most
programs use standard output to print usage messages or the results of commands.
Standard error is associated with file descriptor 2 and is usually mapped to the screen but it is
sometimes useful to map it to a printer to record errors.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
You can redirect file descriptors in a similar way to performing ordinary redirection, using the
following syntax where n is a file descriptor:
<&n
You use <&n to redirect standard input from another descriptor. For example, you could type <&2
to feed standard error into standard input.
>&n
You use >&n to redirect standard output to another descriptor. For example, you could type >&2
to send standard output into standard error.
n< filename
339

You use n< with a filename to redirect a descriptor from the specified file.
n> filename
You use n> with a filename to redirect a descriptor to the specified file. As with ordinary
redirection, this overwrites an existing file. To change this default behavior and not have the file
overwritten, you set the noclobber variable using the set noclobber command.
n>> filename
You use n>> with a filename to redirect a descriptor to the specified file. This redirects to a file
but, as with ordinary redirection, appends to an existing file.
n>| filename
You use n>| with a filename to redirect a descriptor to the specified file, overriding the
noclobber variable if this has been set.
Question
Match the descriptors with their redirection function.
Options:
A. 2>
B. >&2
C. 1>
D. 2>|
Targets:
1. Redirect standard error to a file
2. Redirect standard output to standard errors
3. Redirect standard output to a file
4. Overwrite existing files with standard error
Answer
You use 2> to redirect standard error to a file, which is useful for printing error messages.
You use >&2 to redirect standard output to a standard error. If standard error is connected to a
printer instead of the display, this is a quick way of printing command output.
Instead of the output going to the screen it can be redirected to a file using 1>.
You use 2>| to redirect a descriptor to the specified file while overriding the noclobber variable.
Correct answer(s):
340

Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Question
You want to use the find command to locate reports, and you want to redirect both standard output
and standard error to text files. Complete the first part of the command required to redirect the
standard output to a text file called output.txt.
Code
$ find / -name "report*" INSERT THE MISSING CODE output.txt MISSING CODE
error.txt
Answer
You type > to redirect standard output to a file.
Correct answer(s):
1. >
Question
Now complete the command required to redirect standard error to a file called error.txt.
Code
$ find / -name "report*" > output.txt INSERT THE MISSING CODE error.txt
Answer
You type 2> to redirect standard error to a file.
Correct answer(s):
1. 2>
3. Scripting with redirection
For convenience, you may sometimes want to pass multiple lines of input to a command. You
do this using a here document.
341

Here documents make it possible to give batch input to a command to pass the command a
list of instructions you want it to carry out.
You start here documents with a command interpreter that loads a command to read and
execute the rest of the shell script. You can use here documents in two syntax forms. When
you use this syntax the shell executes the command and passes it the input you specify line by
line, until it reaches the word or character you've specified as a terminator.
Syntax
command << terminator [input ]
However, when you use this syntax, the trailing dash causes all leading tabs in the subsequent
input to be stripped.
Syntax
command <<- terminator [input ]
You want to automate a telnet session to e-mail yourself some data from a remote machine.
You begin by setting up the telnet command with a here document, using the word END as a
terminator.
Code
$ telnet << END
You press Enter, and the shell waits for further input.
Code
$ telnet << END
>
The first value that a telnet session needs is the address of the target machine, which is
192.168.2.3 in this case. So you enter the full command to open a session to that machine.
Code
$ telnet << END
> open 192.168.2.3
342

You know that the remote machine requires a username and password, so you type them on the
next line. In this case, your username is gregl and your password is simply password. Then
you press Enter.
Code
$ telnet << END
> open 192.168.2.3
> gregl password
The remote system should have logged you on by this point in the script, so you enter the
commands you need to fetch the file you want. You also enter the quit command to end the
telnet session.
Code
$ telnet << END
> open 192.168.2.3
> gregl password
> mail s "remote userlogs" gregl@192.168.2.1 < /var/log/userlog
> quit
To finish and execute the here document, you type the terminator that you specified to begin
with, which is END in this case, and you press Enter.

The shell executes the telnet command and feeds it the here document line by line.
Code
$ telnet << END
> open 192.168.2.3
> gregl password
> mail s "remote userlogs" gregl@192.168.2.1 < /var/log/userlog
> quit
> END
Question
Identify the ways in which you can work with here documents.
Options:
1. You can strip leading tabs from a here document using the <<- operator
2. You can automate login processes using here documents
343

3. The last line of a here document is always a command
4. The terminator in here documents is always END
Answer
Option 1: Correct. Automatically stripping tabs from your here document allows you to improve its
legibility.
Option 2: Correct. Most interactive command line programs, such as telnet or FTP, can be
automated using here documents.
Option 3: Incorrect. Here documents start with a command interpreter that loads a command to
read and execute the rest of the shell script. They end with a terminator.
Option 4: Incorrect. Although END is frequently used as a terminator in here documents, you can
use any string as a terminator.
Correct answer(s):
1. You can strip leading tabs from a here document using the <<- operator
2. You can automate login processes using here documents
Question
You're setting up a here document to run an ssh command, using the word Finish as a terminator.

Complete the command required to ensure that any leading tabs in the here document will be
stripped out.
Code
$ ssh INSERT THE MISSING CODE Finish
Answer
You use the <<- operator to ensure that leading tabs are stripped out of here documents.
Correct answer(s):
1. <<-
Summary
Most UNIX commands behave as filters, accepting input and providing processed output. You
can redirect command output to a file, and you can redirect command input from a file.

344

File descriptors are numeric placeholders for input/output (I/O) objects. The default file
descriptors present in any shell environment include standard input, standard output, and
standard error. You can redirect file descriptors.

Here documents provide a convenient way of sending batch input to a command. They're most
commonly used for setting up scripts for interactive commands, such as telnet.




















345

Substitution and Patterns in UNIX
Learning Objectives
After completing this topic, you should be able to
use file substitution
use command substitution
1. Substitution and matching
You can use filename substitution when entering commands to specify a range of files that you
want to work with. For example, you may want to work with all log files numbered 1 through 15.
Filename substitution involves using wildcard characters either on their own or with a pattern
fragment. The shell resolves a wildcard to a list of files, which it then passes to the command
you're trying to execute.
There are a number of wildcard characters that UNIX supports:
Code
w*
file0?
ls [!w]*
asterisk
You use the asterisk wildcard to match a string of any length. For example, if you specify this
code, the shell will return a list of every file in your current working directory with a name
beginning with w.
w* is indicated.
question mark, and
You use the question mark wildcard to match a single character. For example, if you specify this
code, the shell might return a list containing file01 through file09 if these files exist.
file0? is indicated.
exclamation mark
You can perform reverse matching using the exclamation mark character. In other words, this
code would return a list of files that don't start with w.
ls [!w]* is indicated.
You can specify limited lists of characters for filename substitution using square brackets in one
of a number of forms.
346

[abc]
You use the form [abc] to perform substitution with any character that appears between the
square brackets. For example, if you specify file0[147], the shell will return a list containing
file01, file04, and file07 if these files exist.
[a-d]
You use the form [a-d] to perform substitution with any character that appears in the range
between the square brackets. For example, if you specify data_[a-c], the shell will return a list
containing data_a, data_b, and data_c if these files exist.
[a-ce-g]
You use the form [a-ce-g] to perform substitution with any character that appears in any of the
ranges between the square brackets. You can include any number of ranges in this way. For
example, if you specify log[1-36-8], the shell will return a list containing log1, log2, log3, log6,
log7, and log8 if these files exist.
For example, you can type this command to retrieve a list of all files that begin with a lowercase
letter or a digit. In this case, the square brackets hold two ranges a to z and 0 to 9. The
brackets are followed by an asterisk, which allows any type of string to follow the specified
ranges.
Graphic
The code is [a-z0-9]*
Code
$ ls [a-z0-9]*
120415_log report1.txt report3.txt staffdata
120603_log report2.txt searchdata
$
Note
You can also use the code [0-9a-z]*.
You can perform reverse matching using the exclamation mark character. In this example, the
command lists all files in the current directory that don't end in a digit.
Code
$ ls l *[!0-9]
120415_log report1.txt report3.txt staffdata
347

120603_log report2.txt searchdata
$
Occasionally, you may need to refer to a user's home directory in a script. You can refer to a
user's home directory without knowing their username using the tilde character. This enables
you to write scripts with path references that any user can run.
Code
$ echo ~
/home/vincep
$
You can use the tilde character for substitution in the following forms:
~
The shell resolves the ~ character to the value of the current user's $HOME environment variable.
~user
The shell resolves ~user to the path of a specific user's home directory.
~-, and
The shell resolves ~- to the path of the previous directory you were working in.
~+
The shell resolves ~+ to the path of the current directory.
Question
How can you use the tilde character?
Options:
1. cd ~
2. cd ~$HOME
3. cd -~
4. cd ~Fred
Answer
Option 1: Correct. This command changes the directory to the home directory of the current user.
Option 2: Incorrect. The tilde character substitutes for the $HOME variable, so this command
wouldn't work.
348

Option 3: Incorrect. To change the current directory to its previous value, you must place the
hyphen after the tilde.
Option 4: Correct. In this case, the tilde changes the current directory to the home directory of the
user Fred.
Correct answer(s):
1. cd ~
4. cd ~Fred
Question
Match each filename substitution format with its function.
Options:
A. ls file[abc]
B. ls text.[a-e]
C. ls file*
D. ls file?
Targets:
1. Substitute from a list of characters into a filename
2. Specify a range
3. Substitute for any character zero or more times
4. Match any single character
Answer
The command ls file[abc] would use filename substitution to match and list files named filea,
fileb, and filec if they exist.
The command ls text.[a-e] matches and lists every file named text with a suffix consisting of a
period followed by a character in the range of letters from a to e. In other words, text.a, text.b, text.c,
text.d, text.e will be listed.
The command ls file* will match and list any file with a filename that starts with file, including
file123.
The command ls file? will match and list any file with a filename that starts with file and has one
additional character, such as file1 or filea if they exist.
349

Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Question
Complete the command required to list all files in the current directory with a lowercase initial letter
or digit.
Code
$ ls INSERT THE MISSING CODE
Answer
You type [a-z0-9]* or [0-9a-z]* to retrieve a list of all files that begin with a lowercase letter or
a digit.
Correct answer(s):
1. [a-z0-9]*
2. [0-9a-z]*
2. Command substitution
Command substitution allows you to use the output of one command as an argument for
another command.
You can perform command substitution using two forms of syntax:
$(command), and
When you use $(command) as an argument for another command, the shell executes the
bracketed command first. It then passes this command's entire output to the unbracketed
command.
$(< filename)
When you use $(< filename) as an argument for a command, the shell reads the specified file and
passes its entire contents to the command.
350

In this example, the current user is retrieved using this code, and the output - the username - is
passed to the grep command to display files that belong to that user.
Graphic
The code referred to is $(whoami).
Code
$ ls l | grep $(whoami)
-rw-r--r-- 1 vincep vincep 9880 Feb 11 15:40 120415_log
-rw-r--r-- 1 vincep vincep 9372 Feb 11 15:41 120603_log
-rw-r--r-- 1 vincep vincep 73234 Jan 8 09:22 report1.txt
-rw-r--r-- 1 vincep vincep 247416 Jan 8 09:23 report2.txt
-rw-r--r-- 1 vincep vincep 451008 Jan 8 09:24 report3.txt
When you include a special character, such as a wildcard, for example an asterisk, or a pipe as
part of an argument for a command, the command doesn't interpret that character. Instead, the
shell resolves it and passes the output to the command as an argument. If you intend a
command to use a special character as an argument, you must prevent the shell from
interpreting it by enclosing the character in quotation marks.

In the example code, without the quotation marks, the shell would have resolved the asterisk to
a list of all the files in the current directory.
Code
$ echo '*'
*
$
Instead of quotation marks, you can use backslash escaping to perform quoting. To do this, you
place a backslash immediately before the special character. This instructs the shell to pass the
character literally to the command instead of trying to interpret it. For example, to display a
single backslash you can use two backslashes.

Backslash escaping is also useful for situations in which you need to pass an actual quote mark
as an argument. For example, this code uses backslash escaping to print out this message.
Graphic
The message is '*' is a special character.
Code
351

$ echo \'\*\' is a special character
'*' is a special character
$
Question
How can you use command substitution and wildcards?
Options:
1. Command substitution allows you to use the output from a command as standard input for a second
command
2. Command substitution allows you to use the output from a command as part of the argument for another
command
3. Wildcards are used to perform command substitution
4. Wildcards are used to perform filename substitution
Answer
Option 1: Incorrect. Redirecting standard output into the standard input of a command is performed
using the UNIX pipe facility.
Option 2: Correct. The command echo It is $(date), for instance, provides the following
output: "It is Fri Aug 18 11:25:55 BST 2003."
Option 3: Incorrect. The shell only performs filename substitution with wildcards. The command
echo It is $(dat*) will yield a "command not found" error message.
Option 4: Correct. Filename substitution provides a quick way of searching large directories for files
conforming to a specific pattern.
Correct answer(s):
2. Command substitution allows you to use the output from a command as part of the argument for
another command
4. Wildcards are used to perform filename substitution
Question
If you need to pass special characters to a command in an argument, you enclose them in quotes to
prevent them from being interpreted.

Which command uses a suitable alternative method for escaping special characters?
Options:
352

1. echo \$USER
2. echo $($)USER
3. echo $(< $)USER
Answer
Option 1: Correct. The backslash prevents the $ from being interpreted as a special character, so
$USER will be printed onscreen, rather than the value of the $USER variable.
Option 2: Incorrect. The $(command) syntax allows you to pass the output from a command as a
parameter to another command.
Option 3: Incorrect. The $(<filename) syntax allows you to pass the contents of a file as a
parameter to a command.
Correct answer(s):
1. echo \$USER
Question
Complete the command to display a list of files that belong to the current user.
Code
$ ls l | grep INSERT THE MISSING CODE
Answer
The $(whoami) command returns your current username, and the grep command uses the output
from the bracketed command to filter the output of the ls l command.
Correct answer(s):
1. $(whoami)
Summary
Filename substitution involves specifying groups of files to use as arguments for commands.
Most shells let you use wildcards like the asterisk or a question mark in filename substitution.
The shell resolves a wildcard into a list of files that match specified search criteria.

Similarly, you can perform command substitution to use the output of one command as an
argument for another command. The shell resolves the argument command first and passes its
output to the main command.
353

Using UNIX Commands in a Script
Learning Objectives
After completing this topic, you should be able to
use command execution
use redirection
use substitution in a script
Exercise overview
In this exercise you're required to use UNIX shell commands to perform certain operations.
This involves the following tasks:
performing UNIX command execution
using redirection, and
using substitution in a script
Executing commands
Question
Complete the command to copy the records file to the /usr/jen directory, and then display the
contents on screen.
Code
# cp records /usr/jen INSERT THE MISSING CODE cat records
Answer
You use a semi-colon to separate and consecutively execute two shell commands written in the
same line.
Correct answer(s):
1. ;
Question
You want to execute the rebuildscript executing other commands.

354

Complete the command that executes the script in the background so that it doesn't interfere with
other work.
Code
# ./rebuildscript INSERT THE MISSING CODE
Answer
You use an ampersand to specify that a command should run only when the CPU is idle.
Correct answer(s):
1. &
Question
Complete the command to list the filename.txt file on screen, and subsequently delete the file if it
exists.
Code
# ls filename.txt INSERT THE MISSING CODE rm filename.txt
Answer
You use double ampersands to execute a second command if the first command returns a
successful result.
Correct answer(s):
1. &&
Question
Complete the command to list the file.txt file on screen, and subsequently return an error message if
it isn't found.
The code is:

# ls file.txt MISSING CODE echo file.txt not found
Answer
Correct answer(s):
355

1. ||
Question
You've written a command to change the shell's working directory to /lists and display the contents
of the employees file on screen. You plan however to use conditional execution to perform other
operations in the same command, and want to execute this piece of code in a new shell instance.

Select the brackets you'd use to do this.
Code
# cd /lists; cat employees
Options:
1. { }
2. ( )
3. [ ]
4. < >
Answer
Option 1: Incorrect. You use braces to execute a command in the current shell instance.
Option 2: Correct. You use parentheses to execute a command in a new shell instance.
Option 3: Incorrect. You use parentheses to execute a command in a new shell instance.
Option 4: Incorrect. You use parentheses to execute a command in a new shell instance.
Correct answer(s):
2. ( )
The first command is executed in a new shell and conditional execution is used to perform other
operations if the file doesn't exist.
Code
# (cd /lists; cat employees) || (echo Employee details not found/
> && cd /backup; cp employees /info/)
356

Performing redirection
Question
Use the ls command to list the files in the current directory in a new file called library.
Code
$ INSERT THE MISSING CODE
Answer
You enter $ ls > library to send the output of the ls command to a file called library.
Correct answer(s):
1. ls > library
2. $ LS > LIBRARY
Question
You want to change the permissions for a file called private, and send standard error output to a file
called log.txt.

Complete the command required to do this.
Code
$ chmod a-w private.txt INSERT THE MISSING CODE
Answer
You enter 2> log.txt to send standard error output to the log file.
Correct answer(s):
1. 2> log.txt
2. 2> LOG.TXT
Question
You want the shell to execute the tar command and pass it input from the Backup file, until it
reaches the word close as a terminator.
357


Complete the code required to do this.
Code
$tar INSERT THE MISSING CODE Backup.txt
Answer
You enter << close to have the Backup file passed to the tar command until the terminator
close is encountered.
Correct answer(s):
1. << close
2. << CLOSE
Performing substitution
Question
Complete the code required to return a list of all the log files in the range log4 to log6 and log9 to
log12.
Code
$ls -l INSERT THE MISSING CODE
Answer
You list a range of files using log[4-69-12].
Correct answer(s):
1. log[4-69-12]
2. LOG[4-69-12]
Question
You want to use the command find . -name logs.txt and send its output to the cat
command to display the results on the screen.

Complete the code required to do this.
Code
cat INSERT THE MISSING CODE . -name logs.txt)
358

Answer
You enter cat $(find . -name logs.txt) to redirect the find results to the cat command.
Correct answer(s):
1. $(find
2. $(FIND
UNIX command execution has been performed as well as execution with redirection and with
substitution.

















359

UNIX Files and Directories
Learning Objectives
After completing this topic, you should be able to
recognize the basic characteristics of files and directories
describe UNIX file types
1. Files and directories
The UNIX OS uses a file system to organize and store files so they can be easily accessed.
These files can be made up of text, data, or program source code, or can represent hardware
devices.
Files appear as a single item stored in a particular part of the hard drive. Like other operating
systems, the actual data for a single file is made up of many blocks of data that are stored in
various locations across a hard drive. The hard drive references each of these blocks in order to
create a single file.
Each of the files in a UNIX file system has its own unique filename. These filenames follow a
certain set of rules established by the OS. UNIX allows you to use ASCII symbols, such as
dashes, underscores, hash signs, or spaces in filenames. For example, you can name a file
New_database or New-database. These filenames can be a maximum of 255 characters long.
Some of these symbols can't be used in certain instances or certain positions because they're
also used in command line operations and their use may produce unexpected results.
The following symbols may cause problems at runtime when used in filenames:
the exclamation mark
the hash sign
the ampersand
the at symbol
the dollar sign
the asterisk
the question mark
the caret, and
the backslash
360

Supplement
Selecting the link title opens the resource in a new browser window.
Job Aid
Access the job aid for more symbols that may cause problems in filenames.
For example, -document may be misinterpreted as a command option because of the position
of the hyphen. Another example is the backslash symbol, which is used to separate directories
and files, and is therefore not suitable for use in a filename.
UNIX files can have uppercase or lowercase letters in their filenames. It's important to be aware
that UNIX is case sensitive, so uppercase letters are considered to be distinct from lowercase
letters. For example, if you name one file "document" and another "Document" they'll be
recognized as two different files by UNIX.
You can also use numbers in filenames. For example, you can name a backup copy of a file
Backup05.
Another part of a file is its extension, which is usually optional in UNIX. An extension can be
used to help the OS identify the file type and how to use it. For example, in Windows the text
editor is called notepad.exe. The .exe component indicates to Windows that the file is an
executable program. In UNIX, an extension is not always necessary for a file to work correctly.
UNIX extensions can also be longer than the typical three-character extension. For example,
you can name a file January2011.database to indicate that the file is a database.
UNIX files can also have more than one extension. For example, the file Notes.txt.Z is a
compressed text file. The .txt indicates that it's a text file and the .Z shows that it's been
compressed.
Other common file extensions include
.au
.class
The .class extension indicates a compiled Java file type.
.gif
The .gif extension indicates a GIF image file type.
.html
The .html extension indicates a web page file type.
.jar
The .jar extension indicates a Java archive file type.
361

.log
The .log extension indicates a log file type.
.py
The .py extension indicates a Python script file type.
.uu, and
The .uu extension indicates an unencoded file type.
.wav
The .wav extension indicates a wave audio file type.
Supplement
Selecting the link title opens the resource in a new browser window.
Job Aid
Access the job aid for additional extension information.
To make file management easier, you can use directories or folders to store files. The rules
for naming directories is the same as filenames except that a single or double period can't be
used in a directory name.
Graphic
For example, the C drive contains the Documents, Program Files, and Users folders.
Directories can also contain directories, or subdirectories, within themselves, which can in turn
store files. These directories are visible to the user in the form of a hierarchical tree structure.
The base or parent directory of the file system is called root.
For example, you may have database and document files for a project that need to be organized
and stored. You can create a directory for the project, and within that directory, you can create
separate directories for the database and document files. You can then place the database and
document files into the relevant directories.
Question
Identify the different characteristics of filenames and directories.
Options:
1. You can use letters in your filenames
2. Directories can contain directories within themselves
362

3. UNIX filenames are case sensitive
4. You can't use symbols in filenames
5. You can't use numbers in filenames
Answer
Option 1: Correct. You can name files using uppercase and lowercase letters.
Option 2: Correct. Directories within directories are called subdirectories.
Option 3: Correct. Uppercase and lowercase letters are treated as different letters by UNIX.
Option 4: Incorrect. You can use symbols in filenames, but the use of certain symbols, or the use of
certain symbols in specific places, is discouraged.
Option 5: Incorrect. You can use numbers in filenames.
Correct answer(s):
1. You can use letters in your filenames
2. Directories can contain directories within themselves
3. UNIX filenames are case sensitive
2. File types
Every file in UNIX is indexed and referenced using inodes. Inodes store referencing information
for all files, directories, and objects in UNIX. For instance they store details pertaining to
permissions, ownership, and file type.
UNIX supports a number of file types:
regular or ordinary files
device or special files
named pipes, and
symbolic and hard links
Regular or ordinary files can contain data such as ASCII or plain text, or binary and image data.
In UNIX, all hardware devices are represented as a device or special file. You can read from or
write to a device file in exactly the same way that you would with any other file. The file is
defined with a major number that specifies the device driver and a minor number that specifies
the device itself. Some devices also use the minor number to specify device behavior.
363


Device files can be special character files or special block files, depending on whether the data
is written to it one byte at a time or one block at a time.
Each entry in a directory is either a hard link or a symbolic link.

Hard links refer directly to a file and allow multiple users to share the same file. A hard-linked file
is accessible from multiple directories. Changes made to a hard-linked file are visible to
everyone with access to the hard links. Each hard link must be deleted in order to make the file
inaccessible.
Symbolic links are very similar to shortcuts in Windows and connect a user to the original file
using its full pathnames. This allows you to refer to files in other locations. You can also rename
symbolic links. These links are simply references to a filename and won't work when the original
file is deleted.
Also known as sockets, pipes allow one UNIX process or program to communicate with another.

Unlike a regular pipe, a named pipe can be used by processes that don't have to share a
common process origin. The message sent to the named pipe can be read by any authorized
process that knows the name of the named pipe. A named pipe is sometimes called a FIFO
first-in, first-out because the first data written to the pipe is the first data that is read from it.
When you list the files in a UNIX directory, details for each file, such as the permissions and file
types, are displayed.

In a file listing, directories and subdirectories are indicated by a lowercase d, and each file is
assigned a character to indicate its type.
Several characters are assigned to file types.
b
Block special files are indicated by a lowercase b.
c
Character special files are indicated by a lowercase c.
l
Symbolic links are indicated by a lowercase l.
_
Regular files are indicated by an underscore.
s
Socket or named pipe files are indicated by a lowercase s.
p
364

FIFO named pipe files are indicated by a lowercase p.
Question
Match each file type to its description.
Options:
A. Regular file
B. Symbolic link file
C. Device file
D. Named pipe
Targets:
1. A file type that can be made up of different types of data
2. A file type that is similar to a shortcut in Windows
3. A file type that is used to represent hardware components
4. A file type that allows one UNIX process or program to communicate with another
Answer
Regular files can be constructed from a variety of different types of data, including ASCII text or
binary data, for example, image files.
A symbolic link refers to the pathname of a file and allows you to refer to files in other locations.
A device file uses a major number to specify the device driver and a minor number to represent the
device.
Also known as a socket or FIFO, named pipes can be used by processes that don't share a
common process origin.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
365

Summary
In a UNIX system, all major entities are represented as files, including programs, data,
directories, and peripheral devices. These files are labeled using filenames that follow a certain
set of rules in order to work in UNIX. Filenames can also contain extensions that help you
identify how the file is used. Files are stored in directories that can contain subdirectories and
are presented to the user as a hierarchical tree structure.

In addition to regular binary or text files, UNIX files can include symbolic and hard links, device
files, and named pipes. Each files type is assigned a specific character to identify it in a file
listing.

















366

The UNIX File System
Learning Objectives
After completing this topic, you should be able to
name files and directories in a UNIX file system
navigate the UNIX file system
list files in a UNIX file system
view files in a UNIX file system
1. Naming files and directories
A UNIX system consists of files, directories, and subdirectories. Directories are used to organize
the components of the system in a logical, upside-down tree structure.
The topmost directory in the system is known as the root directory, and is usually represented
by a forward-slash symbol.
The root directory contains files and subdirectories, and each subdirectory can contain further
subdirectories and files, which are logically arranged. In this way, UNIX components are
interconnected and each component can be traced back to the root directory.
Graphic
In this example, the root directory contains subdirectories called bin/, dev/, users/ and usr/. The /usr/
subdirectory contains a further subdirectory called local/, which itself contains subdirectories called
bin/ and apps/.
When an instance of a user or program is working within the system, their location within the file
system can be accurately pinpointed at any given time. The location of a working subject is
known as its current working directory.
Graphic
For example, if a user is working in the local/ directory, that is the user's current working directory.
The UNIX system receives commands using prompts. A prompt is indicated by a specific
symbol, which varies depending on the system and its configuration. In this example, the prompt
is indicated by a hash symbol.
Code
#
367

In some systems, the prompt is preceded by information such as the name of the system, the
name of the shell, or the current working directory. In this example, the prompt indicates the
username of the subject, which is samo.
Code
samo#
When a user wants to access or execute a specific file, they can issue a command directly after
the prompt. The command contains information that indicates the location of the desired file. In
this example, the file is called A and is located in the home directory.
Code
# /home/A
As in most systems, files in the UNIX system are located according to a path. The path can be
specified in different ways, including
Graphic
For example, if a file called "A" is located in the bin/ folder, its path can be traced back to the root
folder.
using an absolute or full path
using a relative path, or
referencing a home directory
A full or absolute path is a path that starts at the root directory and ends with the filename. It
includes the names of all the directories between the root and the file, separated by forward
slashes.
Graphic
In this example, the absolute path is /usr/local/bin/A.
A relative path also ends with the name of file, but it can start in different places. The place
where the path begins is indicated at the beginning of the path. If it starts with a single period,
the path starts in the current working directory. For example, if the current working directory is
the local/ directory, this can be the relative path.
Graphic
368

The relative path is ./bin/A
If it starts with a subdirectory name, it starts in a subdirectory of the current working directory.
Here is an example of a relative path.
Graphic
The relative path is local/bin/A
Finally, if the path starts with a double period, it starts in the parent directory of the current
working directory. For example, this can be the path.
Graphic
The relative path is ../local/bin/A
Each user has a home directory in which all the files and directories associated with that user's
account are found, and where the user first logs onto the system. One way of expressing a path
is by referring to a home directory, which you might want to do if the file is located there.
Graphic
In this example, the home directory is the users/ directory, which contains a file called B.
You can reference a home directory using just a tilde symbol, which represents a complete
absolute path from the root directory to your home directory. For example, if the users/ directory
is the home directory, the path represented by the tilde symbol is users/. To indicate the B file in
this directory, this would be the path.
Graphic
The path is ~/B
You can also specify the home directory of another person by adding a forward slash followed
by that person's username to the path. For example, if you wanted to access a file called C in
John's home directory, you could use this path.
Graphic
The path is ~/john/C
Question
369

Match each path to the method that's used to indicate the path to a file called X.

Targets may be used more than once.
Options:
A. /usr/local/X
B. ./local/X
C. ~/nancy/X
D. ../etc/bin/X
Targets:
1. Absolute path
2. Relative path
3. Reference to a home directory
Answer
Correct. The absolute path to a file begins at the root directory, as indicated by the forward slash,
and includes all the directories between the root and the file.
A path that starts with a single period is a relative path, which begins with the current working
directory and ends with the file. A path that starts with a double period is also a relative path, but
begins with the parent directory of the current working directory.
A path beginning with a tilde is indicative of a home directory. In this case, the path refers to the
home directory of a user called Nancy.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B, Option D
Target 3 = Option C
2. Navigating the UNIX file system
When you log in to a UNIX system, you're placed in your home directory by default. You can use
the cd command, which stands for change directory, to move from the current working directory
to a different directory.

To find out which directory is the current one, you can use the pwd command, which stands for
present working directory.
370

Graphic
In this example, a directory called samo/ is located in the users/ directory.
You've logged in as Sam Oswald with the username samo and have worked in various
directories. To check your current directory, you type pwd at the shell prompt and press Enter.
Code
# pwd
The output of the command shows that you're back in your home directory, which is
/users/samo. The fact that the users/ directory is prefixed with a forward slash indicates that it's
a subdirectory of the root.
Code
# pwd
/users/samo
#
When using the cd command to navigate through a file system in UNIX, you can use a forward
slash to move down the tree to the next embedded directory.
You can use a double period to move back up the tree towards the root directory, one directory
at a time. This is also known as going back one level or one directory. To navigate back several
levels in this fashion, you append ../ for each level.
Using cd with a tilde symbol returns you to your home directory, which in this case is
users/samo. To navigate from the root, you can prefix your path string with a forward slash. To
relatively navigate from your current location, you omit the initial forward slash.
The major difference between UNIX and DOS notation is that UNIX uses a forward slash to
indicate directories and DOS uses a backslash. In addition, UNIX requires a space between the
cd command and the directory name.
In UNIX, using the cd command without parameters takes you to your home directory. In DOS
you can substitute chdir with cd, but UNIX doesn't support this.
You're currently in the users/ directory, and you want to move to the local/apps/ subdirectory in
the usr/ directory.
371

You use the cd command to change directories. However, because you aren't in the usr/
directory, you cannot use a relative pathname and so need to spell out the exact path, starting at
the root.
Code
# cd /usr/local/apps/
Again, you can use the pwd command to check your location in the tree.
Code
# cd /usr/local/apps/
# pwd
/usr/local/apps
#
You now want to move back up the tree from the /usr/local/apps directory into the usr/local/
directory. To move back up one directory at a time, you use the .. notation.
Code
# pwd
/users/samo
# cd /usr/local/apps/
# pwd
/usr/local/apps
# cd ..
When you check your location using the pwd command, you find you're in /usr/local/.
Code
# pwd
/users/samo
# cd /usr/local/apps/
# pwd
/usr/local/apps
# cd ..
# pwd
/usr/local
#
372

In addition to shortcuts for navigating back to the root, UNIX supports pathname expansion, in
which it attempts to supply the pathname from a fragment. This is helpful when you can't recall
the full name of a file.
For example, you want to move to a directory in /usr/ftp/ that stores mail, but can only remember
that it starts with an i. You can enter the part of the pathname that you know.
Code
# cd /var/ftp/i
Having entered what you know of the pathname, you press the Tab key and UNIX completes
the name. If there's more than one subdirectory beginning with i, you can view them in turn by
pressing the Tab key again.
Graphic
The full name of the file is incoming.
Code
# cd /var/ftp/incoming/
Note
In many UNIX systems, you can also use the Esc key for pathname completions.
Question
Match each UNIX navigation command to the statement that best describes its function.
Options:
A. pwd
B. cd
C. cd ..
D. cd ~
Targets:
1. To show the user their current location
2. To move the user from one location to another
3. To move the user to the directory above the current directory
373

4. To move the user to their home directory
Answer
The pwd command displays the name and path of the user's current working directory.
The cd command allows users to switch from one directory to another.
The .. command moves the user back towards the root by one directory.
The cd command allows a user to change directories, and the tilde symbol represents the user's
home directory.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
3. Listing files
You can use the ls command to list the visible contents of a current directory onscreen. When
specified without options, the ls command displays the files and subdirectories in the current
directory.
If you're working in the root directory, for example, you can use the ls command to find out
what subdirectories it contains.
Code
# ls
The output reveals that there are six subdirectories in the root directory, and lists their names.
Code
# ls
bin dev etc lib users usr
374

There are a number of options you can specify with the ls command to modify its output. These
are also known as switches. The most commonly used are
Code
# ls
-a

Code
# ls -a

-F

Code
# ls -F

-G

Code
# ls -G

-l

Code
# ls -l

-r, and

Code
# ls -r

-t

Code
# ls -t

The -a switch displays all the files in the current directory, including hidden files, which are
prefixed with a dot. For example, if you were working in the /usr/ directory and entered the
command ls -a, the output would be as shown.
375

Code
# ls -a
. .profile boot dev home sbin tmp
.. altroot bsd emul mnt stand usr
.cshrc bin bsd-rd etc root sys var
The -F switch identifies the types of files in a listing. Directories are marked with a trailing
forward slash, executable files with a trailing asterisk, first-in first-outs or FIFOs with a trailing
vertical bar, symbolic links with a trailing at sign, and AF_UNIX address family sockets with a
trailing equals sign.
Code
# ls -F
.cshrc bin/ bsd-rd etc/ root/ sys@ var/
.profile boot dev/ home sbin/ tmp/
altroot/ bsd emul/ mnt/ stand/ usr/

The -G switch colorizes screen output, so that categories of files can be distinguished easily.
This switch is only available with particular versions of UNIX and Linux, and is useful for finding
specific files at a glance.
Code
# ls -G
.cshrc bin bsd-rd etc root sys var
.profile boot dev home sbin tmp
altroot bsd emul mnt stand usr
The -l option displays details in long format and display information such as its type,
permissions, owners, size, when it was last modified, and filename.
Code
# ls -l
Total 24476
-rw-r--r-- 1 root wheel 578 Aug 12 2008 .cshrc
-rw-r--r-- 1 root wheel 292 Aug 12 2008 .profile
drwxr-xr-x 2 root wheel 512 Aug 12 2008 altroot
drwxr-xr-x 2 root wheel 1024 Aug 12 2008 bib=n
drwxr-xr-x 1 root wheel 43348 Mar 27 2009 boot
drwxr-xr-x 1 root wheel 686156 Mar 27 2009 bsd
376

The -r option reverses the order in which the files in a directory are displayed by default. The
default is that directories are listed after the files.
Code
# ls -r
var sys root etc bsd.rd bin .cshrc
usr stand mnt emul bsd altroot
tmp sbin home dev boot .profile
The -t option displays files according to their modification times.
Code
# ls -t
etc root sys sbin .profile altroot stand
tmp emul bsd.rd bin usr home
dev boot bsd .cshrc var mnt
When specifying more than one option at a time, one hyphen is sufficient for all the options,
which are specified together without spaces between them. For example, combining the a and l
options displays all files, including hidden files, with the extended information in addition to the
filename.
Code
# ls -al
total 7
drwxr-xr-x 21 root wheel 512 Nov 21 11:01 .
drwxr-xr-x 21 root wheel 512 Nov 21 11:01 ..
-rw-w--r-- 2 root wheel 802 Jun 11 00:20 .cshrc
#
Question
Match the switches you can use with the ls command to their functions.
Options:
A. -a
B. -F
C. -r
D. -l
377

Targets:
1. Displays hidden files
2. Identifies file types
3. Reverses file order
4. Displays file details
Answer
The -a switch displays the hidden files in a directory, and indicates them with a period.
The -F switch identifies the types of files in a directory with certain symbols. For example, an
executable file is identified by a trailing asterisk.
The -r switch displays directory contents in reverse order. This means that the files are listed
before the directories.
The -l switch displays details about each file in the directory, including the file's owners,
permissions, file type, and name.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
4. Viewing file content
The cat command from the word concatenate allows you to view the contents of a file. To
view the content, you enter the name of the file after the cat command.
Code
# cat filename.txt
line a
line b
line c

line d
line e
378

There are several switches you can use with the cat command to modify its output. For
example, you can add the -b switch to display numbers for all the lines in the file except the
blank lines.
Code
# cat -b filename.txt
1. line a
2. line b
3. line c

4. line d
5. line e
You can add the -n switch to number all the lines in a file, including the blank lines.
Code
# cat -n filename.txt
1. line a
2. line b
3. line c
4.
5. line d
6. line e
Finally, you can use the -u switch to prevent buffering in screen output when the file's output is
displayed. This is useful when a file is very large or when memory is limited.
Code
# cat -u filename.txt
When viewing the content of a directory or a file, you can control the number of lines displayed
on screen by using a pager. The common pager utilities in UNIX are more and less. When you
use a pager, the file displays one screen at a time.
In both utilities, pressing the spacebar brings up the next screen of information, q quits the
utility, and h displays help information.
You want to view the content of the FreeBSD copyright notice one screen at a time. To achieve
this, you enter the cat command with the options you want to specify. Then you add the pipe
symbol, followed by the more command.
379

Code
# cat COPYRIGHT | more
You can use pagers when listing the contents of a directory. To advance to the next screen of
the directory listing, you press the spacebar.
Code
afs
amd
authpf
bgpd
conf
ccd.conf
changelist
chio.conf
csh.cshrc
csh.login
csh.logout
daily
dhclient.conf
dhcpd.conf
disklabels
disktab
dumpdates
dvmprd.conf
exports
fbtab
firmware
fstab
ftpchroot
ftpusers
gettytab
byte 215
The next screen of the directory listing is then displayed.
Code
group
hostapd.conf
hostname.Vic0
hosts
hosts.equiv
380

hosts.lpd
hotplug
ifstated.conf
inetd.conf
ipsec.conf
isakmpd
kerberosV
ksh.kshrc
localtime
locate.rc
login.conf
lynx.cfg
magic
mail
mail.rc
mailer.conf
man.conf
You can also use the cat command to combine two or more existing files into a new file. To do
this, you add the names of the existing files after the command, followed by a greater-than
symbol and the name you want to assign to the new file.
Code
# cat text1.txt text2.txt > project#1.txt
For example, you could combine two files called text1 and text2 into a single file called
project#1. The contents of the two files are now combined in the new file, but the original files
remain unchanged.
Graphic
For example, if the text1 file consists of one line that reads text1 contents and text2 contains text2
contents, the resulting project#1 file would contain the text text1 contents text2 contents.
Question
You are viewing a file called names.txt. Match each command and parameter with its output.
Options:
A. cat -n names.txt
B. cat -b names.txt
C. cat names.txt
D. cat names.txt | more
381

Targets:
1. names.txt is displayed, and all lines are numbered
2. names.txt is displayed, and all lines except the blank lines are numbered
3. names.txt is displayed without line numbering
4. names.txt is displayed one screen at a time
Answer
The -n switch, when used with the cat command, displays the contents of a file with all the lines
numbered including the blank lines.
The -b switch, used with the cat command, displays the contents of a file with all the lines
numbered except the blank lines.
The cat command, when used without switches, simply displays the contents of a file.
The more pager can be used to view the contents of a file in one screen at a time.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Summary
The UNIX file system consists of a root directory and various subdirectories and files, which
form a tree structure. When a user or program is working in the file system, their location is
known as the current working location. A file can be located according to its path, which can be
expressed as an absolute path, a relative path, or a reference to a home directory.

Navigation in a UNIX system is done with various commands, such as cd to change directories,
or pwd to find the current working directory. If you forget the name of a directory, you can type
the first letter and use the Tab key to let UNIX find it for you.

You can quickly view the contents of a directory using the ls command. There are various
switches available for use with ls that let you choose how the contents are displayed. You can
combine switches to use them simultaneously.

382

The cat command allows you to view the contents of files, and you can use switches to view
the contents in different ways. You can also use cat to combine two or more files into one.






















383

File Creation, Deletion, and Permissions in UNIX
Learning Objectives
After completing this topic, you should be able to
create files and directories
delete files
set permissions on files
1. Creating files and directories
When you create files and directories in UNIX, the UNIX kernel allocates disk space to it
dynamically.
Filenames can be up to 256 characters long, and can use any character and some reserved
characters, such as *, $, and ?. In addition, you can divide a multiword filename using either an
underscore or a period.
There are three common methods for creating files and directories in UNIX. These are
using the touch command,
using redirection, and
using an application
You can use the touch command to create a new file with a specified name. For example, you
can create a new file named update.may. A file created in this way has the default permissions.
Code
#touch update.may
When a file already exists, you can use the touch command to change the modification and
access time of the specified file using redirection. When you execute commands in UNIX, the
kernel sends the output of the command to standard output, which is usually the screen.
Before a command, such as echo, cat, or ls is executed, you can redirect its output to a file,
using the > notation. In this example, the output of the ls command is redirected to a file named
ls_home.
Code
384

#ls > ls_home
You can also use the cat and ls methods with the redirection operator to create files and
directories.
The cat command takes in two or more files at input, concatenates them, and outputs the result
either to the screen, a printer, or a new file. In the example, the cat command concatenates
file1 and file2 and outputs the result to file3.
Code
#cat file1 file2 > file3
The ls method uses the ls command to list the contents of a directory. You have options to list
hidden files or to sort a listing. You can also output the list to a new file. For example, you can
output the list of all files including hidden files and subdirectories of the current directory to a
text file.
Code
#ls a > mylist.txt
Files are often created when you use a UNIX application, such as the vi or emacs text editor. In
this case, you call up the editor and input whatever text you want the file to contain. You then
save the results of your editing session, writing it to disk and giving it a name.
Question
You need to create a new file named Backup.March.

Complete the command to create the file.
Code
#INSERT THE MISSING CODE Backup.March
Options:
1. touch
2. cat
3. ls
Answer
385

Option 1: Correct. The touch command can be used to create a new file with any name you
specify.
Option 2: Incorrect. The cat method concatenates two or more files to create a new file.
Option 3: Incorrect. The ls method is used to list the contents of a directory and output that list to a
new file.
Correct answer(s):
1. touch
Question
You need to redirect data to a file named filelist.txt that contains a list of all the files in a directory.

Complete the command to redirect the data and create the file.
Code
#INSERT THE MISSING CODE filelist.txt
Answer
Correct. The ls method with the > operator allows you to create a file that contains a list of all the
files in a directory.
Correct answer(s):
1. ls >
2. Deleting files
In UNIX, you use the rm command, which stands for remove, to delete single or multiple files.
Unless you specify a particular directory with the filename for deletion, UNIX assumes that the
file resides in the current working directory.
You need to remember that there's no undelete command in UNIX. Once you delete a file, it's
gone, unless you have a backup somewhere.
In the example, you know that a file called text1 resides in your current location. So you type rm
text1 to remove the file. Had your current location been different from the file's location, you
would need to specify the full pathname with the rm command.
386

Code
# rm text1
When deleting more than one file at a time, you can either specify each file by name or use
wildcards to specify lists of filenames containing the same characters.
For instance, if you specify *.txt as the filename, all files with the extension .txt will be
removed from the current or specified directory.
In this example, all files with names beginning with the word update will be deleted, regardless
of whether they have an extension.
Code
# rm update*
Question
You no longer need the backup file you created for your project.

Complete the command to delete the file.
Code
# INSERT THE MISSING CODE BackupProject.txt
Answer
Correct. The rm command will remove the file.
Correct answer(s):
1. rm
Now you can check the directory to see that the files have been deleted. You can use the pwd
command to check that you're in the correct directory, and then run the ls command to list the
files.

In this case, no files are listed, so the task was successful.
Code
387

# ls
#
You can also use rm with extended wildcard options to remove files.
For example, if you have files with the common name Doc that are numbered from one to five,
you can use wildcards to remove all the numbered files at once.
Code
#~/Sample/Dir rm Doc[12345]
Or if you have files that contain the common word Test within their names such as JulyTest_1,
AugustTest4, and so on you can also use wildcards to remove all of them.
Code
#~/Sample/Dir rm *Test*
You can also modify the behavior of the rm command using a variety of options.
-f
The -f option removes files without prompting for confirmation.
-i
The -i option prompts for confirmation before removing the specified files.
-d
The -d option removes directories as well as files.
-P
The -P option overwrites regular files before deleting them.
-r
The -r option deletes the content recursively. This includes the contents of the directory and all
directories and files under it.
Question
Identify the rm option that deletes all files beginning with the word sample from the current directory
and all subdirectories without asking for confirmation.
Options:
1. rm -r sample*
388

2. rm -i sample*
3. rm -P sample*
Answer
Option 1: Correct. The command rm -r sample* looks for all files that start with the word sample
in the current directory and subdirectories. These files are then deleted.
Option 2: Incorrect. The command rm -i sample* asks you to confirm that you want to delete
any files that start with the word sample.
Option 3: Incorrect. The command rm -P sample* overwrites regular files before deleting them.
Correct answer(s):
1. rm -r sample*
Question
You've opened a directory containing seven files and you want to delete five files named
SampleFile1 to SampleFile5 in the current directory and all subdirectories.

Complete the command to do this.
Code
#rm -r SampleFileINSERT THE MISSING CODE
Answer
Correct. The command SampleFile[12345] selects the files named SampleFile1 to
SampleFile5 to be deleted. The -r option checks for these files in all subdirectories.
Correct answer(s):
1. [12345]
3. Setting permissions on files
Every file and directory stored on the hard drive has a set of permissions associated with it,
which restricts who's allowed to do what with a particular file or directory.
Every file and directory also has an owner and a group associated with it
389

When you create a file, you're usually the user or owner of that file, and your group, or the group
associated with the directory you created the file in, will usually have access to that file unless
you specify otherwise.
There are three operations you can perform on files or directories:
read a file or list the contents of a directory
write to, or modify, a file or create and delete files in a directory, and
execute, or run, a file if it's a program or script
Each of these operations is indicated with a special character. Read is indicated with a
lowercase r, write with a lowercase w, and execute with a lowercase x. If you don't wish to grant
a permission, you can enter a hyphen in place of the r, w, or x.
The permissions for a file are displayed in sets of three.
The first set represents the user permissions, the second the group permissions, and the third,
the permissions granted to all other users.
For example, a file listing of rwxr-xr-- indicates that the user has read, write and execute
permissions, the group has read and execute permissions, and other users only have read
permissions.
Question
What does rwxrw-r-- in a file listing mean?
Options:
1. The user has all permissions, the group has read/write permissions, and all other users have read-only
permissions
2. The user has all permissions, the group has only execute permissions, and the other users have read-
only permissions
3. The user has read/write permissions, the group has read-only permissions, and the other users have no
permissions
Answer
Option 1: Correct. The user will usually have full access to a file. You can give similar or lower
access to other users within the group, while giving other users little to no access to the file.
Option 2: Incorrect. The group has read and write permissions. In other words, the user has all
permissions, the group has read/write permissions, and all other users have read-only permissions.
390

Option 3: Incorrect. Other users have read permissions. In other words, the user has all
permissions, the group has read/write permissions, and all other users have read-only permissions.
Correct answer(s):
1. The user has all permissions, the group has read/write permissions, and all other users have
read-only permissions
Some UNIX systems use the first slot in the permissions notation to denote file type. For
instance, in the notation drwx------, the d denotes a directory. In the same way, an initial hyphen
may well denote a regular file rather than an unassigned first permission in the user set.
Code
# ls -l
total 2
-rwxrw------ 1 root wheel 2 Jul 14 2010 profile
#
File and directory permissions can be represented in symbolic or octal notation. The numeric
equivalents of the symbolic notations are r = 4, w = 2, x = 1, and - = 0.
For instance, if you were to assign 7 (4+2+1) to a user, that user would have full permissions.
Similarly, if you assigned a user, group or others 6 (4+2), they would have read and write
permissions but not execute permission.
UNIX displays the permissions of a file in symbolic notation, such as rw-r--r--. However, it
displays the umask used to set the default permissions in octal mode. In this case, the numeric
value of rw-r--r-- is 644.
When you create a new UNIX file, it's given the default permissions. In octal mode, the default is
755, which equates to -rwxr-xr-x in symbolic notation for a directory and to -rw-r--r-- for a file.
In the case of directories, this value is derived by subtracting the umask in this case 022
from 777, which grants full permissions to everyone.
Question
Identify the octal notation for the symbolic notation rwxr-x-r--.
Options:
1. 754
2. 644
3. 752
391

Answer
Option 1: Correct. The value for the user is 7, the value for group is 5, and the value for other users
is 4.
Option 2: Incorrect. A value of 6 means that users would only have read and write permissions. A
value of 4 means that the group and other users would only have read permissions. The correct
octal notation is 754.
Option 3: Incorrect. A value of 7 is correct for users, giving them full permissions. The value of 5
would give the group read and execute permissions, which is correct. However, the value of 2 would
mean other users would only have write permissions. The correct octal notation is 754.
Correct answer(s):
1. 754
In the case of files, you derive the value by subtracting the umask from 666, which grants read
and write permissions to everyone.
You can use the umask command to display or change these defaults. In the example, the
default is changed in octal mode to 744.
Code
# umask 744
To change the default permissions to 744 using symbolic mode, you can use the symbols in
combination with the command options that define the permission sets. The command option u
sets the user permissions, g sets the group permissions, and o sets the other user permissions.
Code
umask u+rwx,g+r,o+r
You can remove the permissions using the rm command with the umask command.
Code
# rm umask u+rwx,g+r,o+r
Question
392

The file in the current directory is fully accessible to the user, group and other users.

Use octal mode to complete the command so that the user has read, write, and execute
permissions, the group has read permissions, and other users have no permissions.
Code
# INSERT THE MISSING CODE
Answer
Correct. The octal notation of 7 sets read, write and execute permissions for the user. The octal
notation of 4 sets read permissions for the group. The zero octal notation sets no permissions for
the other users.
Correct answer(s):
1. umask 740
Summary
When you create a file or directory, UNIX dynamically assigns it disk space. The filenames in
UNIX can be up to 256 characters long, and can use almost any ASCII character, including
specific reserved ones. You can create files using the touch command, redirection, or an
application.

You can delete files and directories in UNIX using the rm command. By default, UNIX assumes
the file you're attempting to delete is in the current directory, except when you specifically define
the file location. After you've deleted a file, it can't be recovered. When deleting multiple files,
you can specify each filename or use wildcards.

Each file and directory has a set of permissions associated with it that defines who has access
and what they can do with it. You can grant read, write, and execute permissions to a file or
directory for the user, the user's group, and other users. These permissions can be set using
symbolic notation or octal notation.






393

Using the UNIX File System
Learning Objectives
After completing this topic, you should be able to
work with the UNIX file system
create, delete, and set permissions for files
Exercise overview
In this exercise, you are expected to answer questions relating to the UNIX file system.
This involves the following tasks:
navigating, listing and viewing files, and
creating and deleting files, and setting file permissions
Working with the UNIX file system
You're working in an unfamiliar UNIX file system, and you want to explore its contents.
Question
You've forgotten which directory you're working in, and you want to quickly find out. Which
command should you use?
Code
# INSERT THE MISSING CODE
Options:
1. pwd
2. ls
3. cd
Answer
Option 1: The pwd command can be used to instantly retrieve the name of the current working
directory.
Option 2: Incorrect. The ls command is used to view the contents of a directory, but doesn't give
an indication of the directory name.
394

Option 3: Incorrect. The cd command is used to change to a different directory, but doesn't help to
identify the current working directory.
Correct answer(s):
1. pwd
Question
You've viewed the contents of the current directory using the ls command. Now you want to list the
full details of each file and directory in long format.

Enter the command you would use to do this.
Code
# ls
.cshrc bin bsd-rd etc root sys var
.profile boot dev home sbin tmp
altroot bsd emul mnt stand usr
#INSERT THE MISSING CODE
Answer
The ls command lists the contents of the directory, and the -l switch includes details such as the
type, permissions, owners, and size of each file.
Correct answer(s):
1. ls -l
Question
You want to view the contents of the file called names1.txt. You also want each line in the file to be
numbered, even if a line is blank.

Which command would you use to view the file?
Code
# INSERT THE MISSING CODE
Options:
1. cat -n names1.txt
2. cat -u names1.txt
395

3. ls -b names1.txt
Answer
Option 1: Correct. The cat command with the -n switch allows you to view the contents of a file,
and numbers the lines of the file, including blank lines.
Option 2: Incorrect. You need to use the cat command with the -b switch in relation to the
names1.txt file. If you use the cat command with the -u switch, the names1.txt to view without
buffering and with numbering the lines.
Option 3: Incorrect. The ls command is used to list the contents of a directory, but can't be used to
view the contents of a file.
Correct answer(s):
1. cat -n names1.txt
Creating and deleting files
You want to create, delete, and configure files in UNIX.
Question
You need to create a new text file named Data.txt to store unimportant data.

Complete the command to create the file.
Code
#INSERT THE MISSING CODE Data.txt
Answer
Correct. The touch command is used to create a new file.
Correct answer(s):
1. touch
Question
You need to redirect the listing of all the files in the current directory to a file named filelist.txt.

Complete the command to do perform this action.
396

Code
# INSERT THE MISSING CODE > filelist.txt
Answer
Correct. The ls command is used to list all the files in the current directory, and the > operator
redirects that data to a specific filename.
Correct answer(s):
1. ls
Question
You need to delete CurrentFiles.txt as it is out of date.

Complete the command to delete the file.
Code
# INSERT THE MISSING CODE CurrentFiles.txt
Answer
Correct. The rm command is used to remove files.
Correct answer(s):
1. rm
Question
The permissions for the file whose properties you have open are rwxrw-r--.

What do these permissions mean?
Options:
1. The user will have read, write, and execute permissions. The group will have read and write
permissions. The other users will have read permissions.
2. The user will have read and execute permissions. The group will have read permissions. The other
users will also have read permissions.
3. The user will have read, write, and execute permissions. The group will have write permissions. The
other users will have no permissions.
397

Answer
Option 1: Correct. The user usually has full permissions in order to handle any necessary changes
to the file. The group and other users will generally have limited permissions compared to the user.
Option 2: Incorrect. The user will have read, write, and execute permissions. The group will have
read and write permissions. The other users will have read permissions.
Option 3: Incorrect. The user will have read, write, and execute permissions. The group will have
read and write permissions. The other users will have read permissions.
Correct answer(s):
1. The user will have read, write, and execute permissions. The group will have read and write
permissions. The other users will have read permissions.
Question
The file in the current directory has no permissions for the user, group, and other users.

Using octal mode, complete the code so that the user has read, write, and execute permissions, the
group has read and write permissions, and other users have read permissions.
Code
# INSERT THE MISSING CODE
Answer
Correct. The octal notation of 7 sets read, write and execute permissions for the user. The octal
notation of 6 sets read permissions for the group. The final octal notation of 4 sets read permissions
for the other users.
Correct answer(s):
1. umask 764
Various commands have been used to work with the UNIX file system. Files have been created
and deleted, and permissions have been set on a file.



398

Searching UNIX Files with Patterns
Learning Objectives
After completing this topic, you should be able to
use wildcards to locate files
use regular expressions to locate files
use grep to search for file content
use find to search for files
1. Using wildcards
Wildcards and regular expressions are both used in combination with search commands to
locate files on a UNIX computer. However, the application of wildcards differs from that of
regular expressions.
Code
# ls -l *.txt
You can use wildcards with a variety of commands, such as ps, rm, and ls. The wildcard used
in this example allows you to view details of all files with a .txt extension.
Code
# ls -l *.txt
You can use shell wildcards to construct patterns that match files in this directory.
Code
# ls
app.exe app1.exe app5.exe
app49.exe App1.exe App2.exe
Asterisk (*)
You can use the * wildcard to match zero or more instances of any character.

The command used in the example will list the files app, app1, app5, and app49.

Code
#ls app*.exe
399

app.exe app1.exe app5.exe
app49.exe
#
Question mark (?)
You can use the ? wildcard to match a single instance of any character. You can use multiple
question marks to indicate more than one character. So, if for instance, three question marks are
used, it will indicate three characters.

The command used in the example will list the files app1 and app5 only.

Code
ls app?.exe
app1.exe app5.exe
#
Square brackets ([ ])
You can use the [] syntax to create patterns that match sets of characters. You can include lists
of characters, such as [adf], or you can specify inclusive ranges, such as [a-f].

The command used in the example will list the files app1 and App1 only.

Code
ls [aA]pp1.exe
app1.exe App1.exe
#
Exclamation mark (!)
You can use the ! wildcard within the square brackets to match any character that is not listed in
the brackets.

The command used in the example will list the files app, app1, app5, App1 and App2.

You can also specify a range of characters if you like. For example, typing ls [!1-8] returns
any character except characters ranging from 1 through 8.

Code
ls *[!9].exe
app.exe app1.exe app5.exe
App1.exe App2.exe
#

Question
400

On your computer you have a directory that contains five files Ee, Eda, ee, e23b, and e4ec. You
want to use shell wildcards to search for files which contain specific text strings.

Match each search string to the expected output.
Options:
A. ls e*
B. ls e?
C. ls [eE]e
D. ls [!e]?
Targets:
1. ee
e23b
e4ec
2. ee
3. Ee
ee
4. Ee
Answer
The command ls e* will return all files that begin with "e" regardless of how many characters
follow it.
The command ls e? will return all files that have two characters and start with "e".
The command ls [eE]e will return all file names that start with "E" or "e", are two characters long,
and end with a lowercase "e".
The command ls [!e]? will return all file names that are two characters only and that don't begin
with a lowercase "e".
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
401

2. Using find to search for files
You can use the find command to locate a file when you don't know its exact location on your
file system.
In the syntax, the path specifies the start of the directory hierarchy that's to be searched
recursively.
Syntax
find path -expression filename
The expression can include instructions on what the find command should look for, and
actions that it should perform.
Syntax
find path -expression filename
You can specify different expressions for use with the find command.
-atime


Code
find / -atime 2
-ctime
You use the -ctime option to find files according to their modification time. The command used
in the example will find all files modified in the last two days.

Code
find / -ctime 2
-group
You use the -group option to find files according to their owners. The command used in the
example will find all files owned by the wheel group.

Code
find / -group wheel
-size
402

You use the -size option to find files according to their size. The command used in the example
will find all files whose size is equal to 10 512-byte blocks.

Another example is find / -size 512c, which will find all files 512 bytes in size.

Code
find / -size 10
The most common method of using the find command is to search for files by name, using the
-name option.

For example, you want to find a file named reports. You don't know which directory it's in, but
you want to start the search from your /home directory. To locate this file, you can use this
command.
Code
# find /home -name reports
The command searches all directories, starting at /home, and returns any files named reports.
Code
# find /home -name reports
reports
#
Searching the entire filesystem takes time and system resources, so it's generally a good idea to
restrict the scope of your searches where possible.
Code
# find /home -name "no*"
If you know only part of the filename for the file you want to find, you can use wildcards with the
find command. In this example, the * wildcard is used with the find command to locate files
and directories that begin with "no".
Code
# find /home -name "no*"
The result shows one file that matches the search criteria.
403

Code
# find /home -name "no*"
nomad
#
Question
What additional criteria can defined in conjunction with the find command when used to locate
files?
Options:
1. By the last time they were accessed
2. By the contents of each file
3. By finding the owner
4. By the size of the file
5. By matching characters using the exclamation mark wildcard in square brackets
Answer
Option 1: Correct. You can find files by the last time they were accessed in a specified period. You
use the -atime option to find files according to their access times.
Option 2: Incorrect. You use the find command to locate files by their details, rather than their
content. If you want to search for string patterns within files, you can use the grep or egrep
commands.
Option 3: Correct. You can find all files belonging to a particular owner. You use the -group option
to find files according to their owners.
Option 4: Correct. You can find all files that are of a specified size. You use the -size option to
find files according to their size.
Option 5: Incorrect. You use the exclamation mark wildcard in the square brackets to specify
characters that you don't want to make a match to.
Correct answer(s):
1. By the last time they were accessed
3. By finding the owner
4. By the size of the file
Question
404

You want to look for files on your computer using the find command.

Match each search scenario to the relevant find command.
Options:
A. Lists all files named "application"
B. List all files accessed in the last six days
C. List all files modified in the last six days
D. List all files whose size is equal to 5 512-byte blocks
E. Lists all files starting with "ap"
Targets:
1. #find /home -name application
2. #find / -atime 6
3. #find / -ctime 6
4. #find / -size 5
5. #find /home -name "ap*"
Answer
The name option allows you to search for a file by its exact name. If you are uncertain about the
complete file name, you can include the "*" wildcard.
The atime option allows you to view all the files that have been accessed in the last six days.
The ctime option allows you to view all the files that have been modified in the last six days.
The size option used with the find command will list all files that have a size equivalent to 5 512-
byte blocks.
The name option used here with the asterisk wildcard will list all files that start with the characters
"ap."
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
405

Target 5 = Option E
3. Using grep to search file contents
You can use the grep command together with regular expressions to search the actual contents
of files.

This is the syntax for using the grep command to search for content within local files.
Syntax
grep options regular expression file
You can use these options with the grep command.
-c
You use the -c option to suppress output by printing a count of matching lines for each input file.

The command used in the example will output only the number of occurrences of the word "car"
in the file called file.txt.

Code
grep c car file.txt
-h
You use the -h option to suppress prefixing of filenames on output when searching multiple files.
Using -H prints the filename for each match.

The command used in the example will output all instances of "car" in all files in the /etc directory,
showing only the lines without listing the specific file name.

Code
grep h car /etc
-i
You use the -i option to ignore case distinction in both the pattern and input files.

The command used in the example searches for all instances of "car", regardless of case, such
as car, Car, CAR, or CaR, in the specified file.

Code
grep -i car file.txt
406

-n
You use the -n option when you want to prefix each line of output with the line number within its
input file.

The command used in the example searches for all instances of "car", and displays the line
number for each instance of "car" in the specified file.

Code
grep -n car file.txt
-v
You use the -v option to print nonmatching lines for each input file.

The command used in the example displays only the lines that do not contain the word "car" in
the specified file.

Code
grep -v car file.txt
-w
You can use the -w option with the grep command to search for a specific pattern as a word.

The command used in the example will return "is" as a word within a file as an alternative to
including spaces with the quotes.

Code
grep -w 'is' reports
You can also use the -i option in combination with other options for example -vi. The
command used in this example, will list all the lines that don't contain the "is" pattern, regardless
of case.
Code
grep -vi 'is' reports
Regular expressions can contain either metacharacters and literals, or literals only. For
example, to search a local file called reports for the word "agent", you can use this command.
Code
# grep -i agent reports
407

When executed, the command prints all the lines that contain the word "agent."
Code
# grep -i agent reports
The agents list is still being updated
Sales agents
Health food agents
Agents for vitamin supplements
List by agent
#
Question
You can use the grep command to search the contents of files.

Match each search scenario with the appropriate command.
Options:
A. Search for all instances of the text "sales" in the reports files, regardless of case
B. Search for and display the number of instances of "sales" in the reports file
C. Search for and display the file name of each file that contains the text "sales" in the meeting directory
D. Search for and display the line number of each line that contains "sales" in the reports file
E. Search for and display all the lines that don't contain "sales" in the reports file
Targets:
1. grep -i 'sales' reports
2. grep -c 'sales' reports
3. grep -H 'sales' /meeting
4. grep -n 'sales' reports
5. grep -v 'sales' reports
Answer
You use the -i option to ignore case distinction in both the pattern and input files.
You use the -c option to suppress output by printing a count of matching lines for each input file.
You use the -H option to print the name of each file in the directory that contains an instance of
"sales."
408

You use the -n option when you want to prefix each line of output with the line number within its
input file.
You use the -v option to print nonmatching lines for each input file.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
You can also use the grep command to search for text strings that contain spaces, such as a
whole sentence or phrase.

For example, you decide to use this command to find all instances of the actual word "is" in the
data file.
Code
# grep is reports
However, when you run the command, the result includes all the lines that contain the pattern
"is" even when these patterns are included in other words.
Graphic
All instances of the "is" pattern are specified.
Code
# grep is reports
This product will sell well
Fish oil
Earthfarm is online
The agents list is still being updated
#
409

To ensure that grep only returns instances where "is" occurs as a word, you need a pattern that
includes spaces on either side of the "is" pattern. To prevent the shell stripping out the spaces,
you use quoting.
Syntax
grep 'pattern' filename
Now when you execute the command with the proper syntax, all the lines that contain the word
"is" will be returned.
Graphic
Instances of the word "is" are specified.
Code
# grep ' is ' reports
Earthfarm is online
The agents list is still being updated
#
To search for more than one pattern within a file, you can use the egrep command. It's used in
a similar way to the grep command.
To use the egrep command, you need to separate the patterns with pipe characters and you
need to enclose the entire expression in quotation marks.
Syntax
egrep 'pattern|pattern' filename
You can use this egrep command to search for lines that contain either "agent" or "is" in a file
named reports.
Code
# egrep 'agent|is' reports
The command returns the lines that contain either string in the specified file.
Code
410

# egrep 'agent|is' reports
This product will sell well
Fish oil
Earthfarm is online
Earthfarm product list
The agents list is still being updated
Sales agents
Health food agents
Agents for vitamin supplements
List by agent
#
Question
Which command will allow you to search for all instances of the text "high" and "low" in the Rates
file?
Code
# INSERT THE MISSING CODE
Options:
1. egrep 'high|low' Rates
2. egrep high|low Rates
3. grep 'high|low' Rates
Answer
Option 1: Correct. The command egrep 'high|low' Rates will search for all instances of the
specified text in the Rates file. The egrep command allows you to create a search pattern with
more than one search string.
Option 2: Incorrect. The command egrep high|low Rates will not return the desired results, as
the quotation marks are missing around the search pattern.
Option 3: Incorrect. The grep 'high|low' Rates will not return the desired results, as the
egrep command is required to search for more than one pattern.
Correct answer(s):
1. egrep 'high|low' Rates
411

4. Using regular expressions
Searches conducted by programs such as grep use pattern matching based on regular
expressions.
If a regular expression contains spaces or regular expression metacharacters that are also shell
special characters for example the dollar, asterisk, or dash you should enclose the regular
expression in double quotes. This is to ensure that the metacharacters will be interpreted by the
grep command and not the shell.
There are many regular expression metacharacters.
Dot (.)
The dot matches a single instance of any character except the newline character.

The command used here will search in the specified file for any single character followed by the
"ar" pattern. Some examples are car, far, and bar, but not star.

Code
grep .ar file.txt
Caret (^)
The caret matches the beginning of the line.

The command used here will search for "car" at the beginning of a line in the file called file.txt.

Code
grep '^car' file.txt
Square brackets ([ ])
The square brackets match a single instance of any character within the brackets. It can be used
in a regular expression with the grep command to search for lines that have a certain character
anywhere within the specified term.

The command used here will search for "Car" or "car" in the file called file.txt.

Placing the caret inside square brackets, for example [^1-8], matches any single character except
those within the brackets.

Code
grep [C,c]ar file.txt
Dollar sign ($)
412

The dollar sign in a regular expression matches the end of the line. The search program returns a
match to the specified pattern at the end of the line.

The command used here will search for "car" at the end of a line in the file called file.txt.

Code
grep 'car$' file.txt
Asterisk (*)
The asterisk matches zero or more recurrences of the previous regular expression. However, on
its own, the asterisk does not match anything when used as a regular expression.

The command used here will search for all instances beginning with "car" and ending with zero or
more recurring r characters. Possible output includes car, carr, and carrr.

Code
grep car* file.txt
plus (+)
The plus matches one or more recurrences of the previous regular expression. This needs to be
used together with the egrep command.

The command used here will search for all instances beginning with "car" and ending with one or
more recurring r characters. Possible output includes "carr" and "carrr" but not "car".

Code
egrep car+ file.txt
Question mark (?)
The question mark matches zero or one recurrence of the previous regular expression. This
needs to be used together with the egrep command.

The command used here will search for all instances beginning with "car" and ending with zero or
one recurring r character. Possible output includes "car" and "carr" but not "carrr".

Code
egrep car? file.txt
Backslash (\)
The backslash used in a regular expression removes the special meaning of the next character.
Sometimes you need to create a regular expression that matches a special character, such as
the asterisk or question mark. To escape metacharacters that is, to use the special character as
a literal you precede the metacharacter with a backslash.

413

Even though a dollar sign normally means the end of a line, by using the backslash in this
command, grep will search for an instance of the dollar sign character instead.

Code
grep \$ [123456789]* file.txt
You can search for lines that begin or end with a certain pattern by using the caret and dollar
sign special characters.
Code
# grep '^Calcium' reports
For example, to search a file for a line that begins with a certain pattern in this case, "Calcium"
in the reports file, you can use this command.
Code
# grep '^Calcium' reports
The command returns lines that begin with "Calcium."
Code
# grep '^Calcium' reports
Calcium deficiency
Calcium supplement
#
Question
You are searching for some data in the agenda.doc file using metacharacters.

Match each search scenario with the relevant command.
Options:
A. Returns all six letter words that end with the "eport" pattern
B. Returns values such as "reportt' and "report" but not "reporttt"
C. Returns all instances of the "report" pattern
D. Returns values such as "reportt' and "reporttt" but not "report"
Targets:
414

1. grep .eport agenda.doc
2. egrep report? agenda.doc
3. grep report* file.txt
4. egrep report+ agenda.doc
Answer
This command will match the pattern and return every six letter word that ends with "eport". The dot
indicates a single instance of a character, except for the newline character.
This command will return every instance that starts with report and have zero or one recurring t
characters. The question mark is used with the egrep command and matches zero or one
recurrence of the previous regular expression.
This command will return every instance that starts with report and ends with zero or more recurring
t characters. The asterisk matches all recurrences of the previous regular expression, or no
occurrence of the expression.
This command will return every instance that starts with report and ends with one or more recurring t
characters. The plus sign is used with the egrep command and matches one or more recurrences
of the previous regular expression.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Question
You can use grep with metacharacters to search for certain patterns in the file agenda document.

Match each desired search result with the appropriate command.
Options:
A. Searches for all lines that end with "report"
B. Searches for all instances of "report" or "Report"
C. Searches for all lines that start with "report"
D. Searches for all lines that contain the "*report" pattern
415

Targets:
1. grep 'report$' agenda.doc
2. grep [r,R]eport agenda.doc
3. grep '^report' agenda.doc
4. grep \*report file.txt
Answer
This command will return all lines that end with the pattern report. The dollar sign is used to specify
a match to the end of the line.
This command will return all instances of "report" or "Report." Square brackets are used to list the
specific characters being searched for.
This command will return all lines that start with "report". The caret is used to specify a match to the
start of the line.
The command will return all instances of "*report" in the file. The backslash is used to remove the
special meaning of the asterisk character.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Summary
You can use shell wildcards such as the exclamation mark, question mark, asterisk, and square
brackets to construct patterns when you are searching for files. Wildcards can be used with
commands such as ls, rm, and ps.

You can use the find utility to locate files on your computer. This command can be used with
wildcards and with expressions such as atime, ctime, size, name, and group to find files.

The grep command is used to search the contents of a file for a specified pattern. There are
many options for constructing a pattern to match data in your files. You can use the egrep
command to search a data file for more than one pattern at a time.

You can also use regular expressions with grep to make better matches to patterns. In addition,
416

you can use regular expression metacharacters such as the caret, asterisk, and question mark
to perform similar functions to shell wildcards.






















417

Working with UNIX directories
Learning Objectives
After completing this topic, you should be able to
create and delete directories
copy and move files and directories
archive directories
1. Creating and deleting directories
When you work with directories, it's important to remember that directories are themselves a
type of file. They're never very large, however, because they contain only information about their
immediate contents or children.
Code
# ls -l
total 10
-r--r--r-- 1 samo wheel 0 Dec 12 08:44 data#3
-rwxrw-rw- 1 samo wheel 173 Dec 4 13:56 en_figures
drwxr xr x 2 samo wheel 512 Dec 10 07:20 myfiles
-rwx------ 1 samo wheel 0 Nov 29 12:29 nfsreport
-rw-r--r-- 1 samo wheel 559 Nov 29 09:38 nomad
-rwxrw---- 1 samo wheel 2 Jul 14 2000 prcfile
-----w--w- 1 samo wheel 0 Dec 4 11:05 psbook.ps
-rw-r--r-- 1 samo wheel 0 Dec 4 14:06 sales
-rw-r--r-- 1 samo wheel 512 Dec 4 14:09 sales1
#
In this sample listing, there's a directory named myfiles. It's differentiated from the other files by
a d that precedes its permissions.
You can use this syntax to create a directory, using the mkdir command.
Syntax
mkdir options pathname
The mkdir command supports these options.
-m
418

You use the -m option to specify permissions on the new directory. You can only specify these
permissions in the chmod command's numerical format, where the value of execute is 1, the
value of write is 2, and the value of read is 4.

In this example, a directory called dirname is created, with read and write access for 1. Owner
and 2. Group, and read-only access for 3. Others.

Even though the value 6 is not explicitly listed in the chmod numerical format, it's a combination
of write (2) + read (4) = read and write (6).

Code
mkdir -m 664 dirname
-p
You use the -p option to create any necessary parent directories without generating errors. This
means you could create a directory called /files/data even if the /files directory didn't
exist.

In this example, the directories usr, dir1, dir2, and dir3 are created within each other. In other
words, dir3 is in dir2, dir2 is in dir1, and dir1 is in usr.

If any of the directories already exist, in this case usr already would, an error would be returned
that can be ignored.

Code
mkdir -p /usr/dir1/dir2/dir3
-v
You use the -v option to get verbose output a diagnostic report for every directory processed
from the mkdir command.

In this example, a directory named newdir is created and provides verbose feedback from the
shell.

Code
mkdir -v newdir
Question
You are creating some new directories using the mkdir command.

Match each scenario with its corresponding command.
Options:
419

A. You want to create a directory named new_files, with read and write access for 1. Owner,
and read-only access for 2. Group and 3. Others
B. You want to create the directories new_files, test1, and test2 within each other
C. You want to create a directory named new_files and get a diagnostic report on it
Targets:
1. mkdir -m 644 new_files
2. mkdir -p /new_files/test1/test2
3. mkdir -v new_files
Answer
You use the -m option to specify permissions for a new directory. The permissions are assigned
using the chmod numerical format.
You use the -p option to create any required parent directories without generating any errors. This
means that you can create a child directory even if the parent directory doesn't already exist.
You use the -v option to create a new directory and also get verbose information back about the
directory.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
You can use this syntax to remove a directory, using the rmdir command.
Syntax
rmdir options pathname
If the directory still has files in it, you should run the command with the --ignore-fail-on-
non-empty option. This forces the command to delete the directory anyway, and you lose the
files it contained.
And you can specify the -p option to remove the specified directory's parents. If you don't use
this option, the files in the directories will be removed but the actual directories will still remain.
420

You can also remove directories using the rm command. Generally the rm command is used to
remove specific files, but if you specify the -R option, the command recursively removes the
contents of a specified directory including any subdirectories it may contain.
Code
# rm -R myproject
#
Using rm -R is very effective but also very dangerous, as the command can't be reversed once
it's executed.
Even though UNIX is case sensitive, in certain instances lowercase and uppercase commands
are explicitly mapped.

In this case, rm -r and rm -R will accomplish the same task.
Code
# rm -r myproject
#
Question
You want to delete some unwanted directories on your computer.

Match each scenario to the command you would use.
Options:
A. You want to remove the test1 directory and any subdirectories and files it may contain
B. You want to remove the test1 directory and any parent directories
C. You want to remove the test1 directory even if it still contains files
Targets:
1. rm -R test1
2. rmdir -p new_files/test1
3. rmdir --ignore-fail-on-non-empty test1
Answer
You use rm -R to recursively remove the directory and all of its contents, including any
subdirectories and other files. This command can't be reversed once it is executed.
421

The -p option allows you to remove the specified directory and any parents it has at the same time.
This will prevent a build up of empty directories on your computer.
The --ignore-fail-on-non-empty option forces a directory to be removed even if it still
contains any files.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
2. Copying and moving files and directories
You can copy and move files and directories around your UNIX system very easily. It's also
possible to copy files to other storage media such as flash disks and external hard drives.
Being able to copy files to other media allows you to easily transport files between different
computer systems.
You can use this syntax to copy a file, using the cp command.
Syntax
cp options source_file|source_dir target
The cp command supports these options.
-f
You use the -f option to force the copy operation, even if it means overwriting existing files. You
won't be prompted for confirmation.

In this example, the file filename.txt will be copied from the current directory to the directory
/usr/bin.
-i
You use the -i option to run the copy operation in interactive mode. In interactive mode, you
have to confirm every copy and every overwrite.

This can be tedious with large copy jobs, but it's safest.

In this example, every file in the current directory will be copied to the /home/files directory.
However, you'll be asked to confirm every copy or overwrite.
422

-p
You use the -p option to run the copy operation in preserve mode. In preserve mode, UNIX tries
to keep as much file information consistent as possible between copies and originals, such as
group IDs, file flags, and modification times.

In this example, all files in the current directory will be copied to the /home/files directory, along
with any file information that can be retrieved.
UNIX supports the asterisk wildcard character, which is useful when you want to copy a group of
files with similar filenames. You can use the asterisk with a string to specify all files that contain
the string.
Code
#
This command will copy all files beginning with "my" to the newfiles directory.
Code
# cp my* newfiles
In this example, all the files that end in .txt will be copied to the newfiles directory.
Code
# cp *.txt newfiles
You can also surround a string with asterisks. The string *e1* would copy all files that contain
"e1" somewhere in their names to the newfiles directory.
Code
# cp *e1* newfiles
UNIX also supports the question mark wildcard character, which is useful when you want to
copy a group of files with names differentiated by one character.
Code
# cp data0? newfiles
423

It's particularly useful for files with numerically incremental filenames. For example, data0?
would copy data01 through data09, if they existed, to the newfiles directory.
Code
# cp data0? newfiles
Question
You're working with the cp command.

Match each scenario to the relevant command.
Options:
A. You want to copy all files that contain the word "at" to the new_files directory
B. You want to copy all the files that begin with "at" to the newfiles directory
C. You want to force the copy operation so that the test1 file will be copied to the newfiles directory even if
the name already exists
Targets:
1. cp *at* newfiles
2. cp at* newfiles
3. cp -f test1 newfiles
Answer
By enclosing the "at" string with asterisks, all files that contain the string will be copied.
This command uses the asterisk wildcard to indicate all files that begin with "at" but can have any
other characters in its name. So all files that start with "at" will be copied.
The -f option will force a file to be copied to a new location even if an existing file has that name in
the destination directory.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
424

Question
You're working with the cp command.

Match each scenario to the relevant command.
Options:
A. You want to copy all files in the current directory to the newfiles directory, but want to confirm
every operation
B. You want to copy all the files in the current directory to the newfiles directory, while also preserving the
file information
C. You want to copy all the files in sequence from test11 to test19 to the newfiles directory
Targets:
1. cp -i * newfiles
2. cp -p * newfiles
3. cp test1? newfiles
Answer
The -i option allows you to confirm every copy operation that is taking place. It is the slowest copy
method but it is the safest.
The -p option is used to copy files in preserve mode so that files can be copied with as much
information as possible.
By using the question mark wildcard, you can specify a range of files that has only a single
character difference in the file name. So, in this case, test11 to test19 will be copied.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
You can use the mv command to move files and directories from one location to another. This is
the syntax.
Syntax
mv options source_file | source_dir target
425

The mv command uses the same -f and -i options as the cp command.

For example, the file filename.txt is being moved from the current directory to the tmp directory.
By using the -f flag, you force Unix to move the file without any confirmations, even if a file with
the same name already exists in the tmp directory.
Code
# mv -f filename.txt /tmp


In this example, all the files from the current directory will be moved to the path /home/files.
The -i option means that you'll have to confirm every operation that occurs.
Code
# mv -i * /home/files
You use the mv command to move files, and you use the asterisk wildcard to select groups of
files with similar names. In this example, all the files that end in .conf will be moved to the
myfiles directory.
Code
# mv *.conf myfiles
A better way to move the contents of an entire directory is to use the mvdir command.
Syntax
mvdir source_dir target_dir
While mv is typically used for moving files, mvdir is specifically for moving directories. It's a
privileged command, and typically only the root user may use it.
Syntax
mvdir source_dir target_dir
When using mvdir, if the directory newname doesn't exist, a new directory called newname will
be created.
426


If newname already exists, the entire contents of oldname will be moved into newname.
Code
# mvdir oldname newname
Question
You're moving some files around on your computer.

Match each situation to the relevant command.
Options:
A. You want to move the entire contents of myfolder to newfolder
B. You want to move file1.txt to the myfolder directory without any confirmations or warnings
C. You want to move file1.txt to the myfolder directory with a prompt for any warnings or errors
D. You want to move all files that end with .txt to myfolder
Targets:
1. mvdir myfolder newfolder
2. mv -f file1.txt /myfolder
3. mv -i file1.txt /myfolder
4. mv *.txt /myfolder
Answer
The contents of myfolder will be moved to newfolder if it exists already. If newfolder doesn't exist,
myfolder will be renamed newfolder.
The -f option will force the file to be moved to the new destination and will overwrite any file with
the same name without any warning.
The -i option will move the file to the new destination but will ask for a confirmation if the file name
is already in use.
The asterisk wildcard used here allows you to select a group of files to copy that have similar
names. So all the files that end in .txt will be copied to myfolder.
Correct answer(s):
Target 1 = Option A
427

Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
3. Archiving directories
You may find that in certain instances, you need to create archives of files and directories on
your computer. This is useful when you need to create backup copies of files or if you want to
copy any data to an external storage device.
You can use this syntax to create archives, called tarfiles, by using the tar command.

The tar command can create archives, update their contents, and extract files from them.
Syntax
tar -arguments archivename filename1 filename2
The name tar is an abbreviation of tape archiver, from a time when the only practical way to
back up data was to a tape drive.
The command still tries to write to a tape drive at /dev/sa0 by default, but it now includes the -
f option, which lets you specify a file instead.

For example, this code creates an archive in a file called myarchive.tar. Similar to most UNIX
commands, the -v option causes verbose output, allowing you to track the command's
operation.
Code
# tar -cvf myarchive.tar *
file1
file2
file3
#
The tar command needs to use one of these arguments to run. The -f flag is used in all the
commands to indicate to tar that the name of the file will follow.
-A
You use -A to append the contents of a tarfile to the end of another. You should note that the
source tarfile doesn't become an element of the target tarfile only its contents move.
428


In this example, the contents of archive2.tar will be added at the end of archive1.tar.

Code
tar -Af archive1.tar archive2.tar
-c
You use -c to create a new tarfile and write files to it.

In this example, an archive called archive1.tar is created, which will contain all the files from the
files directory.

Code
tar -cf archive1.tar /files
-d
You use -d to ascertain the difference between files in a tarfile and the matching data structure
still on disk.

In this example, the contents of archive1.tar is compared to the files directory and all the
differences between the two will be listed.

Code
tar -df archive1.tar /files
-r
You use -r to append files to the end of an existing tarfile.

In this example, the file newfile.txt is added to the archive1.tar tarfile.

Code
tar -rf archive1.tar newfile.txt
-t
You use -t to list the entire contents of a tarfile. If you specify a filename argument with t, tar
lists only those files you're looking for.

In this example, the entire contents of the archive1.tar file will be listed.

Code
tar -tf archive1.tar
-u
429

You use -u to update the contents of a tarfile if the files it's based on have been modified since
the tarfile was created.

In this example, the file archive1.tar will be updated with the contents of the files directory, only if
the contents of the directory has changed.

Code
tar -uf archive1.tar /files
-x
You use -x to extract all of the files from a tarfile. If you specify a filename argument with -x, tar
extracts only those files you're looking for.

In this example, all the files in archive1.tar will be extracted to the files directory.

Code
tar -xf archive1.tar /files
When you extract files from an archive, you often use wildcards to extract only certain files.
When you pass a search string that contains a wildcard to the tar command, you need to
enclose it in single quotes.
This is because the shell program will parse the command and try to extrapolate the wildcard
itself, converting it into a result before passing it to the tar command's program. Using single
quotes prevents this behavior.
The code in this example shows a successful extraction using wildcards.
Code
# tar -xvf myarchive.tar 'file?'
file1
file2
file3
#
You can compress archive files to make them
smaller to store
quicker to download, and
easier to copy to external devices
430

You can compress the contents of an archive by passing a compression option to the tar
command.
-y
You use the -y option to filter the archive through the bzip2 command.

In this example, a compressed archive is created from the files directory using bzip2.

Code
tar -cyf archive1.tar /files
-z
You use the -z option to filter the archive through the gzip command.

In this example, a compressed archive is created from the files directory using gzip.

Code
tar -czf archive1.tar /files
-Z
You use the -Z option to filter the archive through the compress command.

In this example, a compressed archive is created from the files directory using compress.

Code
tar -cZf archive1.tar /files
Question
You're creating tarfile archives.

Match each scenario with the required command.
Options:
A. You want to add the contents of old_archive.tar to the end of new_archive.tar
B. You want to create the newarchive.tar file that contains all the files from the oldfiles directory
C. You want to check if there are any differences between the newarchive.tar file you've created and the
oldfiles directory on your computer
D. You want to add the file update.txt to the end of the newarchive.tar file
Targets:
1. tar -Af old_archive.tar new_archive.tar
431

2. tar -cf newarchive.tar /oldfiles
3. tar -df newarchive.tar /oldfiles
4. tar -rf newarchive.tar update.txt
Answer
You use -A to add the contents of a tarfile at the end of another. However, only the contents are
moved. The original tarfile still remains.
You use -c to create a new tarfile and write files to it.
You use -d to ascertain the difference between files in a tarfile and the matching data structure still
on disk.
You use -r to add files to the end of an existing tarfile.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Question
Complete the command below to create a tarfile using gzip compression.
Code
# tar INSERT THE MISSING CODE myarchive.tar *

Answer
You use c to create the archive, and z to use gzip compression. The f option is always necessary
when you aren't using a tape drive.
Correct answer(s):
1. -czf
432

Summary
Directories are a type of file, however they're normally very small as they generally only contain
information about their contents. You can create new directories using the mkdir command and
you can delete directories using the rmdir command.

You can copy and move files and directories around your computer system. You can also copy
them to other devices to enable transport and content sharing. To copy files, you use the cp
command. And to move files, you can use the mv command. You move directories using the
mvdir command.

You may need to create archive copies of data in order to make a backup copy or just to copy it
to a new location. You use the tar command to archive files and you can also compress
archive files using gzip or bzip2.















433

Searching and Organizing a UNIX File System
Learning Objectives
After completing this topic, you should be able to
find files in the Unix file system
create and archive directories
Exercise overview
In this exercise, you are required to answer questions relating to searching and organizing a
UNIX file system.
This involves the following tasks:
finding files in UNIX, and
creating and archiving directories
Finding files in UNIX
You're searching your computer for files that match specific patterns and also for specific
patterns inside files.
Question
The myfiles directory on your computer contains six files Doc1, doc, Doc, doc21, do, and DO. You
are using shell wildcards to search for files which contain specific text strings.

Match each search string to its expected output.
Options:
A. ls D*
B. ls d?
C. ls [Dd]oc
D. ls [!d]?
E. ls *
Targets:
1. Doc1
Doc
DO
2. do
434

3. Doc
doc
4. Do
5. Doc1 doc Doc
doc21 do DO
Answer
The command ls D* will return all files that begin with uppercase D, no matter how many
characters follow it.
The command ls d? will return all files that have two characters and start with lowercase d.
The command ls [Dd]oc will return all file names that start with lowercase or uppercase D, are
three characters long and end with a lowercase oc.
The command ls [!d]? will return all file names that are two characters only but don't begin with a
lowercase d.
The command ls * will return all the files in the myfiles directory.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
Question
You're using metacharacters to search the meetings.doc file on your computer.

Match each search result to the appropriate command.
Options:
A. Returns all five letter words that end with the "lose" pattern
B. Returns values such as "closee' and "close" but not "closeee"
C. Returns all instances of the "close" pattern
D. Returns values such as "closee' and "closeee" but not "close"
435

Targets:
1. grep .lose meeting.doc
2. egrep close? agenda.doc
3. grep close* file.txt
4. egrep close+ agenda.doc
Answer
This command will match the pattern and return every five-letter word that ends with "lose". The dot
indicates a single instance of any character, except for the newline character.
This command will return every instance that starts with "close" and have zero or one recurring e
characters. The question mark is used with the egrep command and matches zero or one
recurrence of the preceding regular expression.
This command will return every instance that starts with "close" and ends with zero or more
recurring e characters. The asterisk matches all recurrences of the previous regular expression, or
no occurrence of the expression.
This command will return every instance that starts with "close" and ends with one or more recurring
e characters. The plus is used with the egrep command and matches one or more recurrences of
the previous regular expression.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Question
You're using grep with metacharacters to search for patterns in the file meetings.doc.

Match each desired search result to the relevant command.
Options:
A. All lines that end with "staff"
B. All instances of "staff" or "Staff"
C. All lines that start with "Staff"
436

D. All lines that contain the "*staff" pattern
Targets:
1. grep 'staff$' meetings.doc
2. grep '[S,s]taff' meetings.doc
3. grep '^Staff' meetings.doc
4. grep '\*staff' meetings.doc
Answer
This command will return all lines that end with the pattern "staff". The dollar sign is used to specify
a match to the end of the line.
This command will return all instances of "staff" or "Staff." Square brackets are used to list the
specific characters being searched for.
This command will return all lines that start with "Staff". The caret is used to specify a match to the
start of the line.
The command will return all instances of "*staff" in the file. The backslash is used to remove the
special meaning of the asterisk character.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Question
You're using the grep command to search the meetings file on your computer.

Match each search scenario with the appropriate command.
Options:
A. Find all instances of the text "target" in the meetings files, regardless of case
B. Find and display the number of instances of "target" in the meetings file
C. Find and display all the lines that don't contain "target" in the meetings file
D. Find and display each line of each file in the July directory that contains the text "target"
437

E. Find and display the file name of each file that contains the text "target" in the July directory
Targets:
1. grep -i 'target' meetings
2. grep -c 'target' meetings
3. grep -v 'target' meetings
4. grep -h 'target' /July
5. grep -H 'target' /July
Answer
You use the -i option to ignore case distinction in both the pattern and input files.
You use the -c option to suppress output by printing a count of matching lines for each input file.
You use the -v option to print nonmatching lines for each input file.
You use the -h option to print each line of each file in the directory that contains an instance of
"target."
You use the -H option to print the name of each file in the directory that contains an instance of
"target."
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
Question
Select the command you use to find all the lines that don't match the "target" pattern in the meetings
file.
Options:
1. grep -v 'target' meetings
2. grep -H 'target' meetings
438

3. grep -i 'target' meetings
4. grep -w 'target' meetings
Answer
Option 1: Correct. You can use the -v option to search for lines that don't contain a specified
pattern.
Option 2: Incorrect. You need to use the -v option to search for lines that don't match the pattern.
You use the -H option to print the name of each file in the directory that contains an instance of
"target."
Option 3: Incorrect. You need to use the -v option to search for lines that don't match the pattern.
You can use the -i option to disable case sensitivity. In this way, the search command you issue
returns all matching output regardless of case.
Option 4: Incorrect. You need to use the -v option to search for lines that don't match the pattern.
You can use the -w option with the grep command to search for a specific pattern as a word.
Correct answer(s):
1. grep -v 'target' meetings
Question
You are examining some files on your computer using the find command.

Match each search option to the relevant find command.
Options:
A. Find all files named "meeting"
B. Find all files accessed in the last three days
C. Find all files modified in the last three days
D. Find all files whose size is equal to 3 512-byte blocks
E. Find all files starting with "me"
F. Find all files that have a size of 3 bytes
Targets:
1. #find /home -name meeting
2. #find / -atime 3
3. #find / -ctime 3
4. #find / -size 3
439

5. #find /home -name "me*"
6. #find / -size 3c
Answer
The name option allows you to search for a file by its exact name. If you are uncertain about the
complete file name, you can include the asterisk wildcard.
The atime option allows you to view all the files that have been accessed in the last three days.
The ctime option allows you to view all the files that have been modified in the last three days.
The size option used with the find command will list all files that have a size equivalent to 3 512-
byte blocks.
The name option used here with the "asterisk wildcard will list all files that start with the characters
"me".
The size option used here will list all files that have a size of 3 bytes.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
Target 6 = Option F
Creating and archiving directories
You want to create a directory and then archive it.
Question
You want to create a new directory using the mkdir command.

Match each scenario with the relevant command.
Options:
440

A. Create a directory named mywork, with read and write access for Owner and Group, and read-only
access for Others
B. Create the directories mywork, 2012, and March within each other
C. Create a directory named mywork and get a diagnostic report on it
Targets:
1. mkdir -m 664 mywork
2. mkdir -p /mywork/2012/March
3. mkdir -v mywork
Answer
You use the -m option to specify permissions for a new directory. The permissions are assigned
using the chmod numerical format. In this case "6" indicates read and write access and "4" indicates
read access only.
You use the -p option to create any required parent directories without generating any errors. This
means that you can create a child directory even if the parent directory doesn't already exist. if any
of the directories exist, any errors generated can be ignored.
You use the -v option to create a new directory and also get a diagnostic report about it as it is
being processed.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Question
You are creating tarfile archives.

Match each scenario to the command you use.
Options:
A. Add the contents of oldwork.tar to the end of mywork.tar
B. Create the myworkarchive.tar file that contains all the files from the mywork directory
C. Compare the myworkarchive.tar file you have created and the mywork directory on your computer
D. Add the file sales.xls to the end of the myworkarchive.tar file
441

Targets:
1. tar -Af oldwork.tar mywork.tar
2. tar -cf myworkarchive.tar /mywork
3. tar -df myworkarchive.tar /mywork
4. tar -rf myworkarchive.tar sales.xls
Answer
You use -A to add the contents of a tarfile at the end of another. However, only the contents is
moved, the original tarfile still remains.
You use -c to create a new tarfile and write files to it.
You use -d to ascertain the difference between files in a tarfile and the matching data structure still
on disk.
You use -r to add files to the end of an existing tarfile.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Question
You want to compress the myworkarchive tarfile using gzip.

Complete the command to do this.
Code
# tar INSERT THE MISSING CODE myworkarchive.tar *

Answer
This command will compress the myworkarchive tarfile. You use c to create the archive, and z to
use gzip compression. The f option is always necessary when you aren't using a tape drive.
442

Correct answer(s):
1. -czf
Files have been searched for in Unix, and directories have been created and archived .




















443

Introduction to Windows 7
Learning Objectives
After completing this topic, you should be able to
recognize how to log on to Windows 7
identify the benefits of Windows 7
1. Introduction to Windows 7
Windows 7 is the latest version of Microsoft's Windows operating system. The main focus in this
new edition are improvements to security, performance, and usability.
Among the new and updated features are
Windows desktop
The Windows desktop provides improved navigation, which enables you to work more easily and
efficiently. For example, you can view thumbnail previews of any open windows, by mousing over
the taskbar, or you can use jump lists to easily locate recent documents and files related to
applications.
HomeGroup
HomeGroup enables you to quickly and easily create a home network in order to connect your
computer to a printer, or share media such as music and videos with other Windows 7 computers.
Windows Search, and
Windows Search enables you to quickly find documents on your computer. You are also able to
locate and run programs more quickly, using the integrated search function in the Start menu.
Windows Media Center
Windows Media Center enables you to watch, pause, rewind, and record television on your
computer. You are also able to play media files in many different formats, for example MPEG-1
Audio Layer 3 (MP3), Windows Media Video (WMV), or Windows Media Audio (WMA).
To ensure that the features function optimally, Windows 7 supports various hardware
improvements such as improved memory handling, and optimization for multi-core processors.
Windows 7 can be installed on a 32-bit or 64-bit system. These are the recommended minimum
requirements for each type of installation.
32-bit system
A 32-bit system installation requires a 1 GHz processor, 1 GB of RAM, 16 GB of available disk
space, and a DirectX 9 graphics device with Windows Display Driver Model, or WDDM, 1.0 or
higher driver.
444

64-bit system
A 64-bit system installation requires a 1 GHz processor, 2 GB of RAM, 20 GB of available disk
space, and a DirectX 9 graphics device with Windows Display Driver Model, or WDDM, 1.0 or
higher driver.
The 64-bit version of Windows 7 can utilize larger RAM sizes than the 32-bit version. The 32-bit
version cannot use more than 4GB. 32-bit programs will still work on the 64-bit version of
Windows 7.

64-bit versions of Windows 7 may perform better than 32-bit versions if more than 4GB of RAM
is available, and lots of programs are running simultaneously.
You can also choose a particular edition of Windows 7 to suit your requirements. These include
Starter
The Windows 7 Starter edition offers basic Windows 7 functionality, such as desktop
enhancements and Windows Search.

However, the Starter edition does not include the Aero theme, and is available in 32-bit only.
Home Premium
The Windows 7 Home Premium edition is useful if you are interested in a home system that
provides increased entertainment features.

For example, the Home Premium edition enables you to easily share photographs, videos, and
music with people.
Professional, and
The Windows 7 Professional edition includes all the features of Home Premium and includes
business features such as backup and restore, and joining a domain.
Ultimate
The Windows 7 Ultimate edition combines all features included in the various Windows 7 editions.
This edition includes support for BitLocker drive encryption.
Supplement
Selecting the link title opens the resource in a new browser window.
Job Aid
Access the job aid Windows 7 Editions to view a list of the features provided in some of the
Windows 7 editions.
Question
445

Which edition of Windows 7 includes support for BitLocker?
Options:
1. Starter
2. Home Premium
3. Professional
4. Ultimate
Answer
Option 1: Incorrect. The Windows 7 Starter edition offers basic Windows 7 functionality, such as
desktop enhancements and Windows Search. The Starter edition does not support BitLocker.
Option 2: Incorrect. The Windows 7 Home Premium edition is useful if you are interested in a home
system that provides increased entertainment features. The Home Premium edition does not
support BitLocker.
Option 3: Incorrect. The Windows 7 Professional edition includes all the features of Home Premium
and includes business features such as backup and restore, and joining a domain. The Professional
edition does not support BitLocker.
Option 4: Correct. The Windows 7 Ultimate edition combines all features included in the various
Windows 7 editions. This edition includes support for BitLocker drive encryption.
Correct answer(s):
4. Ultimate
2. Logging on to Windows 7
Before you can access a Windows 7 desktop you need to log on to the computer. If there is only
1 user, and no password is set for that user, then Windows will log you on automatically.

However, if a computer has multiple user accounts, you will be required to log on at each
startup.
How you log on depends on what type of user you are and the account you have:
local user or
As a local user, you only have access to the computer you're currently logged on to. So you can't
use your local user account to access multiple computers or computers and groups that are part
of a domain.
An example of a local user is Jennifer Westlein.
446

domain user
If you log on to a computer as a member of a domain, you have access to resources such as
printers and files that are shared on other computers logged on to the same domain.
An example of a domain username is quick24x7\Jennifer Westlein.
At startup, Windows 7 displays a logon screen, which displays a list of all computer accounts.

Computers can either have multiple user accounts or a single account. If only one account is
available, the logon screen will prompt you to enter a password immediately.
Graphic
The logon screen displays two user accounts: Jennifer Westlein and Jonathan Gold. A shut down
button is also available in the lower right-hand corner of the logon screen.
In this case, the computer has multiple accounts, so you select the desired account by clicking
the account name.
Graphic
The account that's selected belongs to Jennifer Westlein.
You enter the account password, before clicking the logon arrow.
Graphic
The logon arrow is located next to the password field.
The logon is successful and the Windows 7 desktop displays.
Once you're logged on to a Windows 7 system you can change users by simply logging off the
current account and logging on to a new one.

To do this, you access the Start menu and click the arrow located next to the Shut down
button.
Graphic
Options in the Shut down menu are Switch user, Log off, Lock, Restart, Sleep, and Hibernate.
From the Shut down menu you can select a variety of options.
Switch user
447

The Switch user option enables you to change user accounts, without ending the current user's
session.

For example, if a user switches accounts without closing a document in Microsoft Word, the
current user will be able to log on to the account again and resume work without having to reopen
the document.
Log off
The Log off option ensures that all open applications are closed and the current user's session is
ended.
Lock
The Lock option enables you to secure the computer so that only an account owner, who has a
valid username and password, can access the system.
Restart
The Restart option enables you to close all programs before shutting down the computer and
then starting up again.

This option is generally used if you've installed an application, for example, and you need to start
Windows again to activate the new settings.
Sleep
The Sleep option enables you to place the computer in a low-power state, while ensuring that all
open applications aren't closed.

You can use this option if you intend being away from the computer for a while and want to
conserve energy, while still maintaining a working session.
Hibernate
The Hibernate option enables you to switch off the computer, while maintaining your current
session. It's similar to the Sleep option, however the Hibernate setting saves data from RAM to
your local hard drive, then powers off the computer.
You want to switch users so you select the Switch user option.
And you select Jonathan Gold's account from the log on screen.

Because you haven't logged Jennifer Westlein off her account, it reflects a logged on status.
Finally, you proceed with the logon by entering the password in the required field.
Graphic
448

The logon screen for Jonathan Gold displays. The password has been entered and logon arrow is
selected. A Switch User button is available.
If you type in the wrong password the logon fails and you are prompted to click OK to try again.
Graphic
A message displays stating that the username or password is incorrect. An OK button displays
below the message.
Windows provides you with a password hint, which you would have specified when you created
your user account.

Using this hint, you enter the correct password and then click the logon arrow to complete the
logon process.
Graphic
Jonathan Gold's account logon page opens. The password hint "What is my favorite animal?"
displays below the password field. There is also an option to reset the password.
And the desktop displays.
Try It
Now you try logging on to Jonathan Gold's Windows 7 local user account. The account password is
"elephant."
The logon screen displays with two accounts: Jennifer Westlein and Jonathan Gold.
To complete the task
1. Click Jonathan Gold
Jonathan Gold's logon screen displays.
2. Type elephant in the password field and click the logon arrow
Type the password in lowercase.

The desktop is displayed.
Jonathan Gold's account has been accessed.
To log on to a computer as a member of a domain, you first need to access the domain logon
page by pressing Ctrl+Alt+Delete.
449

Graphic
The logon page displays with the message Press CTRL + ALT + DELETE to log on.
By default, Windows 7 recalls the last domain account logged on to the system. This account is
specified using the domain\username or Computer\username format.

If you want to log on to the current domain account, you enter the account password and click
the logon arrow.
Graphic
The domain logon screen displays quick24x7\administrator. A password field is available as well as
a Switch User button.
In this case, you want to switch domain user accounts so you click Other User, before selecting
the option to log on to another domain account.
Graphic
The Other User account is selected.
You specify the domain logon details before clicking the logon arrow.
Graphic
The domain account specified is quick24x7\Jennifer Westlein. A message displays below the
password field that reads "Log on to: quick24x7." There is also an option that enables you to learn
how to log on to another domain.
The logon is successful and the Windows 7 desktop displays.
Question
Sequence the steps that enable you to log on to Jennifer Westlein's account, which is part of the
quick24x7 domain. The currently logged-on domain account belongs to Jonathan Gold.
Options:
A. Switch users
B. Select the required domain account
C. Enter the logon details in the relevant text box
450

Answer
Correct answer(s):
Switch users is ranked the first step.
Since the logon screen is currently displaying Jonathan Gold's details, you first need to switch
user accounts, before specifying Jennifer Westlein's logon details.
Select the required domain account is ranked the second step.
After you switch users, you are able to select the required domain account from the list of
available accounts on the logon screen.
Enter the logon details in the relevant text box is ranked the third step.
After you select the required account, you need to specify the account details by entering the
domain, username, and password.
Summary
Windows 7 offers you various benefits, for example an enhanced interface and better use of
multi-core processors. Windows 7 can be installed on a 32-bit or 64-bit system. It is available in
four editions Starter, Home Premium, Professional, and Ultimate.

You can log on to Windows 7 systems as either a local user or domain user. You can log on
during start up or you can switch user accounts from the desktop Start menu.











451

The Windows 7 Desktop
Learning Objectives
After completing this topic, you should be able to
recognize the main features of the Windows 7 desktop
recognize how you can use desktop features to manage open windows
1. Windows 7 desktop features
The Windows 7 desktop is similar to other versions of Windows. Familiarity with the Windows
environment will ease the transition to Windows 7, but there are some key changes.
Common to all versions of Windows, the desktop displays a taskbar at the bottom of the screen.
This area enables you to move between open applications, preview open files and folders, and
launch other applications on the computer.
Graphic
The taskbar shows two open applications: Notepad and Windows Media Player.
The Windows 7 taskbar contains various elements.
Graphic
The Windows 7 desktop is displayed.
start button
You can use the Start button to access the Start menu, which enables you to launch the
programs and open files available on the computer. You can also access system settings from
this menu.
Options in the Start menu include an All Programs link, a list of applications pinned to the Start
menu, such as XPS Viewer, and Notepad, and options like Control Panel, and Help and Support.
taskbar
The taskbar contains all applications and files that are currently in use. It's useful as you can see
which items are open, as well as easily switch between them.

In Windows 7 you can pin applications to the taskbar so they're available even when they're not in
use. By default, the Windows 7 taskbar has three applications pinned to it: Internet Explorer 8,
Windows Explorer, and Windows Media Player.

452

Applications that are running are surrounded by a rectangular border, which differentiates them
from pinned applications.
notification area
The notification area is located on the bottom right-hand side of the screen and contains the
system clock as well as icons of processes that monitor the status of the computer.

By default, only four icons display in this area in Windows 7: Action Center, Battery - for
notebooks - Network, and Volume. If you install new applications the icons are automatically
hidden by default in the tray area, which reduces clutter.

In addition, the notification area contains a Show desktop shortcut, which you can use to quickly
preview the desktop, without closing or minimizing currently open applications.
main desktop
The main desktop area contains shortcuts to various applications and files on the computer,
which enables you to navigate more quickly than you can using the Start menu for example. It's
also the main interface that's used when working with various open programs and files.

In addition, the main desktop area includes the optional sidebar, which runs various small
programs called gadgets. Gadgets installed by default include a clock and a calendar.
The desktop displays icons for the Recycle Bin, Internet Explorer, Windows Media Center, and
Notepad. Two gadgets are also displayed.
Question
Match each desktop element to its description.
Options:
A. Start button
B. Taskbar
C. Notification area
D. Main desktop
Targets:
1. Provides access to all files and applications on the computer
2. Displays programs that are currently in use
3. Contains icons that monitor the status of the computer
4. Includes the sidebar
Answer
453

The Start button provides access to the Start menu, which in turn enables you to access all the
applications and files on the computer.
The taskbar displays programs that are currently in use, and enables you to switch between them.
This area also contains applications that have been pinned to the taskbar.
The notification area contains programs that monitor the status of the computer, such as the Action
Center or battery life.
The main desktop provides the interface you can use when working with open programs and files.
This area also contains shortcuts to applications as well as a sidebar with gadgets.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
2. Using Snap and Aero Shake
Windows 7 contains various new desktop features, for example Snap, which makes managing
programs and files on the desktop easy.

Snap enables you to perform tasks such as maximizing or stacking windows quickly, using a
single click of the mouse.
Graphic
Two non-maximized Notepad windows are opened in Windows 7.
Snap is useful if you are working with multiple windows at the same time because it enables you
to position and resize windows in various new ways.

For example, you can use Aero Snap to compare two documents placed side-by-side on the
desktop.
Graphic
Two windows have been positioned so that they each fill 50% of the screen.
Windows 7 enables you to maximize a document by using a window's title bar.
454

Graphic
The Notepad application displays on the desktop and is non-maximized.
To maximize the window you simply click the title bar and drag the window to the top of the
screen.

When the cursor reaches the top, the window automatically maximizes.
Keyboard Sequence
The keyboard alternative for maximizing a window using Aero Snap is Windows Key +Up arrow.
You can also expand an application so that it fills the screen vertically, but not horizontally.

You can do this using the same click-and-drag method for maximizing a window. However,
when you maximize a window vertically, you click the edge of the window and not the title bar.
Graphic
The Notepad application has been minimized and the Paint application displays, in a non-maximized
view.
Keyboard Sequence
The keyboard alternative for maximizing a window vertically using Aero Snaps is Windows Key +
Shift +Up arrow.
To maximize the screen vertically, you drag the window to the nearest edge of the screen, either
to the top or the bottom.
Graphic
The window is dragged to the top edge of the screen and is maximized vertically.
You can also use Snap to work between applications simultaneously, by snapping two windows
to the left and right of the screen, so that each window fills half of the screen.

Doing this enables you to perform actions such as dragging files between windows, or in this
case working between two documents.
Graphic
455

Two Notepad applications are non-maximized and open on the desktop.
You snap the window to the right of the screen by clicking the title bar and dragging the window
to the right.

When the cursor reaches the edge of the screen, the window's outline appears. You release the
mouse and the window snaps into position.
Graphic
The Notepad window fills half of the screen, to the right.
You perform the same action for the other application, in this case dragging the window to the
left of the screen.

When you release the mouse, the documents are displayed side-by-side.
Graphic
The Notepad applications each fill half of the screen.
To restore a window to its original size, you click the window's title bar and drag the window to
the middle of the screen. The window will assume its previous dimensions.
Graphic
The Notepad window displaying the Northglennfitness_contact file is non-maximized and in its
original position.
Aero Shake is a Windows 7 feature that enables you to minimize multiple windows that are open
entirely, while keeping a single, selected window open on screen.

Aero Shake is useful as it enables you to minimize different windows simultaneously and not
individually, which saves you time when working. However, you need to remember that you can
only use Aero Shake on windows that are not maximized.
Graphic
Three non-maximized windows are open on the desktop: Paint, Notepad, and Calculator.
To minimize all windows except the one you want to use, you click the application's title bar,
keep the mouse button held, and shake your mouse vigorously.

This shaking causes all other open windows to be minimized.
456

Graphic
You click the Calculator's title bar and shake the mouse. The Paint and Notepad windows are
minimized.
Keyboard Sequence
The keyboard alternative for Aero Shake is Windows Key +Home.
You can restore the minimized windows to their previous states by clicking the title bar of the
open window and shaking the mouse again.
Graphic
The Paint and Notepad windows display on the desktop in their previous positions.
Try It
Now you try using the Snap feature to maximize the Control Panel window.
The Control Panel displays and is non-maximized.
To complete the task
1. Click the window title bar and drag it to the top of the screen
Using keyboard: The keyboard alternative to maximizing a window vertically using Aero Snaps is
Windows Key + Shift + Up arrow.
The Control Panel window has been maximized.
Question
Identify situations in which it would be suitable to use the Snap feature.
Options:
1. Minimizing windows open on the desktop
2. Previewing open windows
3. Comparing two open documents side by side
4. Maximizing a window
Answer
457

Option 1: Incorrect. Aero Shake enables you to minimize windows open on the desktop. You use
Snap to maximize, resize, or align windows.
Option 2: Incorrect. Snap enables you to maximize, resize, or align windows on the desktop. You
can't use Snap to preview a program or file.
Option 3: Correct. You can use Snap to compare documents on the desktop by snapping each
window to the left and right of the screen.
Option 4: Correct. You can use Snap to maximize a window so that it fills the screen entirely or to
maximize it vertically only.
Correct answer(s):
3. Comparing two open documents side by side
4. Maximizing a window
Summary
The Windows 7 desktop contains various features that assist in navigating the system. The
taskbar contains elements such as a Start button, the taskbar, a notification area, and the main
desktop.

Windows 7 contains desktop enhancement features such as Snap and Aero Shake. Snap
enables you to manage multiple programs using quick methods of maximizing, resizing, and
aligning windows. Aero Shake makes it easier to work with multiple windows by enabling you to
minimize all windows while keeping a single window maximized.









458

The Windows 7 Start Menu and Taskbar
Learning Objectives
After completing this topic, you should be able to
access programs and files via the Start menu and the taskbar
identify the features of the Windows 7 Start menu and taskbar
identify features of jump lists
1. Using the Start menu and taskbar
In Windows 7, understanding the Start menu and the taskbar is crucial to successfully using the
computer.
Graphic
The Windows 7 desktop is displayed.
The Start menu enables you to access your computer's files, programs, and settings. In
Windows 7 the Start menu has been designed to provide you with much more control over
which programs and files appear on the Start menu. So you can change the Start menu to
reflect the programs and files that are most important to you.
Graphic
The Start menu has a search field, an All Programs link, and various options like Pictures, Music,
Computer, Control Panel, and Devices and Printers.
To open the Start menu, you click the Start button in the bottom left corner of the computer
screen.
The Start menu contains four main areas:
left pane
The left pane contains a list of programs. You can open any of the listed programs by clicking the
program once. Generally, only the most commonly used programs are listed here.
In this case, three programs are listed: Windows Media Player, Internet Explorer, and Windows
Media Center.
bottom of left pane
The bottom of the left pane contains a search box. You can enter the name of any program,
service, or file you are looking for in the search box, and windows will search for it as you type.
You do not need to press Enter, and may not need to complete the name of what you are
459

searching for. If you press Enter, Windows opens a separate search window.

You select All Programs to display all the programs installed on the computer.
right pane, and
The right pane lists folders, files, settings, and features that are used often. Windows 7 has a new
Libraries feature that lets you view the contents of all the folders you use for a specific type of file
by clicking on the matching library link in the Start menu. You can add all the locations for one file
type to one library link, then use the link to work with all the files at once.
Some folders and features are Pictures, Music, and Control Panel.
Power buttons
Also known as the Shut down button, the Power options enable your computer to switch users,
log the current user off, lock the computer, restart Windows, or put the computer into sleep or
hibernate.
The Power buttons contain the Switch user, Log off, Lock, Restart, Sleep, and Hibernate options.
Question
How can you access the Windows Media Center program if it is not listed on the Start menu?
Options:
1. Use the All Programs option
2. Use the Power button
3. Use the Search feature
4. Use the available libraries
Answer
Option 1: Correct. The All Programs option enables you to open a list of all programs installed on
the computer.
Option 2: Incorrect. The Power button is used to shut down the computer, not to launch a program.
Option 3: Correct. You can use the search box to enter the name of a file program and search for it.
Option 4: Incorrect. Libraries are used to view the contents of all the folders used for a specific type
of file, not to access programs.
Correct answer(s):
1. Use the All Programs option
3. Use the Search feature
460

The taskbar is used to switch between running programs. However, you can use other features
of the taskbar to perform common computer tasks.
The taskbar consists of three areas apart from the Start button:
notification area
The notification area gives you information about processes running on the computer, as well as
notifications about the computer's security and maintenance.
taskbar buttons, and
The taskbar buttons enable you to quickly access programs which are currently running. You can
also launch programs which are not running by pinning them to the taskbar and clicking the
taskbar button.
the Show Desktop button
The Show Desktop button minimizes all open windows so that you can quickly view the desktop
by minimizing all open windows. You can also see a preview of the desktop by hovering your
cursor over the Show Desktop button.
Question
Where on the taskbar is information about security and maintenance displayed?
Options:
1. Notification area
2. Taskbar buttons
3. Show Desktop button
Answer
Option 1: Correct. The notification area is used to display information related to security and
maintenance.
Option 2: Incorrect. The taskbar buttons represent regularly used programs, not information about
security and maintenance.
Option 3: Incorrect. The Show Desktop button displays the desktop and doesn't display
information about security and maintenance.
Correct answer(s):
1. Notification area
461

2. Using jump lists
Jump lists are a feature of Windows 7 that you can use with the left and right panes of the Start
menu, as well as the taskbar. These lists contain all the files, folders, and web sites that you
have used or opened recently. Jump lists assist in quickly accessing documents, web sites, files,
or programs from their associated start menu item, or taskbar button.
Jump lists also list the common tasks for a particular program, such as playing music with
Windows Media Player or creating a new document with Microsoft WordPad.
The items in a jump list are the same, whether you access them using the taskbar or the Start
menu.
Windows automatically lists the files according to the application you use to work with them. For
example, all the recently opened documents are listed in the jump list for Microsoft WordPad.
Graphic
When you hover the mouse over the small arrow to the right of the application in the Start menu, a
jump list displays. In this example, the items listed on the jump list include Agenda for staff meeting,
Northglenn Timetable, basic layout, about us, membership, and northglenn fitness club.
Jump lists are created by Windows for all the programs in your taskbar. You can access these
jump lists by right-clicking the taskbar icons.
Graphic
The Windows Media Player icon is shown on the taskbar. The jump list that displays when you right-
click the icon lists the most commonly performed tasks using this program, which in this case are
Resume previous list and Play all music.
To access jump lists for the applications listed in the Start menu, you can hover the mouse over
any applications that have a small arrow to the right of the application's name.
Graphic
The Start menu lists Notepad, Paint, Windows Media Player, Internet Explorer, and Windows Fax
and Scan.
You can display jump lists from the taskbar. To do so, you first right-click the program icon.
Graphic
462

You right-click the Windows Media Player icon on the taskbar to display a jump list with two task
options, Resume previous list, and Play all music. Under the jump list, the program name, Windows
Media Player, is listed, as well as the option to unpin the icon from the taskbar.
In this instance, you select Play all music from the jump list.
Windows Media Player opens.
Alternatively, you can open files via jump lists using the Start menu. To do so, you open the
Start menu and click the arrow to the right of the application in this case Internet Explorer.
Graphic
The Start menu lists Notepad, Paint, Windows Media Player, Internet Explorer, and Windows Fax
and Scan. You hover the cursor over the small arrow to the right of the Internet Explorer option.
The jump list opens, and you select Open new tab.
Graphic
Clicking the arrow to the right of the Internet Explorer option opens a jump list that gives you two
options, Start InPrivate Browsing and Open new tab.
The new tab opens.
Question
What are some of the key features of jump lists?
Options:
1. The Start menu's and taskbar's jump lists are different
2. Organized by the program used to work with them
3. They contain all recently used files, folders, and web sites
4. You can customize jump lists
Answer
Option 1: Incorrect. A jump list contains the same items whether it is accessed via the Start menu
or the taskbar.
Option 2: Correct. Jump lists are grouped according to the programs used to work with the files,
folders, or web sites on the list.
463

Option 3: Correct. Jump lists are automatically created by Windows and include all of the most
recently used files, folders, or web sites.
Option 4: Incorrect. Jump lists are automatically created by Windows and include all of the most
recently used files, folders, or web sites.
Correct answer(s):
2. Organized by the program used to work with them
3. They contain all recently used files, folders, and web sites
3. Using the Start menu
You can use both the Start menu and the taskbar to open programs, but beyond that, each has
its own functions.

You can use the Start menu to access libraries, and the taskbar to preview open windows and
jump to recently used files and programs.
If the program you want to use appears in the Start menu, you can click it once to launch it
directly.
Graphic
The programs listed in the Start menu are Notepad, Paint, Windows Media Player, and Internet
Explorer.
If the program you want to open is not listed in the Start menu, you click All Programs.
Programs are grouped together according to the type of task being performed.
Graphic
Programs listed individually appear at the top of the list. In this case, some of the programs listed
are Adobe Pixel Bender Toolkit, Default Programs, Desktop Gadget Gallery, Internet Explorer,
Windows DVD Maker, Windows Fax and Scan, Windows Media Center, Windows Media Player,
Windows Update, and XPS Viewer. The programs listed in groups are next. The groups are
Accessories, Games, Maintenance, Microsoft Windows AIK, Startup, and WinPcap.
For example, all the programs that perform tasks to do with the performance of the computer are
grouped together under Maintenance.
To view all the programs to do with computer maintenance, you click Maintenance. A list of the
maintenance programs displays.
464

Graphic
The programs listed under Maintenance are Backup and Restore, Create a System Repair Disc,
Help and Support, and Windows Remote Assistance.
Try It
Now you try to open the XPS Viewer using the Start menu.
The desktop is displayed.
To complete the task
1. Click Start and select All Programs
2. Select XPS Viewer
The XPS Viewer is opened.
The XPS Viewer has been successfully opened.
Question
If the Start menu does not list a program you want to launch, how can you find the program?
Options:
1. Use the Search feature
2. Use a Power option
3. Use the All Programs feature
4. Use the notification area
Answer
Option 1: Correct. You can enter the name of the program you want in the search box and press
Enter to find it.
Option 2: Incorrect. You use Power options to shut down the computer, including open programs,
not to find programs.
Option 3: Correct. You can view all installed programs using the All Programs feature.
Option 4: Incorrect. The notification area provides information about processes running on the
computer, and isn't used to find programs.
Correct answer(s):
465

1. Use the Search feature
3. Use the All Programs feature
4. Using the taskbar
You can use the taskbar to launch programs by clicking on program icons found on the taskbar.
Graphic
The program icons shown on the taskbar are Notepad and Windows Media Player.
To launch a program that is shown on the taskbar, you click on the program icon and the
program launches.
Graphic
You click the Windows Media Player icon.
When a program has been launched from the taskbar, the icon changed to show that the
program is running.
Graphic
To show that the program is running, the Windows Media Player icon is boxed and highlighted.
By clicking the Show Desktop button, you can quickly minimize all open windows.
Try It
Now you view the desktop.
The Windows Media Player is open.
To complete the task
1. Click Show Desktop
The open windows are minimized and the desktop is displayed.
If you want to see the desktop quickly but then return to all the windows you have open, you can
hover your cursor over the Show Desktop button so that the desktop reappears.
Graphic
466

The Windows Media Player application window disappears, and only its outline is displayed.
As soon as you move your cursor away from the Show Desktop button, all the open windows
display. The feature that enables you to hover over the Show Desktop button to quickly view
the desktop without minimizing any of the open windows is called Aero Peek.
You can use Aero Peek to preview applications that are running on your computer. If you hover
your cursor over the taskbar icon that represents a running program, a thumbnail appears that
shows the application's window.
Graphic
When you place the cursor over the Windows Media Player icon, the icon becomes highlighted in
orange and a thumbnail displays above the icon. The thumbnail contains the name of the program,
rewind, pause, and fast forward buttons, and the name of the slideshow currently playing on
Windows Media Player.
If more than one instance of an application is running at one time, all the windows representing
each instance appear in thumbnail form when you hover over the application's taskbar icon.
Graphic
When you place the cursor over the Notepad icon, two thumbnails display above the icon. The
thumbnails are titled northglenn - Notepad, and northglenn brochure - Notepad.
You can click either of the thumbnails to open the instance as an active window.
Graphic
Northglenn brochure thumbnail has been selected and the Northglenn brochure document displays
on the screen.
If the Windows Fax and Scan application is running on your computer, you can preview the
application's window by hovering your cursor over the Windows Fax and Scan icon.
Graphic
The Windows Fax and Scan icon is now available on the taskbar next to the Notepad icon and the
Windows Media Player icon.
If you decide that you want to open the window displayed in the thumbnail, you click the
thumbnail and the window opens in full size.
467

Try It
Now you activate the XPS Viewer window from the taskbar.
The desktop is displayed. On the taskbar, applications like Notepad, Windows Media Player, and
XPS Viewer are open.
To complete the task
1. Select the XPS Viewer icon
The XPS Viewer window is active.
SkillCheck
Use the taskbar icons to open the Windows Update application.
The Windows desktop is displayed.
Task:
1. Open the application.
Answer
To complete the task
Step 1: Select Windows Update
Summary
The Start menu and the taskbar are the main means of interacting with and managing a
computer running Windows 7.

Both the Start menu and the taskbar give access to jump lists. Jump lists contain all the files,
folders, and web sites that have been used or opened recently, as well as tasks most frequently
performed by programs. The jump lists are organized according to the programs used to work
with the files, folders, or web sites.

The Start menu lists some available programs and gives access to libraries of files. The All
Programs option on the Start menu makes all available programs visible. Programs that perform
related tasks are grouped together.

The taskbar gives quick access to programs whose icons are shown on the taskbar, and also
468

provides the ability to quickly view the desktop. The Aero Peek feature creates thumbnails of
open programs, which you can access through the icons on the taskbar.






















469

Getting Around the Windows 7 Interface
Learning Objectives
After completing this topic, you should be able to
compare two files side by side
access a program
use a jump list to open a file
preview and activate an open window using Aero Peek
Exercise overview
In this exercise, you're required to navigate the Windows 7 interface.
This involves the following tasks:
using Snap
accessing a program
using a jump list to open a file, and
using Aero Peek to preview and activate an open window
Task 1: Using Snap
You're working with two photographs and need to compare them side-by-side on the desktop.
Align the Paint and Windows Photo Viewer windows so that each window occupies 50% of the
screen. The Paint window should appear on the right of the screen and the Windows Photo
Viewer on the left.
Steps list
Instructions
1. Click the Paint title bar and drag the window to the right-hand side of the screen
2. Click the Windows Photo Viewer title bar and drag the window to the left-hand side of the screen
Task 2: Accessing a program
Without using the Search feature, access the Command Prompt program in the Accessories
folder from the Start menu.
470

Steps list
Instructions
1. Click Start and select All Programs
2. Select Accessories - Command Prompt
Task 3: Using jump lists
Use a jump list on the Start menu to open a new Internet Explorer tab.
Steps list
Instructions
1. Click Start and click the arrow next to Internet Explorer
2. Select Open new tab
Task 4: Using Aero Peek
Use the taskbar to preview and open the Gadget Gallery.
Steps list
Instructions
1. Click the Gadget Gallery icon
Windows 7 desktop enhancement features have been used, a program has been accessed, a
jump list has been used to open a file, and a window has been previewed and accessed.





471

Using Windows Explorer
Learning Objectives
After completing this topic, you should be able to
navigate to files and folders using Windows Explorer
identify the different parts of the Windows Explorer window
work with folders and files in Windows Explorer
1. The Windows Explorer window
Windows Explorer provides the interface to work with files and folders, and search your
computer to find them. By mastering Windows Explorer, you can get the most out of Windows 7.
The Windows Explorer interface has various components.
Navigation pane
You use the navigation pane to quickly navigate to different parts of your computer. From here
you can access commonly used folders, libraries, saved searches, hard disks, and networks.
Locations on the computer include Favorites like Desktop, Downloads, and Recent Places;
Libraries such as Documents, Music, and Pictures; and drives like Local Disk (C:).
Back and Forward buttons
As you navigate through folders and libraries you can use the Back and the Forward buttons to
view those you have already opened. If, for example, you navigated to a folder within a library you
can click the Back button to view the various folders in the library again. The Forward button will
then take you again to the folder you opened before.
Toolbar
The toolbar displays various common tasks that you can easily perform. These tasks are
associated with the type of files contained in the specific folder. So the toolbar will display one set
of tasks for music files and a different set of tasks for picture files, for example.
Address bar
The address bar displays the location of the current folder you are in. The path to the current
folder is displayed as links separated by an arrow. You can navigate to a new location by clicking
on a link in the address bar or typing the path to the new location.
Library pane
The library pane displays only when you are in a library location. Using the libraries you can bring
similar files from different locations together as a single collection without having to move them to
a new folder from where they are stored.
Column headings
472

By clicking the column headings you can change how the files in the file list are organized. You
can change the order in which the files are arranged by clicking the left side of the column
heading. Or you can change the way the files are filtered by clicking the right side.
In this case, the files are arranged by Name.
File list
The file list displays the contents of the currently open library or folder. The files in the list can, for
example, be arranged alphabetically or according to the date and time they were created.
Search box
The search box enables you to locate files or folders in the current folder or library. Searching
takes place as you type, and you do not need to press enter to view results.
Details pane
When you select a file in the file list, the details pane displays common properties associated with
that file. This can include the date and time it was created or last modified, who created it, and
any descriptive tags that were added to it.
You can use the Libraries feature to gather similar files together as a collection. You don't have
to copy or move those files to the specific library folder because they only link to it. If you delete
or modify a file from the library, it will be deleted from it's original location.
Windows 7 has four library folders created by default. These are
Documents
Music
Pictures, and
Videos
The Computer folder in Windows Explorer enables you to access different locations on your
computer. This includes the local hard disks as well as devices with removable media, such as
the CD or DVD drive, and external storage devices, such as USB flash drives.
Graphic
The contents of the Computer currently displays. It includes Local Disk (C:), Floppy Disk Drive (A:),
and CD Drive (D:).
The Computer folder also displays the amount of space still available for each hard disk or
removable medium.
Graphic
473

The space meter under Local Disk (C:), colored blue almost to the halfway point, illustrates available
space. Text immediately beneath it details memory use and availability, indicating "8.34 GB free of
15.8 GB."
If you right-click an item in the Computer folder, you can perform tasks such as ejecting a CD or
DVD, view the properties of a hard disk, or formatting a disk.
Graphic
The CD Drive (D:) icon has been right-clicked and the context menu displays with the following
options: Open, Open in new window, Share with, Eject, Copy, Create shortcut, and Properties.
Question
Match each characteristic to the correct part of the Windows Explorer window.
Options:
A. Navigation pane
B. Toolbar
C. Address bar
D. Library pane
Targets:
1. Enables you to quickly navigate to different parts of your computer and network
2. Enables you to perform common tasks associated with the file types currently displayed
3. Enables you to determine exactly where on your computer or the network the current file or folder is
located
4. Enables you to bring similar files from different locations together as a single collection
Answer
Using the navigation pane you can quickly navigate to different parts of your computer including
hard disks, libraries, and the network.
The toolbar displays various common tasks associated with the type of files contained in the specific
folder.
The address bar displays the various links that lead to the current location so you can determine
exactly where on your computer or the network it is located.
Using the library pane you can bring similar files from different locations together as a single
collection without having to move them from where they are stored.
474

Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
2. Navigating to files and folders
Using Windows Explorer there are three ways that you can navigate to files and folders. You
can use the
navigation pane
address bar, and
libraries
The navigation pane enables you to find files and folders by making quick selections. All the
available resources are grouped in logical categories with subcategories and folders that you
navigate through to get to the file you need.
The default categories in the navigation pane are
Favorites
From the Favorites section, you can navigate to the most commonly used folders and searches.
This includes, for example, viewing the files and folders located on the desktop.
The Favorites category is expanded by default and the locations listed under it are Desktop,
Downloads, and Recent Places.
Libraries
From the Libraries section, you directly access the different libraries and the files linked to them.
The Libraries category is expanded by default and the libraries listed under it are Documents,
Music, Pictures, and Videos.
Computer, and
You can view the expanded folder structure located on various drives and disks connected to
your computer by accessing the Computer category.
By default, the Computer category is not expanded.
Network
475

In the Network category, you can access different computers on the network that your computer
is a part of.
By default Network category is not expanded.
To expand a category and view its subfolders in the navigation pane, you click the Expand icon
associated with a folder or category name.
When the folder is expanded, you can then expand one of its subfolders to view the files or
folders it contains.

You navigate in this way until you locate the file that you need.
Graphic
The expanded Documents folder has two subfolders, namely My Documents and Public
Documents.
When you click a folder in the navigation pane, the file list section displays its contents.
Graphic
The My Documents folder has been selected in the navigation pane and its contents displays in the
file list section of the window. The contents include the following folders: 2009 brochure,
Easynomadtravel, Print Ads, and wordpadfiles.
To navigate to a location using the address bar, you click one of the links in the path to jump
there directly.
Graphic
The address in the address bar is currently Libraries - Documents - My Documents. The Libraries
link in the path is highlighted because it is being selected.
Another option is to click the arrow associated with one of the links. This displays the contents of
that link and you select a location from the list.
Graphic
The arrow next to Libraries is currently selected. Four libraries Documents, Pictures, Music, and
Videos are listed in the Libraries drop-down box.
If you know the full path of a location you want to navigate to, you can type it in the address bar.
Then you press Enter.
476

Graphic
The address typed in the address bar is C:\Users\JenniferW.QUICK24X7\Documents\PrintAds.
You then can select the location to display its contents. The path with the various links now
displays in the address bar.
Graphic
In this example, the PrintAds directory contains several files. The address bar reflects a simplified
directory path, Libraries - Documents - PrintAds.
For some common locations, such as Control Panel, you can just type the name and press
Enter.
Graphic
Control Panel is typed in the address bar.
The documents, pictures, and music libraries can be selected from the Start menu.
Graphic
In the right-hand pane of the Start menu the documents, pictures, and music libraries can be
selected by default amongst many other options such as Games, Computer, Control Panel, and
Devices and Printers, for example.
The selected library opens in Windows Explorer and you navigate through the folders and files it
contains. You double-click a folder to display its contents in the file list.
Graphic
The wordpadfiles folder has been opened and its contents are listed in the file list section. It contains
only one file named Easynomad.
And you double-click a file in the list to open it in the program that created it.
Another feature of Windows Explorer is the preview pane, which enables you to view the
contents of some files without having to open them.
To display the preview pane in the Windows Explorer window, you click the Preview pane icon.
Graphic
477

This icon is located on the right side of the toolbar, next to the Help icon.
When you select a file in the file list, such as a text document or a picture, you can preview it
before opening the software program that created it.
Graphic
Only a part of the WordPad document displays in the preview pane but it is enough to determine
whether it is the correct file. Currently, headings and some body text is displayed.
SkillCheck
Navigate to the Landscapes folder in the Pictures library and open the file named fall.
The desktop is displayed.
Task:
1. Open the library of image files.
2. Display the contents of the folder that contains the file you want to open.
3. Open the file.
Answer
To complete the task
Step 1: Click Start and select Pictures
The Pictures library opens. It contains the Edited Photos, Hotels, Landscapes, and Sample Pictures
folders.
Step 2: Double-click the Landscapes folder
The Landscapes folder contains the country, fall, road, and turbines01 files.
Step 3: Double-click the fall file
The fall image opens in the Windows Photo Viewer.
3. Working with folders and files
Folders are containers where you can store various files that belong together. They help to keep
your files organized and make it easier to find a specific file when you need it.
You can also place folders within folders to organize your files. Such folders are called
subfolders.
478

Everyday computing tasks often involve working with files and folders. Some common tasks you
perform with folders include
creating new folders
moving folders
renaming folders
deleting folders, and
viewing folder properties
Suppose, for example, you're starting a new design project. You will need to create a new folder
to save the project files in.
You can move relevant files and folders into the newly created folder, and rename them as
necessary.
You can also view the properties of the new folder to customize how it appears on the screen.
There are different ways to create a new folder, but the simplest way is to click the New folder
button on the Windows Explorer toolbar.
Graphic
The contents of the 2009 brochure folder in the Documents library currently displays. It includes a
single folder named text.

The Windows Explorer toolbar also contains Organize and Share with buttons.
New folders are created with the default name New folder. For organizational purposes it is
important to name the folder something meaningful.
Graphic
A new folder displays above the text folder in the 2009 brochure folder. It contains the placeholder
text New folder.
When you've just created a folder, the name field can be edited immediately. To do this, you
simply start typing a name and then you press Enter or click anywhere on the screen to save it.
Graphic
The new folder has been renamed pictures.
479

It can sometimes be necessary to rename an existing folder. You rename a selected folder by
clicking Rename in the Organize menu.
Graphic
The Easynomadtravel folder in the Documents library is selected and the Organize menu displays.
The Organize menu contains the following selectable options: Cut, Copy, Undo, Select all, Layout,
Folder and search options, Delete, Rename, Properties, and Close.
You then type the new name for the folder and press Enter or click away from the folder to save
the new name.
Graphic
The new name is 2008 brochure.
The drag-and-drop method is a common way to move folders to a different location. You start by
opening the folder that contains the folder or file you want to move.
Graphic
The contents of the Downloads folder currently displays and it includes a single folder named
classical.
You then also open the folder where you want to move it to and arrange them next to each other
on the screen.
Graphic
Two Windows Explorer windows are displayed next to each other. The one is the Downloads folder
and the other is the Music library containing a single folder named Sample Music.
Next you click and drag the folder over to the new location, where you release the mouse
button.
Graphic
The folder named classical is dragged to the Music library.
You can drag and drop a folder more efficiently by dragging it to a folder and dropping it in a
location in the navigation pane.
Graphic
480

The Pictures library contains the following folders: Edited Photos, Hotels, Landscapes, and Sample
Pictures.
With the folder displayed, you use the navigation pane to go to the location where you want to
move the folder.
Graphic
The Documents library has been expanded in the navigation pane. The 2009 brochure folder has
also been expanded and contains two folders. One of the folders is named text and the other,
pictures.
You then drag and drop the folder to its new location.
Graphic
The Landscapes folder is dragged and dropped in the pictures folder in the 2009 brochure folder in
the navigation pane.
If the folder's new location is not on the same hard disk as the original location, for example on
removable media or a network location, the folder is copied by default. This means that two
copies of the folder now exists one in the original location and one in the new location.

If, however, the new location is on the same hard disk as the original location, the folder is
moved and only one folder exists in the new location.
Graphic
The Documents library originally contained the following folders: 2008 brochure, 2009 brochure,
Print Ads, and wordpadfiles.

With the wordpadfiles moved to the Print Ads folder, both of which are on the same hard disk, the
Documents library now displays only three folders namely: 2009 brochure, 2008 brochure, and Print
Ads.
Try It
Now you try moving and creating a new folder. You want to move the Edited Photos folder from the
Pictures library to the Print Ads folder located in My Documents in the Documents library. You then
want to add a new folder to the Print Ads folder.
The Pictures library is accessed in Windows Explorer.
To complete the task
481

1. Expand Documents in the navigation pane and then expand My Documents
With My Documents expanded, four folders are available: 2008 brochure, 2009 brochure, Print Ads, and
Public Documents.
2. Drag and drop the Edited Photos folder from the Pictures library to the Print Ads folder
The Print Ads folder now contains two folders: Edited Photos and wordpadfiles.
3. Select the Print Ads folder in the navigation pane
4. Click the New folder button in the Windows Explorer toolbar
You have moved a folder and created a new folder.
You delete a file by right-clicking it and selecting Delete from the menu that displays. A Delete
Folder dialog box asks if you are sure you want to delete the folder and you click Yes.

This does not permanently delete the folder but moves it to the Recycle Bin. If you later realize
that you still need that folder, you can retrieve it.
Graphic
The 2008 brochure folder in the Documents library has been right-clicked. The context menu
displays with the following options: Open, Open in new window, Share with, Restore previous
versions, Send to, Cut, Copy, Create shortcut, Delete, Rename, Open folder location, and
Properties.
Note
If you delete a folder from a network location or removable media, such as a USB flash drive, it will
not be moved to the Recycle Bin but will be deleted permanently.
You can also drag a folder to the Recycle Bin to delete it. Or you select it and then press the
Delete key.
Graphic
The folder named classical in the Music library is being moved to the Recycle Bin that displays on
the desktop.
To permanently delete a folder without moving it to the Recycle Bin, you select it and you press
the Shift and Delete keys simultaneously. The Delete Folder dialog box then asks whether you
want to permanently delete the selected folder.
Graphic
The Print Ads folder in the Documents library is being deleted and the Delete Folder dialog box
displays with a Yes and a No button.
482

To delete the folder in the Recycle Bin, you open the Recycle Bin by double-clicking its icon on
the desktop or opening it from the navigation pane. You then delete the folder by right-clicking it
and selecting Delete from the options.
Graphic
The classical folder has been right-clicked in the Recycle Bin and the context menu displays the
following options: Restore, Cut, Delete, and Properties.
If you have many items in the Recycle Bin and you want to permanently delete them all, you
select the Empty the Recycle Bin button from the Tools menu.
To recover an item from the Recycle Bin and move it back to its original location, you select it
and click Restore this item in the Tools menu.
Graphic
The 2008 brochure folder in the Recycle Bin has been selected and the Restore this item button
has been clicked.
Try It
Now you practice deleting and restoring a folder. You want to delete the 2008 brochure folder. You
realize you still need the brochure, so you want to restore it from the Recycle Bin.
My Documents is open in Windows Explorer. It contains three folders: 2008 brochure, 2009
brochure, and Print Ads.
To complete the task
1. Right-click the 2008 brochure folder and select Delete
The Delete Folder dialog box opens.
2. Click Yes
My Documents opens once more and now contains two folders: 2009 brochures and Print Ads.
3. Select Desktop under Favorites in the navigation pane
The desktop contains icons for various locations and files, such as Library, Computer, Recycle Bin, and
Adobe Reader 9.
4. Double-click Recycle Bin from the list
The Recycle Bin contains two folders: brochure 2008, and classical.
5. Select the 2008 brochure folder and click Restore this item
The Recycle Bin now contains only the classical folder.
You have deleted and restored a folder.
483

Files are created by various software programs and you usually save them in a folder with other
files that belong together. Renaming, moving, and deleting files works in the same way as it
does with folders.
Graphic
The contents of the wordpadfiles folder displays a single WordPad file icon named Easynomad.
SkillCheck
Move the Hotels folder from the Pictures library to the pictures folder. This folder is located inside
the 2009 brochure folder in the Documents library. Locate this folder in the navigation pane. Then
create a new folder in the pictures folder for miscellaneous use but rename it later.
The Pictures library is open in Windows Explorer. Two folders are available: Hotels, and Sample
Pictures.
Task:
1. Navigate to the location where you want to move the specified folder.
2. Move the folder to the new location.
3. Open the folder in which you want to create a new folder.
4. Create a new folder.
Answer
To complete the task
Step 1: Expand Documents in the navigation pane and then expand My Documents
Step 2: Drag the Hotels folder from the Pictures library and drop it in the pictures folder
Step 3: Select the pictures folder
The pictures folder has two folders: Hotels, and Landscapes.
Step 4: Click the New folder button in the Windows Explorer toolbar
Summary
Windows Explorer is the main interface for working with files and folders in Windows 7. The
Windows Explorer interface contains the navigation pane, Back and Forward buttons, toolbar,
address bar, library pane, column headings, file list, search box, and details pane.

You use the navigation pane, address bar, and libraries to navigate Windows Explorer. The
484

navigation pane enables you to find files and folders by making quick selections from logical
categories and subcategories. The address bar contains links in the path or you can type the full
path to jump there directly. You can select the common libraries from the Start menu and then
navigate to the required location. The preview pane enables you to see the contents of some
files without having to open them.

Folders are containers storing various files that belong together. You can place folders within
folders to further structure the organization of your files. You can create, move, and rename
folders, as well as view their properties.


















485

Searching for Files and Folders
Learning Objective
After completing this topic, you should be able to
search for files or folders using the Windows Explorer search box
1. Using the search box
As you work with your computer, you may end up with thousands of files and folders scattered
through various locations. Depending on how well you organize them, it may get difficult and
time-consuming to find the files that you need.
The two most common methods to locate files and folders in Windows 7 are
the navigation pane and
the search box in the Windows Explorer window
The navigation pane enables you to browse for files. But this only really works if you know
where to look. Even if you know the files should be in a specific library, for example, it may still
have thousands of files. So unless you know exactly where to go, finding files in this way may
take considerable time.
Graphic
The navigation pane displays with four categories that can be expanded. The four categories are
Favorites, Libraries, Computer, and Network. The Favorites category is expanded and displays
Desktop, Downloads, and Recent Places as subcategories. The Libraries category is expanded and
displays the following subcategories: Documents, Music, Pictures, and Videos. The Documents
subcategory is expanded to display My Documents as a subfolder which is expanded to display
2009 brochure, Easynomadtravel, Print Ads, and wordpadfiles as subfolders. The Documents
subcategory also has Public Documents as a subfolder.
The search box that displays at the top of every Windows Explorer window can make finding
files a lot easier and more efficient.
Graphic
The search box currently displays with the default text Search My Documents because My
Documents has been selected in the navigation pane and its contents currently displays in Windows
Explorer's file list section.
486

If you know what type of file you're looking for, you start by navigating to the most logical folder
that may contain it, such as the Documents library for example.
Graphic
The Documents library is opened by selecting Documents from the Start menu.
To locate a file, you type search text in the search box. This text can be a keyword contained in
the file or a part of the filename.
Graphic
In the example, the search text that has been entered is contact details.
The search is limited to the folder or library that is currently open. This means that only matches
found in this folder and all its subfolders will be displayed.
Graphic
The Documents library is highlighted. Two files that are called Easynomad are found, they are
copies of same files in different locations. The one is located in a folder named text within a folder
named 2009 brochure while the other is located in a folder named wordpadfiles within a folder
named Print Ads.
A match is made when the search text corresponds to a filename, any part of the contents of a
file, or the properties of a file, such as tags.
Graphic
Three possible matches to the search text Contact details are found. The about us file in the
websites folder and two further files named Easynomad in the text and wordpadfiles folders are
listed. The search phrase, contact details, is highlighted in the about us file's content preview.
Matches are made as soon as you start typing. If you type the letter c, all matches including the
letter c will be displayed. As you type, the search is filtered always displaying files or folders
which contain the characters you have typed so far.
Graphic
The letter c is currently entered in the search box and a long list of possible matches are displayed.
All the files and folders that contain the letter c in their name or content are displayed with the letter
c highlighted whenever it occurs. For example, a file named northglenn fitness club displays with the
c in club highlighted.
487

A preview of the files displays in the list of matches and you can determine whether the file you
are looking for has been found.
Graphic
For text files the first two lines of text that contains the match to the search text displays under the
name of the file.
To narrow your search, you can use search filters which enable you to base your search on the
properties of the file. This includes tags such as the name of the author or artist, the date the file
was last modified, the type of file, or the size of the file.

When you position the cursor inside the search box, the various filters display underneath it.
Graphic
A drop-down box displays under the search box with the text Add a search filter. Currently the filter
options you can select are Authors, Type, Date modified, and Size. Type is selected.
You select the filter that suits your needs and then you select a value from the list that displays.
Or you type filter text if the option doesn't display in the list. This can be a file extension such as
.rtf, for example.
Graphic
With the Type filter selected the word type now displays after the search text in the search box. A
drop-down list displays matching file types for the location the search is being run in. The current
search is in the Documents library and the file type options displaying in the list are .rtf and Rich
Text Document.
You can further refine the search by selecting more than one filter. This way you filter through a
filter, narrowing the possible matches.
Graphic
Both Type and Date modified filters has been selected. A drop-down box for the Date modified filter
currently displays with a calendar and the following quick selection options: A long time ago, Earlier
this year, Earlier this month, Last week, Earlier this week, and Yesterday.
If you've completed the search for a file in one location without finding it, you can expand the
search to include other locations. These are listed in the "Search again in" section. You select a
location from the list and the search is filtered through it.
Graphic
488

The location currently selected is Computer.
Using the "Search again in" option you can expand the search to
libraries
Selecting Libraries will run the search across all the libraries on your system.
the computer
Selecting Computer runs the search across the entire computer. You would do this to search for
system or program files.
custom locations, and
When you select Custom, you can search specific locations that you select from a list.
the Internet
Selecting Internet will run your search online using the default browser and search provider.
You can also save specific searches. This can be useful if you have successfully run a
complicated search involving filter combinations and you know that you may need to run it again
in the future. It can also be useful for any searches that you may perform regularly.
Once the search results display, you save the search by clicking the Save search button from
the toolbar.
You then name the search with a recognizable name in the Save As dialog box.
Graphic
The Save As dialog box displays the default location to save the search in the address bar. The
default location is a folder named Searches located in the Jennifer Westlein user account. The
default file name, which is the same as the search text, displays in the File name text box. The Save
As dialog box also contains a Save as type drop-down list box.
Suppose you're creating a web site for a client, Northglenn Fitness Club. You have created
various files in WordPad containing the text that will appear on the web site but you didn't save
them all in one place. You now want to locate the Rich Text Document or .rtf file that
contains the contact details of the fitness club.
Try It
Now you practice performing a search and adding a filter. You want to start your search in the
Documents library and use "contact details" as search text. Narrow your search using the Type
search filter and by selecting .rtf from the list of file types.
The desktop is displayed.
489

To complete the task
1. Click Start and select Documents
The Documents library is open in Windows Explorer.
2. Type contact details in the search box and select Type from the filter options
Type the search phrase is lowercase letters.
3. Select .rtf from the list
You have performed a search using the search box and added a filter.
Try It
You still haven't found the file, so you want to expand the search to the Jennifer Westlein user
account. You then want to save the search in the default folder with the default filename.
To complete the task
1. Select Custom from the Search again in list
The associated dialog box opens.
2. Select the Jennifer Westlein checkbox and click OK
You return to Windows Explorer and the phrase "Contact details" is highlighted in the about us file.
3. Select Save search from the toolbar
The Save As dialog box is opened.
4. Click Save in the Save As dialog box
You return to Windows Explorer.
You have expanded and saved a search.
SkillCheck
You're creating a brochure for Northglenn Fitness Club. Earlier you created an RTF file, named
basic layout, but you've forgotten where you saved it.

Start a search of the Documents library for the basic layout file. Then add a Type filter for .rtf files,
this time by typing the file extension in the search box. Then expand the search to include the other
libraries.
The desktop is open.

Type the search phrase using lowercase letters.
Task:
1. Open Windows Explorer in the location you want to start your search.
2. Enter the search text and select a filter. Type the search phrase using lowercase letters only.
3. Enter the filter text and expand the search.
490

Answer
To complete the task
Step 1: Click Start and select Documents
Windows Explorer opens and the Documents library is displayed.
Step 2: Type basic layout in the search box and select Type from the filter options
Two options display: .rtf and Rich Text Document.
Step 3: Select .rtf from the list
One result is found and displays.
Summary
In Windows 7, the search box enables you to locate a file by entering a keyword or search text.
You can use search filters to narrow your search or expand the search to include other
locations. And you can save specific searches.













491

Navigating Windows and Searching for Files
Learning Objectives
After completing this topic, you should be able to
create a new folder with a specified name in a given location
move a file to a new location
delete and restore a file
find a document using the search box in Windows Explorer
Exercise overview
In this exercise, you're required to navigate Windows as well as manage and search for files and
folders.
This involves the following tasks:
creating and naming a folder in a specific location
moving a file to a new location
deleting and restoring a file, and
finding a document using the search box in Windows Explorer
Task 1: Creating and naming a folder
You are creating a brochure for the Northglenn Fitness Club for which you have written some
text. You have already created a project folder and now you want to create a new folder to save
the text files in.
Navigate to the brochure folder that is located in the Northglenn Fitness Club folder in the
Documents library. Create a new folder and name it text.
Steps list
Instructions
1. Expand the Documents library in the navigation pane
2. Expand the Northglenn Fitness Club folder
3. Select the brochure folder
4. Click the New folder button, type text, and press the Enter key
492

Task 2: Moving a file to a new location
You have created a new folder for text documents. You now want to move the text document
you created for the brochure to this new folder.
Move the file named Northglenn Facilities located in the wordpad files folder. Place it in the new
folder you created, named "text," that displays in the navigation pane.
Steps list
Instructions
1. Select the wordpad files folder in the navigation pane
2. Expand the brochure folder
3. Drag and drop the Northglenn Facilities file to the text folder
Task 3: Deleting and restoring a file
You want to delete a folder, but after deleting it you realize that you still need one of the files in
that folder. You then restore that folder.
Delete the older versions folder and then restore it.
Steps list
Instructions
1. Select the older versions folder
2. Select Delete from the Organize menu
3. Click Yes
4. Select Desktop in the navigation pane
5. Double-click Recycle Bin
6. Select the older versions folder
7. Select Restore this item
493

Task 4: Using the search box
You now want to continue working on the brochure. You want to find a picture file named "spa."
You start your search in the Pictures library using a filter and then you want to expand your
search. When you have located the file, you want to save the search.
Perform a search for the .png file named spa. Add a Type filter, and expand the search to the
entire Jennifer Westlein user profile. Save the search in the default location with the default
name.
Steps list
Instructions
1. Select Pictures in the navigation pane
2. Type spa in the search box
3. Select Type from the filter options
4. Type .png in the search box
5. Select Custom from the Search again in options
6. Select the Jennifer Westlein checkbox and click OK
7. Select Save search
8. Click Save
You have created and named a folder in a specific location, moved a file to a new location,
deleted and restored a file, and found a document using the search box in Windows Explorer.






494

Installing and Removing Programs
Learning Objectives
After completing this topic, you should be able to
install and remove programs
identify the settings accessible through the Control Panel
1. The Control Panel settings
The Control Panel is the central point from which you can change all user adjustable settings in
Windows 7.
The Control Panel has many uses. For example, you can make simple changes such as setting
the time and date or configure more advanced options such as network and hardware settings.
From within the Control Panel you can configure various settings, including
hardware and
Hardware refers to internal or external devices you can attach to your computer, such as printers,
scanners, or hard drives. The Control Panel enables you to adjust their settings so that they
perform according to specifications.

One example is the computer's audio speakers. Through the Control Panel you can set the
balance of sound from the speakers and volume.
software
The software settings in the Control Panel enable you to control programs on your computer. For
example, you can uninstall some software installed on the computer, or add a gadget to the
desktop.
You can access the Control Panel from the Start menu by clicking Start and selecting Control
Panel, or by accessing it from Windows Explorer by clicking the option button on the address
bar and selecting Control Panel.
Graphic
You can also access features such as Computer, Devices and Printers, and Default Programs from
the Start menu.
There are two ways you can view the Control Panel:
Category Control Panel view
495

The Category Control Panel view is the default view. It groups similar items together under one
category. For example, all network and Internet related tasks are grouped together. This view is
used most often because it is quick and easy to navigate.
In this view, there are eight categories: System and Security; Network and Internet; Hardware
and Sound; Programs; User Accounts and Family Safety; Appearance and Personalization;
Clock, Language, and Region; and Ease of Access.
All Control Panel Items view
The All Control Panel Items view displays all the separate items at the same time, instead of
grouping them into categories. This lets you scroll through all of the individual programs on the
same page.
Some of the items are Action Center, Backup and Restore, Credential Manager, Desktop
Gadgets, and Display.
The Category Control Panel view contains eight categories. Each category has a link for
opening it, as well as links to its most common tasks.
System and Security
In the System and Security category, you can adjust your computer's settings for optimum
performance and security. For example, you can schedule Windows Backup to regularly back up
folders on your hard drive.
The links in this category are Review your computer's status, Backup you r computer, and Find
and fix problems.
Network and Internet
The Network and Internet category enables you to manage your network connections, and
manage homegroup, workgroup, or domain membership. You can also access your Internet
settings.
Links in this category are View network status and tasks, and Choose homegroup and sharing
options.
Hardware and Sound
In the Hardware and Sound category, you can set up your external hardware, such as your
printer. You can also adjust your computer's sound settings as well the settings for the external
speakers.
Links in this category are View devices and printers, and Add a device.
Programs
In the Programs category, you can adjust the settings for organizing your desktop, as well as
setting up default programs. For example, you can set your computer to automatically open a
sound file using Windows Media Player.
This category contains an Uninstall a program link.
User Accounts and Family Safety
The User Accounts and Family Safety category includes programs that enable you to manage
and control your different user accounts. For example, you can restrict a child's user account from
496

accessing certain web sites, or playing games of a certain rating.
Links in this category are Add or remove user accounts, and Set up parental controls for any
user.
Appearance and Personalization
The Appearance and Personalization category contains programs you can use to personalize
your computer, like your desktop and screen saver.
Links in this category are Change the theme, Change desktop background, and Adjust screen
resolution.
Clock, Language, and Region
The Clock, Language, and Region category enables you to configure the correct date and time on
your computer. It also enables you to select the language of your choice.
Links in this category are Change keyboards or other input methods, and Change display
language.
Ease of Access
The Ease of Access category includes programs that help make your computer and its software
more accessible. For example, you can use a speech recognition tool if you have problems using
a keyboard.
Links in this category are Let Windows adjust settings and Optimize visual display.
You can search for items in the Control Panel. To do this, you access the search box and enter
the name, task, or related word or phrase. Then you click Search.

You can also type the beginning of something you are looking for if you're not sure of the full
name. The Control Panel will then sort the items for you. For example, if you type the word
network, the Control Panel will show you all of the available options relating to networking.
Question
What category of settings enables you to configure settings to specify workgroups and domains?
Options:
1. System and Security
2. Network and Internet
3. Ease of Access
4. Programs
Answer
Option 1: Incorrect. Using the System and Security category, you can set up the security for your
computer and also adjust your system settings.
497

Option 2: Correct. Using the Network and Internet category, you can configure workgroups and
domains. It also enables you to manage your networks and adjust your Internet settings.
Option 3: Incorrect. The Ease of Access category has settings that help make your computer
software more accessible.
Option 4: Incorrect. The Programs category enables you to add and remove programs, configure
desktop gadgets and choose default programs.
Correct answer(s):
2. Network and Internet
2. Installing and removing programs
One of the common uses of the Control Panel is uninstalling programs. You can use the
Programs category to view the installed programs on your computer. From here, you can
uninstall, change, or repair existing programs.
To uninstall a program from your computer, you access the Programs category within the
Control Panel.
Then you access the Programs and Features settings to display a list of all the installed
programs on your computer.
You select the program you want to remove and click the Uninstall button. Then you follow the
prompts on the screen. Some programs also let you change or repair them.
You can install programs from
a CD or DVD
When you insert a CD or DVD, an Autoplay dialog box usually appears. Most application CDs or
DVDs will have an option to initiate installation. If it doesn't, you have to access the drive and
open the program installation file. Instructions should be provided with the CD or DVD to help you
install it.
the Internet, or
When you want to install a program from the Internet, you click the link provided to the program
you wish to install. You can then open, run, or save it. To install it immediately, you click Open
and follow the instructions onscreen. To install it later, you click Save. This means that the
installation file is saved to your computer and you can complete the installation later by double-
clicking the file and following the instructions.
a network
498

You can install a program from a network through Control Panel on your computer. With
Programs and Features open, you select Install a program from the network. Once you have
selected this, you choose the program you want to install and follow the instructions onscreen.
To install a program from CD or DVD, you first insert the disc into your computer, and the
Autoplay dialog box should appear.

If the Autoplay dialog box doesn't open automatically, you open the installation folder by clicking
Start, selecting Computer, and double-clicking the relevant drive.
Graphic
Windows Explorer is open.
To install the program, you then double-click the setup file on the disc.
Next you allow the program to make changes to your computer, and the installation begins.
Graphic
The dialog box asks you whether you want to allow the following program to make changes to this
computer. It gives you the options of Yes and No. In this case you click Yes to install the program on
your computer.
After entering the product key and clicking Continue, the installation will run.
You then select the I accept the terms of this agreement checkbox and click Continue.
You then click Install Now.
And the program is installed from the CD or DVD.
To install a program from a network, you access the Control Panel and access the Programs
and Features settings.
Graphic
The Control Panel is open and Programs is selected.
Note
Before you can install programs from the network, this functionality must have been set up by your
network administrator.
499

From the Programs and Features window, you click Install a program from the network.
Graphic
Other links are View installed updates and Turn Windows feature on or off. A list of installed
applications is also displayed.
You select the program you want to install, and click Install.
Graphic
In this case, Adobe Reader 9.2 is selected.
The program takes you through the set up of the installation where you can determine the
destination you want it installed to and finally installs by clicking Install.
You then click Finish to exit the wizard.
And Adobe Reader 9.2 is installed.
If you're running a 32-bit edition of Windows 7, all programs are installed to the Program Files
folder.

If you're running a 64-bit edition of Windows 7, 32-bit programs are installed in the Program
Files (x86) folder, and 64-bit programs are installed to the Program Files folder.
SkillCheck
You need to install Adobe Reader 9.2 from the network. You've already opened the Programs and
Features category in the Control Panel.

Install Adobe Reader 9.2 from the network.
The Programs and Features category is open in the Control Panel.
Task:
1. Begin the program's installation.
2. Install the program.
3. Run the installation.
4. Complete the installation.
Answer
500

To complete the task
Step 1: Click Install a program from the network
A list of available programs displays. One option s available: Adobe Reader 9.2.
Step 2: Select Adobe Reader 9.2, click Install, and click Next
The Setup dialog box opens and displays the destination folder, in this case, C:\Program
Files\Adobe\Reader 9.0\. A Change Destination Folder button is also available.

When you click Next, the Ready to Install the Program page opens.
Step 3: Click Install
The Setup Completed page opens.
Step 4: Click Finish
You return to Windows Explorer.
Summary
You can adjust many different settings through the Control Panel. You can browse and
configure software and hardware settings using various categories such as System and
Security, Network and Internet, Hardware and Sound, Programs, User Accounts and Family
Safety, Appearance and Personalization, Clock, Language, and Region, and Ease of Access.

You can install programs on a computer from a network, from a CD or DVD, and from the
Internet. You can also use the Control Panel to install and remove programs. And you can
manage programs via the Programs and Features settings.









501

Installing and Using Printers
Learning Objectives
After completing this topic, you should be able to
install and remove printers
manage printing in Windows 7
identify the options available when printing
1. Local and network printers
Printing documents is one of the most popular and widely used ways of sharing information. You
use a printer to produce physical copies of documents.
To use a printer, you need to connect and install it on the computer correctly. It's useful to read
the printer guidelines to get a better understanding of an individual printer's requirements.
There are two main types of printers:
local printers and
Local printers are directly connected to your computer. These are typically connected via a USB
port or in some cases a serial or parallel port.

Local printers are typically used for your home computer.
network printers
Network printers are shared between several computers on the same network. They connect to a
network rather than directly to one computer. They can be connected using Ethernet, Bluetooth,
or Wi-Fi.

Network printers are often used in an environment with multiple computers, for example an office.
This saves costs and space because all the computers can access the same printer instead of
using multiple printers.
You can connect a printer to a computer in various ways:
USB connector
To connect a printer using USB, you simply plug the USB cable from your printer to a USB port
on your computer. The computer will detect the printer automatically and lead you through the
installation process.
Bluetooth
502

Bluetooth connects a printer to a computer using short length radio waves. You may need to
attach an adapter to the computer to establish a Bluetooth connection, which enables the printer
and computer to communicate wirelessly over short distances.
parallel or serial ports, and
Some older model printers still may connect to a computer via a parallel or serial port. This
method uses a printer cable from the printer that connects directly to the computer. This method
of connecting printers is quickly becoming outdated.
network devices
The computer and printer can communicate with each other over a wired or wireless network.

Connecting to a printer over a network is useful in an office environment because computers do
not need to be physically close to the printer, and can use different printers for different tasks.
Question
Which methods of connecting a printer to a computer require a physical cable connection?
Options:
1. Wireless network
2. USB
3. Bluetooth
4. Parallel port
Answer
Option 1: Incorrect. If you connect to a printer over a wireless network, you do not need a physical
connection to the printer.
Option 2: Correct. A printer can be physically plugged in to a computer or computer network using a
USB cable.
Option 3: Incorrect. Bluetooth uses short length radio waves to connect a printer to a computer,
which doesn't require a physical connection.
Option 4: Correct. Parallel ports connect printers physically to a computer, and are specific to each
printer. Parallel ports are slowly being replaced by more modern connection methods, such as USB.
Correct answer(s):
2. USB
4. Parallel port
503

2. Manually installing a local printer
No matter how you choose to install a printer, the computer will usually detect and install it
automatically. However, in some cases you may need to install the printer manually.
Network printers will not be detected and must be added manually.
You can install a printer manually using the Control Panel.
Graphic
To install a printer manually you click the Start menu and select Control Panel.
You access the Hardware and Sound category within the Control Panel, which can be used to
add or remove printers and devices.
Graphic
There are eight categories displayed in the Control Panel: System and Security, Network and
Internet, Hardware and Sound, Programs, User Accounts, Appearance and Personalization, Clock,
Language, and Region, and Ease of Access.
To view the devices and printers that are connected to the computer, you click the Devices and
Printers link.
Graphic
The Hardware and Sound page contains five main options: Devices and Printers, AutoPlay, Sound,
Power Options,and Display.
On the Devices and Printers page, you click the Add a printer button.
Graphic
The Devices and Printers page contains two buttons: Add a device, and Add a printer. Two sections
are also available: Devices, and Printers and Faxes.
The Add Printer wizard opens. On the first page you specify whether you want to install the
printer as a local printer or a network, wireless, or Bluetooth printer.
Graphic
In this case, you want to install a local printer, so you click Add a local printer.
504

Next you select the port you would like to install the printer on.
Graphic
The Choose a printer port page opens. The default port that is selected is LPT1: (Printer Port).
There is also an option to create a new port. You accept the default port by clicking Next.
The next page displays a list of printer manufacturers. Another list displays the printer drivers
that are available from each manufacturer. For example, if you select HP from the list of
manufacturers, the second list displays all the available HP printer drivers.
Graphic
The Install the printer driver page is open. Two buttons are available: Windows Update and Have
Disk. A Tell me why driver signing is important link is also available.
If the driver for your printer is not listed, you can use Windows Update to search for new drivers
to install.
This will update the list of drivers available. You can again click the manufacturer of the printer
and then browse through the updated list of drivers available and select the correct driver. You
accept these by clicking Next.
Graphic
HP is selected in the Manufacturer list and HP LaserJet 5L in the Printers list on the Install the
printer driver page.
The wizard then gives you the choice of naming the printer. You rename the printer or accept
the default name and advance to the next page.
Graphic
The Type a printer name page opens. The default printer name is HP LaserJet 5L. You click Next.
Once the printer is installed, it is advisable to print a test page to make sure the printer is
working correctly. If you decide not to print a test page you complete the wizard by clicking
Finish.
Graphic
The You've successfully added HP LaserJet 5L page opens. A Print a test page button is also
available.
505

Question
Sequence the steps you would take to install a printer manually from a network.
Options:
A. You access the Hardware and Sound category within Control Panel
B. View the devices and printers connected to the computer
C. Open the Add Printer wizard
D. Select the manufacturer of the printer
E. Select the printer you want to install
F. Specify the name of the printer
Answer
Correct answer(s):
You access the Hardware and Sound category within Control Panel is ranked as the first
step.
The first step is to launch the Control Panel, open the Hardware and Sound category, and click
Devices and Printers to view the printers and devices attached to the computer.
View the devices and printers connected to the computer is ranked as the second step.
To view the devices and printers that are connected to the computer, you click the Devices
and Printers link.
Open the Add Printer wizard is ranked as the third step.
After you have opened the Devices and Printers page, you click the Add a printer button to
open the Add Printer wizard.
Select the manufacturer of the printer is ranked as the fourth step.
You select a manufacturer from the Manufacturer list on the Add Printer wizard's Install the
printer driver page.
Select the printer you want to install is ranked as the fifth step.
The wizard identifies printers on the network that the computer is connected to. You can
choose the network printer you want to install by selecting it and proceeding with the wizard.
Specify the name of the printer is ranked as the sixth step.
You complete the wizard by specifying printer details, for example naming the printer, and click
Next.
506

3. Installing a network printer
Installing a network printer on a computer is similar to installing a local printer. You launch the
Add Printer wizard and select the type of printer you want to install.
Graphic
The Add a network, wireless, or Bluetooth printer option is selected.
The wizard identifies printers on the network that the computer is connected to. From there you
can choose the network printer you want to install by selecting it and proceeding with the wizard.
Graphic
The Select a printer page opens. The HP LaserJet 5L printer is selected and the Next button is
clicked. There is an option on the page that you can click if the printer you are looking for is not
listed.
Note
If the printer does not show up in the list of available network printers, then you will need to obtain
the network address from your network administrator.
You complete the wizard by specifying printer details, for example naming the printer, and click
Next.
Graphic
The page displays the default printer name, HP LaserJet 5L. In this case, you accept the default
printer name.
You complete the installation by clicking Finish.
Graphic
The wizard displays a message stating that you have successfully installed a printer. There is also
an option to print a test page.
You can print a test page at any time after you've installed a printer. To do this, you right-click
the printer and select Printer properties from the shortcut menu.
Graphic
507

Other options in the shortcut menu include Open, See what's printing, Remove device, and
Properties.
In the General tabbed page of the properties, you then click Print Test Page.
Graphic
The Printer Properties dialog box contains tabs that include General, Sharing, Ports, and Advanced.
If you need to disconnect a printer, you can uninstall it by accessing the Devices and Printers
option through the Control Panel. You can remove the printer by selecting it and clicking
Remove device.
The wizard then asks you to confirm your decision to remove the printer. You confirm it by
clicking Yes.
Graphic
A dialog box appears asking if you're sure you want to remove this device.
SkillCheck
You want to install a network printer using the default name HP LaserJet 5L. You don't want to print
a test page.
The Devices and Printers page is already open.
Task:
1. Access the wizard that enables you to install a new printer.
2. Select the option that enables you to install a network printer.
3. Select the printer you want to install and proceed with the wizard.
4. Accept the default printer name.
5. Select the option to complete the installation.
Answer
To complete the task
Step 1: Click Add a printer
The Add a printer wizard opens.
Step 2: Click Add a network, wireless or Bluetooth printer
The Select a printer page opens.
508

Step 3: Select HP LaserJ et 5L on WIN7-PC120 and click Next
The You've successfully added HP LaserJet 5L page opens.
Step 4: Click Next
Step 5: Click Finish
You return to the Devices and Printers page.
4. Printing documents
Once you've successfully connected and installed the printer, you can use it immediately, to
print reports, envelopes, and photographs.
Most applications have a File menu that allows you to access printing options. For example, you
can perform printing in Windows 7 using the File menu in Microsoft Word. To access this menu,
you click the Office button.
Graphic
The File menu opens and displays these options: New, Open, Save, Save As, Print, Prepare, Send,
Publish, and Close.
There are three different options you can choose when printing.
Print
The Print option enables you to access the Print dialog box where you can specify print settings,
such as the number of copies to be printed, which pages to print, and whether you want to print
double- or single-sided pages.
Quick Print
You can use the Quick Print option to print the document immediately, without changing any
print options.
Print Preview
You can use the Print Preview option to view how the document will be printed. This feature is
useful because you can then adjust the layout of the page before printing.
In the Print dialog box you can adjust the settings to specify the number of copies you want to
print using the Number of copies spin box.
Graphic
509

The Print dialog box is divided into five sections: Printer, Page range, Copies, Print what, and Zoom.
The Copies section displays and the number of copies specified is 2. A Collate checkbox is also
available.
You also specify which pages you want to print. To do this, you select the Pages radio button in
the Page range section before specifying the required page numbers.
Graphic
The Pages radio button is selected and the page number 3 is entered in the Pages field. Three other
options are available: All, Current page, and Selection.
You accept the settings and print the document by clicking OK.
Question
What does the Print dialog box enable you to do?
Options:
1. Specify the pages you want to print
2. Preview the document you want to print
3. Specify the number of copies that you want to print
4. Specify the printer that will print the document
5. View the print queue
Answer
Option 1: Correct. You can select the pages of the document that you want to print in the Print
dialog box.
Option 2: Incorrect. You cannot preview the document using the Print dialog box. To do this, you
choose the Print Preview option in the File menu.
Option 3: Correct. You can specify the number of copies in the Print dialog box. You can also
specify whether the printer will collate the copies or not.
Option 4: Correct. You can specify the name of the printer that will print the document.
Option 5: Incorrect. You cannot access the print queue from the Print dialog box. You access this
from Devices and Printers in the Control Panel.
Correct answer(s):
510

1. Specify the pages you want to print
3. Specify the number of copies that you want to print
4. Specify the printer that will print the document
SkillCheck
You want to print pages 3 and 6 of the "Brochure_NFC" document. The document is already open in
Microsoft Word.

Complete the print job.
Task:
1. Select the option to access the print dialog box.
2. Choose to print specific pages.
3. Specify the pages that need to be printed and then complete the print action.
Answer
To complete the task
Step 1: Click the Office button, select Print, and then select Print again
The PRint dialog box is opened. In the Page range section, the All radio button is selected by
default.
Step 2: Select the Pages radio button
Step 3: Enter 3, 6 in the Pages field and click OK
You return to the Word interface.
You can also view the documents that have been sent to the printer by accessing the print
queue. This enables you to track documents waiting to be printed as well as the status of
printing jobs. In addition, this option is useful if you want to cancel a print job or even reorganize
the queue so that a certain document has priority.
A good example of using the print queue is if you've sent the wrong document to the printer and
you want to stop it from printing.

To access the print queue, you select the printer and click See what's printing.
Graphic
The Devices and Printers page is open in the Control Panel.
511

The dialog box for the printer named "Library Area on ntserver2" displays and lists three
documents in the print queue.
Graphic
In this example, the dialog box for the Library Area on ntserver2 printer lists the documents under
the following column headings: Document Name, Status, Owner, Pages, Size, and Submitted. For
Example, the first document is a Microsoft Word document named Easy Nomad, nothing is specified
in the Status column, the Owner is Jennifer Westlein, it is a one page document with a size of 14.5
KB, and it was submitted at 10:15 AM.
You want to cancel a print job so you select the document name and select Document.
Graphic
The print job Microsoft Word - Brochure_NFC is selected.
You can now pause, cancel, or restart the print job. In this case you want to cancel the print job.
Graphic
The Document menu is open and contains the options Pause, Resume, Restart, Cancel, and
Properties. Cancel is selected.
You are prompted to confirm the cancellation by clicking Yes.
The document Microsoft Word - Brochure_NFC has been removed from the print queue.
Graphic
The document Microsoft Word - Brochure_NFC has been removed from the print queue.
Summary
Printers enable you to produce physical copies of documents. There are two main types of
printers, namely network printers and local printers. Local printers can be connected to
computers in various ways, for example via Bluetooth or USB.

Printers are usually installed automatically when connected to a computer. They can also be
installed manually via the Control Panel.

There are several different print options, including options to preview the document to be
printed, and an option to print documents quickly.
512


You can adjust various print settings. You can also view documents that are printing or cancel,
pause, or restart print jobs.





















513

Working with Programs, Printers, and the Control Panel
Learning Objectives
After completing this topic, you should be able to
install a program
remove a program
install a local printer
print a document
Exercise overview
In this exercise, you're required to work with programs and printing devices.
This involves the following tasks:
removing a program
manually installing a program
manually installing a printer, and
setting printer properties
Task 1: Removing a program
You want to uninstall a program that you no longer use from a computer.
Uninstall the program Adobe AIR from the computer.
Steps list
Instructions
1. Select Start - Control Panel
2. Click Programs
3. Click Programs and Features
4. Select Adobe AIR and click Uninstall
5. Click Uninstall
514

Task 2: Installing a program
You're installing a program, but when you put the CD in the drive the automatic installation fails.
You now need to install it manually.
Install the Office 12 program on a computer. The product key will appear automatically in the
Type your 25-character Product Key text box.

Run the setup manually.
Steps list
Instructions
1. Select Start - Computer
2. Double-click the CD Drive (D:) OFFICE12
3. Double-click setup
4. Click Continue
5. Click Install Now
6. Click Close
Task 3: Installing a printer manually
You're installing a printer on a computer but the automatic installation fails.
Install the local printer, HP PSC 1500 series, manually to the computer. Use the existing port
connection and accept the default printer name. The Devices and Printers page in the Control
Panel is already open.
Steps list
Instructions
1. Click Add a printer
2. Click Add a local printer
3. Click Next
515

Steps list
Instructions
4. Select HP, select HP PSC 1500 series, and click Next
5. Click Next
6. Click Finish
Task 4: Printing a document
You want to configure settings so that only certain pages of a document are printed.
Specify settings to print pages 2 and 4 of the document currently open in Microsoft Word.
Steps list
Instructions
1. Select Start - Print and click Print
2. Select Pages
3. Enter 2, 4 in the Pages field and click OK
A program has been removed from a computer, a program has been installed, a printer has
been installed manually, and printer settings have been configured.






516

System Maintenance
Learning Objectives
After completing this topic, you should be able to
use the Action Center to solve and troubleshoot problems
change the power plan settings
1. Features of the Action Center
Windows 7 keeps you informed of potential problems on your computer through its Action
Center. The Action Center is also linked to the centralized location for preloaded troubleshooting
guides, which you can use to resolve most issues.

Troubleshooting guides can be kept up to date with automatic online updates.
Note
Action Center in Windows 7 replaces the Security Center feature used in Windows Vista.
You can access the Action Center via the Control Panel and clicking System and Security.
Graphic
There are eight categories displayed in the Control Panel: System and Security, Network and
Internet, Hardware and Sound, Programs, User Accounts, Appearance and Personalization, Clock,
Language, and Region, and Ease of Access.
In System and Security, you click on Action Center to view and address any problem reports.
Graphic
The System and Security page has main options that include Windows Firewall, System, Windows
Update, and Power Options.
The problems that Action Center alerts you to are divided into two main categories security
and maintenance.
Graphic
Some security issues found are a lack of antivirus software on the computer and Windows Update
being turned off. An example of a maintenance problem is that the files aren't being backed up.
517

You can expand and collapse the Security and Maintenance headers by clicking on them.
Expanded sections provide more detailed information on problem areas that need to be
addressed.
Security messages are grouped into six categories:
Windows Update
Internet security settings
Network firewall
Spyware and related protection
User Account Control, and
Virus protection
Maintenance messages are grouped into three categories:
Windows Backup
Windows Troubleshooting, and
Check for updates
In addition to the alerts that Action Center displays, it also proposes appropriate resolutions. If
no resolution is readily available, you can troubleshoot problems or roll back to a previously
saved setup.
Graphic
The Troubleshooting option, which enables you to find and fix problems, is found beneath the
Security and Maintenance categories.

The Recovery option, which restores your computer to an earlier time, is also found here.
The default icon for Action Center in the notification area is a white flag. If there are error
messages for you to attend to, a red circle with an X displays over the white flag.
When you click on the icon, a pop-up box appears containing quick links to Action Center
messages, as well as proposed solutions.
Graphic
518

In this example, the Action Center pop-up displays:
2 important messages
3 total messages

Find an antivirus program online (Important)
Change Windows Update settings (Important)
Set up backup

Open Action Center
Alternatively, you can open Action Center itself from within the pop-up box, by clicking Open
Action Center.
In the Action Center window, messages are assigned colors according to urgency. Yellow items
denote suggested tasks that may require attention. Red items are important and demand
immediate attention.
Graphic
The Security messages "Virus protection (Important)" and "Windows Update (Important)" are
marked in red.

The Maintenance message "Set up backup" is marked in yellow.
You can disable message alerts, which is useful if the message is not relevant to you.

It is advisable not to turn messages off unless you are certain they don't apply to you.
Maintenance messages, for instance, may prompt you to perform or set up a backup of your
files.

Backups are extremely important in the event of a system crash, or any other unforeseen loss of
data.
Graphic
The option to turn off messages appears at the end of each message.
When messages are turned off, they will no longer appear in the pop-up window, or Action
Center.
To turn off messages about Windows updates, you click the Turn off messages about
Windows Update link inside the Windows Update message box.
To turn an alert back on, you access the settings and select which messages you want to
receive. You can do this by clicking Change Action Center settings.
519

Graphic
The Change Action Center settings link appears in the left navigational pane. Other links in this
pane are Change User Account Control settings, View archived messages, and View performance
information.
You can then select the Windows Update checkbox to turn the alert on again. You click OK to
confirm the changes.
Graphic
The Windows Update checkbox is in the Security messages section.
If no solution to your problem is listed in Action Center, you can click the Troubleshooting
option below the Maintenance category to find and fix problems.
The Troubleshooting window displays the most commonly used Windows troubleshooters.

Each troubleshooter category contains tasks to help you find and fix common computer
problems.
Graphic
The Troubleshooting window displays the default troubleshooters: Programs, Hardware and Sound,
Network and Internet, Appearance and Personalization, and System and Security.
For instance, you can select Fix problems with Windows Update under System and Security
to address Windows Update issues.
Graphic
Other options in the System and Security section are Run maintenance tasks, Improve power
usage, and Check for performance issues.
In the Troubleshooting window, the troubleshooters are grouped into five main categories:
Programs
The task in the Programs category is Run programs made for previous versions of Windows.
Hardware and Sound
The tasks in the Hardware and Sound category are Configure a device, Use a printer, Troubleshoot audio
recording, and Troubleshoot audio playback.
520

Network and Internet
The tasks in the Network and Internet category are Connect to the Internet and Access shared files and
folders on other computers.
Appearance and Personalization, and
The task in the Appearance and Personalization category is Display Aero desktop effects.
System and Security
The tasks in the System and Security category are Fix problems with Windows Update, Run maintenance
tasks, Improve power usage, and Check for performance issues.
You select the troubleshooter that offers the best solution to address your problem. The
resulting wizard guides you through a step-by-step process to resolve the issue.
It is good practice to ensure that the Get the most up-to-date troubleshooters from the
Windows Online Troubleshooting service checkbox is selected. This keeps your
troubleshooting guides updated with the latest versions.
Question
Which of the following areas fall under maintenance messages?
Options:
1. Windows Troubleshooting
2. Windows Backup
3. Network firewall
4. Internet security settings
5. User Account Control
Answer
Option 1: Correct. Windows Troubleshooting can be found under the Maintenance header.
Option 2: Correct. Windows Backup can be found under the Maintenance header.
Option 3: Incorrect. Network firewall can be found under the Security header.
Option 4: Incorrect. Internet security settings can be found under the Security header.
Option 5: Incorrect. User Account Control can be found under the Security header.
Correct answer(s):
521

1. Windows Troubleshooting
2. Windows Backup
2. Using the Action Center
Any PC issues that need to be addressed will be displayed as soon as you log on to Windows 7.
You'll notice a red circle with an X displaying in the notification area.

When you move your cursor over the icon, a small pop-up appears, displaying messages about
PC issues that need to be addressed.
Graphic
The pop-up displays the message "Solve PC issues: 2 important messages 3 total messages."
To view a summary of the messages, you click the Action Center icon. Windows suggests a
quick remedy for each message, which you can click to address immediately.
Graphic
In this example, the Action Center pop-up displays:

Update Windows Defender (Important)
Find an antivirus program online (Important)
Back up your files
Open Action Center
To address the maintenance issue, you click the Back up your files option.
Next you click Backup in progress to find out how far the backup process is.
Graphic
The Backup in progress option was automatically added to Action Center notification area on the
desktop.
While the backup is in progress, you may be prompted to select a destination for the backup.
This can be a network folder or removable media such as an external drive or DVD disc.
In this instance, you specify the external DVD RW Drive (T:) as the destination, before you click
Next to continue setting up the backup.
Graphic
522

The destinations are listed in the Save backup on list box. Two buttons are also available: Refresh
and Save on a network.
You can either specify what you want to back up or let Windows proceed with the default
settings, by selecting Let Windows choose (recommended) and then clicking Next.
Graphic
A Let me choose radio button is also available.
Once you have completed setting up the backup, you can review the settings before you click
Save settings and run backup to complete the process.
Windows saves your settings and returns you to the Backup and Restore window, where you
can click View Details to monitor the progress of the backup.
You can also troubleshoot an array of problems from within Action Center. If you want to check
for problems that don't appear in the list, you can click the Troubleshooting link at the bottom of
the page.
Graphic
After the back up has been completed, there are no longer Maintenance messages in Action Center.
You click the Run maintenance tasks link in the System and Security troubleshooter.
Graphic
The Troubleshooting window displays the default troubleshooters: Programs, Hardware and Sound,
Network and Internet, Appearance and Personalization, and System and Security.

The Programs troubleshooter solves application-related problems, such as running programs made
for previous versions of Windows.

The Hardware and Sound troubleshooter resolves device-related issues, such as printer setup and
audio playback.

The Network and Internet troubleshooter can be used to solve network-related problems, and to set
up a connection to the Internet.

The Appearance and Personalization troubleshooter deals with display-related issues, such as Aero
desktop.

The System and Security troubleshooter deals with system-related problems, as well as
maintenance tasks and performance issues.
523

In the System Maintenance dialog box you click Next to initiate the troubleshooter and detect
issues that need resolving.
If you're not logged on as an administrator, you click Try troubleshooting as an administrator
to continue.
Graphic
The System Maintenance dialog box states: Issues might be found troubleshooting with
administrator permissions. There is also a link to explore other options.
Windows proceeds to search for issues.
Graphic
The System Maintenance dialog box displays a status bar while detecting issues.
When the troubleshooter has run its course, it displays any issues it has found, and whether
they have been resolved. In this case, the troubleshooter found one issue and resolved it.
Graphic
The System Maintenance dialog box indicates that a problem with troubleshooting history taking up
disk space has been resolved. You can close the troubleshooter or explore other options.
To stop the Action Center icon from appearing in the notification area, you can access the
settings in the Control Panel and click Appearance and Personalization.
You click Taskbar and Start Menu to access the Taskbar and Start Menu Properties dialog
box.
Graphic
The Appearance and Personalization page contains six main options: Personalization, Display,
Desktop Gadgets, Taskbar and Start Menu, Ease of Access Center, and Folder Options.
To specify how icons and notifications appear you click Customize.
Graphic
The Taskbar and Start Menu Properties dialog box has three tabs: Taskbar, Start Menu, and
Toolbars. The Taskbar tabbed page contains three sections: Taskbar appearance, Notification area,
524

and Preview desktop with Aero Peek. The Customize button appears in the Notification area
section.
In the Notification Area Icons window, you can modify icon behaviors by selecting an option from
the Behaviors drop-down menu.
Graphic
The Behaviors drop-down menu next to Action Center displays the options: Show icon and
notifications, Hide icon and notifications, and Only show notifications.
To hide the Action Center icon, you select Hide icon and notifications and click OK.
And you click OK to implement the changes.
SkillCheck
The Action Center icon in the notification area has alerted you to perform a Windows backup. You
have already clicked the link in the Action Center pop-up message and you're currently in the
Backup and Restore window.

Specify that the backup be saved to DVD, save your settings, and view the progress of the backup
process in detail.
Task:
1. Specify the backup destination.
2. Allow Windows to choose which files to back up.
3. Confirm the settings.
4. View details of the backup's progress.
Answer
To complete the task
Step 1: Select backup destination DVD RW Drive (T:) and click Next
The What do you want to backup page opens. The Let me choose radio button is selected.
Step 2: Select Let Windows choose (recommended)
Step 3: Click Next and select Save settings and run backup
Step 4: Click View Details
525

3. Configuring power plan settings
The term power plan refers to a collection of hardware and system settings that manage your
computer's energy conservation.

In addition to saving energy, power plans also maximize system performance, or in some cases,
balance energy with performance.
You can access your power plans by opening the Control Panel and clicking Hardware and
Sound.
In the Hardware and Sound window, you click Power Options to access, modify, and create
power plans.
Graphic
Other options in the window are Devices and Printers, AutoPlay, and Display.
Note
The Power Options window can also be accessed through Start - Control Panel - System and
Security.
Windows provides default power plans that meet the needs of most users. These are the
Balanced, High performance, and Power saver plans.
Graphic
On the Select a power plan page in the Power Options window, the plans Balanced (recommended)
and High performance appear under the Preferred plans section.

The plan Power saver appears under the Hide additional plans section.

In the example, Balanced (recommended) is selected.
The High performance plan optimizes screen brightness and may even improve the
performance of your computer, but it also uses the most energy.

On the other hand, the Power saver plan reduces screen brightness and performance. This
helps maximize energy efficiency, and is ideal for extending battery life on laptop computers.
The Balanced power plan balances performance with energy efficiency. It automatically saves
energy when the computer is idle, and offers performance when in use.
526


It is the default power plan, and recommended for most users.
While the default plans are sufficient for most people's requirements, they can be modified in a
number of ways to suit different situations.
By default, the plan options are faded out and inaccessible. If this is the case, you need to click
Change settings that are currently unavailable.
You can now access each plan's settings, or select a new plan.
You can perform the following tasks to modify power plans:
change the settings for a selected power plan
You can configure after how long the display will turn off, or after how long the computer will go to sleep,
for example.
change the settings that affect all power plans
In the left navigational pane, the options "Require a password on wakeup" and "Choose what the power
button does" affect all power plans.
create a new power plan, and
The option "Create a power plan" appears in the left navigational pane.
delete a plan you created
The "Delete this plan" option appears in a selected plan's settings.
To change settings for the Balanced power plan, you select Change plan settings.
You can now specify when your computer goes into sleep mode, adjust the screen brightness,
and choose when the display switches off during idle periods.
Graphic
In the Edit Plan Settings window, the "Turn off the display" drop-down box is set at "45 minutes".
The "Put the computer to sleep" drop-down box is set to "Never". You can also change advanced
power settings or restore default settings.
You then select Never, before clicking Save changes to apply your settings.
In the Power Options window, there are also two links that affect all power plans when modified.

The Require a password on wakeup link enables you to create a password that needs to be
entered after your computer exits sleep mode. And the Choose what the power button does
link lets you specify what the power or sleep button does when pressed.
527

Clicking on either of these links takes you to the System Settings window, where you are able to
configure the settings.
Graphic
In the System Settings window, under the "Power button settings" section, the "When I press the
power button" drop-down box is set to "Shut down".

Under the "Password protection on wakeup" section, "Require a password (recommended)" is
selected. A "Don't require a password" option is also available.
In the left pane of the Power Options window, you click Require a password on wakeup to
navigate to the System Settings window.
You then select the Require a password (recommended) radio button. By default, your
password will be the same as your user account password, entered when logging onto
Windows.

To apply the new settings, click Save changes and you'll end up back in the Power Options
window.

Once applied, the password prompt will always appear, regardless of what power plan is active.
When the default power plans aren't ideal, you can create a new power plan to suit your specific
requirements.

For instance, when using a laptop to screen a video, you can create a plan that prevents the
display from entering sleep mode. To set up a new plan, you click Create a power plan.
Graphic
The Create a power plan option is in the left pane of the Power Options window.
You then select one of the three default power plans closest to your needs, name your custom
plan, and click Next.
Graphic
In the "Create a Power Plan" window, the plan High performance is selected, and the plan is titled
"Presentations" in the Plan name field.
In the final step, you configure the display and sleep settings, before you click Create.
Graphic
528

In the Edit Plan Settings window, the "Turn off the display" drop-down box is set to "Never", and the
"Put the computer to sleep" drop-down box is set to "Never."
The newly created plan appears under Preferred plans, and the default plan you used as a
template now appears under Hide additional plans.
You can delete customized plans when you no longer have use for them.

To delete a plan, you need to ensure that it isn't in use by deselecting it in the Power Options
window. Then you click Change plan settings next to the plan you want to remove.
Graphic
In the Power Options window, the plan Balanced (recommended) is selected. The option "Change
plan settings" next to the plan "Presentations" is clicked.
Then you select Delete this plan.
It's also important to remember that a plan can't be restored after you delete it. You click OK to
confirm.
Graphic
A Power Options dialog box asks you to confirm if you want to delete the plan.
Windows default power plans Balanced, High performance, and Power saver can't be
deleted under any circumstances.
SkillCheck
Change the Balanced power plan to never turn off the display. You have already accessed the
Power Options window.
Task:
1. Make all options accessible and choose the power plan.
2. Access the power plan's settings.
3. Make options accessible and access the display options.
4. Configure the setting and confirm your changes.
Answer
To complete the task
529

Step 1: Click Change settings that are currently unavailable and select the Balanced
(recommended) radio button
Step 2: Click Change plan settings
The Edit Plan Settings page opens.
Step 3: Click Change settings that are currently unavailable and click the Turn off the display
drop-down arrow
Step 4: From the drop-down menu, select Never and click Save changes
You return to the Power Options window.
Summary
Windows 7 Action Center not only builds on the Security Center from previous versions, but also
offers a comprehensive, central location to monitor potential issues. It is fully customizable and
can be configured to suit your specific needs.

Users are informed of problems through security and maintenance messages. When no solution
is apparent, Action Center can also be used to troubleshoot problems.

You use power plans to manage your computer's power consumption. Power plans essentially
balance your computer's performance with energy conservation. If the default plans don't meet
your requirements, you can create new, custom plans.











530

Windows 7 Security
Learning Objectives
After completing this topic, you should be able to
recognize the words and phrases that follow the guidelines for strong passwords
recognize the security impact for User Account Control settings
1. Creating strong passwords
Computer security is becoming increasingly important, particularly if you work with sensitive or
critical data. Personal information can also be exploited by hackers, and should be guarded
closely.
Passwords and passphrases are security measures that prevent unauthorized access to your
system, files, or any other password-protected resource.

A password is a series of characters which, when entered, provides access to a protected
resource. It's good practice to change passwords regularly.
Passphrases are longer than passwords, and usually comprise words that make up a phrase.
Longer passphrases are considered more secure than passwords.
The stronger a password or passphrase is, the harder it is to crack, or guess.

Strong passwords and passphrases should not
contain personal information, such as your name, business name or address
be similar to previous passwords or passphrases, or
contain words found in the dictionary
It's best not to use words found in the dictionary because this makes your password much more
difficult to guess.

Also, it's essential that passwords are different to previous versions, especially if you're
changing them because they've become known to others.
Additionally, passwords should always contain more than eight characters.

By the same token, a passphrase should never exceed 30 characters, or be less than 20, nor
contain everyday, common phrases.
531

Passwords and passphrases can consist of uppercase and lowercase letters, numbers, spaces,
and symbols found on the keyboard.
Using extended ASCII characters, found in the Character Map, can also help strengthen
passwords. You can access it by clicking Start, typing Character Map in the search box, and
selecting it from the list of results.
Note
Before you use ASCII characters, you need to ensure that it is compatible across all operating
systems and networks used by the password-protected resource.
Windows passwords can comprise up to 127 characters, but to avoid compatibility issues with
earlier versions of Windows, you should limit your passwords to 14 characters.

It helps to mix up numbers, letters, and symbols to make your password stronger, and more
difficult to guess.
For instance, easily remembered information, used in an acronym with numbers and symbols is
ideal.

Deliberate misspellings and substituting letters with numbers can also strengthen passwords or
passphrases.
Regularly changing your Windows password could prove effective in foiling any hacking
attempts. This is necessary if your current password becomes known, and you need to prevent
it being used.
To quickly change your password, you press Ctrl+Alt+Delete and select the Change a
password option. Then you enter your current password, followed by your new password,
which you confirm in the last text box.
You can reset forgotten passwords using a password reset disk, or they can be changed by an
administrator.

However, when passwords are changed by an administrator, all encrypted data or mail is lost to
the user whose password was changed.
Question
What are the guidelines for creating strong passwords and passphrases?
Options:
1. They shouldn't contain any words found in the dictionary
532

2. They should be a combination of letters, symbols, and numbers
3. They should be similar to previous versions
4. They should be made up of common, everyday phrases
5. They shouldn't be changed regularly
Answer
Option 1: Correct. Strong passwords and passphrases shouldn't comprise words easily found in the
dictionary because this makes them easier to guess.
Option 2: Correct. Strong passwords and passphrases are a combination of uppercase and
lowercase letters, numbers, and symbols, which makes them difficult to guess.
Option 3: Incorrect. New passwords and passphrases shouldn't be similar to previous versions
especially if you changed the password or passphrase because it had become known to others.
Option 4: Incorrect. Strong passwords and passphrases shouldn't be made up of common,
everyday phrases because those are easy to guess.
Option 5: Incorrect. Strong passwords and passphrases should be changed regularly in case your
password has been cracked and is being used without your knowledge.
Correct answer(s):
1. They shouldn't contain any words found in the dictionary
2. They should be a combination of letters, symbols, and numbers
To create stronger passwords and passphrases, you need to combine numbers, symbols,
spaces, uppercase and lowercase letters in ways that you can remember yet are difficult for
someone else to guess.
Graphic
An example of a password is 143LP*142.
You can use easily remembered personal information, such as a favorite sport, hobby, or
pastime of a family member. Converting this information into an acronym combining numbers
and symbols creates a very strong password.

For example, "I live for Superbowl Sundays!" could read as "eYeL4SS!" and result in a strong
password.
Furthermore, intentionally spelling a word incorrectly also helps strengthen passwords and
passphrases. So too would replacing letters with numbers, and vice versa.
533

Using this as a guideline, "Pittsburgh Steelers No. 1 fan!" could read as "PITTSt33l3rs#1f@n!"
and provide more security than the original.
Birth dates and full words make poor passwords that can easily be guessed and bypassed.

For example, Bob Smith names his son, born 4 September 2004, Bob Junior. Based on this,
Bob creates the password "bobsmith.0904". Anyone who knows a little bit about Bob could
easily guess this password.
But if Bob combined the information with symbols, numbers, and uppercase letters, he could
strengthen the password.

For instance, "b0B!5m1th\ID4" would be much more secure.
Question
Which passwords follow the guidelines for strong passwords?
Options:
1. T0dd!Gr3y\ID4
2. $w33T_t00th
3. p@ssword
4. jennifer.westlein
5. toddgreyjr.0704
Answer
Option 1: Correct. "T0dd!Gr3y\ID4" follows the guidelines for strong passwords because it
substitutes letters with numbers.
Option 2: Correct. "$w33T_t00th" follows the guidelines for strong passwords because it combines
symbols and numbers with letters.
Option 3: Incorrect. "p@ssword" follows some of the guidelines for strong passwords, but is a
commonly used variation of the word "password" and easily guessable.
Option 4: Incorrect. "jennifer.westlein" doesn't follow the guidelines for strong passwords because it
is a username, and easy for hackers to guess.
Option 5: Incorrect. "toddgreyjr.0704" doesn't follow the guidelines for strong passwords because
while it combines numbers and letters, it is still easy to crack.
Correct answer(s):
534

1. T0dd!Gr3y\ID4
2. $w33T_t00th
2. User Account Control
When you use Windows, there are many programs that run in the background. Some programs
may even attempt to make changes to your system without your knowledge or consent.
User Account Control, or UAC, is a security feature in Windows 7 that enables you to monitor
and control programs. Each time a program tries to make changes that require administrator-
level permission, the UAC pop-up appears on screen.

If you are an administrator on the computer you're using, you can either grant or deny access.
However, if you're a standard user, you may have to enter an administrative password before
continuing.
In this way, UAC lessens the likelihood of malware and spyware affecting your computer and
compromising security.
At the same time, UAC also adjusts the permission level of your user account, according to the
tasks you're performing.
If none of the tasks require administrator-level access, UAC adjusts the permission level to that
of a standard user. This helps keep your computer secure because any programs that require
administrator-level access will cause UAC to prompt you for confirmation.
When you perform a task that requires administrator permission, the UAC pop-up appears by
default. If you grant permission, the computer temporarily allows administrative access, until the
task is completed.
UAC notifies you of permission requests using four different types of dialog boxes and icons:
A task, setting, or program that's part of and trusted by Windows
This icon indicates content published and signed by Microsoft. Although this is the most
trustworthy type of program, it's advisable to check the content before granting permission.
A shield divided into four colored squares, with like colors diagonally opposite each other.
A task, setting, or program that's not part of Windows
This icon indicates content with a valid digital signature, but not developed by Microsoft. You
need to ensure that the program is the one you want to run before granting access.
A shield with a question mark across it.
A task, setting, or program from an unknown publisher, and
This icon indicates content not developed by Microsoft, which doesn't have a valid digital
signature.
535


Sometimes, older, trustworthy programs without signatures elicit this type of response. If you're
running the program from the original disc or a trusted source, it's safe to grant permission.
A shield with an exclamation mark across it.
A task, setting, or program that's been blocked by the system administrator
This icon indicates content generally considered untrusted, and intentionally blocked by the
administrator. You need to negotiate access with the administrator, if it's essential you access the
resource.
A shield with an X across it.
It's good practice to log on to your computer as a standard user, since it still allows access to
most commonly used programs. This way, the UAC remains at its most secure setting.
Whenever a situation arises where you need administrative access, you can simply enter the
administrative password when prompted by Windows.
UAC in Windows 7 is fully customizable so you can control when you want to be notified of
changes. To err on the side of caution, and for optimal security, it's best to choose to always be
notified.
Question
Match each UAC description to the related icon.
Options:
A. A task, setting, or program that's part of and trusted by Windows
B. A task, setting, or program that's not part of Windows, but has a digital signature
C. A task, setting, or program from an unknown publisher
D. A task, setting, or program that's been blocked by your system administrator
Targets:
1. T32_301
2. T32_302
3. T32_303
4. T32_304
Answer
This describes content published and signed by Microsoft. It is the most trustworthy type of dialog
box.
This icon indicates content bearing a valid digital signature, but not developed by Microsoft.
536

This icon indicates content not developed by Microsoft, which doesn't bear a valid digital signature.
This icon indicates content generally considered to be untrusted, and intentionally blocked by the
administrator.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Windows 7 notifies you whenever programs attempt to make changes to your computer, by
default. These notifications are controlled through the UAC.
To access the UAC settings, you click Start - Control Panel.
Graphic
Other options in the Start menu include Computer, Devices and Printers, and Windows Security.
You then click System and Security.
Graphic
There are eight categories displayed in the Control Panel: System and Security, Network and
Internet, Hardware and Sound, Programs, User Accounts, Appearance and Personalization, Clock,
Language, and Region, and Ease of Access.
Next you click Action Center.
Graphic
Other options in the System and Security page include Windows Firewall, System, Windows
Update, and Power Options.
In Action Center, you click Change User Account Control settings in the left pane.
Graphic
Other options in the left pane are Change Action Center settings, View archived messages, and
View performance information.
537

Note
You can also access the UAC settings by clicking Start - Control Panel. Then, from within Control
Panel, you type UAC in the search text box and click Change User Account Control settings.
There are four User Account Control settings you can configure to customize notifications.
These are selected by moving the slider up and down the scale. These settings are
Never notify me
This is the least secure setting. With UAC on this setting, you should be vigilant when running
programs, especially at administrator-level access because changes could be made to protected
data and system settings. Viruses could also potentially infiltrate your system from the Internet.

If you're logged on as a standard user, all administrator-level requests will be denied. If you're
logged on as an administrator, changes could occur without notification.

This setting isn't recommended and should only be chosen when critical programs are uncertified
for use with Windows 7.
Notify me only when programs try to make changes to my computer (do not dim my
desktop)
This setting is marginally more secure than 'Never notify me'. With UAC on this setting, secure
desktop doesn't dim the desktop when the pop-up notification appears. This means the pop-up
may be obscured by other windows, and you would be unaware of it.

On this setting, notifications appear when programs attempt to make changes at administrator
level, but not when you make changes to Windows. Notifications also appear when an outside
program attempts to make changes to Windows settings.

This setting isn't recommended unless secure desktop takes too long to dim.
Notify me only when programs try to make changes to my computer, and
This is the default Windows setting. With UAC on this setting, secure desktop dims the desktop to
ensure that pop-ups are noticed.

Notifications appear when programs attempt to make changes at administrator level, but not
when you make changes to Windows settings. Notifications also appear when an outside
program attempts to make changes to Windows settings.

While it's not unsafe to allow changes to Windows without notification, certain Windows programs
are susceptible to attack by malware. For this reason, you need to be aware of all programs
running on your computer.

538

This is the easiest setting to work with, especially if you regularly visit familiar web sites and use
trusted programs.
Always notify me
This is the most secure setting. With UAC on this setting, notifications appear every time a
program attempts to make changes to your computer. Secure desktop dims the desktop each
time, and you have to confirm or deny requests before you can continue.

This setting offers optimum security, and you should read each pop-up notification carefully
before granting or denying access.

If the software on your computer is changed often, this is ideal. Also, if you visit unfamiliar sites
on a regular basis, this setting provides an added layer of security against viruses.
Question
Match each UAC setting level to its relevant characteristics.
Options:
A. Always notify me
B. Notify me only when programs try to make changes to my computer
C. Notify me only when programs try to make changes to my computer (do not dim my desktop)
D. Never notify me
Targets:
1. The most secure setting, in which a notification appears every time changes are attempted
2. The Windows default setting, which makes use of secure desktop
3. Like the Windows default, but without secure desktop
4. The least secure setting, in which there is no notification when changes are made
Answer
Notifications appear every time a program attempts to make changes to the computer.
Notifications will appear when programs attempt to make changes at administrator level, but not
when users make changes to Windows settings. When pop-ups appear, secure desktop dims the
desktop until you acknowledge the notification.
Notifications appear when programs attempt to make changes at administrator level, but not when
users make changes to Windows settings. Secure desktop doesn't dim the desktop and this means
the pop-up may be obscured by other windows, without your knowledge.
When logged on as an administrator, changes could occur without notification.
539

Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Summary
Passwords and passphrases provide a security barrier between your personal data and
unauthorized users. Strong passwords are combinations of letters, numbers, and symbols. The
stronger a password, the more protected your resource.

Windows 7 has made improvements to the User Account Control feature, providing more
customized security. While keeping the UAC at its lowest setting may be more convenient, it is
not necessarily more secure. To ensure the best security possible while using Windows 7, the
UAC should be set to Always notify me.













540

Backing up and Restoring Folders and Files
Learning Objectives
After completing this topic, you should be able to
back up and restore data
create a restore point and perform a system restore
1. Windows 7 backup tools
Michael is the manager of a small publishing company and is constantly on the go. He relies
heavily on his laptop for both storage of information and coordinating projects, but disaster
strikes when he accidentally deletes a folder containing crucial files relating to his recent project.
If Michael had backed up his laptop, he could have avoided the consequences of lost data. By
performing regular system and data backups, he would have been able to restore his files and
keep the damage to a minimum.
Windows 7 provides various tools that can be used to back up data:
file backups
When Windows Backup is enabled, it automatically makes regular copies of files for each
registered user. Windows automatically chooses what to back up or you can make a custom
selection.

Windows performs these backups on a regular schedule, which you can modify. You can also
manually back up your files whenever you choose.
previous versions, and
You can maintain previous versions of files and folders that enables you to restore data in the
event of a system failure. You can use previous file versions to restore damaged files and folders,
which can be opened, or saved to a different location. This isn't a backup method as the files are
only on one drive, and would be lost if the drive were damaged.
system restores
The System Restore tool enables you to undo changes to your computer's system files by
restoring them to versions from an earlier point in time. It uses the system protection feature to
create regularly scheduled restore points, which contain registry settings and system information.

You can also create restore points manually. For instance, you can create one prior to installing
an application you're not sure of. If the application causes problems, you can then restore the
system to the state it was in prior to installing the application.
541

It is important to use all the backup tools and configure them to suit your system. This ensures
maximum protection for files in the event of a system or hardware failure.
You should back up files to media that is physically separate from your computer so that the
data and settings can be restored to a new computer if necessary.
You can back up files and the system to an external hard drive, some of which can hold 1 TB or
more. This ensures that data is safe if the computer suffers physical damage.
While it is recommended that you back up to a drive that doesn't contain Windows, it is also
possible to back up data over a network, and onto writable media like CDs and DVDs.
Question
Match each tool to the function it performs.
Options:
A. File backup
B. System restore
C. Previous versions
Targets:
1. Creating a copy on another disk
2. Rolling back the whole computer to a previous state
3. Storing older copies of a file
Answer
When Windows Backup is enabled, it automatically makes regular copies of files for each registered
user.

Windows performs these backups on a regular schedule, which you can modify. You can also
manually back up your files whenever you choose.
The System Restore tool enables you to undo changes to your computer's system files by restoring
them to versions from an earlier point in time. It uses the system protection feature to create
regularly scheduled restore points, which contain registry settings and system information.

You can also create restore points manually. For instance, you can create one prior to installing an
application you're not sure of. If the application causes problems, you can then restore the system to
the state it was in prior to installing the application.
542

You can maintain previous versions of files and folders that enables you to restore data in the event
of a system failure. You can use previous file versions to restore damaged files and folders, which
can be opened, or saved to a different location.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
2. Identifying types of backups
Backing up data involves making copies of the data so that it can be recovered if the original is
lost or deleted. Many people rely heavily on backups, as data loss happens all too often, and
lost data can easily translate to a financial loss.
You can perform backups from the Backup and Restore center, which enables you to configure
Windows to perform regular backups in two ways:
scheduled backups
You can change the Windows default schedule from every Sunday at 7:00 p.m. to a time that
suits your requirements. For instance, you might want backups done twice a week or only
monthly.

By default, Windows backs up data files saved in libraries, files on the desktop, and in default
Windows folders. It also creates a system image to be used for system restores. You can specify
additional files and folders that you want backed up.
manual backups
After performing your first backup you can manually back up your data anytime from the Backup
and Restore center. You can then specify where you want the backup stored and which files and
folders to back up.
The settings you need to configure for your first backup include the destination drive and what
files you want to include.
Graphic
The Review your backup settings page lists the backup location New (E:), the backup summary of
items and included files and folders, and the schedule.
Before the backup starts, you are given a chance to change your settings, including the default
schedule that Windows has set.
543

Once you have specified the backup settings, you can run the manual backup any time you
choose.
If you are backing up data onto a CD or DVD, you can create a new, full backup using the
Create a new, full backup option in the left-hand pane. This option is not available if you are
backing up onto a hard drive or across a network.
Even if your computer is scheduled to back up files regularly, there are times when it is wise to
perform a complete manual backup. If you are installing a new suite of software that may alter
your system settings, or embarking on a business trip with your laptop, a complete manual
backup is good insurance for your data.
Question
Which option enables you to back up data for the first time?
Options:
1. Creating a system image
2. Creating a system repair disc
3. Configuring backup settings
4. Recovering system settings on your computer
Answer
Option 1: Incorrect. Creating a system image creates a complete copy of your Windows drive,
which can be used in restores.
Option 2: Incorrect. Creating a system repair disc creates a CD/DVD of Windows system recovery
tools that can be used to help with a system restore.
Option 3: Correct. Before you can back up data for the first time, you need to specify what you want
to back up, how often you want the data backed up, and when you want the backup process to run.
Option 4: Incorrect. You use this option to launch the System Restore center and access system
recovery options.
Correct answer(s):
3. Configuring backup settings
3. Backing up and restoring data
To access the Backup and Restore center, you select Start - Control Panel.
544

Graphic
Other options in the Start menu include Computer, Devices and Printers, and Windows Security.
Then you click System and Security.
Graphic
There are eight categories displayed in the Control Panel: System and Security, Network and
Internet, Hardware and Sound, Programs, User Accounts, Appearance and Personalization, Clock,
Language, and Region, and Ease of Access.
Finally, you click Backup and Restore.
Graphic
This option also contains two links: Backup your computer and Restore files from backup.
The Set up backup wizard opens, and displays a list of destination drives for backed up data. It
also gives the option to navigate to a network destination.
Graphic
New (E:) is selected by default.

Two buttons are available: Refresh and Save on a network.
Windows offers you two choices of what will be backed up.
Graphic
The What do you want to backup page is open.
Let Windows choose
If you let Windows choose the files to back up, it will back up all users' data files saved in
libraries, on the desktop, and in Windows default folders, such as AppData, Contacts, Desktop,
Downloads, Favorites, Links, Saved Games, and Searches.
This option contains a How does Windows choose what files to back up link.
Let me choose
If you specify certain files to be backed up you can back up any files except program files, files on
FAT formatted hard drives, files in the Recycle Bin, and temporary files on drives under 1 GB in
size.
545

You can now review the files you are about to back up. Windows also sets a default schedule for
regular back ups, which can be edited or turned off.

You choose to save your settings and start the backup.
Graphic
In the Backup Summary section, there are the items All users, and System image.

A Save settings and run backup button is available.
While Windows backs up the data you can view its progress or cancel the backup.
Graphic
The Windows Backup window shows that the backup is 31% complete and that a file called
Wildlife.wmv is currently being copied.
Once the backup is complete, Windows returns to the Backup and Restore center.
You can use the Restore section of the Backup and Restore center to restore all users' files,
select another backup to restore files from, and recover system settings from your computer.
Graphic
This section contains a Restore my files button and three links: Restore all users' files, Select
another backup to restore files from, and Recover system settings from your computer.
To restore files from the most recently created backup, you click the Restore my files button.
Graphic
Windows indicates that the Restore my files option restores files that were backed up on the current
location.
The Restore Files wizard opens and enables you to choose what you want to restore or to
browse to backed up files.
Graphic
To browse to backed up files, you click the Browse for files button. Search, and Browse for folders
buttons are also available.
546

The backed up file that you want to restore is the desktop configuration settings file. This is
stored on the destination drive that you specified in the initial backup. You now need to navigate
to the appropriate folder and add the file to the list.
Graphic
The desktop file in New (E:)\Jennifer Westlein\Documents has been selected and you click the Add
files button.
Once the file has been added to the list, you proceed to the next screen of the wizard.
Graphic
To proceed to the next screen of the wizard, you click Next.
You can then choose whether to restore the file to its original location, or browse to a new
location. Once you have chosen, you click Restore to restore the file.
Graphic
The In the original location radio button is selected. An In the following location radio button is also
available and contains a text box, and associated Browse button.
Before the file is restored to its original location, Windows gives you three options.
Graphic
The Copy File dialog box is open and has three options: Copy and Replace, Don't copy, and Copy,
but keep both files.
Copy and Replace
Copy and Replace replaces the original file with the file in the backup.
Don't copy
Don't copy stops the restore and no files are copied.
Copy, but keep both files
Copy, but keep both files copies the backup to the original file's destination, but renames it so
that the original file isn't overwritten.
You choose Copy and Replace, so Windows replaces the file in the destination folder with the
file from the backup location.
547

SkillCheck
Back up your files for the first time to the CD drive, letting Windows choose which files to back up
and retaining the default schedule.

You've already opened the Backup and Restore center.
Task:
1. Access the option to configure backup settings.
2. Specify a location for the backup and proceed with the wizard.
3. Ensure that the settings are correct and proceed with the wizard.
4. Perform the backup.
Answer
To complete the task
Step 1: Click Set up backup
The Set up backup wizard is open.
Step 2: Select CD Drive (D:) and click Next
The wizard now allows you to choose what files will be backed up.
Step 3: Click Next
The wizard lists the backup summary and schedule.
Step 4: Click Save settings and run backup
The backup is complete and you return to the Backup and Restore center.
4. System protection settings
System protection is a Windows feature that enables you to save system file information,
settings, and previous versions of modified files. These are saved in restore points, which you
are prompted to create before system changes, such as software or drive installations.
You can use restore points to return a system to a previous condition or to restore previous
versions of files and folders that have been modified or deleted.

This feature is particularly handy if you have accidentally deleted or saved over an important file
as it can be restored to the most recent version, or a suitable older version.
Restore points can only be activated for NTFS formatted drives and are created automatically
on the drive on which Windows is installed. By default, Windows creates restore points seven
548

days after the last restore if there have been no major system changes, but can be manually
created at any time.
You can configure system protection options in the System Protection dialog box.
Restore system settings and previous versions of files
The Restore system settings and previous versions of files option creates restore points that
contain system information, settings, and previous versions of files. It enables you to restore the
system and previous versions of files.
Only restore previous versions of files
The Only restore previous versions of files option only makes backups of previous versions of
files, so you will be unable to perform a system restore from restore points created with this
setting.
Turn off system protection
The Turn off system protection option deactivates system protection, so no restore points will be
created.
By default, system protection only runs on a drive that is 1 GB or larger. However, you can
change the amount of hard drive space it uses over and above 1 GB in the System Protection
dialog box.
Graphic
The dialog box is divided into two sections: Restore Settings, and Disk Space Usage.
You can increase the space allocation by dragging the slider in the Disk Space Usage section to
the right, or decrease it by dragging the slider to the left.

If the space allocation is decreased, older restore points may be deleted. Generally however,
older restore points are deleted as new points are created.
The System Protection settings window also enables you to manually delete restore points.
Question
Which options enable you to specify system protection?
Options:
1. Restoring system settings and previous versions of files
2. Deleting a restore point
3. Only restore previous versions of files
549

4. Decreasing the system protection disk usage to below 1GB
Answer
Option 1: Correct. This option creates restore points allowing full system restores and the restoring
of previous versions of files.
Option 2: Incorrect. This would delete your restore points and actually prevent you from performing
a system restore.
Option 3: Correct. This option creates restore points storing only previous versions of files.
Option 4: Incorrect. It isn't possible to decrease the disk usage amount below the minimum required
to run system protection.
Correct answer(s):
1. Restoring system settings and previous versions of files
3. Only restore previous versions of files
5. Performing a system restore
To enable system protection for a second drive, you select System in the System and Security
section of the Control Panel.
Then you select System protection.
Graphic
The left-hand pane of the View basic information about your computer page contains links to Device
Manager, Remote settings, System protection, and Advanced system settings. The main part of the
page is divided into sections, including Windows edition, System, and Computer name, domain, and
workgroup settings.
In the System Protection tab of the System Properties dialog box you choose the new drive
and click Configure to access the configuration settings.
Graphic
The System Protection tab contains two sections: System Restore and Protection Settings. In this
case, you choose the New (E:) drive.
You specify settings to restore the system settings and all previous versions of files, and accept
the changes by clicking OK.
550

You click Create to create a restore point.
You give the new restore point a name, click Create, and Windows adds the time and date.
Graphic
The restore point is called Restore_e.
Windows informs you that the restore point was successfully created.
To perform a system restore, you select Start - All programs - Accessories.
Then you expand the System Tools program group and select System Restore.
Graphic
Other system tools include Computer, Control Panel, and System Information.
Windows then opens the System Restore wizard.
The System Restore wizard prompts you to access the next page.
Graphic
The System Restore wizard displays the text: System restore can help fix problems that might make
your computer run slowly or stop responding. System restore does not affect and of your
documents, pictures, or other personal data. Recently installed programs and drivers might be
uninstalled. It then provides a link to answer the question, is this process reversible? You click Next.
You accept the default restore point and click Next.
Graphic
The Restore your computer to the state it was in before the selected event page displays, with the
Automatic Restore Point option selected by default. A Show more restore points checkbox is
available, as well as a Scan for affected programs button.
You click the Scan for affected programs button to check which programs may be affected by
the restore.
Windows scans for affected programs, and you click Close.
Graphic
551

In this case, Windows finds no affected programs.
You confirm which drive or drives you want to restore and you click Next.
Graphic
Local Disk (C:) (System) is selected for the restore process.
Then you confirm the system restore settings and click Finish.
Windows then offers a chance to go back and change your settings before the restore begins.
Graphic
The pop-up box states that System Restore cannot be interrupted once it has started, and asks if
you want to continue.
The system restore then begins. Your computer will restart as part of the restore, and Windows
will be restored to the settings from the restore point you chose.
Graphic
A progress bar indicates that Windows is preparing to restore the system.
When you want to restore a single file to a previous version, you can access the Previous
Versions tabbed page in the file's Properties dialog box.
To do this, you right-click the file and select Properties from the shortcut menu.
Graphic
In this case, the file is called test.doc. Other options in the shortcut menu include Open with, Share
with, Create shortcut, and Rename.
You then access the Previous Versions tabbed page, which lists all the restore points containing
copies of the file you want to restore.
Graphic
The Properties dialog box has four tabs: General, Security, Details, and Previous Versions. The File
versions pane lists the available restore points. In this case, there is just one version.
552

Once you have selected the file, it is advisable to make a copy of it before you overwrite the
original. This way you can ensure it is the correct version.
Graphic
The file, test, has been selected, and the Copy button is clicked.
You choose to copy the file to the desktop, so you can open it and ensure it is the correct
version.
Graphic
The Copy Items dialog box is open. A list box lists the available locations. A Folder text box is
available, and Make New Folder, Copy, and Cancel buttons. In this case, you copy the file to the
desktop.
Because your original file is stored on the desktop, you select the Copy, but keep both files
option so that you don't overwrite the original.
The copy of the restored file is now on your desktop. Once you have made sure it is correct, you
can either delete the original file, or perform another previous version's restore and use that to
overwrite the original.
Graphic
The name of the newly restored file has (2) appended to it.
SkillCheck
Restore the entire system from a restore point called backup and scan for programs that may be
affected by the restore.

You have already accessed the System Tools program group in the Start menu.
Task:
1. Open the System Restore tool.
2. Proceed with the wizard.
3. Scan affected programs, then proceed with the wizard.
4. Perform the system restore.
Answer
553

To complete the task
Step 1: Select System Restore
The System Restore wizard is open.
Step 2: Click Next
You can now select a restore point. Two points are available: backup and Restore_e.
Step 3: Click Scan for affected programs, click Close, and then click Next
When no errors are detected, you click Close and return to the wizard. You click Next, and you're
asked to confirm your restore point settings.
Step 4: Click Finish, then click Yes
Windows prepares to restore the system.
Summary
Windows 7 provides three backup tools File backup, Previous versions, and System Restore,
which can be used to ensure the safety of your system, files, and settings.

Backups can be scheduled or created manually. The first time you backup your computer,
Windows enables a default weekly schedule, which you can change to suit your requirements.

You follow the wizard when you create your first backup, choosing what you would like to back
up, and where to back up the data to. You can choose between hard drives or writable media.

System protection settings create restore points before major system changes. Restore points
can be used to return your system to a previous state prior to a change or to access previous
versions of files.

You can perform a system restore if you have installed new software or changed system
settings and Windows no longer works properly. You can also access previous versions of files
if they have become corrupt or have accidentally been deleted.






554

Performing Maintenance and Security Tasks
Learning Objectives
After completing this topic, you should be able to
use the Action Center to solve a problem
backup data to a disc
restore data from a backup
perform a system restore
Exercise overview
In this exercise, you're required to perform maintenance and security tasks.
This involves the following tasks:
using the Action Center
backing up data to a disc
restoring data from a backup, and
performing a system restore
Task 1: Using the Action Center
You want to schedule when updates will be automatically installed on your computer.
The Action Center icon in the notification area is displaying an important message to set up
Windows update. Open Action Center and manually schedule updates to install automatically
every Monday at 2:00 PM.
Steps list
Instructions
1. Click the Action Center icon and select Open Action Center
2. Click Change settings
3. Select Let me choose
4. Select Install updates automatically (recommended)
5. Select Every Monday at 2:00 PM
555

Steps list
Instructions
6. Click OK
Task 2: Backing up data to a disc
You now want to create a backup for the first time.
Back up your data for the first time to the E drive, letting Windows choose which files to back up.
The default schedule should remain unchanged. You've already opened the Backup and
Restore center.
Steps list
Instructions
1. Click Set up backup
2. Click Next
3. Click Next
4. Click Save settings and run backup
Task 3: Restoring data from a backup
You now want to restore data from the backup you created earlier.
Restore the Easynomad brochure file from the backup you just created. The file has been
backed up to Backup on New (E:)\Backup of C:\Users\Jennifer
Westlein\Documents\wordpadfiles. Overwrite the original file with the restored backup. You have
already opened the Backup and Restore center.
Steps list
Instructions
1. Click Restore my files
2. Click Browse for files
556

Steps list
Instructions
3. Double-click Backup of C:, then double-click Users, then double-click Jennifer Westlein, then double-click
Documents, then double-click wordpadfiles
4. Click Easynomad brochure and click Add files
5. Click Next
6. Click Restore
7. Click Copy and Replace
8. Click Finish
Task 4: Performing a system restore
You've installed a new security patch but you now want to return Windows to the state it was in
prior to installing the patch.
Perform a system restore from the restore point called extra, scanning for affected programs
before completing the restore. You have already accessed the System Tools folder under
Accessories in the All Programs list.
Steps list
Instructions
1. Click System Restore
2. Click Next
3. Click extra and then click Scan for affected programs
4. Click Close
5. Click Next
6. Click Finish
7. Click Yes
557

A problem has been solved with the Action Center, data has been backed up to disc, data has
been restored, and the system has been restored.






















558

Customizing the Windows 7 Desktop
Learning Objectives
After completing this topic, you should be able to
personalize the desktop
personalize your desktop with Windows 7 gadgets
1. Identifying ways to personalize your desktop
Windows 7 offers a wide range of personalization options, enabling you to change the look, feel,
and sounds of your PC.
You can personalize your computer using a variety of personalization options that are
accessible from the Personalization section in the Control Panel.
A quick way to customize your computer desktop is to choose one of the themes already
installed on a Windows 7 system. A theme is a preconfigured collection of display options and
sounds.
Windows 7 contains three types of themes:
Basic
Basic themes use fewer computer resources than other themes and are recommended for
computers with limited processing abilities. Basic themes run only the standard elements required
by the Windows 7 interface.
High contrast, and
High contrast themes make onscreen items stand out through the use of different colors and high
contrast. This makes the onscreen items more visible and easier to read.
Aero
Aero themes use translucent windows with tints and animations to create distinctive graphical
user interfaces. They have glass-like effects and transparent windows, where non-Aero themes
use solid colors.
Each Windows 7 theme provides a distinctive
desktop background
The desktop background, also called the wallpaper, is the image that decorates the computer
screen. This can be a personal image or photograph, or a default image provided by Windows 7.
You can also create a desktop background in the form of a slide show. By default, each theme
includes a particular desktop background.
window color
559

Most Windows 7 editions, including the Windows 7 Home Premium, Professional, Enterprise, and
Ultimate editions, come with the option to use Aero themes, which provide a number of graphical
enhancements including glass like semi-transparent window borders. Each theme includes a
particular set of colors and window display settings.
sound scheme, and
Windows can play different sounds on your computer to signify different events for example
when you log on or off, or when you receive new e-mail. Some desktop themes include their own
customized sound schemes.
screen saver
A screen saver is a picture, pattern, or animation that appears on your computer screen once the
computer has been idle for a specified period of time. Screen savers can be personal pictures, or
you can select one of the default images installed on the operating system. A theme has a default
screen saver.
You can configure your computer to display a customized user account picture, which displays
on the Welcome screen you see when you first log on and on the Start menu.
In addition, you can use the Control Panel's display options to adjust the computer's display
settings, either increasing or decreasing the size of the font and images.
Question
You want to personalize your Windows 7 desktop by installing a photograph you took as wallpaper.

How would you do this?
Options:
1. By changing the desktop background
2. By changing the screen saver
3. By setting the window color
4. By altering the sound scheme
Answer
Option 1: Correct. Wallpaper is another term for a desktop background. You can choose a desktop
background from the list of those that come with Windows or choose a personal photograph or
image for use as a background.
Option 2: Incorrect. Wallpaper is another term for a desktop background, rather than for a screen
saver which displays only when a computer has been idle for a specified time. However, you can
also change the screen saver on your computer, using either a default image available in Windows
or another image you choose.
560

Option 3: Incorrect. Changing the window color will change the tint and translucency settings of the
existing desktop background, rather than letting you install a new image as the background.
Option 4: Incorrect. You need to install a personal photo as the desktop background in this case,
rather than changing the sounds your computer uses to signify specific events.
Correct answer(s):
1. By changing the desktop background
2. Personalizing the desktop
You can customize a selected theme by modifying each of its features, including its
desktop background
window color
sound scheme, and
screen saver
To configure the individual features of a theme, you first click Start and select Control Panel.
Next you click Appearance and Personalization.
Graphic
The Control Panel displays a number of categories that you can use to adjust your computer's
settings for example, System and Security, Network and Internet, Appearance and
Personalization, and Programs.
You then click Personalization.
Graphic
The Appearance and Personalization screen contains options such as Personalization, Display, and
Desktop Gadgets. A panel on the left of the screen displays links to the other Control Panel
categories.
Note
You can also access the Personalization settings by right-clicking the empty space on your desktop
and selecting the Personalize option from the shortcut menu that displays.
561

The Personalization screen enables you to configure the visual and sound settings on the
computer. Currently, the Windows 7 default Aero theme is selected.

Suppose you want to change the desktop background image this theme applies which is
named "Harmony" to one of the sample images available in the Pictures Library in Windows 7.
To begin, you click Desktop Background.
Graphic
The Personalization screen includes a pane for choosing a theme. The Windows 7 theme in the
Aero Themes category is currently selected. The screen also includes four labeled icons identifying
the settings of the selected theme Desktop Background, which is currently set to Harmony;
Window Color, which is set to Sky; Sounds, which is set to Windows Default; and Screen Saver,
which is set to None.
Then you select Pictures Library from the Picture location drop-down list.
Graphic
On the Desktop Background screen, the Picture location drop-down list includes Windows Desktop
Backgrounds, Pictures Library, Top Rated Photos, and Solid Colors options.
You select the image you want to use as a background in this case of a chrysanthemum and
click Save changes.

If the image or picture that you want to use as your desktop background is not in the list of
Windows desktop backgrounds, you can browse your computer directory, locate the image, and
double-click it. The image will then display as your desktop background.
Graphic
The Pictures Library screen enables you to choose from a number of sample pictures. The page
also contains options that enables you to specify how the image will fill the screen and if you have
selected a slide show format, how often the image will change.
Now suppose you want to change the window color. You begin by clicking Window Color on
the Personalization screen.
The Window Color and Appearance screen lets you choose one of a set of different colors for
the window borders, the Start menu, and the taskbar. You can also enable or disable the
translucency effect for a selected color, adjust color intensity, or mix your own colors using the
color mixer feature, which includes sliders for hue, saturation, and brightness.

In this case, you select the predefined Leaf window color.
562

Graphic
The Window Color and Appearance screen displays thumbnails of different colors, an Enable
transparency checkbox, and a color intensity slider. A Show color mixer drop-down button is
available, and an Advanced appearance settings link.
You then click Save changes.
Next you want to change the sound scheme, which is currently set to the Windows Default
option. To begin, you click Sounds.
In the Sound dialog box, you select the Garden sound scheme from the Sound Scheme drop-
down list.
Graphic
The Sound dialog box contains Playback, Recording, Sounds, and Communications tabs. It's
currently open on the Sounds tabbed page. Other options in the Sound Scheme drop-down list
include Afternoon, Festival, and Landscape.
And you click OK.
To change the default screen saver the theme uses, you first click Screen Saver.
Graphic
The sound scheme has changed to Garden.
In the Screen Saver Settings dialog box, you select the Bubbles screen saver from the Screen
saver drop-down list.
Graphic
The Screen Saver Settings dialog box contains options for selecting a screen saver, previewing it,
and changing its settings.
You can specify how much time must elapse before the screen saver displays using the Wait
spin box, and choose whether to display the logon screen once you resume using your
computer.

Once you've finished configuring the screen saver, you click OK.
Graphic
563

The dialog box includes a Wait spin box currently set to 2 minutes and an "On resume, display
logon screen" checkbox.
To save the customized theme so that you can use it again, you click Save theme.
Graphic
A Get more themes online link is also available.
You type a name for the theme in this case, Carol's Theme in the Theme name text box
and click Save.
Graphic
The Save Theme As dialog box displays. It contains a Theme name text box.
The theme you've saved now appears in the My Themes section on the Personalization screen.
You can also change your user account picture using the Personalization settings. To do this,
you first click Change your account picture.
Graphic
The Personalization screen includes a panel with three links Change desktop icons, Change
mouse pointers, and Change your account picture.
You can select the new picture you want to use for your user account from the gallery that
displays or import a personal photograph as your account picture.
Graphic
Below a section displaying available images, a Browse for more pictures link displays.
You decide to select the picture of a soccer ball. You then click Change Picture. The picture of
the soccer ball will now appear on the Welcome screen you see when you log on and on the
Start menu.
Another setting that can be personalized is the font size display, which affects the size of text
and other items on your screen.

To change the font size display, you first click Appearance and Personalization in the Control
Panel.
You then click Display.
564

You want to increase the font size to 125%, so you select the Medium setting and click Apply.
Graphic
You can choose one of three settings smaller - 100%, which is the default setting, medium -
125%, and larger - 150%.
SkillCheck
You want to customize the Windows 7 theme on your computer. Set the image named "Desert",
which is available in the Pictures Library, as the desktop background and choose the 3D Text
screen saver.
You have already accessed the Personalization screen in the Control Panel.
Task:
1. Access the desktop background settings.
2. Select and save the desktop background.
3. Access screen saver settings.
4. Select the required screen saver.
Answer
To complete the task
Step 1: Click Desktop Background
Step 2: Select Pictures Library from the Picture location drop-down list, select Desert and click
Save changes
Step 3: On the Personalization screen, click Screen Saver
The Screen Saver Settings dialog box opens.
Step 4: Select 3D Text from the Screen saver drop-down list and click OK
You return to the Control Panel.
3. Adding gadgets to your desktop
Windows 7 enables you to install mini software applications, commonly referred to as gadgets,
on your desktop.

A variety of gadgets for example, weather and clock gadgets is available.

565

Gadgets are distinct from full applications in that they tend to have a single, simple function, and
use fewer resources, such as disk space and processing. Gadgets can connect to web
information sources, such as stock prices, or RSS news feeds.

Gadgets are not loaded on the desktop by default but they are easy to add.
You can access a selection of gadgets by right-clicking the empty space on the desktop and
selecting Gadgets from the shortcut menu that displays.
Graphic
The shortcut menu also contains options such as Screen resolution and Personalize.
Note
You could also navigate to the gadget gallery via the Appearance and Personalization settings in the
Control Panel.
A dialog box displays the default gadgets you can choose to add to desktop. The Get more
gadgets online link enables you to download gadgets from the Internet.
Graphic
The gadgets available include a calendar, clock, CPU meter, and the weather.
You want to install a clock gadget onto your desktop.

To do this, you right-click an empty space on the desktop and select Gadgets.
Then you double-click the Clock gadget.
Graphic
Other gadgets in the gallery include the Calendar, CPU Meter, Currency, Feed Headlines, Picture
Puzzle, Slide Show, and Weather.
The Clock gadget is installed on your desktop.
Graphic
The Clock gadget now displays the current time on your desktop.
566

You can access options for customizing a gadget you've installed by right-clicking it to display a
shortcut menu.
Graphic
The shortcut menu options include Add gadgets, Move, Size, Always on top, Opacity, and Close
gadget.
Note
You can also access basic customization options for a gadget by moving your mouse over it. A
small toolbar will appear. Depending on the type of gadget, the toolbar may contain additional
options, but the basic functions enable you to reposition it on the desktop or delete it completely.
Using the menu, you can move a gadget from one part of the desktop to another or adjust its
size.

You can also make a gadget lighter or darker, and specify whether it should display on top of
other windows that are opened.
Now say you want to download a gadget the Bing Search tool from the Internet and install it
on your desktop.
You click Desktop Gadgets - Get more gadgets online.
The online Microsoft Personalization Gallery opens. You scroll down and click the Download
button under the Bing Search tool. This automatically installs the gadget to your desktop.
Graphic
Gadgets like Bing Search, LifeCam Video Messages, and Outlook Upcoming Appointments are
available for download.
SkillCheck
Install the default clock gadget on the desktop.
The desktop is displayed.
Task:
1. Access the Gadgets shortcut menu.
2. Access the gallery.
3. Select and install the required gadget.
567

Answer
To complete the task
Step 1: Right-click the desktop
Step 2: Select Gadgets
The gadgets gallery is opened.
Step 3: Double-click the Clock gadget
The clock gadget is added to the desktop.
Summary
Windows 7 contains pre-packaged themes that enable you to customize the appearance of your
desktop. Each theme applies a particular desktop background, window color, sound scheme,
and screen saver. The Aero themes in Windows 7 enable you to create a distinctive user
interface with colors, tints, and translucency that can easily be customized.

You can personalize your desktop by altering the default settings for a selected theme. You can
also save a theme you've customized as a new theme.

In Windows 7, you can install specialized software applications called gadgets on your desktop.
You can install various built-in gadgets like a clock or calendar or download and install
gadgets from the Internet.










568

Customizing the Start Menu
Learning Objective
After completing this topic, you should be able to
customize the Start menu
1. Ways to customize the Start menu
One of the aims of Windows 7 is to make it quicker and easier to perform everyday tasks. One
of the ways it does this is by enabling you to customize the Start menu so that it provides easy
access to the settings, files, and programs you use most often.
You can customize the Start menu in these ways:
fix programs permanently to the menu
remove programs from the menu
automatically store recently opened items on the menu
adjust how items display on the menu
adjust the number of programs listed on the menu
adjust the number of items listed on jump lists, and
return the Start menu to its default settings
You can make some changes directly using the Start menu. These changes include fixing
programs to the menu and removing programs from it.
You use the Taskbar and Start Menu Properties dialog box to make all other changes to the
Start menu.
The Windows 7 Start menu is divided into two sections.
favorite programs
The favorite programs section on the left of the Start menu contains shortcuts to the programs
you've used most often, listed from top to bottom in the order in which you last used them. The
program you use most often appears at the top of the list. So depending on how often you use a
program, the order can change. You can fix items to the favorite programs list by pinning them.
Pinned items are displayed at the top of the list and the icons always stay in the same place,
regardless of how often you use the programs.

569

For example, on this Start menu's favorite programs section, the Notepad and Paint items are
pinned to the menu. Windows Media Player is also listed in the favorite programs section
because it has been used regularly.
built-in features
The built-in features section of the Start menu lists all the features that are automatically
available, such as the Music, Documents, and Pictures folders. You can customize this section,
changing which features are included and whether they're listed as links or menus. If you list an
item as a link, clicking the link will open a page. If you list an item as a menu, hovering your
cursor over it will display a menu of options.

In the built-in features section on this Start menu, the Computer and Control Panel items are
listed as menus, whereas the rest of the items are listed as links.
Question
What are some ways in which you can customize the Start menu, using the menu directly?
Options:
1. Remove items from the menu
2. Restore the menu's default settings
3. Pin programs onto the menu
4. Increase the number of programs listed on the menu
Answer
Option 1: Correct. You can remove programs from the Start menu using options on the menu itself.
Option 2: Incorrect. You use the Taskbar and Start Menu Properties dialog box to restore the Start
menu's default settings.
Option 3: Correct. You can pin programs to the Start menu using options available via the menu
itself.
Option 4: Incorrect. You use the Taskbar and Start Menu Properties dialog box to adjust the
number of programs listed on the Start menu.
Correct answer(s):
1. Remove items from the menu
3. Pin programs onto the menu
If you want a program to appear in the favorite programs section of the Start menu, you first
need to navigate to it using the All Programs link.
570

Graphic
The Start menu lists Notepad, Paint, and Windows Media Player.
In this case, you want to pin Adobe Flash CS4 Professional to the menu.
Graphic
Other applications in the All Programs menu include Adobe Media Encoder CS4, Desktop Gadget
Gallery, and folders like Accessories, Games, and Maintenance.
You right-click Adobe Flash CS4 Professional and select Pin to Start Menu from the shortcut
menu that displays.
Graphic
When you right-click Adobe Flash CS4 Professional, a menu of options displays. The options
include Open, Run as administrator, Troubleshoot compatibility, Open file locator, Pin to Taskbar,
Pin to Start menu, Restore previous versions, Adobe Drive CS4, Sent to, Cut, Copy, Paste, and
Delete.
You click the Back button, and the program icon is pinned to the Start menu.
Graphic
The Start menu lists Notepad, Windows Media Player, Paint, and Adobe Flash CS4 Professional.
You can rearrange the order of pinned items by clicking and dragging them to new positions.
Graphic
The Adobe CS4 Professional program now appears at the top of the favorite programs list.
You can also remove a program icon from the Start menu if you no longer need it. To do this,
you right-click the program you want to remove Notepad in this case and select Unpin from
Start Menu from the shortcut menu.
Graphic
The menu that displays when you right-click a program on the Start menu lists the following options:
Open, Run as administrator, Unpin from Taskbar, Unpin from Start Menu, Remove from this list, and
Properties.
571

Notepad is removed from the Start menu.
Graphic
The Start menu now lists Adobe Flash CS4 Professional, Windows Media Player, and Paint.
Question
Most days you use the Notepad application, so it appears in the Start menu. However, some days it
appears at the top of the list and some days it appears at the bottom and very occasionally, when
you're using a lot of different programs, it disappears entirely from the menu. How can you
overcome this?
Options:
1. Restore the Start menu to its default settings
2. Move the program to the built-in features section of the menu
3. Pin the application to the Start menu
4. Make sure the program is listed as a link
Answer
Option 1: Incorrect. Restoring default settings clears the Start menu and displays only the most
recently opened program icons.
Option 2: Incorrect. Programs can be listed only in the favorites section of the Start menu not in
the built-in features section.
Option 3: Correct. You can fix a program icon's position on the Start menu by pinning it to the
menu.
Option 4: Incorrect. Programs are listed in the favorites section not the built-in section and so
are listed as neither links nor menus.
Correct answer(s):
3. Pin the application to the Start menu
2. Start menu properties
You can use the Taskbar and Start Menu Properties dialog box to further customize the Start
menu.
572

To access the Taskbar and Start Menu Properties dialog box, you right-click the Start button
and select Properties.
Graphic
Two options display: Properties and Open Windows Explorer.
The Privacy section of the Taskbar and Start Menu Properties dialog box enables you to choose
whether to store recently opened items on the Start menu or taskbar.
Graphic
The Taskbar and Start Menu Properties dialog box has three tabs: Taskbar, Start Menu, and
Toolbars. The Start Menu tabbed page is selected and contains a Customize buttons, as well as a
Power button action option. A Privacy section is also available and has two checkboxes: Store and
display recently opened programs in the Start menu, and Store and display recently opened items in
the Start menu and the taskbar.
If you want to remove all programs from the Start menu, you clear the Store and display
recently opened items in the Start menu and the taskbar checkbox.
You can click Customize to access options for customizing links, icons, and menus on the Start
menu. Doing this, you can change what items appear on the menu and how these items look.
Note
You can also access options for customizing the Start menu through the Control Panel.
The Customize Start Menu dialog box contains a list of all the links, icons, and menus that you
can customize on the Start menu.

You can scroll down the list to access further items. For example, you can customize Computer,
Control Panel, Default Programs, Devices and Printers, Documents, Downloads, the Favorites
menu, Help, Homegroup, Network, the Personal folder, Pictures, Recent items, the Run
command, System administrative tools, and Videos.
Graphic
The dialog box also contains a Start menu size section, which has two sin boxes: Number of recent
programs to display, and Number of recent items to display in Jump Lists.
Using the Customize Start Menu dialog box, you can
adjust the items in the built-in features section
573

You can choose whether to display each of the items in the built-in features section. This means
that you can customize the built-in features section to include only those features and items that
you use on a regular basis.
adjust the behavior of items in the built-in features section
You can choose to display each item in the built-in features section as a link or a menu. Links are
useful if you want to access comprehensive interfaces, whereas menus are useful if you want to
access a set of more concise options.
adjust the number of programs listed on the Start menu
You can use the Number of recent programs to display counter to increase or decrease the
number of recently used programs that are automatically listed on the Start menu. You may want
to reduce the number of programs that appear so that the menu looks less cluttered, or you may
want to increase the number if you regularly use many programs.
adjust the number of items listed on jump lists, and
You can use the Number of recent items to display in Jump Lists counter to adjust how many
items are automatically displayed on jump lists when they are regularly accessed. You can
increase or decrease the number of items depending on how many you use regularly.
return the Start menu to its default settings
You can click the Use Default Settings button to return the Start menu to its original settings.
With the default settings, no favorite programs are listed.
Question
In which ways can you use the Customize Start Menu dialog box to customize the Start menu?
Options:
1. Adjust the items that are listed in the built-in features section
2. Adjust the number of items listed in jump lists
3. Pin program icons to the Start menu
4. Enable or disable the display of recently opened programs on the Start menu
Answer
Option 1: Correct. Using the Customize Start Menu dialog box, you can choose to display or hide
each item in the built-in features list. If you choose to display an item, you can also specify whether
it must display as a link or a menu.
Option 2: Correct. You can use the Customize Start Menu dialog box to increase or decrease the
number of items that are automatically listed in jump lists on the Start menu.
574

Option 3: Incorrect. You can pin program icons to the favorite programs section of the Start menu
by right-clicking the icons on the menu itself. You don't use the Customize Start Menu dialog box to
do this.
Option 4: Incorrect. You use the Taskbar and Start Menu dialog box to enable or disable the display
of recently opened programs on the Start menu.
Correct answer(s):
1. Adjust the items that are listed in the built-in features section
2. Adjust the number of items listed in jump lists
You can increase the number of programs that display on the Start menu, up to a total of 15.
You can either click the up arrow on the spinbox or use your keyboard to enter the new value.
You can change the number of items listed in jump lists in the same way.
On your Start menu, the Documents item displays as a link. You want to change it to display as
a menu. To do this, you select the Display as a menu radio button.
Once you've finished making changes, you close the Customize Start Menu and Taskbar and
Start Menu Properties dialog boxes by clicking OK.
The Start menu can now list 15 program icons and 10 jump list items, and Documents is listed
as a menu.
To return the Start menu to its default settings, you access the Customize Start Menu dialog
box again and click Use Default Settings.
The settings you customized are changed back to the default settings.
SkillCheck
Increase the number of items that display on the Start menu from five to ten, and adjust the menu
so that Documents is not displayed.
The desktop is displayed.
Task:
1. Open the Taskbar and Start Menu Properties dialog box.
2. Access customization options.
3. Increase the number of recent programs that display and prevent the Documents item from displaying in
the built-in features section.
4. Accept the changes.
575

Answer
To complete the task
Step 1: Right-click Start and select Properties
The Taskbar and Start Menu Properties dialog box is opened.
Step 2: Click Customize
The Customize Start Menu dialog box opens.
Step 3: Type 10 in the Number of recent programs to display spin box and select the Don't display
this item radio button under Documents
Step 4: Click OK twice
You return to the Taskbar and Start Menu Properties dialog box, and then return to the desktop.
Summary
The Windows 7 Start menu is divided into two sections favorite programs and built-in features.
The favorite programs section contains shortcuts to the programs you've used most often, listed
in the order in which you used them. The built-in features section of the menu lists all the
features that are automatically available, such as Music, Documents, and Pictures. You can pin
program icons to the Start menu to fix their positions in the menu.

You can use the Customize Start Menu dialog box to adjust the number of programs and jump
list items that display, to determine which built-in features display, and to specify whether these
built-in features must display as links or menus. You can also choose to restore the Start
menu's default settings.








576

Customizing the Taskbar
Learning Objective
After completing this topic, you should be able to
customize the taskbar
1. Ways in which the taskbar can be customized
The Windows taskbar is the horizontal strip that displays along the base of the desktop by
default. Unless otherwise configured, the taskbar is always visible.
Graphic
The desktop is displayed and the taskbar is available.
You can use the taskbar to launch programs, switch between them, and display buttons for
programs in use.
The taskbar consists of three main sections:
the Start button, which provides access to the Start menu
The Start button provides quick access to documents, programs, and system settings. The
Windows 7 Start menu also features a search bar, so you can easily search for programs and
files.
the notification area, where you'll find the clock and system icons, and
The notification area can vary in appearance, depending on the programs and services installed
on your computer.

When you move your mouse pointer over any of the icons in the notification area, its name or
status will display. Double-clicking an icon usually opens the associated program or its settings.

Whenever Windows wants to bring something to your attention, a pop-up window appears in the
notification area.
the middle section, which displays open programs and files
When you have multiple programs, files, and folders open at the same time, you can use the
middle section of the taskbar to navigate between them easily.

You can also minimize, restore, or close an open item using its corresponding button on the
taskbar.
577

You can adjust most taskbar settings in the Taskbar and Start Menu Properties dialog box. To
access this dialog box, you first click Start and select Control Panel.
Graphic
Other options in the Start menu include Computer, Devices and Printers, and Windows Security.
You then click Appearance and Personalization.
Graphic
The Control Panel consists of eight main categories: System and Security; Network and Internet;
Hardware and Sound; Programs; User Accounts; Appearance and Personalization; Clock,
Language, and Region; and Ease of Access.
Finally, you click Taskbar and Start Menu to open the dialog box.
Graphic
The Appearance and Personalization window contains various major options, such as
Personalization, Display, and Taskbar and Start Menu. The Taskbar and Start Menu option contains
three links: Customize the Start menu, Customize icons on the taskbar, and Change the picture on
the Start menu.
Note
You can also access the Taskbar and Start Menu Properties dialog box by right-clicking any open
space on the taskbar and selecting Properties.
On the Taskbar tabbed page, you can configure the appearance of the taskbar, specify what
must display in the Notification area, and enable or disable the use of Aero Peek functionality for
viewing the desktop.
Graphic
The Taskbar and Start Menu Properties dialog box has three tabs: Taskbar, Start Menu, and
Toolbars. The Taskbar tabbed page is selected, and the Taskbar appearance section contains
options to lock the taskbar, auto-hide the taskbar, use small icons, specify the taskbar location on
screen, and modify the taskbar buttons.

The Notification area section enables you to customize which icons and notifications appear in the
notification area.

578

The Preview desktop with Aero Peek section lets you stipulate whether or not Windows should use
Aero Peek to preview the desktop. This function enables you to temporarily view the desktop when
you move your mouse to the Show desktop button at the end of the taskbar.
The Taskbar appearance section enables you to
lock the taskbar
enable auto-hide
choose between large or small icons
specify where the taskbar is located, and
adjust the appearance of taskbar buttons
By default, the taskbar appears at the base of the desktop, but you can move it to the top or
sides. First, however, you have to unlock the taskbar. You do this by clearing the Lock the
taskbar checkbox.
You select the Auto-hide the taskbar checkbox if you want the taskbar to disappear from view
when you're not using it.
You can toggle the appearance of icons on the taskbar between large and small using the Use
small icons checkbox, depending on your preference.
You can also configure the appearance of the buttons that display for open windows using the
Taskbar buttons drop-down list.
You can use these options to adjust the appearance of taskbar buttons:
Graphic
The Taskbar buttons drop-down list has three options: Always combine, hide labels; Combine when
taskbar is full; and Never combine.
Always combine, hide labels
The Always combine, hide labels option is the default, and prevents the taskbar from becoming
cluttered. Even when multiple windows for the same program are open, a single button for the
program displays on the taskbar. The label for the button displays only if you move your cursor
over the button.
Combine when taskbar is full, and
The Combine when taskbar is full option gives the taskbar the look and feel it had in earlier
versions of Windows. Each button is shown individually and labeled. But when the taskbar gets
too full, multiple buttons collapse into a single button, grouped by program.
579


When you click the collapsed buttons, they display a list of the windows open for a specific
program.
Never combine
The Never combine option is similar to Combine when taskbar is full, except multiple buttons
never collapse into a single icon. Each button gradually gets smaller as more programs and
windows are opened.

You can navigate the buttons by scrolling along the taskbar area.
The Notification area section features a Customize button, which provides access to options for
adjusting icon behaviors, as well as how notifications appear.
You use the Preview desktop with Aero Peek section of the dialog box to enable or disable the
Aero Peek function.
Aero Peek lets you view your desktop through all open windows, when you hover your cursor
over the Show desktop button on the taskbar.

The same functionality lets you view a program window, while making all others transparent,
when you hover your cursor over its button on the taskbar.
When the taskbar is unlocked, you can further customize its position and size by clicking and
dragging it.
Graphic
The taskbar is repositioned on the right if the desktop, with the icons displaying from top to bottom.
You can also reorder buttons for open programs by clicking and dragging them to different
locations on the taskbar.
Graphic
The Calculator button is dragged and repositioned on the taskbar.
You can pin a program to the taskbar by right-clicking the program's button and selecting the
option to do so. This provides quick, easy, and unobscured access to programs you use often.
Graphic
The jump list for the Calculator button displays the options Calculator, Pin this program to taskbar,
and Close window.
580

You can also pin programs to the taskbar by dragging and dropping items from the desktop or
Start menu onto the taskbar.
Graphic
The Calculator is dragged from the Start menu and pinned to the taskbar.
When programs are pinned to the taskbar, their buttons remain where you've positioned them
the next time you start up your computer. If not pinned, the buttons retain their positions on the
taskbar only until the corresponding programs are closed.
Graphic
Windows Media Player and Calculator are pinned to the taskbar.
Question
In which ways can you customize the taskbar?
Options:
1. Reposition it
2. Pin programs to it
3. Add the Slide Show gadget to it
4. Add a search box
Answer
Option 1: Correct. You can move the taskbar to the right, top, left, or bottom of the screen.
Option 2: Correct. You can pin frequently used programs and folders to the taskbar for ease of
access.
Option 3: Incorrect. You can't add gadgets to the taskbar they can be added only to the desktop.
Option 4: Incorrect. You can search from the Start menu, or in an explorer window, but you can't
add a search box to the taskbar.
Correct answer(s):
1. Reposition it
2. Pin programs to it
581

2. Customize the taskbar
You've installed Windows 7 and want to customize and streamline the taskbar to suit your
needs.

Your daily duties require that you use Windows Media Player and the Windows 7 calculator
often, so these would be best pinned to the taskbar.
First you click Start and select All Programs.
Then you right-click Windows Media Player and, from the jump list that displays, select Pin to
Taskbar.
Graphic
The jump list for Windows Media Player displays the options Open, Run as administrator, Open file
location, Pin to Taskbar, Pin to Start Menu, Restore previous versions, Send to, Cut, Copy, Paste,
Delete, Rename, and Properties.
Note
Alternatively, you can drag and drop the Windows Media Player icon onto the taskbar.
The calculator is already open, with its button visible on the taskbar. To pin it, you right-click its
button and select Pin this program to taskbar.
Graphic
The jump list for the Calculator button displays the options Calculator, Pin this program to taskbar,
and Close window.
Both Windows Media Player and the calculator are now pinned to the taskbar and easily
accessible.
Currently the Paint and Control Panel buttons appear between the Windows Media Player and
the Calculator buttons on the taskbar.
To place the pinned buttons alongside each other, you click the Windows Media Player button
and drag it into position next to the Calculator button.
The taskbar buttons are now logically arranged, from pinned items to open items. Other
programs you open from now on will have their buttons displayed alongside these, unless you
reposition them.
582

Graphic
The Calculator and Windows Media Player buttons are pinned to the taskbar alongside each other,
and the open program buttons for Paint and Control Panel are positioned next to them.
The taskbar is locked in its default location at the base of the desktop. You can change its
appearance and location using the Taskbar and Start Menu Properties dialog box.
Graphic
The Taskbar and Start Menu Properties dialog box is open.
In the dialog box, you clear the Lock the taskbar checkbox to unlock the taskbar, so that you'll
be able to reposition it. Then you select Top from the Taskbar location on screen drop-down list,
to move the taskbar to the top of the desktop.
Graphic
The other options are Left, Right, and Bottom.
You want always to be able to see exactly which programs are open by looking at the taskbar,
so you select Never combine from the Taskbar buttons drop-down list.
You also want to keep the taskbar buttons at their current, larger size, so you leave the Use
small icons checkbox clear.
The notification area displays a number of unnecessary icons. To access options for hiding
icons and notifications, you click Customize.
The only notification icon you currently need displayed is the Action Center icon. So you hide all
other icons and notifications, and click OK.
Graphic
On the "Select which icons and notifications appear on the taskbar" page, the Action Center icon is
set to "Show icon and notifications." All other icons are set to "Hide icon and notifications."
You click OK in the Taskbar and Start Menu Properties dialog box, and all your changes to the
taskbar are implemented.
To widen the taskbar, you can simply click and drag it, provided it's unlocked. You move the
cursor over the taskbar until the double-sided arrow displays, and then resize it to your liking.
You can also click and drag the taskbar to reposition it on the desktop.
583

Graphic
The taskbar is moved from the top to the bottom of the desktop.
SkillCheck
Unlock the taskbar, reposition the taskbar on the right of the screen, and set the icons on the
taskbar to display at a smaller size.

You've already opened the Appearance and Personalization screen in the Control Panel.
Task:
1. Open properties dialog box.
2. Unlock the taskbar.
3. Reposition the taskbar.
4. Change the icon size and confirm your changes.
Answer
To complete the task
Step 1: Click Taskbar and Start Menu
The Taskbar and Start Menu dialog box is opened.
Step 2: Clear the Lock the taskbar checkbox
Step 3: Select Right from the Taskbar location on screen drop-down list
Step 4: Select the Use small icons checkbox and click OK
You return to the desktop.
Summary
You can customize the Windows 7 taskbar according to your needs, resulting in a more
streamlined interface that improves your productivity. For example, you can customize the
taskbar by altering its location, appearance, and size. You can also configure the taskbar to
disappear from view when not in use, with the Auto-hide feature.

You can pin frequently used programs to the taskbar to make them easier to access.
Additionally, you can specify what must display in the notification area and how buttons on the
taskbar must be grouped.

584

Customizing the Windows 7 Interface
Learning Objectives
After completing this topic, you should be able to
customize the desktop
add a gadget to the desktop
customize the Start menu
customize the taskbar
Exercise overview
In this exercise, you're required to customize the desktop, the Start menu, and the taskbar in
Windows 7.
This involves the following tasks:
customizing the desktop
adding a gadget to the desktop
customizing the Start menu, and
customizing the taskbar
Task 1: Customizing the desktop
Apply the Windows 7 Aero theme to the desktop with Photos as the screen saver. Then save
the theme as "My New Theme." Finally, increase the display font size to 125%.

The Personalization screen is already open.
Steps list
Instructions
1. Select the Windows 7 Aero theme and click Screen Saver
2. Select Photos
3. Click OK
4. Select Save theme
5. Type My New Theme in the Theme name text box and click Save
585

Steps list
Instructions
6. Click Display
7. Select Medium - 125% and click Apply
Task 2: Adding a gadget to the desktop
Install a weather gadget on your desktop.

The Appearances and Personalization screen is already open.
Steps list
Instructions
1. Select Desktop Gadgets
2. Double-click Weather
Task 3: Customizing the Start menu
Customize the Start menu so that the Control Panel displays in menu format, and then adjust
the number of recently opened programs that appear from 10 to 15.

You have already right-clicked the Start button.
Steps list
Instructions
1. Select Properties
2. Click Customize
3. Select the Control Panel Display as a menu radio button and type 15 in the Number of recent programs to display
spin box
4. Click OK
586

Steps list
Instructions
5. Click OK
Task 4: Customizing the taskbar
Drag and drop the Windows Media Player icon onto the taskbar. Then, using the Taskbar and
Start Menu Properties dialog box, reposition the taskbar to the right of the screen and ensure
that you'll be able to resize it.
Steps list
Instructions
1. Click Start and select All Programs
2. Click and drag the Windows Media Player icon to the taskbar
3. Click Start and select Control Panel
4. Click Appearance and Personalization
5. Click Taskbar and Start Menu
6. Clear the Lock the taskbar checkbox and select Right from the Taskbar location on screen drop-down list
7. Click OK
A theme has been adapted and applied to the desktop, the desktop font size has been
increased, and a weather gadget has been installed. The Paint application has been pinned to
the Start menu, the number of programs displayed on the Start menu has been increased, and
the Control Panel has been set to display as a menu. Also, Windows Media Player has been
pinned to the taskbar and the taskbar has been moved to the right of the screen.

587

DBMS
Overview of Databases and DBMSs
Learning Objectives
After completing this topic, you should be able to
recognize the differences between a database and a DBMS
recognize the different types of database users
identify the requirements of a good database
1. Databases and DBMSs
A database is a collection of related data that is organized into a logical structure. This data is
stored in electronic form and can be processed to deliver meaningful information to end users.
An example of a database is a customer order book that contains names, addresses, telephone
numbers, date of order, and products ordered by a number of customers, which is stored in
tables.
Users can add, modify, retrieve, and delete the data within the database according to their
requirements. For example, if a customer's address has changed, the sales manager can
update the customer's information in one table to reflect the new address.
The data in a database is organized by
fields
A field, also called a data item or data element, is the smallest unit of data. It is represented in the
database by a value.
In the employee details table, the following entries are examples of fields: 0546 in the Employee
code column, Keith in the First name column, Franks in the Last name column, and Platinum in
the Benefit package column.
records, and
A record is a set of logically related fields that are of a fixed data type with fixed values. It can be
of two types fixed length record and variable length record.
An example of a record is the First name column in the employee details table. This column
contains several fields, such as Keith, Norma, Luke, Faye, Gavin, and so on.
tables
A table is used to store a set of related records in a structured and organized way. It identifies
where the data is stored on file for the database.
588

There are various types of databases, based on their application and requirements. These
include data warehouses, Online Transaction-Processing or OLTP databases, and Online
Analytical Processing or OLAP databases.
A data warehouse is a database that is designed to help you query and analyze data, rather
than perform transaction processing. Data warehouses usually store information from
operational databases and external sources to archive data that is no longer required for day-to-
day operations. They help users to transform, load, and manage data. They contain data
accumulated over time, which can be used for analysis and reference by business analysts.
For example, to analyze your company's inventory management, you can build a warehouse of
inventory data. Using this warehouse, you can find answers to questions, such as "What was
the average inventory turnover in the previous financial year?," or "How much inventory is
needed per day to minimize machine idle time?"
Unlike data warehouses, OLTP databases are designed to handle real-time online data
processing with simple storage requirements because data is updated regularly. These
databases use SQL queries to enable users to query and update the database with real-time
responses. Because data is dynamic and changes frequently, OLTP databases should be able
to support frequent updates. Common examples of systems that run OLTP databases are online
ticket booking and financial transaction systems.
Supplement
Selecting the link title opens the resource in a new browser window.
Job Aid
Review the job aid OLTP Databases versus Data Warehousing to learn about the differences
between OLTP and data warehousing.
OLAP databases enable users to analyze data provided by other databases. OLAP helps you to
rapidly execute complex queries and assists in planning, problem solving, and decision support.
OLAP databases are widely used in business reporting, budgeting and forecasting, financial
analysis, and sales and marketing management.
Users can access data within a database with the help of a database management system,
commonly known as a DBMS. A DBMS allows users to add, modify, delete, and retrieve data.
A DBMS works with an operating system to manage the data. Users use different applications to
access the data within the database.
A DBMS helps you to
define schemas and subschemas in a database, and establish relationships between different data
elements
589

enter data into a database
manipulate and process data
limit database access to authorized users only, and
query the database by using SQL
A DBMS has five main components:
Graphic
A diagram representing a database system is displayed. The users query the database using
application programs. These programs are connected to DBMS tools that are connected to DBMS
software via query languages. DBMS software is linked to a Database kernel or engine. The
database kernel sends queries and receives responses from a data dictionary and a physical
database.
DBMS tools
DBMS tools help to perform different tasks that users access the database for. These tools help
you with tasks like administering the database, creating screens for entering and extracting data,
processing information in spreadsheets and other documents, and generating reports.
query languages
Query languages help users to access the data stored in a database. For example, SQL is the
most common query language and has different dialects like Oracle SQL and Microsoft Transact-
SQL. SQL has a subset of query languages, including DDL and DML. Short for Data Definition
Language, DDL allows users to define the database, specify the data types, data structures, and
data constraints. DML or Data Manipulation Language is used to process queries, which allow
users to insert, update, delete, and retrieve data from the database.
DBMS software
DBMS software provides the users with controlled access to the database. This software also
controls access to the database by multiple users at the same time. It also manages the recovery
process in case of a system crash.
kernel, and
The kernel, also known as the engine, is a key component of a DBMS. The kernel handles the
storage, security, and transport of data. It verifies data integrity, provides controlled access to the
database, and processes database queries.
data dictionary
A data dictionary includes information about the data in a database. This information is also
known as metadata. A data dictionary also stores and manages information about the database
users, their access privileges, and responsibilities. Additionally, it provides information about
590

physical database design, descriptions of database transactions, and the relationships of users to
the transactions.
A DBMS has several advantages for users:
consistency and limited redundancy
Unlike a traditional filing system where there should be multiple updates of common data, a
DBMS minimizes data redundancy. This not only reduces repetition of data and increases the
storage space but also reduces inconsistencies or inaccuracies in the data.
data security
A DBMS implements security measures like passwords and constraints to ensure that only
authorized users can access the database.
data sharing and concurrency
In a DBMS, data can be shared and used by many users at the same time.
independence from application programs
While using a DBMS, the information within the database is independent of the application
programs that the users access the information with. This helps you to change or update the data
without applying the same changes to the applications.
facility for recovery and backup, and
When there is a sudden system failure, the information in the database can be recovered so that
the system can be brought back to what it was before the failure. Also, the data can be backed up
to ensure it is kept safe.
efficient accessibility
A DBMS provides faster and more efficient means, such as report writers and query languages,
of accessing information. These help the users to quickly and easily retrieve the data they want.
A DBMS also has a few disadvantages. Since it is based on a centralized data collection, the
storage space grows with the growing business operations. So organizations may need to incur
additional costs for scalability. Also, a DBMS needs dedicated staff to administer and manage
the database.
A DBMS collects a large amount of data and supports different application programs. This
increases its complexity and the need for more maintenance efforts. It requires a backup and
recovery process to ensure that data remains accurate and is not lost when there is a system
failure.
Question
Match each description to either database or DBMS. You may use each target more than once.
Options:
591

A. A program that allows users to add, modify, delete, and retrieve data
B. A software package that consists of a kernel, a data dictionary, query languages, and software for
controlled access
C. An integrated collection of data records, files, and tables
D. An organized set of data, usually in electronic form
Targets:
1. DBMS
2. Database
Answer
DBMS is a software program that controls the storage, updating, and retrieval of data. It contains
several key components, such as a kernel, a data dictionary, query languages, and software for
controlled access.
A database is a set of logically related data records, files, and tables. The information in a database
is stored in electronic form.
Correct answer(s):
Target 1 = Option A, Option B
Target 2 = Option C, Option D
2. Types of database users
A database is used by different types of users for different purposes. Based on their skill levels
and the types of uses, database users can be divided into different categories:
database administrators or DBAs
database designers
end users, and
system analysts
DBAs control and manage the database and DBMS. DBAs are responsible for overseeing the
software and hardware resource requirements.

Some of the main responsibilities of DBAs include
regularly monitoring the performance of the database and resolving technical issues
592

choosing and authorizing users to access the database
determining the contents of the database and how data is stored
protecting the database from hackers and viruses, and
using constraints to ensure that data in the database is consistent and valid
DBAs also ensure that there is sufficient space in the database to store new data and that the
right data is available to users at the right time. DBAs back up the database contents at regular
intervals to protect them from sudden system failures.
Database designers are responsible for the overall logical design of the database. They liaise
with users to determine the database views that best meet the users' requirements. Database
designers create a database structure that indicates how the data will be stored physically.
End users send queries to the database, add information to the database, and generate reports.
Depending on their requirements, end users can be classified into four types:
sophisticated end users
Sophisticated end users familiarize themselves thoroughly with the database facilities so they can
create custom applications. Scientists, analysts, and engineers are examples of sophisticated
end users.
parametric end users
Parametric end users may not be aware of the existence of a database because they interact with
the database through an application. They use canned transactions to query and update the
database. The information they query is displayed on a user interface. Examples of parametric
end users are clerks, office staff, and administrators.
casual end users, and
Casual end users use the database infrequently to access information. They use a database
query language to retrieve required data. Managers in an organization would fall into the category
of casual end users.
standalone end users
Standalone users use a database for personal needs. They use software packages to create a
database for their specific needs. An example of a standalone end user is someone using travel
planning software to store personal information about the details and requirements of journeys.
System analysts are another category of database users. Their job is to develop specifications
for canned transactions that are used by parametric end users. They need to have a thorough
knowledge of database systems.
System analysts are supported by application programmers and tool designers. Once the
system analysts define the specifications, application programmers use the specifications to
593

create canned transactions. Application programmers also debug, document, and maintain the
transactions.
Tool designers create software packages to enhance the performance of a particular database
and improve its usability. Software developers are an example of tool designers.
Question
Which database user uses constraints to maintain consistency in the contents of a database?
Options:
1. Database administrator
2. End user
3. System analyst
4. Database designer
Answer
Option 1: This option is correct. A database administrator has the maximum control over the
database and uses constraints to ensure consistency in the database contents.
Option 2: This option is incorrect. End users query and update the database and use it to generate
reports.
Option 3: This option is incorrect. System analysts develop specifications for the canned
transactions that are used by parametric users to interact with a database.
Option 4: This option is incorrect. Database designers interact with different user groups to create a
database structure that meets user requirements.
Correct answer(s):
1. Database administrator
3. Requirements of a good database
For a database user, it is crucial that information is retrieved from the database at the right time.
A database that doesn't provide this fails to meet the purpose that it was made for.
When a database manages the information it contains efficiently and meets the requirements of
the user, it can be called a good database. A database qualifies as a good database when it
provides the users with accurate data, acceptable performance, adequate storage, secure data,
good data availability, and the ability to minimize redundant data.
594

The information that a database stores should be accurate and free of errors. Sometimes,
though, users may enter inaccurate data. You can use constraints to avoid this and control the
accuracy of the data. These constraints are typically applied at column level to ensure that users
enter the correct data type.

To ensure data accuracy, you can
introduce code tables for common data
apply data integrity constraints, and
apply foreign key constraints for referential integrity
When users send queries to the database, it should be able to process them quickly. The
database should also allow users to update it when required. The efficient performance of a
database is based on factors like database design, application design, network speed, and
network hardware.
When the database has a performance problem, you should isolate the problem and rectify it.
For example, when the database takes a long time to respond to queries, first you should
determine the realistic expected response times for queries, and then determine how the
database is currently performing during batch operations.
A good database should have adequate storage space to ensure space is not limited for storing
the data that is required for users. The amount of storage space that is required will be affected
by the amount of data that needs to be stored, the database software, and the operating system.
To avoid having inadequate storage space, you can archive old data or any data that is not
required on a daily basis by users. Also if storage space becomes an issue, you may need to
add storage for the database.
Data security is another important feature of a good database. Insecure data can lead to the
database being corrupt and allow sensitive data to be stolen. To secure a database, you need to
allow only authorized users to access the database, and each user should have a unique ID and
password with specific data-access privileges. All access to the database should be monitored
to ensure that no unauthorized user is accessing the database, and that users who do have
access are only accessing the data they have been given permissions to.
Data availability is another key requirement of a good database. It refers to the time that the
database is available to the users to get the data when they require it. To ensure this, you
should
use a well-designed database
schedule the downtime of the database outside of regular business hours, and
use advanced applications that query and update the database
595

You should select a database that minimizes data redundancy. Redundant data could be
inaccurate or inconsistent and take up space in the database. Minimizing data redundancy helps
to free up storage space, avoid inaccuracies and inconsistencies in the data, and save time in
processing the data.
Question
What are the requirements of a good database?
Options:
1. It should have adequate storage space
2. It should allow all users full access to data
3. It should process queries in a reasonable time
4. It should allow constraints to be applied to ensure that data is accurate
5. It should help increase data redundancy
6. It should make data available to users during business hours
Answer
Option 1: This option is correct. A good database must have sufficient hard-disk space and should
be able to store the estimated volume of data.
Option 2: This option is incorrect. Giving full access to all users can make the database vulnerable
to hacker and virus attacks. To secure a database, you need to limit access to authorized users.
Option 3: This option is correct. A database that process queries and enables users to update it in a
reasonable amount of time meets the acceptable performance criteria for a good database.
Option 4: This option is correct. You use foreign key and data integrity constraints to ensure that
users enter the correct data type. This helps to control the accuracy of the data.
Option 5: This option is incorrect. Data redundancy consumes a lot of storage space and results in
inaccurate and inconsistent data. A good database should have minimal redundant data.
Option 6: This option is correct. A good database allows users to process queries and retrieves
information when needed. Appropriate scheduling of database downtime and using a well-designed
database can improve data availability.
Correct answer(s):
1. It should have adequate storage space
3. It should process queries in a reasonable time
4. It should allow constraints to be applied to ensure that data is accurate
6. It should make data available to users during business hours
596

Summary
Databases and DBMSs are common in all organizations today. While databases help to store
the required information in a systematic way, DBMSs help users to manage and retrieve
information from the database efficiently.

Databases are used by different types of users. These users vary according to their skills and
their requirements. The different types of users include database administrators, system
analysts, database designers, and end users.

To ensure that a database meets the needs of these users, it should meet some key
requirements. A good database enables authorized users to manage and store information
efficiently. Some other requirements for a good database are maintaining the accuracy of data,
acceptable performance, adequate storage space, secure data, good availability of data, and
the ability to minimize redundant data.


















597

The Database Architectures and Models
Learning Objectives
After completing this topic, you should be able to
match the database architecture with its correct description
match the database model with its correct description
1. Database architectures
The database management system or DBMS architecture is a set of processes, rules, and
specifications that describe the nature of the data, how the flow of data is controlled, and how it
is used by applications. It also describes how the database objects are stored and how they are
all integrated with each other.
The DBMS architecture ensures the reliability, integrity, performance, and scalability of the
database.
Depending on their requirements, businesses use different types of DBMS architectures. Some
commonly used architectures are
centralized
client/server
n-tier
distributed, and
parallel
Centralized or single-tier is the oldest form of architecture and it is commonly used in a
mainframe environment.
Users are directly connected to a mainframe computer through dumb terminals. The mainframe
computer is a large server system that stores and processes data and applications. The
terminals do not have any processing power and only exist to display the data to the users.
Centralized architectures are used in situations where simplicity and cost, rather than scalability
and flexibility, are driving factors. For example, a centralized architecture is suitable for inventory
control and business order processing.
Because all terminals are connected to a single server, this type of architecture is easy to deploy
and maintain.
598

In centralized architectures, all data processing is performed at the central server. This means
that this type of architecture doesn't require multiple operating systems to be installed and it also
does not have network protocol issues.
Though centralized architectures are simple and easy to manage, they are becoming less
common today. This is because centralized database architectures have limited operational
capacity for handling more complex, scalable, and flexible processes. Also with hardware
becoming less expensive, many organizations are able to replace the dumb terminals with client
PCs and workstations.
A growing demand for flexible and scalable databases has meant that centralized servers have
paved the way for client/server architectures. The client/server architecture, commonly known as
two-tier architecture, is designed to improve the usability, interoperability, scalability, and
flexibility of the database.

The client/server architecture typically has three main components.
Server
The server is a powerful computer that houses the DBMS and is dedicated to managing
enterprise data. Users access this data from clients using different applications. The server
monitors the clients and allocates the work load. By preventing unauthorized users from
accessing data, the server also maintains data security.
Client
A client is a personal computer or workstation that users access the data in the database from
using applications. Clients interact with servers to process queries and retrieve data from the
database. Clients have client components for the DBMS installed on them so they can interact
with the server.
Network interface
The network interface connects the client computers to the server. This connection helps users to
extract the data stored in the server. When a user sends a query from the client computer, the
network interface uses a set of instructions called protocols to connect to the server to send the
request The server processes the query and uses the network to send the results back to the
client computer.

Transmission Control Protocol/Internet Protocol or TCP/IP is the most commonly used protocol
for transferring data from one computer to another on the Internet.
A client/server architecture has several advantages:
it improves the performance of a DBMS
it can share the network load among multiple clients and help reduce server side processing
it provides a user-friendly interface
599

it supports the development of complex applications
it enables interaction between clients with different operating systems, and
it reduces the overall cost of database management
Having a single server that hosts several clients is a distinct advantage of the client/server
architecture because fewer support staff are needed to manage the network and control access
to network resources.
But since the client/server architecture only contains a single server to manage resources on a
network, there is always a risk that if the server fails client computers will come to a halt. For
example, if there is a hardware failure on the server, the server will have to be shutdown.
Without a server to take over the work load, users will not be able to connect to the database
until the server is brought back online.
To avoid any downtime due to server failure, businesses employ fail-safe systems, such as
backup servers. This duplication of servers and the expertise required to handle such situations
can sometimes offset the cost savings enjoyed by employing fewer support staff.
Another downside of the client/server architecture is that the same applications are installed on
every client machine. This can lead to clients being overloaded and degrade its performance.
Also, each time there is an update to any of the applications, the new or updated application has
to be installed on every client machine, which may require downtime and higher costs for
administration.
The need for a more flexible and scalable database architecture led to the creation of the n-tier
architecture. The n-tier architecture includes three or more logical layers in multiple
configurations. These layers typically contain a client layer, one or more application layers, and
a database server layer. The application layer connects the clients to the database server, and it
is made up of middleware, such as application servers and web servers.
This additional layer shares the load of the client and the server and carries out various
transactions between them.
The application layer in the n-tier architecture performs the following tasks:
transfers data between machines
controls user access to database servers
shares the tasks of clients and servers
connects existing systems to new systems, and
enables clients using different network protocols to access the database
600

N-tier architectures offer several benefits:
flexibility
The n-tier architecture provides flexibility when using a database. You can mix and manage
various programs, applications, and interfaces in different tiers. Since the work load is shared
among multiple tiers, the architecture can support different applications of varying sizes.
scalability
The n-tier architecture offers improved scalability because application servers can be deployed
on several systems. Unlike two-tier architecture, where the database server must be connected to
all client computers, the database server in the n-tier architecture is only connected to a few
application servers.
network intelligence, and
In the n-tier architecture, the division of tasks is easier as the process of recognizing tasks is
faster and more intelligent. This increases the processing speed and frees up memory space
needed by the client computers.
compatibility between server and client machines
The presence of the application layer in the n-tier architecture ensures that applications only need
to be installed and modified in that particular layer. So the different tiers are compatible with each
other and there are no inconsistent configurations.
In a distributed database architecture, data is stored in databases in multiple locations, which
are connected through a network. Each location has its own local database and DBMS, and is
fully independent of the other locations. The clients can access data from any location through
the network without having to know exactly which database they are accessing the data from.
This is known as transparency.
In a distributed database architecture, memory and storage are not shared between the
database servers.

Each location can run the same DBMS, client, and software, which is known as a homogeneous
distributed database system. Alternately, each location can run different DBMSs, clients, and
software, which is known as a heterogeneous distributed database system.
The distributed database is managed by the distributed database management system, also
known as DDBMS. Besides the functions of a centralized DBMS, a DDBMS is responsible for
managing distributed transactions
managing the distributed directory
managing replicated data
processing distributed queries
601

tracking data, and
securing and recovering distributed databases
The distributed database architecture has several advantages when compared to other types of
architectures. They are
multiple levels of transparency for data
increased reliability
local autonomy
security for sensitive data
better performance
ongoing operational facility, and
easier expansion
Although distributed databases have many advantages, they also have a few disadvantages,
such as
complexity
The complexity of the architecture makes it difficult to manage. It requires extra effort and time to
be kept transparent and concurrent.
lack of experience and standards
As the distributed database architecture is fairly new compared to other architectures, there is a
lack of proper experience in setting up and maintaining it. Also, there are no set standards and
tools for implementing the architecture.
additional software and effort, and
A distributed database requires additional software so it can be set up at different sites. It also
needs additional maintenance effort.
increased cost
Since the structure is more complex, the cost of maintaining it is also high. The distributed nature
of the database requires high labor and hardware costs.
Another type of database architecture is the parallel database. It is based on the same principles
as a distributed database, but can share memory and disks. There are three main architectures
for parallel databases the shared-memory architecture, the shared-disk architecture, and the
shared-nothing architecture.

In a shared-memory architecture, the CPUs share the same memory, by using a global memory
602

area. This enables processors to communicate more efficiently with each other through the
memory rather than having to exchange messages via the network.
In the shared-disk architecture, each database has its own memory and only shares disk
storage.
In the shared-nothing architecture, each database has its own memory and storage. They are
interconnected via a network and have similar operating systems and hardware.
Question
Match each database architecture to its description.
Options:
A. N-tier architecture
B. Distributed database architecture
C. Client/server architecture
D. Centralized architecture
E. Parallel
Targets:
1. Used in a mainframe environment
2. Uses a network protocol to connect user computers directly to the main server
3. Has different ways to share memory and disks
4. Each database is independent of each other and connected through a network
5. Has a minimum of three layers in its structure
Answer
The centralized database architecture is the oldest form of architecture. The users are connected to
a mainframe computer through dumb terminals. Centralized architectures are used for simple
processes.
In the client/server database architecture, the client computers rely on a network interface, typically
a TCP/IP protocol, to connect directly to a database server.
Parallel database architecture has three different ways to share memory and disks the shared-
memory architecture, the shared-disk architecture, and the shared-nothing architecture.
In a distributed database architecture, there are multiple databases in various locations. Clients can
access the data from the various locations through the network, without having to know which
database they are receiving the data from.
603

The n-tier architecture has a minimum of three layers client, server, and applications. The number
of applications is unlimited and this helps to spread the processing load among all the layers.
Correct answer(s):
Target 1 = Option D
Target 2 = Option C
Target 3 = Option E
Target 4 = Option B
Target 5 = Option A
2. Database models
A database model is a structured representation of data that provides a way of storing and
organizing data elements within a database. This representation helps users to retrieve and
update data in the database efficiently.
Drill Down Home Page
Based on the types of structures and their complexity, databases can be categorized into seven
models.
Page 1 of 3: Flat-file database
The flat-file database model is one of the first types of models. It consists of files in simple text
format without any formatting or the facility to search for particular information within the file.
This model was mostly used by businesses to store and process information in an unstructured
way.
Graphic
A table with the employee code, name, street address, and city is displayed. For example, the first
row mentions Roy Anderson, with employee code 657, who resides at 906, North Main Street, Los
Angeles.
In the flat-file model, data is entered as fields that may be of constant or variable lengths. If the
fields are of variable lengths, each column is divided by a delimiter. The delimiter, such as a
colon or a comma, should be a character that is not a part of the data.
Two common examples of the flat-file database model are the initialization or INI files and
Windows Registry.
604

Page 2 of 3: Flat-file database
Flat files are useful for storing simple data that doesn't require frequent changes. Nor is a
complex interface needed to edit these files. You can edit the flat files using a simple text editor,
such as Notepad.
The flat-file database can be accessed and used quickly. You can copy them to a new location
easily without any confusing processes.
Page 3 of 3: Flat-file database
Though the flat-file databases are simple and easy to use, they are seldom used today. The
common reasons for this are
inability to edit or insert data in the middle of the file
extra coding required to add more features like a search function
lack of security, and
inability to store dynamic or hierarchical data
Page 1 of 2: Hierarchical database
Because the flat-file model is not adequate for storing hierarchical data, organizations opt for the
hierarchical database model. In the hierarchical model, data is stored in the form of a tree-
structure with parent and child files. The parent and child files are connected using either one-to-
one or one-to-many relationships. A parent file can have multiple child files, however a child file
can only have one parent file.
Graphic
A project team hierarchy is displayed. The Project is shared by two teams.
The hierarchical database helps organize the data. It also helps you to add more details to a
parent or child file by manipulating the hierarchy.
Graphic
The project data is expanded. Each team involved in the project consists of developers, testers, and
quality control staff.
You can also search for and find specific files easily in the hierarchical database. It also allows
you to maintain data integrity.
605

Page 2 of 2: Hierarchical database
The hierarchical database model falls short when it comes to making automatic changes to the
database. Also, this model is not useful with data that is not hierarchical. As well in this model,
redundant data will most likely be stored, making the database larger than required.
For example, you might be able to find the names of employees in an organization who work on
the night shift or the day shift. But with the hierarchical database you cannot find the day shift
employee who has put in hours during the night shift.
Graphic
A list of employees who work the day and night shifts is displayed. The day shift includes the
employees Fran Barnes, Mario Orr, and Sam Smith. Night shift workers include Beth King, Liz Tate,
and Kyle Davis.
If a hierarchical database is used to store nonhierarchical data, it will degrade the performance
benefits of using this model. This is because complex calculations or advanced searches are
required to find data that does not use the hierarchical structure.
Page 1 of 3: XML database
Today, most hierarchical data is stored in text format using the extensible markup language,
commonly known as XML. XML is a language that helps to transfer, store, and retrieve
hierarchical data.
Graphic
The details of an employee, Roy Anderson, are displayed in XML language. They state that
Anderson's employee code is 657 and his address is 906 North Main Street.
As XML is hierarchical in nature, it can recreate the hierarchical data for users quickly. It is a
basic text file that defines the structure of the data it contains by using tokens.
Also, XML files offer you the flexibility to create elements within elements. For this reason, they
are also called semi-structured files. When you are not sure of what the structure of your data
will be after completion, XML is the best option for storing the data.
Page 2 of 3: XML database
An XML file defines the structure of data within the database by using special tokens that are
enclosed by tags. You can add the data after the token and complete it with the same token, but
with an extra slash immediately after the opening tag.
606

Graphic
The details of an employee, Mark, are displayed in XML language. They state Mark's last name is
Alford and his designation is database administrator.
In XML files, you can keep adding these tokens as and when you find them necessary. Since
XML programs ignore any white spaces in the file, you can add spaces and tabs to make the
text readable.
Graphic
More data about Mark Alford is added. This includes the street address and city where Mark lives,
117 Fortnum Avenue and San Francisco respectively.
Page 3 of 3: XML database
Though XML databases offer you fast responses and flexibility, they are not always preferable.
XML is not convenient for
Graphic
Details of an employee Roy Anderson are displayed in XML language. They state that Anderson's
employee code 657 and his address is 906 North Main Street.
storing non-hierarchical data
making small changes in the middle of the file in a large database easily
letting multiple users make changes in the file, or
performing relational queries
Page 1 of 2: Network database
The network database model contains interconnected parent and child files that are also called
nodes. In a network database, a child file can be connected to multiple parent files. The link that
connects parent and child files with each other is called the set structure.
When a user tries to access data in the network database, the application program uses set
structures to navigate to the data required by the user. Users can begin navigating from any
point in the file and move up or down the hierarchy to access the information needed.
607

Page 2 of 2: Network database
Network databases cannot be used when
data does not represent a network
data requires validation
complex queries need to be performed, or
multiple users want to access and update the database at the same time
Page 1 of 3: Relational database
Relational databases consist of tables with rows and columns. The rows indicate a particular
item and columns indicate details about that item. For example, you can store the data about
students in a table. Each row in the table indicates a different student and each column indicates
a different detail about the student.
Graphic
A list of students in a class is displayed in a table along with their IDs.
A piece of data in a relational database might have multiple values. For example, a particular
student in the class might be participating in many activities. To keep track of the activities of
this student, the activity details are stored in another table and relate back to the student.
Graphic
In the second table the student IDs, the activities the student is participating in, and the performance
status of each student are displayed. For example, the student with the ID 248 is participating in
swimming and her performance level is novice. An arrow points from the ID of this student to her
name, Hannah Gates. This is given in the first table.
Page 2 of 3: Relational database
A relational database ensures that when you update an entry in one table, the information about
that entry is automatically updated in related tables. It also ensures data integrity by preventing
users from making any changes to a table that would leave the values in the related table
invalid.
Each column in a relational table has a specific type of value that denotes the data in that
column. The database only allows that type of value to be entered in the table. By defining basic
constraints like these, the relational database ensures that the values entered in a table are
logically correct and ensure data integrity.
608

Page 3 of 3: Relational database
Unlike flat-file databases, relational databases allow you to perform complex queries, such as
sort, filter, add, subtract, count, average, and standard deviation.
Quick joins is another feature of relational databases that helps users to collect the data of a
particular item when it is spread across different tables.

However, in order to complete these tasks, the DBA, developers, and database designers need
to know the query language and understand the relationships between the tables.
Page 1 of 3: Object-oriented database
The object-oriented database model is based on object-oriented programming and it stores data
in the form of objects. It can be used by multiple users without their work interfering with the
others'. The object database provides certain tools for users to make changes in the objects and
save them in the database again.
Users can retrieve the information they want by sending query syntax provided by the object
database. They can use object query language, or OQL, to manage the data in the object
database. These databases are also called object-oriented databases or object stores.
Page 2 of 3: Object-oriented database
The main components of an object-oriented database are objects and literals. Literals are values
associated with objects. One object in the database is associated with another through
identifiers. Literals don't have identifiers.

Objects in the database are such things as customers, orders, products, and inventory.
Objects and literals within an object database are organized by their types classes. Objects
and literals of the same type have the same properties. Users can change the properties of an
object.

A class is the equivalent of a table in a relational database.
In the object database, you can use a programming language to create the database and
applications for the end user. The database and the applications are connected by an object
DBMS.
Page 3 of 3: Object-oriented database
Object databases are useful when you don't have complicated queries. Most of the processes in
the application programs related to the object database are automated. So you can manage the
objects in the database easily.
609

The downside of the object database is that the standards for using it are not fixed yet. Also,
there are situations where object databases are not suitable. You cannot use this type of
database when the data requires external tools, needs to be validated, involves complicated
queries, or doesn't use an object-oriented language.
Page 1 of 2: Object-relational database
To make the object-oriented database more effective and useful, you can combine the concepts
of object-oriented programming with a relational database, to create an object-relational
database management system or ORDBMS.
An ORDBMS is a relational database that provides extra features, like the object-relational
mapping system, to integrate objects into data. It uses special syntax to create the objects in the
database.
The main feature of an object-relational database is the object-relational mapping system that
adds a layer between the object code and the relational database. This layer converts the data
into the required format for programmers and DBAs, saving them time.
Page 2 of 2: Object-relational database
The object-relational database model brings together the benefits of both object-oriented
databases and relational databases. Also, it allows users to create user-defined types, which are
custom data types for use in the tables to specify what can be stored in a particular column.
In an object-oriented programming and architecture environment, you can use the object-
relational database to process complicated queries concerning relational style, perform data
validations, and separate the tasks of programmers and DBAs.
Most organizations today use the relational database model to meet their business needs. The
relational database is stable and versatile, and uses SQL to facilitate data management.

Additionally, referential integrity and other constraints ensure data protection.
Question
Match each database model to the corresponding description.
Options:
A. Flat-file database
B. Relational database
C. Object-oriented database
D. Network database
610

Targets:
1. Includes tables with rows and columns
2. Involves nodes and links
3. Stores simple text
4. Uses a programming language to create the database and applications
Answer
Relational databases consist of tables with rows and columns. The rows indicate a particular item
and columns indicate details about that item.
Network databases involve nodes that are connected to each other via links.
Flat-file databases store data in text format without any additional features.
Object-oriented database uses a programming language to access data.
Correct answer(s):
Target 1 = Option B
Target 2 = Option D
Target 3 = Option A
Target 4 = Option C
Question
Match each description to the corresponding database model.
Options:
A. Stores data in a tree structure
B. Simplifies the creation of objects in the database
C. Uses a markup language to define the structure of data within the database
Targets:
1. Object-relational database
2. XML database
3. Hierarchical database
Answer
611

Object-relational database allows users to create objects in the database with the help of special
syntax.
XML databases consist of XML files. These files contain special tokens enclosed by tags. These
tokens help to define the structure of data within the database.
Hierarchical databases consist of data stored in a tree structure, with parent and child files.
Correct answer(s):
Target 1 = Option B
Target 2 = Option C
Target 3 = Option A
Summary
There are several types of database architectures. Early databases used the centralized
architecture with a mainframe computer and dumb terminals. Later on this gave way to the
client/server architecture where users connect to the main server from client machines.

The client/server architecture was followed by the n-tier architecture where one or more
application layers connect the server to the client computers.

The fourth type of database architecture is the distributed database where multiple servers are
used to store data. These servers are interconnected and spread across a network.

Based on the type of data and user requirements, businesses use different database models.
The flat-file database model uses simple text. The hierarchical database is suitable for data that
has to be stored in an organized way. XML is the main language that is used to store
hierarchical data.

The most common database model is the relational database where data is stored in tables
made up of rows and columns. For data that is network oriented, a network database is used.
Object databases are used for object-oriented data. The concepts of object-oriented
programming and relational databases are combined in object-relational databases.





612

Identifying Database Systems
Learning Objectives
After completing this topic, you should be able to
recognize the features of databases and DBMS
describe database models and database architectures
Exercise overview
In this exercise, you're required to recognize what databases and DBMSs are, the different
database models, and the database architectures.
This involves the following tasks:
recognizing the features of databases and DBMS and
describing database models and architectures
Recognizing database and DBMS features
To control, store, organize, and retrieve data using databases, you need to be familiar with the
fundamental concepts of database systems.
Question
A database differs from DBMS in many ways. To manage database systems, you should know the
differences between the two.

Match each description to either database or DBMS. You may use each target more than once.
Options:
A. Coordinates with applications to manage data
B. Stores information in electronic form
C. Controls the use of data by providing access only to authorized users
D. Consists of data divided into fields, records, and tables
E. Allows users to add, modify, delete, and retrieve data
Targets:
1. Database
2. DBMS
Answer
613

A database consists of information arranged logically in electronic form in database objects. The
data is stored in tables which consist of fields and records.
A DBMS is a software program that coordinates with various applications to manage data within a
database. It controls the access to the database and allows only authorized users to add, modify,
delete, and retrieve data.
Correct answer(s):
Target 1 = Option D, Option B
Target 2 = Option A, Option C, Option E
Question
Your company has recently deployed a new human resources information system. The system uses
a database that stores information about employees, salaries, payroll, and taxes and other benefits.
The company wants to ensure that the performance of the database is regularly monitored and
technical problems are quickly resolved. It also wants to ensure that only authorized users are able
to access the database.

Which type of database user is responsible for monitoring the database performance and providing
database access to authorized users?
Options:
1. System analyst
2. Database administrator
3. Database designer
4. End user
Answer
Option 1: This option is incorrect. System analysts create specifications for developing canned
transactions for end users. System analysts are not responsible for backing up data within a
database.
Option 2: This option is correct. Database administrators are responsible for monitoring the
database performance and resolving technical issues. They determine the software and hardware
requirements of users and provide access to only authorized users.
Option 3: This option is incorrect. Database designers design the database structure that suits the
requirements of users.
614

Option 4: This option is incorrect. End users send queries to the database, add information to the
database, and generate reports.
Correct answer(s):
2. Database administrator
Question
Your company is planning to deploy a database to manage its organizational data. You've been
asked to identify a database that suits your organization's requirements.

What are the key attributes that a database should have?
Options:
1. It should provide adequate storage space
2. It should have constraints to ensure accuracy of data
3. It should provide equal access to all users
4. It should maximize data redundancy
5. It should enable users to update the database when required
6. It should be available to users only for a limited amount of hours
Answer
Option 1: This option is correct. A good database should have sufficient space to store all data
required by the organization. Archiving the old and unnecessary data is one method that can help
you ensure that the database has adequate storage space.
Option 2: This option is correct. The database should set constraints to ensure that the data it
stores is accurate and error free.
Option 3: This option is incorrect. The access to the database should be limited to ensure its
security. For this, only authorized users should be given passwords with specific data-access
privileges.
Option 4: This option is incorrect. A good database should minimize data redundancy as the
repetition of data can lead to its inaccuracy as well as unnecessary use of storage space.
Option 5: This option is correct. Users should be able to update the database when required.
Database design, application design, network speed, and network hardware are a few factors that
decide how the database performs these operations.
615

Option 6: This option is incorrect. A good database should be available to users when required.
Data availability is possible if the database is designed well, its downtime is scheduled outside of
business hours, and it has advanced applications to process queries.
Correct answer(s):
1. It should provide adequate storage space
2. It should have constraints to ensure accuracy of data
5. It should enable users to update the database when required
Describing models and architectures
Your company is planning to expand its business. You need to identify a database architecture
and model that will meet the needs of your company. So you should know about the key
database architectures and models.
Question
You are an employee of a company that runs food retail chains in several cities. To save time and
ensure accuracy and timely delivery, the company intends to introduce an automated order booking
system. For this, the company requires a database model that supports processing of complex
queries, interconnection of data, and easy modifications.

Identify the database model that is suitable for these requirements of the company.
Options:
1. Flat-file
2. Relational
3. Hierarchical
4. Object-oriented
5. Object-relational
6. Network
7. XML
Answer
Option 1: This option is incorrect. The flat-file database model can store only files with simple text
format. Although it can be modified easily, flat-file database does not support complex queries.
Option 2: This option is correct. Relational database can help you store the orders from customers
along with the details of the customers. As it lets users to modify the data, customers can change
their orders if they wish to. It allows the staff to verify the orders to ensure that right delivery is done
616

at the right time. Through the interconnecting keys in the relational database, you can link a new
order to existing customers.
Option 3: This option is incorrect. Hierarchical databases can store data linked to each other.
However, it cannot allow for automated modifications.
Option 4: This option is incorrect. Object-oriented database supports automated processes.
However, it cannot process complicated queries.
Option 5: This option is incorrect. Object-relational database would help you in finding the
connection between various data, but it requires an environment of object-oriented programming for
functioning.
Option 6: This option is incorrect. Network database helps you in storing interconnected data.
However, it doesn't support complex queries.
Option 7: This option is incorrect. XML database doesn't support easy modifications. Also, it cannot
process complex queries.
Correct answer(s):
2. Relational
Question
To help the company in effectively utilizing the relational model database you have chosen, you
need to know the different advantages of the relational database and how you can make use of
them for optimum results.

Identify the benefits of a relational database that will ensure an efficient order booking system for
your company.
Options:
1. It processes complex queries
2. It performs data validation
3. It limits the modifications to a single file
4. It performs joins on different tables
5. It allows any of data to be entered in any table
6. It allows users to add or remove data when required
Answer
Option 1: This option is correct. Relational database processes complex queries that would help in
tracking the orders from different customers across the cities.
617

Option 2: This option is correct. Relational database helps the user to check the accuracy of the
data. This means that the company staff can ensure that the order is accurate before making the
delivery.
Option 3: This option is incorrect. Relational databases have cascading modifications so, if a
customer changes an order, the change is reflected in all the files where the related data is stored.
Option 4: This option is correct. By collecting information from different tables, relational database
can help the staff in getting all the details of an order like the time of delivery, which customer has
made the order, and whether the customer has previously ordered a similar item.
Option 5: This option is incorrect. Relational database has data constraints that ensure that the
right data is entered in the database. It can prevent users from accidentally entering wrong
information in the database.
Option 6: This option is correct. Relational database allows users to add more data to the existing
database. This can help the customers to modify their orders.
Correct answer(s):
1. It processes complex queries
2. It performs data validation
4. It performs joins on different tables
6. It allows users to add or remove data when required
Question
You want to design a database architecture that uses multiple application servers to query database
servers and show results on client computers.

Which database architecture should you choose?
Options:
1. Centralized
2. Client or server
3. N-tier
4. Distributed
5. Parallel
Answer
Option 1: This option is incorrect. The centralized database architecture has processing power only
in the main server that is directly connected to dumb terminals.
618

Option 2: This option is incorrect. In the client-server database architecture, client computers are
directly connected to a server.
Option 3: This option is correct. The n-tier architecture contains three or more logical layers. These
layers include one or more application layers, such as a web server, that connects the client layer
with the database server layers. The application layer shares the load of processing data stored on
the client and the server.
Option 4: This option is incorrect. In a distributed architecture, databases are distributed across
different storage devices and data is stored in several computers that are located at one or more
places.
Option 5: This option is incorrect. Parallel database architecture has data stored in multiple storage
devices that have different ways to share memory and disks.
Correct answer(s):
3. N-tier
Question
To implement the n-tier database architecture successfully, you have to be aware of different
advantages it offers.

What are the benefits of the n-tier architecture?
Options:
1. It allows all users free access to the database
2. It reduces the load of the server and client machines
3. It improves the performance of database and applications
4. It allows limited transactions per day
Answer
Option 1: This option is incorrect. The application layer in the n-tier architecture, the web server in
this instance, offers firewalls to control the access to the database.
Option 2: This option is correct. The presence of the application layer ensures that the different
tasks are shared among the three layers in the architecture the client, server, and applications.
This reduces the load of each layer and increases the processing speed of each query.
Option 3: This option is correct. Since there is no direct connection between the client and the
server, the server and applications connected to it can be monitored and updated as and when
required. This ensures better performance of the database and the applications.
619

Option 4: This option is incorrect. The multiple layers in the n-tier architecture ensure that all data
are received and stored. So any number of orders can be received per day from multiple locations.
Correct answer(s):
2. It reduces the load of the server and client machines
3. It improves the performance of database and applications
























620



Relational Database Concepts
Learning Objectives
After completing this topic, you should be able to
describe the features and recognize the types of relational databases
recognize how to model the database
1. Features and types of RDBMSs
A relational database is a collection of tables made up of data that are related to each other by
common characteristics. This data can be reorganized and grouped in many different ways
without modifying the database tables.
For example, a business order entry database could include two tables Customers and
Orders. The Customers table would include information about the names, addresses, and phone
numbers of customers. The Orders table would include information about products ordered, the
customers, order dates, and sales prices.
A sales manager can reorganize the table to view only the number of orders placed by each
customer on a given date. A finance manager in the same company can group the table entries
to view only the names and addresses of customers with pending payments.
Such a grouping of data is based on the relational database model. This model was conceived
by Dr. Edgar Frank "Ted" Codd in the 1970s in a paper titled "A Relational Model of Data for
Large Shared Data Banks," which he published while working as a researcher at IBM. The
model is based on set theory and predicate logic, branches of mathematics.
The relational model was designed to simplify the database structure. It replaced the
hierarchical model with simple tables containing rows and columns.
In the 1980s, Dr. Codd published 13 rules, zero to 12, for determining whether a database is
relational. This was done to prevent DBMS vendors from labeling their products as relational,
even though they were not fully relational.
Supplement
Selecting the link title opens the resource in a new browser window.
Job Aid
621

Use the job aid Codd's 13 Rules to review the rules that help you determine the characteristics of a
relational database.
Dr. Codd identified three main components of the relational model manipulation, structure, and
integrity.
The relational model consists of manipulative components, which are high level operators that
you can use to convert one set of relations to another. Some of the relational operators used for
data manipulation are union, intersection, difference, and division. These relate to mathematical
relational algebra and relational calculus, which Codd originally specified.
The structural component defines how data is represented. In a relational database, all the
information is presented as relations, also known as tables. These relations are composed of
sets of tuples that have the same attributes. A tuple can be thought of as a row. Whereas an
attribute refers to a column and for each attribute there is a set of values. These relations are
based on relations in set theory, a mathematical concept.
The integrity component defines methods of checking the validity and consistency of stored
data. These methods are called constraints and are designed to enforce rules within and
between relations in a database. A database provides various integrity rules, such as entity
integrity, domain integrity, and referential integrity.

Entity integrity states that a primary key column cannot hold a null value whereas domain
integrity validates entries for a specific column. Referential integrity, in contrast, governs how
tables relate to one another.
Question
Match each component of the relational model with its correct description.
Options:
A. Structural
B. Integrity
C. Manipulative
Targets:
1. Components that define how information is represented in a database
2. Rules that protect the consistency of a database
3. Relational operators that can be used to convert one set of relations into another
Answer
622

The structural component defines how information is represented or structured in a database. In the
relational model, data is represented in relations, which are composed of tuples and attributes.
The integrity component defines constraints or rules that validate and protect the consistency of
data stored in a database. Some key integrity rules are entity integrity, referential integrity, and
domain integrity.
The manipulative components are a set of relational operators, such as union, intersection,
difference, and division, that convert one relation to another.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
The data structure of a relational database mainly consists of four components:
relation
A relational database stores all its data inside relations, commonly known as tables. A relation is
a combination of tuples and attributes. In the example displayed, the Sales table represents a
relation.

You can perform a number of operations on a relation. For example, you can retrieve a subset of
tuples or a subset of attributes from a relation. Alternatively, you can combine items from two
relations into one.
The Sales table contains five columns Order ID, Order Date, Customer ID, Customer Name,
and Sales Amount ($). The table contains four tuples.
tuple
In the relational model, a tuple refers to a row. A tuple consists of a set of attributes, and each
tuple is linked to an entity.

If the values of a tuple are unknown or there are values that don't apply to that tuple, you use a
NULL value.
The Sales table contains four tuples. The first tuple contains 001 as the Order ID, 09/09/2011 as
the Order Date, 101 as the Customer ID, Portage Airlines as the Customer Name, and 244,500
as the Sales Amount ($).
attribute, and
The attributes of a relation refer to its columns. An attribute is the smallest data structure in a
relational database, and gives its name to the column header in a relation. An attribute takes its
value from an appropriate domain.
There are five attributes in the Sales table Order ID, Order Date, Customer ID, Customer
623

Name, and Sales Amount ($). The Order ID attribute contains values, such as 001, 002, 003, and
004.
domain
A domain is a set of values that are assigned to an attribute and can be specified by assigning a
data type. The data type describes the kind of values an attribute can contain. For example, in the
Sales table, the data type for the Order Date domain is DATE specified as DD/MM/YYYY. This
ensures that only values in the appropriate date format can be entered in this domain.

You can specify a name and format for a domain or other information that assists with interpreting
the values in a domain.
There are several types of relational databases available in the market. Some commonly used
databases are
HSQLDB and OpenOffice.org Base
Microsoft Office Access
Microsoft SQL Server
Mysql
PostgreSQL
Oracle, and
IBM DB2
Short for Hyper Structured Query Language Database, HSQLDB is an open source RDBMS.
HSQLDB is written in Java and is available for free under a Berkeley Software Distribution
license. It conforms to almost all SQL:1992 Advanced Level and SQL:2008 standards.
Note
Berkeley Software Distribution or BSD is a modified Unix operating system developed and
distributed by the University of California, Berkeley, California.
HSQLDB is the default database engine used in many open source software programs,
including OpenOffice.org Base. Using HSQLDB, Base implements a one-file database, that is, it
creates databases that contain reports, forms, queries, and tables in one file. This helps to
provide end users with easy access to data.
Base is meant to be used as a desktop database. You can use Base to create new tables for
your data, perform simple or complex sorts, create complex queries, and connect to several
other RDBMSs. It also runs on multiple platforms, including Unix, Linux, and Microsoft Windows.
624

Like OpenOffice.org Base, Microsoft Access is also a desktop file-based database system that
is written in Microsoft Visual Basic language, and is generally included with Microsoft Office
suite applications.
Like Base, Access stores all database tables, forms, queries, and reports as a single file. This
file is stored in the Microsoft Jet Database engine that works in combination with a graphical
user interface and software development tools. In addition to its own Jet Database engine,
Access can be used with other databases and applications.
In addition to Access, which is a desktop database, Microsoft has developed an enterprise-level
relational database server called SQL Server. As the name suggests, SQL Server's primary
query language is SQL, which uses Microsoft implementation called, Transact-SQL.
SQL Server stores and retrieves data queried by applications and users. It can be used for
business administration, application development, business intelligence, reporting, and
integration.
MySQL is another RDBMS that runs as a server and provides access to multiple databases. It is
written in C and C++ programming languages, and is open source.
MySQL runs on several platforms, including Microsoft Windows, Apple iOS, Solaris, and Linux.
It is considered to be simple, agile, and easy to use, and is also supported by several open
source applications, including OpenOffice.org Base.
Unlike some relational database types, MySQL offers a distinguishing feature by allowing users
to query and retrieve data from multiple storage engines. A database table can be created with
different storage engines, each with unique capabilities. This gives the users freedom to choose
the storage engine that best meets their application needs.
Another popular relational database is PostgreSQL, sometimes referred to as Postgres. It is an
object-oriented DBMS, or OODBMS, and is written in the SQL query language. It can run on
several platforms, including Windows, Linux, Solaris, and Apple OS X. Like MySQL and
HSQLDB, PostgreSQL is a free and open source software program.
Just like MySQL, OpenOffice.org Base can be used as the graphic user interface for
PostgreSQL.
Whereas PostgreSQL is an object-oriented DBMS, Oracle database is an object-relational
DBMS, or ORDBMS, developed and marketed by Oracle Corporation.
Oracle database complies with SQL:2008 Standard and supports most of its features.
Oracle database uses three key programming languages SQL, Java, and PL/SQL, short for
Procedural Language/Structural Query Language.
Note
625

PL/SQL is Oracle Corporation's built-in procedural language for its database.
Like Oracle database, IBM DB2 is an enterprise-level RDBMS, and is developed and marketed
by IBM Corporation. IBM DB2 runs on several operating systems, including Windows, Linux,
and Unix.
IBM DB2 is based on its own built-in procedural extension language SQL PL, but it provides
support for other languages, which include Java, Oracle's PL/SQL, and Microsoft's .NET
languages.
Question
What are the key features of a relational database?
Options:
1. A relational database stores all its data inside relations
2. In a relational database, an attribute consists of a collection of tuples
3. In a relational database, the tuples are assigned unique data types
4. In a relational database, the attributes of a relation refer to its columns
Answer
Option 1: This option is correct. In a relational database, data is stored inside relations, which are
tables. They consist of tuples and attributes.
Option 2: This option is incorrect. In a relational database, a tuple consists of a set of attributes, and
each tuple is linked to an entity.
Option 3: This option is incorrect. Domains in a relational database are assigned a data type. The
data type specifies the kind of value an attribute can contain.
Option 4: This option is correct. The attributes of a relation are commonly referred to as the
columns of a table. Attributes are the smallest data structure in a relational database.
Correct answer(s):
1. A relational database stores all its data inside relations
4. In a relational database, the attributes of a relation refer to its columns
Question
Match each type of RDBMS with its description.
Options:
626

A. OpenOffice.org Base
B. Microsoft Access
C. SQL Server
D. MySQL
Targets:
1. An open source RDBMS that uses HSQLDB as the default database engine
2. A file-based database system that is written in the Visual Basic language
3. An enterprise-level RDBMS developed and marketed by Microsoft
4. An open source RDBMS that is written in C and C++
Answer
OpenOffice.org Base is an open source RDBMS that is available under a BDS license, and it uses
HSQLDB as its default database engine.
Microsoft Access is written in Microsoft Visual Basic programming language and stores data in the
Microsoft Jet Database engine.
Microsoft SQL Server is an enterprise-level RDBMS, and it uses SQL as its query language.
MySQL is an open source RDBMS that is written in C and C++ and provides access to multiple
databases.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Question
Match each type of RDBMS with its description.
Options:
A. PostgreSQL
B. Oracle
C. IBM DB2
627

Targets:
1. An OODBMS that is written in SQL query language
2. An ORDBMS that complies with SQL:2008 Standard
3. An enterprise-level RDBMS that uses SQL, Java, Microsoft .NET, and PL/SQL as its programming
languages
Answer
PostgreSQL is an open source, OODBMS and is written in the SQL query language.
Oracle is an ORDBMS developed and marketed by Oracle Corporation. It complies with SQL:2008
Standard.
IBM DB2 is an enterprise-level RDBMS that uses SQL, Java, Microsoft .NET, and PL/SQL as its
programming languages.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
2. Database modeling
When designing a relational database system, you use entity-relationship modeling. This is a
database modeling technique that is used to represent the data requirements of a business into
a logical structure. These logical structures become the physical relations, attributes, and tuples
of the database.
The business processes are represented in the form of entities, with defined relationships
between them. The entity may be a place, person, object, or event for which data is collected.
For example, in a Sales database, entities would include customers, products, and orders.
The relationship represents how one entity is linked with other entities. In the Sales database
example, the order that a customer places for products represents how the customers entity is
linked to the orders entity, and how the orders entity is linked to the products entity to retrieve
accurate data.
Diagrams developed by using this model are referred to as Entity-Relationship Diagrams or
ERDs. Creating an ERD helps you to understand an organization's data needs, and the ERD
can be used as a schema diagram for identifying the required system's database.
628

An ERD consists of data flow diagrams or DFDs that organize the business requirements into
categories and allow you to map the relationships between categories. DFDs help you to
visualize the flow of data through a system which entities the data will come from and go to,
where the data will be stored, and what processes will be performed on the data.
Because an ERD represents the data requirements of a business in a graphical form, it is easy
for users and developers to understand the database structure.
Data modeling is an iterative process, and you can easily adapt an ERD to accommodate any
required changes to the model or data.
Question
Which statements about database modeling are correct?
Options:
1. Database modeling represents data in physical structures
2. Data modeling defines the relationships between entities
3. DFDs represent the flow of data through an information system
4. Entity-relationship modeling is a nonrepetitive process
Answer
Option 1: This option is incorrect. An ERD is used to transform the data requirements of a business
into logical data structures.
Option 2: This option is correct. Data modeling helps you to define the relationships between
entities in a database.
Option 3: This option is correct. A DFD is a graphic representation of the flow of data through an
information system. It shows where data is stored, where it will originate from and go to, and what
processes will be performed on the data.
Option 4: This option is incorrect. Entity-relationship modeling is an iterative process, and you can
make required changes to the data at any time.
Correct answer(s):
2. Data modeling defines the relationships between entities
3. DFDs represent the flow of data through an information system
629

Summary
A relational database is a collection of related data items that are organized in the form of
tables. Dr. Edgar Codd developed the relational database model in a paper that he wrote in
1970. In the paper, Codd identified 13 rules that define the characteristics of a relational
database. Additionally, the relational model explains the various parts of a table, which include
attributes, domains, relations, and tuples.

Database modeling is a technique that is used to represent the data requirements of a business
into a logical structure.






















630

The Relational Database Schema
Learning Objectives
After completing this topic, you should be able to
describe how to outline a relationship database schema
describe the concept of referential integrity
1. Schemas and referential integrity
The usability of a relational database depends on its architecture and on the extent to which the
database can maintain consistency and minimize redundancy.
Various types of schemas constitute the architecture of a relational database, while referential
integrity ensures the consistency and redundancy criteria. You can build an efficient relational
database and manage it effectively if you correctly understand how the schemas and their
components interact.
Each database architecture is made up of three types of schemas to identify the structure and
concepts for the database's system. This is known as the three-schema architecture.
Internal schema
The internal schema provides details of how and where data is physically stored. In other words,
this schema represents the physical structure of a database. The internal schema is not
relational.
Conceptual schema
The logical structure of a database is represented by the conceptual schema. This schema
includes the abstraction of all the database entities, the relationships among them, their
attributes, and constraints. This schema hides the complexities of the physical schema and
presents data in a simplified format. This format is relational, and database administrators and
developers can easily customize and use it.
External schema
The external schema represents the data that is displayed to users. This schema is based on the
conceptual schema. The remaining part of the database is hidden from users.

A database administrator can customize the external schema for each user according to the
user's access rights and permissions. This ensures that users can only view and modify the data
they are authorized to access. The external schema is relational because visible data is in the
form of relational tables.
When managing databases, you mainly have to work with the conceptual and external schemas.

In the conceptual schema, data is organized into a group of tables. Each table is formally known
631

as a relation. This is because each row of data in a table relates to a particular entity, such as a
specific employee.

Each relation, or table, has various components associated with it. These include
Graphic
The example depicts a table named Employees. This table has one header row and three data
rows. Some of the column headings in the table are Employee ID, First Name, Last Name, E-mail
ID, Phone Number, and Salary. The three data rows display data that relates to employees with the
IDs A00001, A00002, and A00003, respectively.
attributes
tuples
domains
data types
constraints, and
keys
Each attribute represents a type of value that you want to associate with every entity in a table.
For example, in the Employees table, the Employee ID and Salary attributes represent the ID
and salary of every employee. An attribute is informally known as a column, and the name of an
attribute serves the same purpose as a column name.
Unlike an attribute or column, a tuple contains all the values associated with a specific entity
for example, the ID, name, salary, and address of a specific employee. Each value maps to a
specific column. A tuple is informally known as a row.
The contents of rows can be stored in any order in the internal schema, and you don't need to
be aware of their physical location. To access or modify the contents, you only have to use a
logical database query. For example, you can use a SELECT query to retrieve the salary of an
employee from the Employees table and an INSERT query to add details about a new employee
to the table.
Each value you add to a row must conform to a certain specification. This is known as the
domain of the corresponding column and specifies what values are allowed to be entered for
that specific column. For example, the domain of the Salary column could be numerical values
greater than zero, while the domain of the E-mail Address column includes valid e-mail
addresses. You should define the domain of each column.
632

You need to define a data type for each column. A data type signifies the type of data a column
can contain. For example, the data type for the Salary column would be a money data type, and
the data type for both the First Name and E-mail Address columns would be an alphanumeric
data type.
Note
There are multiple types of data types, and each database system can use a different set of data
types.
A column can contain any value that maps to its associated data type and domain. If you want to
limit these values, you need to define constraints for the column's domain. For example, you can
define a constraint that specifies the lower and upper bounds for the Salary column. This type of
constraint is known as a domain constraint.
Apart from using domain constraints to specify lower or upper bounds, you can also use them to
prevent any column value such as the first name of an employee from being left blank
specify the format and length of data types such as the format of dates and the lengths of integers and
strings
prevent users from entering column values that don't conform to the specified data type, format, or length
for example, you can prevent users from entering a string under a column whose data type is integer
and
prevent or minimize data duplication and enhance data integrity
Domain constraints are associated with columns. However, you can also define other types of
constraints for columns and even for a row or an entire table.

Two specific constraint types are
check and
A check constraint allows data to be inserted only if it satisfies a Boolean expression. You can
define check constraints at column or table level. An example of the former is a constraint that
allows an age value to be inserted only if it is greater than 18. An example of the latter is a
constraint that ensures that when you update an employee's salary to a value greater than
$30,000, that their compensation level is above 2%.
unique
To ensure that each value under a column is unique, you should apply a unique constraint to the
column. For example, you should apply a unique constraint to an Employee ID column so that
each employee has a different number. You should use discretion and foresight when applying
633

unique constraints. For example, you shouldn't apply a unique constraint to a column such as
First Name or Salary. That's because multiple employees can have the same first name or salary.
The information about any constraints that you define is stored in the system catalog and
database dictionary. The database then accesses the relevant constraints whenever a user tries
to add or update a column value and allows the new value to be inserted only if it adheres to the
constraints.
Keys enable you to further add constraints to the columns in a table.

Keys can be of various types, such as
primary key
surrogate key
superkey
candidate key, and
foreign key
In any table, a primary key comprises single or multiple column values that help to uniquely
identify a row. A table can only have one primary key defined on it, and all the columns must
have unique values for each row.
Graphic
In the example, the Employee ID column is the primary key.
Usually a table will have a specific column added to be the primary key. This column is called a
surrogate key and has no actual meaning to the row. It is only meant to uniquely identify the
rows in the table and is used when no other column can do this. The surrogate key is usually a
system generated value that is defined for each row in the table. For example, in the Orders
table, you can add a column called Order ID to be the surrogate key. Each time a new order is
placed by a customer, the value for this column will be automatically generated to track the
number of orders and uniquely identify each one.
One or more columns in a table that are used to uniquely identify a row is known as a superkey.

For example, if the combination of First Name, Last Name, and Phone Number are required to
uniquely identify each row in the Employees table, these three columns are the superkey for that
table.
Graphic
634

In the example, First Name, Last Name, and Phone Number form a superkey.
A candidate key is a column that makes up the superkey. If you remove any column, the key no
longer remains a superkey, and so it can't help you to identify a specific row. For example, if you
remove the First Name column from the superkey, then Last Name and Phone Number are no
longer a superkey because they require the First Name column to uniquely identify a row.
Therefore, First Name is a candidate key. This is also the case with the other two columns in the
superkey they need each other, and so each of them is a candidate key.

Tables can have multiple superkeys and candidate keys.
You can create a foreign key in a table to reference the primary key in another table to link the
tables together. The foreign key column has the same values as the primary key column. The
table with the primary key is called the parent table, and the linked table, or referenced table, is
the child table.
Graphic
The example depicts the Employees table along with another table named Projects. The Projects
table has one header row and three data rows. Some of the column headings in the table are
Employee ID, Project ID, Project Name, and Role. The Employee ID column is a foreign key. This
key is linked to the Employee ID column in the Employees table. This Employee ID column is a
primary key.
In the example, the foreign key in the Projects table refers to the primary key in the Employees
table. This ensures that any employees working on a project exist in the Employees table before
they can work on a project. That is, when a row is added to the Projects table, the value entered
as the Employee ID must already be a value in the parent table, Employees.

You can also use this column to perform join operations between the two tables for example,
to find the actual employees' names and the projects they are working on.
By using a foreign key to reference a primary key, the database management system ensures
referential integrity. This identifies how the data in the parent and child tables are managed.
Referential integrity ensures data consistency and integrity between the two tables.

For example, referential integrity ensures that data is updated or inserted into the parent table
before data is updated or inserted into the child table to prevent inconsistent data from being
entered.

In addition, when a user tries to delete a row from a parent table, the system can either
prevent the deletion unless the user first deletes rows containing matching column values from the child
table or
delete rows containing matching column values from the child table automatically
635

Note
This depends on the RDBMS that is being used for the database.
Foreign and primary keys also help to establish various types of relationships between tables:
one-to-one
In a one-to-one relationship there can only be one occurrence of a value between two tables. For
example, each department can only have one manager and each manager can only manage one
department.
In the example, the Departments and Managers tables have a one-to-one relationship. The
Departments table has columns named Department Name and Location and the Managers table
has columns such as Employee ID, First Name, Last Name, E-mail ID, Phone Number, and
Salary.
one-to-many, or
In a one-to-many relationship, a single row in a table is linked to multiple rows in another table.
For example, each department has several employees, but each employee can only be in one
department.
In the example, the Departments table has a one-to-many relationship with the Employees table.
The Employees table has columns such as Employee ID, First Name, Last Name, E-mail ID,
Phone Number, and Salary.
many-to-many
In a many-to-many relationship, multiple rows in a table are related to multiple rows in another
table. For example, multiple employees might work on a number of different projects, and each
project can have more than one employee working on it.
In the example, the Employees table has a many-to-many relationship with the Projects table.
The Projects table has columns such as Employee ID, Project ID, Project Name, and Role.
Relationships, keys, and other related components help to organize the conceptual schema.

This schema also contains several other components that enable you to access and manage
data.
Indexes
An index is a type of database structure that allows data to be quickly retrieve from the table the
index is based on. Each index is based on the data that is most frequently queried. Any query
based on the columns the index is created on first searches the index, and then uses the link
provided in the index to directly access the desired row. It doesn't have to read each row in a
table before it can access the desired one. This saves a considerable amount of time.
Triggers
A trigger is a piece of code that executes when a specific event occurs on the database server or
within a database. For example, a trigger may run when a user tries to modify the server or
636

database configuration or a specific table or row. You use triggers to monitor and thereby
eliminate or minimize redundant data.
Stored procedures
A stored procedure is a program that enables you to run batch processing tasks and manage
data in a database. For example, you can run a single stored procedure to add a row to a table,
gather statistical information, and perform calculations. Stored procedures are usually stored in
the corresponding databases.
Unlike components such as stored procedures and tables, a view is part of the external schema.
Each view is a logical structure that enables you to display tabular data selectively. For example,
you can configure a view to display data that's stored in specific columns of one or more tables.
You can also create a view that's based on other views or on a collection of tables and views.
Using a view, you can simplify the presentation of data or hide sensitive data. For example, a
Customer table can contain sensitive data, such as credit card details. You can create multiple
views based on this table, each of which displays data according to the access rights of the
intended user type.
Question
Identify the correct statements about database schemas.
Options:
1. A domain is the range of values a column can have
2. A stored procedure enables you to run batch processing tasks
3. A trigger ensures that a query can quickly retrieve data from a table
4. The external schema enables you to create a different data view for each user type
5. The internal schema organizes database content into tables, columns, and rows
Answer
Option 1: This option is correct. In the conceptual database schema, each column has a domain,
which specifies the range of values for the column.
Option 2: This option is correct. A stored procedure is a program that is stored in a database. This
program enables you to run batch processing tasks and manage data in the database.
Option 3: This option is incorrect. An index ensures that a query can quickly retrieve data. In
contrast, a trigger is any code that runs only when specific events occur in a database. You can use
triggers to monitor redundant data.
637

Option 4: This option is correct. The external schema enables you to selectively create data views.
You can customize this schema for each user according to the user's access rights and
permissions. The external schema is based on the conceptual schema.
Option 5: This option is incorrect. The conceptual schema organizes database content into a logical
structure made up of tables, columns, and rows. The internal schema only represents the physical
structure of a database.
Correct answer(s):
1. A domain is the range of values a column can have
2. A stored procedure enables you to run batch processing tasks
4. The external schema enables you to create a different data view for each user type
Question
Which statements about referential integrity are true?
Options:
1. It promotes data redundancy
2. It helps to ensure data consistency
3. It ensures that data is inserted in the child table first
4. It requires that each parent row be created before its child row
Answer
Option 1: This option is incorrect. Referential integrity minimizes duplication of data. In other words,
it minimizes data redundancy.
Option 2: This option is correct. Referential integrity ensures that data is consistent across all the
tables in a database. You can use primary and foreign keys, which help to build tabular
relationships, as constraints to enforce referential integrity.
Option 3: This option is incorrect. Referential integrity ensures that data needs to be inserted into
the parent table first before inserting data in the child table.
Option 4: This option is correct. A foreign key ensures that each row in a parent table is created or
deleted before the corresponding rows in a child table. This promotes referential integrity. You can
further strengthen referential integrity by ensuring that rows in a child table are deleted along with
related rows in the linked parent table.
Correct answer(s):
638

2. It helps to ensure data consistency
4. It requires that each parent row be created before its child row
Summary
A database's architecture includes various types of schemas internal, conceptual, and
external. The internal schema represents the physical structure of the database, and the
conceptual schema represents its logical structure. The external schema, in contrast, represents
the data views available to each user type.

Referential integrity is achieved by using primary and foreign keys. These keys help to maintain
data consistency and minimize duplication.

Like keys, indexes, triggers, and stored procedures are also components of the conceptual
schema. These components help you to access and manage data.


















639

Database Normalization
Learning Objective
After completing this topic, you should be able to
recognize how to normalize the relations
1. Normalizing the database tables
Normalization is the process of efficiently organizing data in a database by removing duplicate
or redundant data from database relations. This is done to avoid storing the same data in more
than one relation so that the amount of space a database consumes can be efficiently managed.
Normalization typically involves splitting existing relations into multiple smaller relations and
establishing clearly defined relationships between them. These smaller relations are rejoined or
linked each time a user sends a query to the database.
Drill Down Home Page
Normalizing database relations helps to improve data integrity, scalability, and storage
efficiency.

A series of guidelines have been developed to normalize database relations. These are referred
to as normal forms or NF.
Page 1 of 4: 1NF
Short for first normal form, 1NF is the lowest form of normalization, and it sets the basic rules for
an organized database.

The main goal of 1NF is to divide the database data into logical database entities or tables. And
then ensure it meets the following conditions:
there should be no repeating groups or columns in the same table
each row should be unique in a table, that is no duplicate rows, and
each column should contain only one value and only one data type
Page 2 of 4: 1NF
Consider an example of an Employees table with a column to hold the different skills for each
employee. With more than one value in a single Skills field, it would be difficult to search for all
employees with a specific skill. This table is not efficient with storage, and will not be scalable.
640

To conform to 1NF rules, there should be only one value specified in a column, and it should
only have one data type. Therefore the Skills column should be separated into another table to
hold the information about skills.

This table should then be linked back to the main table, Employees, using a primary key and a
foreign key. Now the columns are unique in both tables because the Employee_ID along with
Skill_ID makes each row unique.

The tables are now in 1NF. Because each row can be uniquely identified, there are no repeating
attributes or groups, and each attribute only contains one value.
Page 3 of 4: 1NF
Tables also cannot contain any repeating attributes or group of attributes, that is, for each
occurrence of a row the attribute cannot have more than one occurrence or a many-to-many
relationship.
For example, if you have an Employees table that contains information on the projects that are
being worked on by each employee, there can be multiple projects specified for the employee if
they work on more than one project. In this case, the Project_Name, Start_Date, End_Date, and
Budget attributes would be a repeating group.
Page 4 of 4: 1NF
To correct this, you must create a separate entity for the projects that are being worked on and
also move the primary key of the Employees table to the new table as the foreign key to link the
two tables. This will also ensure that no two rows contain the same values because an
employee can only work on two separate projects at the same time, not the same project. So in
the Projects table, the rows can be uniquely identified by using the columns Project_Name and
Employee_ID. These columns are known as the candidate keys and comprise the superkey.

The tables can now be considered to be in the 1NF, because there are no repeating attributes or
groups. Each row is unique because no row in either table will contain the same values, and
each attribute can hold only a single value.
Page 1 of 3: 2NF
Second normal form or 2NF further addresses the concept of removing duplicate data. To
conform to 2NF, a relational database should
meet all the requirements of the 1NF and
each nonkey column must be fully dependent on the key column or columns
641

Page 2 of 3: 2NF
The main goal for 2NF is to ensure that each nonkey attribute is fully dependent on the key
columns of the table, that is, no attribute can only be partially dependant on the key columns.
You then need to move all nonkey columns that are not fully dependent on the key columns to a
new table, with a copy of the key column they fully depend on. You then use a foreign key to link
the two tables using the key column that is now in both the tables.

To understand this, consider an example of the Animal Details table that has two candidate key
columns Animal_ID and Date.
In this table, each nonkey column must fully depend on both the candidate key columns.
However, the columns Animal_Name and Animal_Type only fully depend on the Animal_ID
column and do not require the Date column.
Page 3 of 3: 2NF
Therefore these nonkey columns need to be moved to a new table along with a copy of the key
column, Animal_ID. The Animal_ID column will then become the primary key in the new table,
called Animals, and a foreign key in the Animal Details table.
These tables are now in 2NF because they conform to 1NF and each nonkey column in each
table fully depends on the key columns in that table.
Page 1 of 2: 3NF
A database table is in the third normal form or 3NF when it fulfills all the requirements of the
2NF. Additionally, any nonkey columns that are independent of the key column are removed.
That is if a nonkey column is fully dependent on another nonkey column, rather than the key
column, it should be moved to a new table, along with the nonkey column it fully depends on.
The new table should have a foreign key to link to the original table.
Page 2 of 2: 3NF
Consider an example of the Sections table. In this table, the columns, Supervisor_Phone,
Supervisor_FName, and Supervisor_LName can be only determined by the Supervisor_ID
column. They cannot be determined by the Section_Name or the Date, which are the key
columns.
Therefore a new table needs to be created that includes the nonkey columns that are fully
dependent on the nonkey column of Supervisor_ID. The Supervisor_ID column is also added to
this new table as the primary key and in the Sections table as the foreign key.

These tables are now in 3NF because they each conform to 2NF and each nonkey column is
now dependent on the key columns in each table rather than dependent on nonkey columns.
642

Page 1 of 3: BCNF
Short for the Boyce-Codd Normal Form, BCNF requires that a table should be 3NF and that
there are no overlapping candidate keys.

Consider the Projects table that is used to store the projects for each employee. Each employee
can work on multiple projects and each project can have multiple employees working on them.
Page 2 of 3: BCNF
In this table, the candidate keys are Employee_ID, Project_Name, First_Name, and Last_name.
This is because you need to use each of these columns together to uniquely identify a row in the
table.

In this case, the Project_Name is the overlapping candidate key. The table is not in BCNF
because after you remove the Project_Name from the candidate keys, they only describe the
employee Employee_ID, First_Name, and Last_Name that is they are determinants of each
other and do not qualify as the candidate key on their own.

The First_Name and Last_Name columns are considered to be dependent because if you
change the first name of one of the employees in one row of the table, the other rows will no
longer be correct. Also if you delete a row because the employee does not work with the
company any more, you may lose the Employee_ID record.
Note
A determinant is a column that partially determines the value in another column.
Page 3 of 3: BCNF
To put this table into BCNF, you need to create a new table that moves the dependent columns
First_Name and Last_Name, along with the Employee_ID column to be used as a link to
relate the tables together.
The candidate keys for the Projects table are Project_Name and Employee_ID, and the only
candidate key in the Employees table is Employee_ID. You can now insert, update, and delete
any of the employee records without affecting other rows in the Employees table or the Projects
table.
Page 1 of 2: 4NF
The fourth normal form or 4NF deals with problems associated with normalizing tables that
contain complex composite primary keys. A table is in 4NF when it meets all the requirements of
BCNF, and doesn't have any multivalued dependencies. Neither should the dependent attributes
be a subset of the attributes they depend on. And the dependent attributes combined with the
643

attributes they depend on should not constitute the entire entity.

In a multivalued dependency, two or more columns depend on a determinant, and each
dependent column has a particular set of values. The values in the dependent columns are
independent of each other.
Page 2 of 2: 4NF
Consider an example of the Employees table that stores information about employees who
travel to different offices. The Skill and Office columns are both dependent on Employee_ID, but
regardless of their skills employees can work at any office, that is they don't need a specific skill
to work at an office.

Therefore, to uniquely identify each row, you need to use all the columns in the table, so there
are no nonkey columns. And the table currently conforms to all normal forms up to and including
BCNF. However there is redundant data.
To conform to 4NF, you need to move the dependent columns to a new table, along with the
column it depends on so the tables can be related back.
Page 1 of 2: 5NF
A table is in fifth normal form or 5NF, which is also known as Project-Join Normal form if, and
only if, it is in 4NF and every join dependency on the table is related to its candidate key. The
requirements of the 5NF help you to design complex relationships that involve multiple tables.
When you decompose tables through normalization, you should be able to reconstruct the
original table by doing joins between the resulting tables without losing data and without
generating extra rows. This is a lossless join.

When you can't decompose a table into smaller tables, which have different keys from the
original without data losses, the table is in 5NF.
Page 2 of 2: 5NF
Using the same example from 4NF, you can add another table that combines the Offices with
the Skills, so only applicable skills are located in a specific office.

So an employee can work in specific offices, each employee has specific skills, and only certain
skills are at certain offices.
Database normalization is a progressive activity. That means you can't have a 3NF normalized
database until the database meets the 1NF and 2NF requirements.

Most databases only need to be normalized to 3NF. At 3NF most tables are free of anomalies
relating to inserting, updating, and deleting data from the tables. And typically when normalized
644

to 3NF, the tables will also adhere to the higher normal forms of BCNF, 4NF, and 5NF.

Usually databases normalized to 3NF will not conform to BCNF, 4NF, and 5NF when the
database is highly complex and where nonnormalized tables may cause serious problems.
A well-normalized database provides users with several benefits:
updates data quickly without introducing any redundancy or inconsistencies
minimizes errors that are often caused by duplicated data
avoids unnecessary coding needed to keep duplicated date in sync, and
allows you to create short and narrow indexes that help in faster index searching
Question
Which statements are correct about normalizing database relations?
Options:
1. A normalized relation doesn't have repeating groups
2. Columns that are dependent on the primary key are removed from the relations
3. A normalized relation has several multivalued dependencies
4. A normalized relation has a set of columns that can uniquely identify a record
Answer
Option 1: This option is correct. A normalized relation should have no repeating groups. This
ensures that no two columns of the relation store similar data.
Option 2: This option is incorrect. A relation is normalized when columns that are not dependent on
the primary key are removed.
Option 3: This option is incorrect. According to 4NF rules, a relation should have no multivalued
dependencies.
Option 4: This option is correct. As per the 1NF requirement, a normalized relation should have a
key column that together can be used to uniquely identify a record.
Correct answer(s):
1. A normalized relation doesn't have repeating groups
4. A normalized relation has a set of columns that can uniquely identify a record
645

Summary
In the relational database design, you need to normalize the relations or tables by eliminating
inconsistencies and minimizing redundant data. A normalized relation ensures that only related
data is stored in a relational database table. 1NF, 2NF and 3NF are frequently used normal
forms for normalization. In highly complex databases, you may need to normalize relations to
BCNF, 4NF, and 5NF.























646

Identifying the Relational Database Concepts and Schema
Learning Objectives
After completing this topic, you should be able to
describe relational database concepts
recognize the constructs in a relationship database schema
normalize database tables
Exercise overview
In this exercise, you're required to identify the characteristics of relational databases and types
of relational databases. You're also required to describe how to normalize database relations
and the key concepts of database modeling. Additionally, you will recognize the constructs in a
relational database schema and referential integrity.
This involves the following tasks:
describing relational database management system concepts
recognizing database schemas and referential integrity, and
normalizing database relations
Describing RDBMS concepts
Question
What are the key characteristics of a relational database?
Options:
1. Data is stored in relations
2. A relational attribute consists of a set of tuples
3. The data type describes the kind of values two relations can take
4. An attribute takes its value from an appropriate domain
Answer
Option 1: This option is correct. A relational database stores all its data inside relations, which are
groups of tuples and attributes.
Option 2: This option is incorrect. In a relational database, a tuple consists of a set of attributes, and
each tuple is linked to an entity.
647

Option 3: This option is incorrect. The data type describes the kind of values an attribute can
contain in a relation.
Option 4: This option is correct. The data type for a domain specifies the kind of value an attribute
can contain.
Correct answer(s):
1. Data is stored in relations
4. An attribute takes its value from an appropriate domain
Question
You're planning to set up a relational database management system or RDBMS in your company.
There are several RDBMSs available in the market. You want to assess the key characteristics of
some of these databases.

Match each type of RDBMS with its description.
Options:
A. Oracle
B. IBM DB2
C. PostgreSQL
D. OpenOffice.org Base
E. Microsoft Access
F. MySQL
Targets:
1. An ORDBMS that complies with the SQL:2008 Standard
2. An RDBMS that is written using SQL, Java, Microsoft .NET, and PL/SQL
3. An OODBMS that is written in the SQL query language
4. An RDBMS that runs on HSQLDB and stores data, forms, and queries in one file
5. A desktop file-based database system that is written in the Visual Basic language and uses the Jet
Database engine
6. An open source RDBMS that is written in C and C++
Answer
Oracle is an ORDBMS developed and marketed by Oracle Corporation. It complies with the
SQL:2008 Standard.
IBM DB2 is an enterprise-level RDBMS that uses SQL, Java, Microsoft .NET, and PL/SQL as its
programming languages.
648

PostgreSQL is an open source OODBMS and is written in the SQL query language.
OpenOffice.org Base is an open source RDBMS that is available under a BDS license, and uses
HSQLDB as its default database engine.
Microsoft Office Access is written in the Microsoft Visual Basic programming language and stores
data in the Microsoft Jet Database engine.
MySQL is an open source RDBMS that is written in C and C++ and allows users to query and
retrieve data from multiple storage engines.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
Target 6 = Option F
Question
You've been instructed to create a database model for storing and managing your company's
employee data.

Select the statements about database modeling that are correct.
Options:
1. Database modeling is performed only once in the database design process
2. Normalization is used to model the database
3. The database structure is represented by using Entity-Relationship Diagrams
4. Data flow diagrams are used to map the relationships between entities
Answer
Option 1: This option is incorrect. Database modeling is an iterative process, and you can make
changes to the data when required.
Option 2: This option is incorrect. Database normalization is the process of organizing data in a
database by removing duplicate data and eliminating inconsistencies in relations.
649

Option 3: This option is correct. Entity-Relationship Diagrams or ERDs are used to visually
represent data in logical structures. This type of diagram helps to identify the database system
requirements.
Option 4: This option is correct. An ERD consists of data flow diagrams that represent the flow of
data through a system. These diagrams help you to map the relationships between entities in a
database.
Correct answer(s):
3. The database structure is represented by using Entity-Relationship Diagrams
4. Data flow diagrams are used to map the relationships between entities
Recognizing database schemas
You want to build an efficient relational database to manage your company's customer
database. To ensure that you develop a good database architecture, you should be able to
correctly use the schemas and their components. You should also be able to maintain referential
integrity.
Question
Before you begin building the architecture of your database, you want to ensure that you're aware of
key concepts related to the relational database schemas.

Which statements about the relational schemas are correct?
Options:
1. The logical structure of a database is represented by the internal schema
2. To control the user's access rights and permissions, you need to customize the external schema for
each user
3. To limit the values a user can add to an attribute, you need to define constraints for the associated tuple
4. A relation should have an attribute or set of attributes for which each tuple has a unique value
5. A relationship where a single tuple in a table is linked to multiple tuples in another table is called one-to-
many relationship
Answer
Option 1: This option is incorrect. The internal schema represents the physical structure of a
database. The logical structure is represented by the conceptual schema.
Option 2: This option is correct. You customize the external schema for each user according to the
user's access rights and permissions. This ensures that only authorized users can view and modify
the data.
650

Option 3: This option is incorrect. If you want to limit the values entered into an attribute, you need
to define constraints for the attribute's domain. Domain constraints help you to specify lower or
upper bounds of the values an attribute can take.
Option 4: This option is correct. Every relation should have an attribute or set of attributes for which
each tuple has a unique value or set of values. This type of attribute is called a primary key and is
used to retrieve a specific tuple.
Option 5: This option is correct. A one-to-many relationship signifies a link between one tuple in a
table and multiple tuples in another.
Correct answer(s):
2. To control the user's access rights and permissions, you need to customize the external schema
for each user
4. A relation should have an attribute or set of attributes for which each tuple has a unique value
5. A relationship where a single tuple in a table is linked to multiple tuples in another table is called
one-to-many relationship
Question
You now want to implement referential integrity in your database.

Select the statements that are correct about referential integrity.
Options:
1. A primary key helps you to implement referential integrity
2. To ensure referential integrity, each parent row should be created or deleted before any child row
3. Referential integrity supports data duplication to create backups
4. Referential integrity allows users to insert data into child tables first
Answer
Option 1: This option is correct. A primary key requires that each of its associated table values be
valid and unique.
Option 2: This option is correct. To strengthen referential integrity, you use foreign keys that ensure
that each parent row is created or deleted before any child rows.
Option 3: This option is incorrect. Data duplication takes up unnecessary table space and slows
down the performance of the database. Referential integrity prevents data duplication by
implementing primary and foreign keys.
651

Option 4: This option is incorrect. Referential integrity ensures that data is first inserted into parent
tables, before being entered in child tables.
Correct answer(s):
1. A primary key helps you to implement referential integrity
2. To ensure referential integrity, each parent row should be created or deleted before any child row
Normalizing database tables
Question
You want to normalize a table in your company's database by using normal forms. The table should
satisfy the requirements of the third normal form or 3NF.

Which requirements should the table fulfill to be in 3NF?
Options:
1. The table should conform to 2NF requirements
2. Two attributes should store similar information in the same table
3. Attributes that depend on nonkey attributes need to be moved to a new table
4. Any attribute that depends on the primary key should be removed
Answer
Option 1: This option is correct. Database normalization is a progressive activity. So one of the
conditions for a table to be 3NF is that it should meet the 2NF requirements.
Option 2: This option is incorrect. There are no repeating groups of attributes or repeating attributes
in a normalized table. So no two columns of a table should store similar information.
Option 3: This option is correct. In 3NF, to reduce redunancy of data in the tables, any nonkey
attributes that fully depend on other nonkey attributes instead of the primay key should be moved to
new tables. The resulting tables must be related to each other by a foreign key which is based on
the nonkey attribute the other nonkey columns depend on.
Option 4: This option is incorrect. To meet the 3NF requirements, attributes that do not depend on
the primary key should be removed from the relation.
Correct answer(s):
1. The table should conform to 2NF requirements
3. Attributes that depend on nonkey attributes need to be moved to a new table
652

Designing a relational database
Learning objective
After completing this topic, you should be able to define and discuss the purpose of database
design and how to use modeling to represent real-world concepts.
1. Choosing a design methodology
Database design is the process of creating a business model based on real-world objects and
converting it into a physical database.

A structured diagram called a "logical data model" represents the business model.
A logical data model comprises entities and attributes, whereas a physical database comprises
tables and columns.

You can enforce business processes in the business model by adding data constraints to the
physical database.
Examples of business processes include
customers placing orders
employees checking an inventory to confirm product availability
employees confirming a customer's order
Once you've created a functional database based on a business model, you can use it to store,
modify, and retrieve information relevant to the business model.
Let's say that a student John enrolls for Visual Basic and Java Programming, Mary for Java
Programming, and James for Project Management and Communication Skills.
In the graphic, the real-world objects Students and Groups represent the business model, and
the lines define the relationships between the objects.
So, James, Mary and John are in the object "Students" and "Project Management,
Communication Skills, Visual Basic Programming and Java Programming are in the object
"Groups". The lines define the relationship between the "Students" and the "Groups".
In database design terms,
Student and Course represent entities
Student_Name and Course_Name represent the attributes of entities
the lines between entities represent the relationships between entities
653

In the physical database, which is based on the logical model, the entities become the tables
Students and Courses, and the Student Name and Course Name become columns in the tables.

And a special constraint known as a "foreign key" defines the "relationships" between the tables.
The foreign key (FK) in a table is a combination of column values that references a "primary key"
(PK) in another table.

A foreign key ensures that parent records are created before child records in a table.

For example, a Student such as John takes two Courses Visual Basic and Java Programming.
Before designing a database, you need to choose a suitable design methodology for the
database.
Question
Using a design methodology has many advantages.
See if you can identify the advantages of using a design methodology.
Options:
1. It enables you to design a database sequentially
2. It eliminates trial and error in the design process
3. It provides a framework for structuring entities and attributes
4. It enables you to document the database through design plans and drawings
5. It enables you to modify the database more easily
Answer
Using a design methodology enables you to design a database sequentially, eliminate trial and
error, and use the design plans and drawings to document the database. Planning a design
methodology enables you to modify the database more easily.
The "top-down" design approach is a popular methodology, which is also known as "design by
analysis".

Using this methodology to design a database, you begin with the high-level "conceptual" design
and mapping of the business model based on a defined set of "requirements."
Once you have created a high-level conceptual design, you develop a "logical data model"
based on that design and on user requirements.

When you use the design by analysis methodology, you need to group the "attributes" of real-
654

world objects into "relations" or "entities", and you need to define the "relationships" between
them.
After defining the relationships between entities, you remove redundancies, resolve complex
relationships, and add constraints.
In the final phase of the design by analysis methodology, you design the actual "physical"
database based on the preceding logical design.
2. Good database design
A well-designed database contains functional data, and it represents an organization's data
accurately.

The database also requires little maintenance, and it secures the data it contains.

During the design process, you should establish which security measures you need to
implement.
Data in a well-designed database is easy to access, modify, back up, and recover.

And the model of a good database accurately documents the physical database, which
application developers and designers can easily use.
A well-designed database has the following properties:
adequate data storage
easily accessible data
secure data
accurate and manageable data
acceptable database performance
a minimum amount of redundant data
adequate data storage
A well-designed database meets an organization's storage needs by storing the required data
effectively and handling the business rules adequately.

Adequate storage depends on suitable hardware components and software, which should be able
to adapt to the possible expansion of the database.
easily accessible data
For a database to function successfully, the data it stores must be available to users whenever
they need to access it.

A badly designed database contains data that is frequently unavailable because of downtime.
655

secure data
Database security is essential to prevent stored data from becoming corrupted.

You should implement security measures at the database's lowest possible level.
accurate and manageable data
To ensure that data in a database maintains integrity and to enforce business rules, you should
design a database that applies constraints to the data.

The data users enter into the database is consequently accurate and easily verifiable.
acceptable database performance
Users often expect instant responses to database queries when the size or design of the
database makes these impossible.

So you need to determine users' expectations of acceptable database performance and then alter
the design of the database to meet those expectations if possible.

It should take one to five seconds to retrieve a record from the database or to perform a small
transaction.
a minimum amount of redundant data
In a relational database, redundant data is stored in more than one table. This redundant data
increases the number of record the database needs to store and maintain, and it slows down
transaction time.

If users update redundant data, the database needs to update all instances of that data. In
addition, users may enter one instance of redundant data incorrectly, causing the data to become
inconsistent. Inconsistent data complicates a database's attempts to compare records and to
establish relationships between them.

You can use normalization to minimize redundant data. Using normalization, you decompose
relations or tables into an optimal logical or physical database design.
The diagrams of the two databases illustrating logical notation are displayed.

In these diagrams, the table structures represent objects groups of students, courses,
instructors, and training venues, for example.

And the connections between them represent the relationships between the groups.
Question
Suppose that Database 1 has an average query time of eight seconds, an average update time of
three seconds, and is 8 MB in size. Its ease of maintenance is average.

656

Database 2 has an average query time of four seconds, an average update time of five seconds,
and is 15 MB in size. Its ease of maintenance is good.
See if you can select the database with the optimal database design.
Options:
1. Database 1
2. Database 2
Answer
Database 2 has been designed optimally.
Database 1 has a design that is heavily normalized because it contains many small entities.
Whereas the database is optimally sized at 8 MB and has a good average update time of three
seconds, its query time is too long. Its complex design means that it would be complex to maintain.
Database 2 has good query times of four seconds. Its longer update time of five seconds is offset by
its simpler, denormalized design, which means it performs optimally.

However, the business requirements of an organization determine the optimality of the system
design and performance.
3. Modeling the real world
Data modeling is a process that aims to produce a complete, accurate, and consistent
representation of real-world objects and the relationships between them.

A diagram representing the real-world relationship between students and the courses they take
is displayed.
When you model data on the real world, you use specific diagrammatical elements to represent
types of objects and the relationships between them.
In a relational database model, the diagrammatic representation of relationships includes a line
with a crow's foot on
the right to represent a one-to-many relationship, or 1: N relationship
both ends to represent a many-to-many relationship, or N: M relationship
neither end to represent a one-to-one relationship, or 1: 1 relationship
A rectangular box represents an object or data group or entity.
657

Question
See if you can model the real-world relationship between students and courses.
Options:
1. Student
2. Course
3. Skill
4. One-to-many relationship
5. Many-to-many relationship
6. One-to-one relationship
Targets:
A. First element
B. Second element
C. Third element
Answer
Many students can take many courses. So the relationship between the Course and Student entities
is a many-to-many relationship, shown by the line with a crow's foot on both ends.
Data modeling is the process of conceptualizing real-world objects, relationships, and processes
into a structured and diagrammatic representation.

This representation is a link between the real world as the user sees it and the underlying
physical database that represents it.
Whereas some real-world or business processes may be represented in the resulting database
as constraints, business processes are primarily defined by application interfaces to the
database.
In the real-world representation of the students and the courses they take, an example of a
process may be the "enrollment of students in courses."
Summary
A database design methodology is the approach you take to design a database following a well-
defined plan. Design methodologies can commonly take a bottom-up or a top-down approach.
Database design is the process of creating a business model that you use to convert business
objects into database components, such as tables and views.

Good database design produces a database that is functional and that represents an
658

organization's data accurately. Properties of well-designed databases include data that is easily
accessible, secure, accurate, and manageable. Well-designed databases also perform
acceptably and store a minimum amount of redundant data.

Data modeling aims to produce a complete, accurate, and consistent representation of objects
and the relationships between them in the real world. It involves representing objects and
relationships with specific notation.
























659

The database design life cycle
Learning objective
After completing this topic, you should be able to describe the three-schema database
architecture and the database design life cycle.
1. The three-schema database architecture
A database can be represented by a three-schema architecture.
The three-schema architecture
provides multiple views of a database from a user perspective
provides a level of abstraction of the physical implementation of the database
represents the database structure conceptually
In database design, a schema is a view of a database at mutually independent levels.
In the three-schema database architecture, each schema is defined at one of the following
levels of the database:
external level
conceptual level
internal level
external level
The external schema represents the user views of the database by describing the parts of a
database that groups of users need to view.

The external schema presents only those views of the database that a group of users may see,
and it conceals the rest of the database from other groups of users.
conceptual level
The conceptual schema describes the database structure and conceals details concerning its
physical data storage.

It describes the characteristics of the database in terms of a logical model and its entities,
attributes, relationships, and constraints.

The conceptual schema is a consolidated true image of the model of the real world that the
database represents.
internal level
660

The internal schema describes the physical structure of the database.

A physical data model at this level describes how the database will store its data and how that
data will be accessed.
Question
The schemas in the three-schema database architecture correspond to stages in the development
of a database, which is much like the design and construction of a home.
See if you can match the stages in the development of the three-schema database architecture to
that of the design and construction of a home.
Options:
1. External model
2. Conceptual model
3. Internal model
Targets:
A. Architecture style and floor plans
B. Construction
C. Construction plans
Answer
The architecture style and basic floor plan correspond to the external model of a database.

The detailed construction plan corresponds to the conceptual model, and the construction of the
house corresponds to the internal model.
When users access information in a database, their requests are transformed between the
levels external, conceptual, and internal in the three-schema architecture, which is called
"mapping".
When database users enter queries at the external level, the database must transform them into
queries at the conceptual level.

The database then transforms the queries into queries at the internal level so that users can
access the relevant data.

The database then formats the query results to match the users' external view.
An advantage of the three-schema database architecture is its ability to support data
independence.
661


The two types of data independence include
physical data independence
logical data independence
physical data independence
Physical data independence is a database's ability to support a change to the structure at its
internal level without its conceptual or external level having to change.

Database administrators, for example, change the internal level of a database when they need to
reorganize physical files.

These changes do not affect the conceptual level of the database.
logical data independence
Logical data independence is a database's ability to support changes to its conceptual level
without its external levels having to change.

For example, if a database designer adds or removes entities, the external schemas that users
use to retrieve the existing data remain unchanged.
2. The database design life cycle
The database design life cycle has three phases:
requirements gathering and analysis
logical database design
physical database design
Question
Suppose that you are designing a database for an organization.
See if you can match the steps in the database design process with the correct database design life-
cycle phases.
Options:
1. Implement the database using a commercial DBMS
2. Create a functional requirements document
3. Create Entity-Relationship diagrams (ERDs) containing entities and attributes
Targets:
662

A. Requirements gathering and analysis
B. Logical database design
C. Physical database design
Answer
The requirements gathering and analysis phase corresponds to the process of creating a functional
requirements document, and the logical database design phase corresponds to the process of
creating Entity Relationship Diagrams (ERDs). The physical database design phase corresponds to
the process of implementing the database using a commercial DBMS.
3. Stages in the database design life cycle
The three stages in the database design life cycle are
requirements gathering and analysis
logical database design
physical database design
requirements gathering and analysis
During the requirements gathering and analysis phase, database designers and analysts create

a requirements document

data flow and process diagrams

a high-level conceptual Entity-Relationship diagram (ERD)

In the requirements gathering and analysis phase of the database system design life cycle,
database designers and business/systems analysts gather and analyze the business
requirements for the database system.

Database designers and analysts do this by interviewing users who will use the database and
analyzing the requirements they gather from those interviews. The designers enter these details
into a "requirements document".

System analysts define "data flow and process diagrams" that specify the "operations" to be
performed on the database.

These diagrams are a part of the applications specification for the database system.

The database designers need to generate high-level "conceptual ERDs." An ERD defines the
data requirements of the database system and is based on the requirements document. The ERD
corresponds to the external models in the three-schema architecture and represents the data
663

categories and relationships between the categories in the database.

Conceptual ERDs are diagrams that focus on the business model instead of the Database
Management System (DBMS) the database designer intends deploying. So conceptual ERDs
should not focus on implementation issues, such as storage space and efficient data retrieval.

The requirements document, together with the data and process flow diagrams and the
conceptual ERDs, make up the "function specification" document for a system. Database
designers and analysts can use this document to verify the business requirements with users.
Verifying the business requirements is defined as the "requirements evaluation" stage of the
requirements gathering and analysis phase and is the final step in the process.
logical database design
The logical database design phase follows the requirements gathering and analysis phase in the
database design life cycle, and it corresponds to the conceptual model in the three-stage
database architecture.

Logical database design is also known as "data modeling." During the logical database design
phase, a database designer maps the high-level conceptual ERD into an implementation data
model for the physical database.

To do so, the designer creates a detailed ERD containing entities, attributes, and relationships.
These logical models are based on business requirements and not the actual database.

During the logical database design phase, database designers normalize the model to minimize
redundant data. Normalization is the process of decomposing relations or tables into an optimal
logical or physical database design.
physical database design
The final phase of the database design life cycle is the physical database design phase. In the
three-schema database architecture, this phase corresponds to the internal database model.

During the physical database design phase, database designers

implement the database using a commercial DBMS

modify the database if required

During the implementation phase database designers, in conjunction with the database
administrators, choose the storage structures.

They also choose access paths and file organizations that will allow users to access the database
files most effectively.

Database designers and administrators almost always need to refine and modify these initial
664

physical design aspects once they have implemented the database. The process of modifying the
physical design aspects of a database is called database tuning.

Database tuning involves optimization and denormalization and often depends on the business
requirements, such as performance considerations.

In conjunction with the physical database design, software developers develop application
interfaces that fulfill the initial functional requirements specifications.
Summary
Schemas are views of the database at mutually independent levels. In the three-schema
database architecture, the internal schema describes the physical structure of the database, and
the conceptual schema is a true image of the model of the real world that the database
represents. The external schema contains the user views for the database.

There are three stages in the database design life cycle requirements gathering and analysis,
logical database design, and physical database design.

In the database design life cycle, database designers create conceptual Entity-Relationship
diagrams (ERDs). In the logical database design phase, database designers map the high-level
conceptual ERD into an implementation data model for the physical database by creating tables.
During physical database design, designers choose the storage structures and access paths
that will allow users to access the database files effectively.













665

Database design requirements analysis
Abstract
This paper provides an overview of the requirements analysis process you implement when
you design a database. You start the requirements analysis process by recording the
requirements of the business. Once you've recorded these requirements, you need to analyze
the information to determine whether you've identified the user, customer, and business needs
correctly. After identifying the business requirements and goals, you can begin the database
design process.
Introduction
To design a database for a business, you need to understand and document the requirements
of the business. This allows you to create and implement a database system that satisfies the
organization's business requirements and the needs of its customers and end users.
The database system requirements analysis process involves determining, analyzing and
evaluating the business requirements.

Stages in the requirements analysis process
The fundamental elements that you need to determine include the rules, data, and processes
that define the business. These elements define what the business requires of a database and
how you will build the database system.
Once you've gathered the business requirements, you can proceed to analyze them. By
analyzing the requirements, you determine the system requirements, and you use these
requirements to generate a functional requirements specification. The functional requirements
specification includes the development of process models, data flow diagrams (DFDs) and a
666

high-level conceptual data model of the database called a conceptual Entity-Relationship
diagram (ERD).
The business/systems analyst produces the process models and DFDs, and the database
designer generates the conceptual ERD. Once you've analyzed and documented the
requirements, you need to evaluate the analysis.
This three-step process is an iterative process. If the analysis is incorrect, you need to repeat
the entire process until you define a final workable solution.
Determining business requirements
You determine the requirements of a business by collecting information from users about their
tasks. You collect information about how data is interchanged and exchanged in the
organization and what factors affect the business processes.
To find out what tasks users perform, you need to divide the business into departments and
then subdivide the departments into the functions that each user performs. You can gather
information about the work and tasks of users by interviewing them. You do this to determine
what information each department deals with, the types of processes involved in the tasks,
and the business rules of the department.
Because information and processes are interdependent, you need to determine the
information in conjunction with the processes that affect it, which means that you don't see
either in isolation.
Once you've determined the information and associated processes, you need to understand
and document the business rules associated with these. For example, a business rule may
determine how information can be accessed or how information relates to other information.
Business rules are often the determinant of database referential integrity.
Business requirements analysis
The primary reason for researching and analyzing the business requirements is to generate a
high-level conceptual data model for the proposed database.
This high-level conceptual data model is called a conceptual ERD. An ERD is a concise
description of the business data requirements and includes detailed descriptions of data
groupings or entities, the relationships between the entities, and some of the constraints
imposed upon data defined by the entities.
Data categories
Category Definition
entity a group or category of data or objects
relationship a connection between objects in a database
You do not define any implementation details at this stage, and you create an ERD to ensure
that the data requirements of the business have been met. You use the ERD, which is in a
667

nontechnical format, to communicate the structure and content of the proposed database to
users.
The ERD defines the structure of the data without being concerned with the storage or
implementation details of the final database. It allows you to see the larger picture clearly, and
once verified, to decompose the ERD into a lower level detailed logical data model.
This ERD and the data operations defined by process models and DFDs represent the
requirements of the business and how the proposed system will be developed.
You can cross check the process models and DFDs with the ERD to determine whether the
business requirements have been met and whether the resulting database system will be
functional and complete.
You can modify the ERD if you discover any inconsistencies between the process model,
DFDs and ERD.
Requirements evaluation
In the final stage of the three-step requirements analysis process, you evaluate the results.
Requirements evaluation is the process of determining whether the business requirements
that you gathered and analyzed from end users and management meet the initial
requirements of the users and business involved. During this phase, you need to ensure that
you've covered all the information and interpreted the information correctly. And you need to
check for any conflicts in the information you collected and analyzed. If you find any significant
conflicts, you need to revise the requirements analysis process.

Stage 3 Requirements evaluation
Summary
668

When you design a database for an organization, you need to analyze its business
requirements. To do so, you need to collect information about the users and their tasks. You
also need to establish how information is interchanged and exchanged and the factors that
affect the business processes. You then analyze the business requirements to identify which
critical business processes and manual processes you can automate and simplify. You also
create data flow diagrams (DFDs) and conceptual Entity-Relationship diagrams (ERDs) to
represent your findings. You then conduct a requirements evaluation to determine whether the
information you gathered meet the organization's business requirements. During this stage,
you need to check for conflicts in the information. When you're sure that the information
contains no conflicts, you can begin designing the database.























669

Interviewing for business requirements gathering
Learning objective
After completing this topic, you should be able to use interviewing techniques to gather
requirements from users to facilitate the information systems analysis and database design
process.
1. Information gathering techniques
During the requirements analysis phase of the software systems development life cycle, you
need to gather information about the organization's
business goals
business rules
data requirements
process requirements
You can use the following techniques to gather information about an organization during the
analysis phase:
interviews
surveys
contextual inquiries
user observation
context of use analysis
focus groups
brainstorming
interviews
You can interview one or several end users to gather information about system requirements.

You interview the end users by asking them a series of questions about a specific topic.

You can interview end users one by one, or you can interview them in a group.
surveys
A survey consists of questionnaires that you can send to a large number of users to gather
information about system requirements.

You analyze the information you gather statistically.
contextual inquiries
670

Using the contextual inquiry method, you interview users performing tasks in a specific context,
usually the workplace.

You use this method to collect as much information as possible at the site of inquiry while the
users are performing their tasks.

For example, if you are designing a database for a bank, you can conduct interviews while the
employees are processing transactions or issuing bankcards.
user observation
Using the user observation method, you study users at work and record their activities.

You use this method to collect as much information as possible at the site of inquiry without
disturbing the users.
context of use analysis
Using the context of use analysis method, you collect information about users, their tasks and
roles, and their environment.

You therefore need to arrange a meeting with the stakeholders, such as users, managers, and
customers to collect this information.

You can also use the information you collect for usability tests.
focus groups
Focus groups provide a range of requirements because different users have different
requirements.

Using this method, you gather a number of users together in a forum so that they can voice their
opinions and attitudes about an issue.
brainstorming
Brainstorming allows several users to contribute to the requirements document.

Brainstorming involves a two-stage process, which a facilitator normally guides.

In the first stage, you gather a group of people together to generate ideas randomly and
spontaneously about a specific topic, for example the data requirements of a business.

In the second stage, the participants evaluate the ideas generated.
Interviewing is a good method for gathering information for the requirements analysis phase.
The advantages of using interviewing include the following:
it provides a direct way of identifying customer needs quickly
671

it can be changed or adapted easily
it can include informal questions
The disadvantages of using interviewing include the following:
it is a time-consuming task
it requires detailed planning
it provides unstructured results that can be misinterpreted
Question
When you conduct one-to-one interviews, you collect qualitative rather than quantitative data.
What do you think are the merits of gathering qualitative rather than quantitative data during the
requirements analysis phase?
Options:
1. You can gather information about users' current and future requirements for a system
2. You can gather information about the types of tasks users perform and the processes involved
3. You can prove a hypothesis using statistics
4. You can measure the number of tasks users perform and generate statistics
Answer
Gathering qualitative data allows you to gather information about the types of tasks users perform
and the processes involved in the tasks. It also allows you to gather information about users' current
and future requirements for a system.
Qualitative research uses methods, such as one-on-one interviewing and observation, to
generate information.

This information provides a range of perspectives and insight into client requirements based on
the actual lived experience of a user.
Quantitative research uses methods, such as surveys or questionnaires, to generate volumes of
measurable information.

However, this information might not describe users' everyday, practical considerations.
2. Planning an interview
You need to interview a cross section of users to gather information about a business.
For example, you can gather information from
672

customers about the information they want from the system
managers about the goals of the business
users about the methods they use to manage information
You need to decide whether you want to interview
one participant at a time
several participants simultaneously
You need to create an interview questionnaire to standardize the questions.

For example, you can create a question template that contains questions covering all the
important information you want to gather.
Question
What do you think is the advantage of using a standardized question template for an interview?
Options:
1. You can analyze all the responses statistically
2. You can compare two groups
3. You reduce the level of information analysis
4. You reduce variation in responses
Answer
When you use a standardized question template for interviews, you can reduce the variation in
responses and the level of information analysis required.
When you develop interview questions, you need to ensure that the wording is unambiguous
and nonthreatening.

If you use open-ended questions, you encourage users to provide detailed information instead
of yes or no answers.
The types of questions and the order in which you ask them influence the interview results
favorably.
Asking questions in the following order can help you to relax the interviewees so that you can
elicit informed responses from them:
experience questions
opinion and feeling questions
knowledge questions
background questions
673

experience questions
Using experience questions enables you to establish what an interviewee does or has done.

These are good to start the interview with because they are nonthreatening, require little
interpretation, are noncontroversial, and are easy to answer.

For example, you could start the interview by asking an interviewee, "What do you do within the
organization?"
opinion and feeling questions
You use opinion and feeling questions to gather information about the interpretative processes of
the interviewee.

These questions enable you to establish what the interviewee thinks and feels about an issue.

After describing an experience, the interviewees would be more inclined to discuss their opinion
about it. For example, you could ask the interviewee, "How would you use the database?"
knowledge questions
You ask knowledge questions to establish what factual knowledge the interviewee has about
using a database.

These questions can be threatening, so you need to contextualize them.

For example, you could ask the interviewee, "What tasks should the database be able to
perform?"
background questions
You can use background questions to gather general information about the interviewee.

For example, you could ask the interviewee, "Since when have you used the current system?"
Planning the interview process includes running a pilot or test of the interview.

Running a test enables you to identify any problems and solve them before you begin the
interview process.
You need to decide how to document the responses of the interviewees.

You can either take notes or use a video or tape recorder to record the responses of the
interviewees.

You also need to decide how to present the interview results, and you need to check whether
the interviewees approve of the method you choose.
674

3. Conducting an interview
When you conduct an interview, you need to create a relaxed atmosphere so that you can
communicate comfortably with the interviewee.

You should conduct the interview at a time and place that suit the interviewee.
You need to interview the following participants in the requirements analysis phase:
managers
end users
customers
managers
Nontechnical and technical managers have different concerns.

For example, a technical manager probably knows what is required from the new database
system. And a nontechnical manager involved with administration probably knows what the
business goals are.

Managers are usually concerned about whether the database system would enable them to
provide a better service to customers, meet contractual and business goals, and increase
productivity.

Managers can provide information about the expected lifespan of the system, the exchange of
data between departments, and the budget for the system design project.
end users
In some organizations, the customer and the end user are the same entity.

When you conduct interviews with end users, you need to gather information about the methods
they use to access the system. You need to identify the main goals of the system and business,
and you need to identify which functions they want the system to perform.

End users are usually concerned with a user-friendly system, acceptable response times, and the
required training to master the new system.
customers
Because the customer could be the principal or secondary system user, you need to interview a
cross section of customers to get an overview of their requirements.

Customers are concerned about whether the system and applications are easy to use and
whether data can be accessed quickly.

675

You interview customers to establish the business goals and requirements, which processes can
be automated and refined, which services or products are provided, and what tasks they perform.
Question
Suppose that you want to conduct interviews to gather requirements for a new system that manages
the online educational requirements of the Brocadero Online University.
See if you can match the interview guidelines to the correct headings.
Options:
1. Censor or delete irrelevant information
2. Use more interviewers than interviewees
3. Use open-ended questions
4. Use one principal interviewer for several interviewees
5. Use questions that limit the interviewee's responses
6. Summarize the interview and ask the interviewee to confirm the information
Targets:
A. Interview don'ts
B. Interview do's
Answer
During an interview, you should not use more interviewers than interviewees, censor or delete
irrelevant information, or use questions that limit the interviewee's responses.

During an interview, you should summarize the interview and ask the interviewee to confirm the
information, use open-ended questions, and use one principal interviewer for several interviewees.
4. Recording and analyzing data
Once you have conducted all the interviews, you can examine the recorded material and
analyze the responses of the participants.
You can record information from interviews using the following methods:
written reports
audio or video recorder
written reports
If you write down interviewees' responses during interviews, you need to document all the
information that interviewees provide, including conflicting information.
676

audio or video recorder
If you use an audio or video recorder to record the interviews, you need to transcribe the tapes.

After transcribing the tapes, you can write a report and analyze the information, or you can
analyze the information and then write a report.
When you analyze the data, you need to consider the business requirements, business goals,
and end-user and customer needs.
In the analysis stage, you can check whether you've omitted anything and re-examine any
conflicts or inconsistencies.
Question
How do you think you resolve any conflict between the information you gathered initially and that
which you gathered during the interviews?
Options:
1. You amend the requirements and goals to reflect the information you gathered during the
interviews
2. You don't amend the requirements you collected
3. You leave out any conflicting information
4. You start the process all over again
Answer
To resolve the inconsistencies, you need to amend the requirements and goals to reflect the
information you gathered during the interviews. You can also choose to start the process all over
again.
After you've documented the results and analyzed the interviews, you need to check with the
managers, customers, and end users to verify the analysis and results.
5. Interview checklist
You create an interview checklist to ensure that you cover all the essential aspects of the
interviewing process.
You can include the following items in an interview checklist:
interview plan
time and location of interviews
interviewees
677

questionnaire template
interview style
recording method
analysis and reporting methods
interview plan
Before you start an interview process, you need to create an interview plan.

In the plan, you can record the date and time of the interviews, the interviewees, and the order of
the interviews.
time and location of interviews
You should reserve a specific location for the interviews in which you won't be disturbed.

And you need to ensure that the time of the interview suits the interviewee.
interviewees
When you conduct interviews, you need to ensure that you interview a cross section of end users,
customers, and managers.
questionnaire template
You must create an interview question template to ensure that all the questions are standardized
and correctly worded.

You do this to ensure that you ask all the participants the same questions, which decreases the
danger of biased results.
interview style
You need to decide whether to interview a group of participants simultaneously or whether to
interview the participants one by one.
recording method
You must decide how to record the information you collect.

Written feedback is easier to collate, but it is a time-consuming task during the interview.

An audio or a video recording is easier to manage during the interview, but you need to transcribe
the information later.
analysis and reporting methods
You should select a method for analyzing the information you collected during interviews.

And you need to decide when and how to report the findings to the participants and other
stakeholders.
678

Summary
To gather information about the requirements for a system in the design phase, you can use
techniques, such as interviews, surveys, contextual inquiries, observation, and brainstorming.

To ensure that you collect accurate and appropriate information, you need to plan the interview
process. This entails creating a standardized question template to ensure that you ask
interviewees the same questions. Effective question types include experience questions, opinion
questions, knowledge questions, and background questions.

When you conduct interviews, you should do so in a manner that ensures that participants are
comfortable. Participants should include managers, end users, and customers. Effective
interviews contain an introductory stage, question stage, and concluding stage.

Once you have conducted all the interviews, you examine the recorded material and analyze the
responses of the interviewees. You also need to decide how to collate the recorded material.
During the analysis stage, you can check whether you've omitted anything and re-examine any
conflicts or inconsistencies.

You can use an interview checklist to ensure that you cover all the essential aspects of the
interviewing process. For example, you can include the interview style and recording method in
the checklist.














679

Developing the conceptual database design
Learning objective
After completing this topic, you should be able to describe how to generate a conceptual Entity-
Relationship diagram (ERD) to support the functional specification for a database system.
1. Creating a conceptual model
You create a conceptual design of the business data requirements by mapping the information
you collected from users into a high-level conceptual model during the database design analysis
phase.

You use this high-level conceptual model called an Entity-Relationship diagram (ERD) to
determine the requirements and verify that they have been met.
The main components of the ERD are the
entities
attributes
relationships
entities
An entity is a class, group, or category of objects.

For example, a company may have entities, such as Department and Manager.

An occurrence is an instance that belongs to an entity.

For example, Laura Wells, a manager, is an occurrence of the Manager entity.
attributes
An attribute of an entity defines the information within an entity.

For example, in the Department entity, the department name is an attribute.

An entity can have several attributes.
relationships
A relationship is a bidirectional association between entities.

Business rules determine the relationships between entities in an ERD.

For example, "Is managed by" defines the relationship between the Department and Manager
entities, and the same relationship can be stated as "Manages."
680

Question
A Student entity has a many-to-many relationship to a Module entity.
Which of the following relationship definitions describe the relationship between these entities?
Options:
1. Students may enroll in one or more modules
2. A Student is an occurrence of a Module
3. Charles is a student
4. Modules can be taken by many students
Answer
A many-to-many relationship between the Student and Module entities means that students may
enroll in one or more modules, and modules can be taken by many students.
2. Determining the data
You can identify the information you need to include in the conceptual ERD by breaking down
the information you gathered into logical categories, such as entities and attributes.

Some categories can exist on their own, whereas others are related to business processes or
tasks.

For example, if instructors, courses, and students are identified as the main categories of an
online university, these categories become the main entities of the conceptual ERD.
Note
In the relational data model, an entity is also known as a "relation."
You can identify an entity by selecting all the nouns in the requirements document and relating
them to business processes or rules.

The entities you define and identify become part of the ERD, and they can be mapped loosely to
tables in the physical database.
You need to assign each entity you identify a unique identifier (UID).

A UID could be a name or a field that describes the data associated with it.

A UID can be singular or a combination of fields.
681

Question
Identify the true statements about information you include in a conceptual ERD.
Options:
1. Categories of information can be related to business processes or tasks
2. You can assign the same identifier to multiple entities
3. You identify information by breaking it down into logical categories
Answer
You identify information you include in a conceptual ERD by breaking it down into logical categories,
which can be related to business processes or tasks.
Option 1 is correct. If, for example, instructors, courses, and students are identified as the main
categories of an online university, these categories become the main entities of the conceptual
ERD.
Option 2 is incorrect. You need to assign each entity in an ERD a unique identifier (UID), which
could be a name or a field that describes the data associated with it.
Option 3 is correct. Logical categories of information include entities and attributes, which enable
better classification of data in an ERD.
3. Determining the fields
Once you've identified the entities, you need to identify a list of fields for each entity.

A field is specific information related to an entity that describes or qualifies the features of the
entity.

For example, the fields for the Instructor entity include all the data associated with that
instructor, such as first name, location, and qualification.
The fields you identify are referred to as attributes in the ERD and become the columns in the
physical database.

You can show attributes in the entities in an ERD, or you can record them as a list associated
with each entity.
Question
Suppose that you are creating an ERD for a business. In the following sentences, some words are
fields of the Department entity, the Employee entity, and the Project entity.
682


"A department is known by a unique name and belongs to a geographical location. The Human
Resources department records information on employees, such as their last names, first names,
starting date and salaries. Projects have a name start date and an optional end date."
Based on the guidelines for fields, identify the words that you think are fields in the previous
sentences.
Options:
1. Project_Name, End_Date, Start_Date
2. Dept_Name, Location
3. Last_Name, First_Name, Address
4. HR_Dept, Emp_Name
Targets:
A. Department entity
B. Employee entity with the fields Start_Date and Salary
C. Project entity
Answer
The Address, First_Name, Last_Name, Salary fields belong to the Employee entity. The End_Date,
Project_Name, Start_Date fields belong to the Project entity. The Dept_Name and Location fields
belong to the Department entity.
4. Determining the relationships
You determine the relationship between entities by mapping the way in which data is associated
between them.

For example, two entities that share a common attribute share a relationship.
Relationships between entities are defined on the "key" attributes of the entities involved.

Entities have a relationship if data from one entity refers to data in another entity.

All entities in a data model share at least one relationship.
Relationships determine how entities can refer to other entities.

For example, when you access the Manager entity in the ERD, you can access the data
associated with the Department that the Manager manages and vice versa. The relationship
between Manager and Department is one-to-one.
683

In an ERD, the duplicate attributes defining the relationships are usually not shown.

You create an ERD to define the primary entities, the primary fields of entities, and the
relationships between the entities.
In relational databases, relationships can be
one-to-one
one-to-many
many-to-many
In a one-to-one relationship, an occurrence in one entity is related to only one other occurrence
in another entity.

A one-to-one relationship has the notation 1:1 (the digit "1", colon, digit "1").
In a one-to-many relationship, an occurrence in one entity is related to one or more occurrences
in another entity.

The relationship is normally defined on the primary key of the "one" entity and a key field in the
"many" entity called the "foreign key".

A one-to-many relationship has the notation 1:N (the digit "1", colon, the letter "N").
In a many-to-many relationship, shown as N:M (the letter "N", colon, the letter "M"), one or more
occurrences in one entity are related to one or more other occurrences in another entity.

In other words, an occurrence in Department may be associated with many occurrences in
Manager, an occurrence in Manager may be associated with many occurrences in Department.
Many-to-many relationships are usually modeled in the final logical data model by resolving the
relationship into two one-to-many relationships involving a third intersection entity.
Question
The relationship requirements are as follows: "A department must be managed by one manager and
have at least one employee, whereas employees belong to one department only. Managers manage
only one department. Each department may be responsible for at least one project, and a project
must be the responsibility of a department. Employees may work on many projects, and projects
must have at least one employee."
See if you can match the correct relationship to the associated entities, based on the preceding
requirements.
Options:
684

1. 1:1
2. 1:N
3. N:M
Targets:
A. Department entity, with fields Dept_Name and Location; Manager entity, with fields Last_Name,
First_Name, Address, Start_Date, Salary, and Dept_Name.
B. Department entity, with fields Dept_Name and Location; Employee entity, with fields Last_Name,
First_Name, Address, Start_Date, and Salary
C. Employee entity, with fields Last_Name, First_Name, Address, Start_Date, and Salary; Project
entity, with fields Project_Name, Start_Date, and End_Date.
Answer
Department Employee share a one-to-many relationship, Department Manager a one-to-one
relationship, and Employee Project a many-to-many relationship.
In a one-to-one relationship, an occurrence in one entity is related to only one other occurrence in
another entity. In this example Dept_Name in the Department table relates to the Dept_Name in the
Managers table.
In a one-to-many relationship, an occurrence in one entity is related to one or more occurrences in
another entity. The relationship is normally defined on the primary key of the "one" entity and a key
field in the "many" entity called the "foreign key". In this example the foreign key is Last_Name in the
employee table.
In a many-to-many relationship, one or more occurrences in one entity are related to one or more
other occurrences in another entity. In this example, an occurrence in Employee may be associated
with many occurrences in Project; an occurrence in Project may be associated with many
occurrences in Employee.
5. Consolidating the views
A database can contain multiple independent views of a business.

During the conceptual and logical database design phases, you need to integrate the multiple
user views into a single complete data model.
You can use either the centralized schema or the view integration method when you design a
conceptual data model.
When you use the centralized design method, you collate the individual requirements of users
into one consolidated set of requirements before you start the data model design.
685


You use this set of requirements to design a single representative data model.
When you use the view integration method, you design a data model for each individual user's
requirements.

You merge these independent data models into a single data model for the entire database.
Summary
You create a conceptual design of the data requirements of business by mapping the
information you collect from users into a high-level conceptual model during the database
design analysis phase. This model is called an Entity-Relationship diagram (ERD). You use this
information to verify that all requirements have been met and that all requirements have been
determined.

You can identify the relevant data you need to include in the ERD by breaking down the
information into logical categories, such as entities and attributes. Some categories of
information exist on their own, and others are related to business processes or tasks.

Once you've identified the entities, you need to identify a list of fields for each entity. The fields
you identify are referred to as attributes in the ERD, and they become the columns in the
physical database. You can show fields in the entities in the ERD, or you can record them as a
list associated with each entity.

A relationship is a bidirectional association between entities. Business rules determine the
relationships between entities in an ERD. Entities also share a relationship if data from one
entity refers to data in another entity.

A view consists of a group of linked database objects. There may be multiple independent views
of the business and resulting database. During the conceptual and logical database design
phases, you need to integrate the multiple user views into a single complete data model.







686

Creating a conceptual database design
Learning objective
After completing this topic, you should be able to develop a conceptual Entity-Relationship (ER)
model based on a given business requirements document.
Exercise overview
In this exercise, you're required to complete the first step of the database design process by
identifying the entities, attributes, and relationships.
This involves the following tasks:
identifying the entities
identifying the attributes
identifying the relationships
Suppose that you are the database design specialist contracted to design a new database for
Brocadero Online University.

You've gathered all the information you require, and you now want to complete the first step of
the database design process by designing an Entity-Relationship diagram (ERD) of the system
requirements.

To complete the exercise, you need to read the requirements document for Brocadero Online
University.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements document
Read the Brocadero requirements document and then make decisions about its entities, attributes,
and relationships.
Task 1: Identifying the entities
Once you've read the requirements document, you have to identify the entities that should be
included in the ERD.
687

Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements document
Read the Brocadero requirements document and then make decisions about its entities, attributes,
and relationships.
Step 1 of 1
Select the entities that should be included in the initial ERD.
Options:
1. Access
2. Instructor
3. Module
4. Student
5. System
6. Course
Result
The entities that should be included in the initial ERD are Instructor, Module, Student, and Course.
Option 1 is incorrect. The Access entity is incorrect because "access" is classified as a process in
the requirements specification.
Option 2 is correct. The Instructor entity should be included in the initial ERD because Instructors
present modules.
Option 3 is correct. The Module entity should be included in the initial ERD because Courses consist
of one or more Modules and students may enroll in one or more modules to complete a course.
Option 4 is correct. The Student entity should be included in the initial ERD because Students may
enroll in one or more Modules to complete a Course.
Option 5 is incorrect. The System entity is incorrect because it is too broad a data grouping.
Option 6 is correct. The Course entity should be included in the initial ERD because Courses consist
of one or more Modules and have unique names and descriptions.
688

Task 2: Identifying the attributes
Suppose you are creating an ERD for Brocadero Online University.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements document
Read the Brocadero requirements document.
Identify the attributes that you think belong to the Module entity.
Options:
1. Address
2. Duration
3. Name
4. Objective
5. Password
6. Subscription
Result
The attributes belonging to the Module entity are the Duration, Name, Objective, and Subscription
fields.
Option 1 is incorrect. The Address is an attribute of the Student entity and not the Module entity.
Option 2 is correct. The Duration is an attribute of the Module entity and is recorded for the benefit
of the students.
Option 3 is correct. The Name is an attribute of the Module entity and is unique for each module.
Module names have an associated objective.
Option 4 is correct. The Objective is an attribute of the Module entity and details what the Module
does. It is associated with the Name of the Module.
Option 5 is incorrect. The Password is an attribute of the Instructors entity and is used to gain
access to the system.
Option 6 is correct. The Subscription is an attribute of the Module entity and details to number of
students who have subscribed to the course. Subscription can be empty.
689

Task 3: Identifying the relationships
You now want to match the notations with the relationships they express.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements document
Read the Brocadero requirements document.
Step 1 of 1
Match the notations with the relationships they express.
Options:
1. 1:1
2. 1:N
3. N:1
4. N:M
5. No relationship
Targets:
A. Course Module
B. Student Module
C. Module Instructor
Result
The Course Module relationship is 1:N (one-to-many), whereas the Module Instructor
relationship is N:1 (one-to-many), and the Student Module relationship is N:M (many-to-many).
In a one-to-one relationship, an occurrence in one entity is related to only one other occurrence in
another entity. This is not the case in this example as there is at least a one-to-many relationship
between the entities.
In a one-to-many relationship, an occurrence in one entity is related to one or more occurrences in
another entity. The relationship is normally defined on the primary key of the "one" entity and a key
field in the "many" entity called the "foreign key". In this example the Name key in the Course entity
is the primary key and is related to the secondary Name key in the Modules entity.
690

In a one-to-many relationship, or in this inatance a many-to-one relationship an occurrence in one
entity is related to one or more occurrences in another entity. In this example the Instructor_ID key
in the Course entity is the primary key and is related to the secondary Name key in the Modules
entity.
In a many-to-many relationship, one or more occurrences in one entity are related to one or more
other occurrences in another entity. In this example a student can enroll in one or more Modules to
complete a course.
No relationship would suggest that the database is not relational and that is not the case as primary
and foreign keys in the different entities all relate.
You've now completed the first step of the database design process for the Brocadero Online
University. You've created a high-level conceptual Entity-Relationship diagram (ERD) by
identifying the main entities, attributes, and relationships.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements document
Read the Brocadero requirements document.











691

Database design using Entity-Relationship modeling
Learning objective
After completing this topic, you should be able to use Entity-Relationship (ER) modeling to
design a relational database.
1. Entity-Relationship modeling overview
To design a relational database that meets the business requirements of an organization, you
use a "top-down" database design methodology.
Question
Database design comprises a set of discrete steps.
See if you can place the steps of the top-down database design methodology in the correct
sequence.
Options
Option Description
A Conceptual design
B Logical design
C Physical design
D Requirements analysis
Answer
Correct ranking
Option Description
D Requirements analysis
A Conceptual design
B Logical design
692

Correct ranking
Option Description
C Physical design
After you've gathered an organization's data requirements, you can use Entity-Relationship (ER)
modeling to create an Entity-Relationship diagram (ERD).

Based on the top-down database design methodology, you first generate a "high-level"
conceptual ERD based on the requirements.

The conceptual ERD specifies the primary data groups or entities, their attributes, and the
relationships between them.
Upon completion and user verification of the high-level data model, you refine the high-level
data abstractions into lower-level entity types and relationships.

The "logical" database design phase results in a logical data model that specifies a complete,
nonredundant set of fully normalized tables or entities and their corresponding relationships,
attributes, and constraints.
Question
You can use software to convert the graphical representations of an ERD into SQL code to create
physical structures in a database.
See if you can map each logical model component to its physical counterpart in a database.
Options:
1. Attribute
2. Constraint
3. Entity
4. Relationships
Targets:
A. Table
B. Column
C. Primary key
D. Foreign key
693

Answer
A logical entity maps to a table structure in a database, a logical attribute to a physical column, and
a logical relationship may map to physical foreign key.
2. Modeling entities
An entity or "entity type" is a physical or abstract class, group, or category of objects.

An "entity instance" is a unique occurrence of an entity record and corresponds to a row in a
table.
In an ERD, you represent entities using a box. Entities are uniquely identified by an "entity
name," and they are often supported by a qualifying definition.
Project
Project
The Project entity has a combined primary key that consists of the Project_Name and Start_Date
attributes. Because these attributes don't allow NULL values, they appear in bold format.

Similarly, the two foreign keys Employee_Name and Department_Name don't allow NULL
values.

However, the End_Date attribute allows NULL values. It appears in plain text.
Question
Which of the following do you think are valid entity instances?
Options:
1. A computer course on CD-ROM released in 1990
2. A Harley Davidson motorcycle with a registration number KGX 503Y
3. Air Seychelles Flight # 135 to the Seychelles
4. Jessica Parker who has a medical practice number 3337
Answer
The registered Harley Davidson, Air Seychelles Flight # 135, and Jessica Parker are entity
instances because they have unique identifying features.
Option 1 is incorrect. A computer course on CD-ROM released in 1990 does not represent an entity
instance because the stipulated features do not identify it as a particular course. The features
describe a range of computer courses released in 1990.
694

Option 2 is correct. A Harley Davidson is an entity instance because its registration number KGX
503Y identifies it uniquely.
Option 3 is correct. Air Seychelles is an entity instance because its flight number identifies it
uniquely.
Option 4 is correct. Jessica Parker is an entity instance because her name and a medical practice
number identify her uniquely.
Entity types in an ERD include
regular entities
weak entities
A regular entity has a specific key attribute of its own.
A weak entity has no key attributes of its own, and its related regular or "owner" entity type
identifies it.

The key attributes of a weak entity consist of the owner's key attributes.
3. Modeling attributes
Attributes are the specific properties that describe an entity.

For example, you can describe a product entity by the product's price, color, and order date.
Each attribute of an entity has a set of permitted values called the domain of that attribute.

You need to distinguish between an attribute name and an attribute value.

For example, the attribute name Flight_Number may draw its permitted values from a domain
whose elements include BA333, LO151, and TWA557.
Types of attributes in the ER model include
composite and simple attributes
single-valued and multivalued attributes
derived and stored attributes
composite and simple attributes
You can divide composite attributes into basic attributes with independent meanings. For
example, you can subdivide the Address attribute of an Employee entity into Street_Address,
City, State, and ZIP_Code.

695

You can use composite attributes to model situations in which a user sometimes refers to the
composite attributes as a unit, but at other times to specific components only.

Attributes that you can't divide are simple or atomic attributes. If users reference a composite
attribute as a whole only, you don't need to subdivide it into component attributes. For example, if
users don't need to refer to the individual components of an address, you can designate the
address as a simple attribute.
single-valued and multivalued attributes
Single-valued attributes have a single value for a specific entity. For example, Salary is a single-
valued attribute of an Employee entity. In some cases, an attribute can have multiple values for
the same entity. For example, Colors is an attribute of an Office Chair entity.

Office chairs with one color have a single value, whereas two-tone office chairs have two values
for Colors. Attributes such as these are called multivalued attributes.

A multivalued attribute may have upper and lower limits on the number of values allowed for each
entity. For example, the Colors attribute of an Office Chair entity may have between one and
three values if that office chair can have three colors at most.
derived and stored attributes
Sometimes, two or more attribute values are related, for example the Selling_Price and
Cost_Price attributes of a product. If you know the markup value of a product, you can determine
the value of the Selling_Price from the Cost_Price.

The Selling_Price attribute is therefore called a derived attribute.

And the Cost_Price attribute in this example is called a stored attribute.
Question
See if you can match each example of an attribute with its type.
Options:
1. Age
2. Birth_Date
3. Colors
4. Product_Description
Targets:
A. Composite attribute
B. Derived attribute
C. Multivalued attribute
D. Stored attribute
696

Answer
Age is an example of a derived attribute, Birth_Date of a stored attribute, Colors of a multivalued
attribute, and Product_Description of a composite attribute.
Age is an example of a derived attribute because you can determine the value of Age from the
current date and the value of a person's Birth_Date.
Birth_Date is an example of a stored attribute because you can use it to derive a person's age,
which is a derived attribute.
Colors is an example of a multivalued attribute because you can specify a set of values for the same
entity. For example, two-tone cars can have two values for Colors.
Product_Description is an example of a composite attribute because you can divide it into
independent subparts, such as Size and Style.
Attributes for the Project entity include
Project_Name and Start_Date
Employee_Name
End_Date
Department_Name
Project_Name and Start_Date
When defining the attributes for an entity, you first need to specify a unique identifier (UID)
attribute or combination of attributes for the entity. The UID can be a primary key, candidate key,
or a surrogate key.

Each entity should start with a unique primary key a nominated column or combination of
columns that has a unique value for each row in a table. For example, the Project_Name and
Start_Date columns form a composite primary key.

In the ERD, PK and an underline beneath the key attribute(s) identify primary keys. A table has
one primary key only. The primary key may not have a NULL value, which is defined as the
"entity integrity constraint."
Employee_Name
In some cases, a natural primary key may be NULL, which invalidates the NOT NULL constraint
of primary keys. You can use a "surrogate key" in this case. A surrogate key is often a system-
generated, automatically incremented number that serves as the unique identifier (UID) for an
entity.

Sometimes a table has more than one column or a combination of columns that could serve as
the primary key. For example, if a different employee handles each project, you could choose
697

Employee_Name instead of Project_Name and Start_Date as the primary key of the Project
table.

Such possible primary keys irrespective of whether you choose to use one as the primary key
are called candidate keys.
End_Date
In some cases, a specific entity may not have an applicable value for an attribute. For example,
the End_Date attribute of a project applies to completed projects only. A project that's not yet
completed would have a NULL value for its End_Date attribute.

This type of NULL value means "not applicable." You can also use NULL when you don't know
the value of an attribute for a specific entity for example, if you don't know when a project
ended. This type of NULL means "unknown."

You can define attributes as NULL or NOT NULL. In the ERD, you represent attributes that are
NOT NULL in bold, and you represent attributes that allow NULL in normal text.
Department_Name
Foreign keys link relevant data from different tables by cross-referencing columns. These keys
are the basis of the relationship defined between any two entities or between an entity and itself.
For example, Department_Name the primary key of a Department table appears as a foreign
key in the Project table, pointing back to the relevant department information.

The Department_Name foreign key serves as an abbreviation for department data. You can get
the full data about a department by looking up the relevant row in the Departments table.

Likewise, the Employee_Name serves as the foreign key referencing back to the Employee data.
The "referential integrity constraint" specifies that each foreign key value should have a matching
primary key value in its related table.
4. Modeling Relationships
A relationship between two entities or between an entity and itself is a bidirectional connection.

In an ERD, you represent relationships using lines between entities.

You represent the "one" side of a relationship using a line, whereas you represent the "many"
side using a "crow's foot."
You can define the cardinality of relationships in the following ways:
one-to-one or 1:1
one-to-many or 1:N
many-to-many or N:M
698

When you model a relationship in a logical ERD, you need to identify an optionality for each
direction of the relationship.

The part of a line closest to an entity applies to its optionality.
A mandatory relationship is one that must exist between entities, whereas an optional
relationship is one that may exist between entities.

You use a solid line to represent a mandatory relationship in an ERD, and you use an "o" to
represent an optional relationship.

For example, employees may work on many projects, and projects must have at least one
employee.
Entity types determine whether a relationship is identifying or nonidentifying.

The relationship that relates a weak entity type to its owner is called the "identifying
relationship," and you use a solid line to represent it in the ERD.
You use a dotted line to represent a nonidentifying relationship or a relationship between regular
entities.
An ERD is displayed. It describes different nonidentifying relationships indicated by dotted
lines between entities. It also demonstrates the use of cardinality and optionality. The ERD
can be summarized as follows: The Department, Employee, Manager, and Project entities are
related. All the entities' relationships to each other are either nonidentifying or between regular
entities. Department Employee have a mandatory 1:N relationship. Employee Project have
an optional/mandatory N:M relationship which is mandatory on the Employee side. Project
Department have an optional/mandatory 1:N relationship that is mandatory on the Department
side. Department Manager have a mandatory 1:1 relationship. The featured relationships are
Mandatory 1:1 relationship
Optional/mandatory 1:N relationship
Optional/mandatory N:M relationship
Mandatory 1:N relationship
Mandatory 1:1 relationship
A mandatory 1:1 relationship exists between Department and Manager if a department must be
managed by one manager, and managers manage one department only.
Optional/mandatory 1:N relationship
An optional/mandatory 1:N relationship exists between Department and Project, if each
department may be responsible for at least one project, and each project must be the
responsibility of a department.
Optional/mandatory N:M relationship
699

An optional/mandatory N:M relationship exists between Employee and Project if employees may
work on many projects, and projects must have at least one employee.
Mandatory 1:N relationship
A mandatory 1:N relationship exists between Department and Employee if a department must
have at least one employee, and employees must belong to one department only.
The ERD displayed demonstrates how the relationship between the entities defines the foreign
keys. The ERD can be summarized as follows: The Department, Employee, Manager, and
Project entities are related. The Department entity has the following attributes: Dept_Name (PK),
Location. The Employee entity has the following attributes: Last_Name (PK), First_Name (PK),
Address, Start_Date, Salary, Dept_Name (FK2), Project_Name (FK3). The Manager entity has
the following attributes: Last_Name (PK), First_Name (PK), Address, Start_Date, Salary,
Dept_Name (FK1). The Project entity has the following attributes: Project_Name (PK),
Start_Date, End_Date, Dept_Name, Last_Name, First_Name. All the entities' relationships to
each other are either nonidentifying or between regular entities. Department Employee have
a mandatory 1:N relationship. Employee Project have an optional/mandatory N:M relationship
which is mandatory on the Employee side. Project Department have an optional/mandatory
1:N relationship that is mandatory on the Department side. Department Manager have a
mandatory 1:1 relationship. The featured relationships are
Mandatory 1:1 relationship
Optional/mandatory 1:N relationship
Optional/mandatory N:M relationship
Mandatory 1:N relationship
Mandatory 1:1 relationship
Dept_Name the primary key of the Department entity appears as a foreign key in the
Manager entity, referencing back to the relevant department information.
Optional/mandatory 1:N relationship
Dept_Name the primary key of the Department entity appears as a foreign key in the Project
entity, referencing back to the relevant department information.
Optional/mandatory N:M relationship
Last_Name and First_Name the composite primary key of the Employee entity appears as a
foreign key in the Project entity, referencing back to the relevant employee data.

Project_Name the primary key of the Project entity appears as a foreign key in the Employee
entity, referencing back to the relevant project data.
Mandatory 1:N relationship
Dept_Name the primary key of the Department entity appears as a foreign key in the
Employee entity, referencing back to the relevant department information.
700

Summary
In database design, you can use Entity-Relationship (ER) modeling to create an Entity-
Relationship diagram (ERD). After you've refined this high-level data model into a logical model,
you can use software to convert the logical data structures into physical structures in a
database.

Entities represent an organization's data in a database. An entity or entity type refers to a
physical or abstract class, group, or category of objects.

An attribute is a property that describes an entity. You define attributes for an entity by
specifying a unique identifier (UID), which can be a primary key, a surrogate key, or a candidate
key. And you use foreign keys to link relevant data from different tables.

A relationship is a bidirectional connection between two entities or between an entity and itself.
Relationships can be mandatory and/or optional, and identifying or nonidentifying.















701

Designing a database using Entity-Relationship modeling
Learning objective
After completing this topic, you should be able to develop an initial logical database design
using simple Entity-Relationship (ER) modeling techniques.
Exercise overview
In this exercise, you're required to develop an initial logical database design from a conceptual
Entity-Relationship (ER) model.
This involves the following tasks:
determining relationship optionality
determining the key attributes
determining the NULL attributes
Suppose that you're a database designer at the Brocadero Online University, and you have
been contracted to develop a new database.

You've generated a high-level conceptual data model of the system requirements by identifying
entities, attributes, and relationships.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements Document
Read the requirements document for the Brocadero Online University.
This has been validated as fulfilling the business requirements and now you need to create a
logical Entity-Relationship (ER) model for the university by developing the existing conceptual
model.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Conceptual ER Model
Study the conceptual ER model for the Brocadero Online University.
702

Task 1: Determining optionality
In the ER model, there are non-identifying relationships between the entities based on the
conceptual ERD.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Conceptual ER Model
Study the conceptual ER model for the Brocadero Online University.
Step 1 of 3
Choose the optionality that defines the relationship between the Student and Module entities.
Options:
1. Mandatory N:M
2. Optional/mandatory N:M
3. Optional N:M
Result
The relationship between the Student and Module entities is an optional many-to-many relationship.
Option 1 is incorrect. A mandatory many-to-many (N:M) relationship indicates that students must
enroll for at least one module, and a module must be taken by at least one student. This contradicts
the requirements.
Option 2 is incorrect. An optional/ mandatory many-to-many (N:M) relationship indicates that
students must enroll for at least one module, and a module must be taken by at least one student.
This contradicts the requirements.
Option 3 is correct. Students may enroll for one or more modules, and modules may have many
students. So the relationship between the Student and Module entities is an optional many-to-many
relationship.
Step 2 of 3
The course entity of the ERD contains the following attributes: Name, Description, and Prerequisite.
The Module entity contains the following attributes: Name, Objective, Duration, and
Subscription.The dotted line between Course and Module has crow's feet on the Module side.
703

Choose the notation that defines the relationship between the Course and Module entities.
Options:
1. Mandatory 1:N
2. Optional/mandatory 1:N
3. Optional 1:N
Result
The relationship between the Course and Module entities is a mandatory one-to-many (1:N)
relationship.
Option 1 is correct. Each course must consist of one or more modules, and each module must
belong to a course. So the relationship between the Course and Module entities is a mandatory one-
to-many (1:N) relationship.
Option 2 is incorrect. An optional/mandatory one-to-many (1:N) relationship indicates that each
course may consist of one or more modules, and each module may belong to a course. This
contradicts the requirements.
Option 3 is incorrect. An optional one-to-many (1:N) relationship indicates that each course may
consist of one or more modules, and each module may belong to a course. This contradicts the
requirements.
Step 3 of 3
The Module entity of the ERD contains the following attributes: Name, Objective, Duration, and
Subscription. The Instructor entity contains the following attributes: Instructor_ID, Last_Name,
First_Name, Address, Email, and Password. The dotted line between Module and Instructor has
crow's feet on the Module side.
Choose the notation that defines the relationship between the Instructor and Module entities.
Options:
1. Mandatory/optional 1:N
2. Mandatory 1:N
3. Optional/mandatory 1:N
Result
The relationship between the Instructor and Module entities is a mandatory/optional one-to-many
relationship.
704

Option 1 is correct. An instructor may present many modules, and modules must be given by an
instructor. So the relationship between the Instructor and Module entities is a mandatory/optional
one-to-many relationship.
Option 2 is incorrect. A mandatory one-to-many (1:N) relationship indicates that an instructor must
be present at least one module and each module must be presented by an instructor. This
contradicts the requirements.
Option 3 is incorrect. An optional/mandatory one-to-many (1:N) relationship indicates that an
instructor must present at least one module but each module may be presented by an instructor.
This contradicts the requirements.
Task 2: Determining the key attributes
The following keys are specified for the ER model:
a surrogate primary key called Mo_ID, which identifies the module
a surrogate primary key called Co_ID, which identifies the course
a natural primary key called Student_ID, which identifies a student
a natural primary key called Instructor_ID, which identifies an instructor
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Conceptual ER Model
Study the conceptual ER model for the Brocadero Online University.
Step 1 of 1
In the Brocadero ER model, match each key to the appropriate entity.
Options:
1. PK Co_ID
2. FK2 Instructor_ID
3. PK Mo_ID
4. PK Student_ID
Targets:
A. Key associated to the Student entity
B. Key associated to the Course entity
C. Key associated to the first attribute of the Module entity
705

D. Key associated to the second attribute of the Module entity
Result
Co_ID is the primary key of the Course entity, and Mo_ID is the primary key of the Module entity.
Instructor_ID is the second foreign key of the Module entity and Student_ID is the primary key of the
Student entity.
Co_ID is the primary key of the Course entity because it uniquely identifies each course in the
Course entity as no two courses can have the same identity.
Instructor_ID is the second foreign key of the Module entity as it uses the Mo_ID as its primary key
from the Module entity and the Co_ID key from the Course entity as its first foreign key.
Mo_ID is the primary key of the Module entity because it uniquely identifies each module in the
Module entity as no two modules can have the same identity.
Student_ID is the primary key of the Student entity because it uniquely identifies each student in the
student entity as no two students can have the same identity.
Task 3: Determining the NULL attributes
The requirements document for the Brocadero Online University shows that certain attributes
can allow NULL values.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Conceptual ER Model
Study the conceptual ER model for the Brocadero Online University.
Step 1 of 1
The requirements document for the Brocadero Online University shows that certain attributes can
allow NULL values.
Choose the attributes that allow NULLs.
Options:
1. The Result attribute of the Student entity
2. The Name attribute of the Course entity
3. The Subscription attribute of the Module entity
706

4. The Email attribute of the Instructor entity
Result
The Result attribute of the Student entity and the Subscription attribute of the Module entity allow
NULL values.
Option 1 is correct. If a student has not yet completed a module, then the result for the module is
NULL.
Option 2 is incorrect. Every course must have a name, as each course name is unique and identifies
the course.
Option 3 is correct. The number of students who subscribe to a module is recorded. If no students
subscribe to a module then the module is empty and therefore has a Subscription value of NULL.
Option 4 is incorrect. Instructors use their Email and password to logon to the system, and therefore
the Email attribute cannot be empty.
By defining relationship optionality and primary and foreign keys, you have completed the first
steps of creating a logical database.












707

Normalizing the database design
Abstract
This white paper discusses normalization and describes how it optimizes database
management by eliminating redundant data and ensuring that only related data is stored in a
table. In addition to describing the normalization process, it focuses on the advantages and
disadvantages of normalization. It outlines the advantages and disadvantages of using
denormalization to improve database performance, and it explains the inevitable trade off
between database performance and database manageability.
Normalization in database design
Normalization optimizes database management by reducing or eliminating redundant data and
ensuring that only related data is stored in a relational database table. Normalization is based
on levels or rules called normal forms. Currently, five normal forms numbered one through
five have been defined. Every normal form builds on the previous one.
When you normalize a database, you want to
arrange the data into logical entities that form part of the whole
minimize the amount of duplicate data that is stored in a database
design a database in which users can access and modify the data quickly
ensure the integrity of the data in the database
optimize query times
The Normal Forms
First Normal Form (1NF)
The aim of 1NF is to divide the database data into logical entities or tables. When you've
designed each entity, you assign it a primary key or unique identifier (UID.)
All attributes of an entity must be single-valued attributes. A repeating or multivalued attribute
is an attribute or group of attributes with multiple values for one occurrence of the UID.
You need to move a repeating attribute or attributes to a separate entity and create a
relationship between the two decomposed entities. When working with tables, you move
repeating columns to their own table. In the new table, you use a copy of the original table's
UID as a foreign key.
Let's say that the Employee table has multiple values to define the various projects an
employee may be involved in over a period of time. Although projects start and finish on a
specific date, they may stop temporarily because of prioritization. The Employee_Name
attribute is the UID for the entity.
The Employee table prior to 1NF is shown here.
708


Employee table before normalization
In the example, Project (13), Start_Date (13), and End_Date (13) are multivalued
attributes or repeating columns. This violates the 1NF normalization rule. So you need to
place Project, Start_Date, and End_Date in a new table called Project:

Employee and Project tables in 1NF
The UID for Project is a composite key comprising Project_Name and Start_Date. And the
foreign key for Project is Employee_Name, which creates a relationship between the
Employee and Project tables.
Second Normal Form (2NF)
The aim of 2NF is to take data that's partly dependent on the primary key and place it in
another table.
If a table has a composite UID, all the non-UID attributes must be dependent on all the UID
attributes not just one or some of them. This is a requirement of 2NF. You need to move any
709

attributes that are not dependent on an entire composite UID to another table and establish a
relationship between the two tables.

The Project table before 2NF
In this example, the department details depend on the Project_Name only instead of on the
whole key. The solution for this violation of 2NF is to move Department_Name and
Department_Location to a new table called Department:

Project and Department tables in 2NF
The Project table has a composite primary key comprising Project_Name and Start_Date. The
foreign key comprises Employee_Name and Department_Name. And the table has an
End_Date column. The Department table has Department_Name as its primary key and a
Department_Location column.
Third Normal Form (3NF)
The aim of 3NF is to remove data in a table that is independent of the primary key.
Let's say that you add a Priority attribute to the Project table. The Priority attribute has
potential values, such as "High", "Medium", and "Low". Additionally, you decide to add an
attribute called Priority_Level, which further qualifies Priority into a more detailed subgroup
with potential values of "1", "2", and "3". The table is shown here.
710


The Project table before 3NF
The Project table has a composite primary key consisting of Project_Name and Start_Date.
The foreign key comprises Employee_Name and Department_Name. Other columns in the
table are End_Date, Priority and Priority_Level.
In this example, Priority_Level depends on Priority first. Priority_Level depends on the
Project_Name and Start_Date UID through Priority only. The transitive dependency of
Priority_Level is unacceptable in 3NF. So you need to move the Priority and Priority_Level
attributes from the Project table to their own Priority table. The tables in 3NF are shown here.

Project and Priority tables in 3NF
The Project table has a composite primary key comprising Project_Name and Start_Date. The
foreign key comprises Employee_Name, Department_Name, and Priority. And the table has
an End_Date column. The Priority table has Priority as its primary key, and it has a
Priority_Level column.
Normalization of production systems usually stops at 3NF. Levels above 3NF are conceptually
complicated and applicable to situations that require specific solutions only.
711

Boyce-Codd Normal Form (BCNF)
Unlike 3NF, BCNF requires each attribute or combination of attributes upon which any
attribute is fully or functionally dependent to be a candidate key.
For example, if Column_B is functionally dependent on Column_A, you can associate every
value in Column_A with only one value in Column_B at a specific point in time. A specific
value for Column_A always has the same value in Column_B, but the reverse is not true. A
specific value for Column_B can have multiple corresponding values in Column_A.
Fourth Normal Form (4NF)
For 4NF, a table needs to be in BCNF, and it shouldn't have any multivalued dependencies.
Neither should the dependent attributes be a subset of the attributes they depend on. And the
dependent attributes combined with the attributes they depend on should not constitute the
entire entity.
In a multivalued dependency, two or more attributes depend on a determinant, and each
dependent attribute has a particular set of values. The values in the dependent attributes are
independent of each other.
Fifth Normal Form (5NF)
For 5NF to be in effect, an entity should be in 4NF, and all join dependencies on the table
should be related to its candidate keys.
When you decompose tables through normalization, you should be able to reconstruct the
original table by doing joins between the resulting tables without losing data and without
generating extra rows. This is a lossless join.
When you can't decompose a table into smaller tables, which have different keys from the
original without data losses, the table is in 5NF.
Advantages of normalization
By reducing the amount of redundant data in a database, normalization simplifies data
structures and the enforcement of integrity constraints. This optimizes database organization,
reduces the possibility of inconsistent data, and minimizes data update anomalies.
Normalization therefore makes it easier to maintain data integrity in a database.
Normalization provides flexibility for modifying existing data structures it's easier to modify
smaller tables with small amounts of data than it is to modify one large table holding all the
data. And smaller tables make it easier to separate and find columns when users query a
database. In this way, normalization can optimize query retrieval speed.
Because normalization enables a DBA to grant access to limited tables to certain users, it
improves security management. And by minimizing or eliminating duplicate data,
normalization optimizes disk space usage.
Disadvantages of normalization
712

Normalization produces many tables, each having relatively few columns. To use the
normalized data these columns contain, you have to put the information back together by
joining the columns using their primary/foreign key relationships.
Querying a normalized database might require retrieval of data from multiple normalized
tables. The database needs to locate the requested tables and then join the information from
the tables to retrieve the requested data or to process the desired data. If you don't join tables
properly using their UIDs in code database queries return extraneous data called a
Cartesian product.
Join operations reduce database performance by slowing processing down and by placing
stress on computer hardware. Normalized databases need more CPU, memory, and I/O to
process transactions and queries than unnormalized and denormalized databases. So join
operations can incur significant overhead.
Denormalization
Denormalization is the process of modifying table structures in a normalized database to allow
controlled redundancy for improved database performance. A denormalized database is not
the same as an unnormalized database. Denormalization involves reducing the level of
normalization within the database by a notch or two.
You usually undertake denormalization to solve performance problems relating to insufficient
processing speed or power for high-volume or high-complexity application functions. You
should perform denormalization only to the degree required to obtain necessary performance.
Usually, denormalization involves one of the following tasks:
replicating some data columns to several tables to make them more easily accessible
without multitable joins
precalculating and storing data that you often need for queries to increase processing
speed
undoing some decomposition of tables usually those that have one-to-one
relationships to avoid the price of multiple joins
By recombining separate tables or creating duplicate data within tables, denormalization
reduces the number of tables you need to join for data retrieval. This results in less I/O and
CPU time and so improves performance.
However, denormalization does come at a cost. By increasing data redundancy,
denormalization makes the data model more complex and less flexible. Denormalization
makes it more difficult to keep track of related information, so you need to consider how to
manage the redundant data.
Application coding also becomes more complicated because you need to retrieve data across
various tables. And because related data is divided among multiple tables, referential integrity
is more difficult to maintain.
Denormalization complicates the modification of a database and its applications. Although
database reads might be much faster after denormalization, writes might be slower because of
the need to update replicated data in various locations.
713

Although denormalization comes at a cost, you may need to implement it if a database design
and the applications that depend on it do not perform fast enough to meet user requirements.
If tuning the database and application hasn't improved the speed, and increasing hardware
resources or network bandwidth hasn't helped or isn't an option, denormalization might be a
necessary tool. By implementing and testing denormalization carefully, you can minimize most
of its negative impacts.
A trade off must take place between database performance and database manageability.
When considering normalization and denormalization, you should aim for a combination of
optimal performance and manageability.
Summary
Normalization reduces or eliminates redundant data in the relational database model. This
process simplifies data structures so it's easier to maintain data integrity. However, the
resulting join operations necessary for data retrieval can incur a higher overhead in terms of
database performance.
The levels of normalization are called normal forms. These include First Normal Form (1NF),
Second Normal Form (2NF), Third Normal Form (3NF), Boyce-Codd Normal Form (BCNF),
Fourth Normal Form (4NF), and Fifth Normal Form (5NF). Each normal form builds on the
previous one. For production databases, 3NF is the standard.
Using denormalization, you can recombine attributes in a normalized database to improve
performance. However, drawbacks include decreased flexibility and increased difficulty in
maintaining data integrity.
When normalizing a database, you should aim for a balance between database performance
and database manageability.










714

Modeling complex relationships in the database design
Learning objective
After completing this topic, you should be able to describe how to use advanced Entity-
Relationship (ER) modeling techniques to define complex real-world scenarios.
1. Self-referencing relationships
In database design, the same entity can appear at both ends of a relationship.

This relationship is called a recursive or self-referencing relationship.
Two examples of self-referencing relationships are
Business_Lot self-referencing one-to-many (1:N) relationship
Manufactured_Part self-referencing many-to-many (N:M) relationship
Business_Lot self-referencing one-to-many (1:N) relationship
The self-referencing 1:N relationship indicates that each business lot may include one or more
business lots.

And each business lot may be included in one bigger business lot.

The Business_Lots table might have Lot_ID as its primary key, and Sub_Lot_ID as its foreign
key, for example.
Manufactured_Part self-referencing many-to-many (N:M) relationship
The self-referencing N:M relationship indicates that each part may consist of one or more parts.

And each part may be a component of one or more parts.

Because this relationship is many-to-many, you can't represent it using a single table with a
foreign key or keys.
Question
There are three instances of the Employee entity. The attributes are: Emp_Id (PK), Last_Name,
First_Name, Address, Start_Date, Salary, Dept_Name (FK2), Project_Name (FK3), Manager_Id
(FK4). The first Employee entity has an optional/mandatory 1:N self-referencing relationship. The
second Employee entity has a mandatory 1:N self-referencing relationship. The third entity has an
optional 1:N self-referencing relationship.
Let's say that requirements state that all managers are employees, that an employee must have a
manager, and that each employee should have an ID.
715

Select the self-referencing relationship that you think models these requirements correctly.
Options:
1. optional/mandatory 1:N self-referencing relationship
2. mandatory 1:N self-referencing relationship
3. optional 1:N self-referencing relationship
Answer
The requirements describe an optional/mandatory 1:N self-referencing relationship.
Option 1 is correct. The requirements state that all managers are employees, that an employee
must have a manager, and that each employee should have an ID. This describes an
optional/mandatory 1:N self-referencing relationship.
Option 2 is incorrect. The mandatory constraint infers that all employees are managers, which
contradicts the business requirements.
Option 3 is incorrect. The optionality indicated by this relationship suggests that all employees may
have a manager, whereas in fact all employees must have a manager.
2. Resolving many-to-many relationships
In a normalized model, you can't represent a N:M relationship using foreign keys.

So you need to resolve an N:M relationship by creating a new entity called an intersection entity.

Using an intersection entity enables you to reduce redundant data and simplify the merging of
related data.
You can use an intersection entity to resolve
an ordinary N:M relationship
a self-referencing N:M relationship
Part of a complete Entity-Relationship Diagram (ERD) is displayed.

The N:M relationship indicates that employees may work on many projects, and projects must
have at least one employee.
You can resolve the N:M relationship by creating an intersection entity called Works_On.

The unique identifier (UID) of the Works_On entity is a composite primary key that consists of
Emp_ID and Project_Name. In the Works_On entity, Emp_ID also serves as foreign key to the
716

Employee entity. And Project_Name serves as foreign key to the Project entity.

Project_Name no longer appears in the Employee entity, and Emp_ID no longer appears in
Project.
The product of the Works_On intersection entity is two 1:N relationships.

And because the intersection entity is identified by the Employee and Project entities, the
relationships are called "identifying" relationships and represented by a solid line.
The intersection entity enables you to navigate easily between the two main entities to find
information.

For example, to establish when an employee called Kelly McGregor started working on projects,
you first match her Emp_ID under Employee with Emp_ID under Works_On.

The Works_On table provides you with the names of the project or projects Kelly is working on.
You can match Project_Name under Works_On with Project_Name under Project.

And the Project entity provides the start date of projects.
A self-referencing N:M relationship involves the Parts entity.

Each part may be comprised of many other parts and a part may be a component of many other
parts.

The primary key is Part_ID. Other attributes include Part_Name and Of_Part_ID. Of_Part_ID
serves as FK2.
To resolve a self-referencing N:M relationship, you split the Parts entity into two temporary parts,
for example, a Parent Parts and a Child Parts.

Each parent part may be an assembly of many child parts. And each child part may be a
component of many parent parts.

In the parent entity, Part_ID serves as primary key and FK2. In the child entity, Part_ID also
serves as primary key and FK1.
After decomposing the self-referencing N:M relationship into an N:M relationship between two
entities, you can create an intersection entity.
After creating an intersection entity, you can merge the temporary Parent and Child Parts
entities to result in the final Entity-Relationship diagram (ERD).
717

3. Ternary relationships
Real-world situations often require that you model a relationship involving three or more entities.
A relationship between three entities is called a ternary relationship.

For example, you may need to indicate which welfare organizations provide which services in
which regions.

So you create three entities Service, Organization, and Region and apply the techniques of
N:M resolution.
Question
Four entities are interconnected, Entity 1, 2, 3, 4. Three options show Entity 2 in various
relationships with entities 1,2 and 4.

See if you can select the correct models from the options that define ternary relationships. In all the
models, one entity is related to three other entities. All relationships are optional/mandatory.
Options:
1. All the relationships are optional on the side of entity 2, and mandatory on the sides of entities 1,
3, and 4.
2. The relationships are optional on the side of entity 2 to entities 1 and 4, mandatory on the side of
entity 2 to entity 3, and mandatory on the sides of entities 1, 3, and 4.
3. The relationships are optional on the side of entity 2 to entities 1 and 3, mandatory on the side of
entity 2 to entity 3, mandatory on the sides of entities 1 and 2 and optional on the side of entitiy 3
Answer
In the first two models, the intersect Entity 2 represents a three-way or ternary relationship between
Entity 1, Entity 3, and Entity 4.
In the diagram, a ternary relationship involves a self-referencing relationship.

Assembly information such as Type and Method have been added to the Comprises entity.
This creates a three-way relationship between Parts both parent and child and Assembly.
4. Subtypes, supertypes, and arcs
Subtyping refers to the use of generalization and specialization in a model.

For example, if a company employs contractors as well as permanent staff, Employee is a
generalization of Contractor and Permanent.
718


Conversely, Contractor and Permanent are specializations of Employee.
The Contractor and Permanent entities are subtypes of the Employee entity.

And Employee is a supertype of Contractor and Permanent.
You allocate attributes specific to individual subtypes to those subtypes. And you allocate
common attributes to the supertype.

For example, you document attributes that can apply to all employees such as Last_Name
and First_Name against Employee.

And you document attributes that can apply to contractors only such as Rate or to
permanent staff only such as Salary against the respective entities.
You should be able to specify a primary key for each entity, regardless of whether it is a
supertype or subtype.

As long as you nominate a primary key for all the entities at one level of subtyping, you can
generate primary keys for the other levels.

For example, if Employee has a primary key of Employee_ID, you can use this attribute as the
primary key for both Contractor and Permanent.
Question
Let's say that you've modeled data using supertypes and subtypes.
What do you think happens when you reach the logical design phase?
Options:
1. You produce a subtype-free model
2. You represent all supertypes and subtypes in a relational model
3. You can level the subtype model by choosing a single level of generalization from each hierarchy
of subtypes
4. You can implement entities at multiple levels of generalization
Answer
Because you can't represent supertypes and subtypes in a relational model, you need to produce a
subtype-free model for the logical design phase.

You can do this by choosing a single level of generalization from each hierarchy of subtypes. Or you
can implement entities at multiple levels of generalization.
719

You can't represent subtypes or supertypes in an ER model.

So at the end of the modeling process, you need to produce a subtype-free model for the logical
database design.

But despite leveling the model in this way, you need to keep the version with the subtypes in
case you need to revise the leveling decisions later.
You can convert subtypes and supertypes into a relational model by implementing them at
a single level of generalization
multiple levels of generalization
You can level a model by choosing a single level of generalization from each hierarchy of
subtypes.

For example, you can discard Employee and implement its subtypes Contractor and
Permanent only.
Alternatively, you can discard Contractor and Permanent and implement their supertype
Employee only.
Because you can't discard attributes, you need to inherit the attributes of any supertypes and roll
up the attributes of any subtypes.

So if you implement Contractor and Permanent, each entity inherits the attributes such as
Last_Name and First_Name of Employee.
If you implement Employee, you need to roll up any attributes such as Rate and Salary
specific to Permanent and Contractor.
In this case, the Rate and Salary attributes are allowed NULL values.
A subtype, such as Permanent, may have a relationship to another entitiy, such as Benefit.

Once the Contractor and Permanent entities are rolled up into the Employee entity, the
relationship to Benefits becomes an optional relationship to the Employee entity.
If you implement entities at the supertype level, you need to add "type" attributes to maintain any
distinctions that the discarded subtypes represented.

For example, you could introduce an Employee_Type attribute to the Employee entity to
distinguish permanent employees from contractors.
You can convert subtypes and supertypes into a relational model by implementing entities at
multiple levels of generalization.
720


For example, you can define all three entities in the Employee hierarchy into the logical ERD.
You connect the entities by carrying the foreign key of Employee in the Contractor and
Permanent entities.

When using this method, you don't need to discard any concepts. But the method may lead to a
proliferation of entities.
When you implement entities at multiple levels of generalization, you may also create an entity
for the supertype and entities for some of the subtypes only.

This usually happens when some subtypes don't have any attributes or relationships in addition
to those of the supertype.

For example, you can create entities for Employee and Contractor only, and leave out the
Permanent subtype.
The exclusivity arc is a useful diagramming tool for generalizing relationships.

If individual 1:N relationships are mutually exclusive, you use an "exclusivity arc" in the ERD.

For example, the mutually exclusive 1:N relationships of Contractor and Permanent to Employee
enable you to use an exclusivity arc in the ERD.
The exclusivity arc can highlight opportunities to generalize relationships and suggest potential
entity supertypes.

You can generalize Contractor and Employee to Employee_Type, for example.
Summary
Complex relationships in database design include self-referencing or recursive relationships. In
a self-referencing relationship, the same entity appears at both ends of the relationship. This
relationship can be either one-to-many (1:N) or many-to-many (N:M).

You resolve an ordinary or a self-referencing N:M relationship by creating an intersection entity.
Intersection entities reduce redundant data and simplify the merging of related data.

A ternary relationship involves three or more entities. To record each allowable combination of
the entities, you define an additional entity. In this entity, each row holds an allowable
combination of the primary keys of the original entities.

You can use subtypes and supertypes when modeling data. But because you can't represent
supertypes and subtypes in a relational model, you need to level the model for the logical design
phase.
721

A database design Entity-Relationship model
Abstract
This case study analyzes an Entity-Relationship (ER) model based on a set of business
requirements. It focuses on the visual representation of the data requirements for an
organization and the relationships between those data structures.
Requirements for an Entity-Relationship model
Every logical Entity-Relationship (ER) model is based on a set of requirements.
In this case, the business requirements specify that a department should have a unique name
and belong to a geographical location. Each department must be managed by one manager
and have at least one employee. Employees must belong to one department only. And each
manager can manage one department only. All managers are employees, each manager must
manage at least one employee, and each employee should have an ID. The human resources
department records information on each employee. This information includes the last and first
names, address, date of joining the company, and salary.
Each department may be responsible for at least one project, and each project must be the
responsibility of a department. Each employee may work on many projects, and each project
must have at least one employee assigned to it. Projects have a start date and optional end
date.
Every logical Entity-Relationship (ER) model like the one in Figure 1 below is based on a
set of requirements.

Figure 1: ERD model
722

Analyzing the ER model
Because each department has a unique name, the Dept_Name attribute serves as the primary
key of the Department entity. Each department must have at least one employee, and
employees must belong to one department only. So a mandatory one-to-many (1:N)
relationship exists between Department and Employee.
Because each employee has a unique ID, Emp_ID serves as the primary key of the Employee
entity. Other attributes of the Employee entity include Last_Name, First_Name, Address,
Start_Date, and Salary. Because an employee must belong to one department only,
Dept_Name serves as a foreign key linking each employee with a department.
The Employee entity involves an optional/mandatory 1:N self-referencing relationship. The
Employee entity represents both participants in the relationship. In this relationship, each
manager may manage one or more employees, and each employee is managed by one
manager only. To implement this self-referencing relationship using a foreign key, you carry
the key of Employee Emp_ID as a foreign key called Manager_ID in the Employee table.
Because each department may be responsible for one or more projects, and each project
must be the responsibility of one department, an optional/mandatory 1:N relationship exists
between the Department and Project entities. The Project_Name attribute serves as the
primary key for the Project entity. Because a project may still be in progress, or its end date
may be unknown, the End_Date attribute allows NULL values. The Project table carries the
primary key of the Department table Dept_Name as a foreign key.
The requirements state that each employee may work on multiple projects, and multiple
employees may work on each project. This indicates an optional many-to-many (N:M)
relationship between the Employee and Project entities. However, a normalized table can't
represent N:M relationships with foreign keys. You can't hold the key to Project in the
Employee table because an employee could work on several projects. The same principle
applies to the Project table, which would need to support multiple Employee keys.
You resolve the N:M relationship between the Employee and Project entities by creating a
new entity to link the two original entities. So you create an intersection entity called
Works_On to resolve the N:M relationship between Employee and Project. The Works_On
entity has a composite primary key that consists of Emp_ID and Project_Name. Both these
attributes also serve as foreign keys in the Works_On table.
Summary
An Entity-Relationship (ER) model serves as the visual representation of a relational database
design. Each logical ER model is based on a given set of business requirements.
Diagramming conventions indicate the names of entities, business relationships between
entities, and the cardinality and optionality of the relationships.
A complete ER model should enable you to understand an organization's data and the
relationships that exist between its data structures.

723

Completing the logical database design
Learning objective
After completing this topic, you should be able to develop a complete logical database design
using advanced Entity-Relationship (ER) modeling techniques.
Exercise overview
In this exercise, you're required to develop a complete logical database design using advanced
Entity-Relationship (ER) modeling techniques.
This involves the following tasks:
stating recursive relationships
resolving N:M relationships
normalizing the logical model
Suppose that you are a database design specialist contracted to design a new database for
Brocadero Online University.

You have created a conceptual database design by identifying entities, attributes, and
relationships. You have also created an initial logical ER model by determining relationship
optionality, key attributes, and NULL attributes.

You now need to complete the logical ER model for the Brocadero Online University database.

To complete the exercise, you need to read the requirements document for Brocadero Online
University.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements Document
Read the requirements document for the Brocadero Online University.
Now view the conceptual ER model for the Brocadero Online University.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Conceptual ER Model
724

Study the conceptual ER model for the Brocadero Online University
Task 1: Stating recursive relationship
The requirements document for the Brocadero Online University indicates that a self-referencing
relationship exists in the ER model.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements Document
Read the requirements document for the Brocadero Online University.
Step 1 of 2
The model includes four entities: Student, Course, Module, and Instructor. The following
relationships exist: a many-to-many (N:M) non-identifying, optional relationship between Student
and Module; a one-to-many (1:N) non-identifying mandatory relationship between Course and
Module; and a many-to-one (N:1) non-identifying relationship between Module and Instructor,
optional on the Module side, and mandatory on the Instructor side.
Choose the self-referencing entity in the model.
Options:
1. Student entity
2. Course entity
3. Module entity
4. Instructor entity
Result
The Course entity is self-referencing.
Option 1 is incorrect. Students can enroll in one or more modules to complete a course. There is a
many-to-many (N:M), non-identifying, optional relationship between Student and Module, suggesting
that there is no self-referencing for the Student entity.
Option 2 is correct. Each course may be the prerequisite for other courses, and each course may
require other courses as prerequisites. In this way, the entity is self-referencing.
725

Option 3 is incorrect. Modules are the primary components of the system. There is a many-to-one
(N:1) non-identifying, optional relationship between Module and Instructor, suggesting that there is
no self referencing for the Modules entity.
Option 4 is incorrect. Instructors may present many modules, but each module must have an
associated instructor. There is a many-to-one (N:1), non-identifying relationship between Module
and Instructor. It's optional on the Module side and mandatory on the Instructor side; suggesting no
self referencing for the Instructor entity.
Step 2 of 2
Four versions of the Course entity are depicted. For all versions, the attributes are Co ID (PK),
Name, Description, and Prerequisite.
Choose the relationship that models the self-referencing Course entity correctly.
Options:
1. Mandatory/optional one-to-many (1:N)
2. Mandatory/optional many-to-many (N:M)
3. Optional N:M
4. Mandatory N:M
Result
The Course entity involves an optional, many-to-many (N:M) self-referencing relationship.
Option 1 is incorrect. The self-referencing 1:N relationship indicates that each course may include
one or more modules, but not that each module may only be a component of one course. This is not
true, as each module may be a component of one or more courses.
Option 2 is incorrect. The requirements state that a course can be the prerequisite for other courses.
The mandatory indicated by the model doesn't reflect this requirement, as a course may not have a
prerequisite.
Option 3 is correct. The Course entity involves an optional, many-to-many (N:M) self-referencing
relationship. The self-referencing N:M relationship indicates a course may be a prerequisite for other
courses and may require other courses as prerequisites. Because this relationship is many-to-many,
you can't represent it using a single table with a foreign key or keys.
Option 4 is incorrect. The mandatory constraint infers that all courses are prerequisites for other
courses. This contradicts the business requirements, in that some courses may not have
prerequisites.
726

Task 2: Resolving N:M relationships
The ER model for the Brocadero Online University has a number of many-to-many (N:M)
relationships that you need to resolve.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Conceptual ER Model
Study the conceptual ER model for the Brocadero Online University
Step 1 of 4
Let's say that you create two intersection entities called Prerequisite and Enrollment to resolve the
N:M relationships in the model.
Match each intersection entity with the correct relationship to resolve the N:M relationships.
Options:
1. Self referencing relationship with Course
2. N:M relationship between Student and Module
Targets:
A. Enrollment
B. Prerequisite
Result
You resolve the N:M relationship between Student and Module using the intersection entity
Enrollment.

And you resolve the self-referencing N:M relationship of Course using the intersection entity
Prerequisite.
The Course entity involves an optional, many-to-many (N:M) self-referencing relationship. A course
may be the prerequisite for other courses, and may require other courses as prerequisites.
Students can enroll in one or more modules to complete a course. There is a many-to-many (N:M)
non-identifying, optional relationship between Student and Module.
727

You now want to define identifying relationships between the intersection entities and their
associated identifying entities.

You define the primary key for Prerequisite as Parent_Co_ID and Child_Co_ID.

This composite primary key serves as the foreign key to the Course entity.
Step 2 of 4
The model includes six entities: Student, Course, Module, Instructor, Enrollment, and Prerequisite.
The following relationships exist: a (N:1) optional relationship between Student and Enrollment; a
(N:1) optional relationship between Module and Enrollment, a (N:1) optional/mandatory relationship
between Module and Instructor, a (N:1) mandatory/mandatory relationship between Module and
Course. The Prerequisite entity is shown in a self-referencing relationship with the Course entity.
Choose the logical constraint that defines the two relationships between the Course and
Prerequisite entities.
Options:
1. Optional/mandatory N:M
2. Mandatory/optional 1:N
3. Mandatory 1:N
4. Optional 1:N
Result
The two relationships between the Course and Prerequisite entities are mandatory/optional one-to-
many (1:N) relationships.
Option 1 is incorrect. The Optional/mandatory N:M suggests that many courses have many
prerequisites, and that they are all mandatory on the Prerequisite entity, which is not the case. A
course can be the prerequisite for other courses and may require other courses as prerequisites.
Option 2 is correct. A course can be the prerequisite for other courses, and it may require other
courses as prerequisites. This suggests that the relationships between the Course and Prerequisite
entities are mandatory/optional one-to-many (1:N) relationships.
Option 3 is incorrect. The Mandatory 1:N constraint suggests that each course must have a
prerequisite. This is not the case as a course may not have an Optional 1:N.
Option 4 is incorrect. The Optional 1:N constraint suggests that associating prerequisites to courses
is optional. This is not the case. if a course has a prerequisite, it is mandatory that the two be
associated.
Refer to the Brocadero Conceptual ER model.
728

Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Conceptual ER Model
Study the conceptual ER model for the Brocadero Online University
Step 3 of 4
The model includes six entities: Student, Course, Module, Instructor, Enrollment, and Prerequisite.
Let's say that you specify Student_ID and Mo_ID as the primary key for Enrollment. This composite
primary key serves as the foreign keys for Student.
Choose the logical constraint that defines the relationship between the Student and Enrollment
entities.
Options:
1. Optional/mandatory N:M
2. Mandatory/optional 1:N
3. Optional 1:N
4. Mandatory 1:N
Result
A mandatory/optional one-to-many (1:N) relationship exists between the Student and Enrollment
entities.
Option 1 is incorrect. The Optional/mandatory N:M is not appropriate as some courses can contain
the same modules as others, but the student does not need to retake these modules.
Option 2 is correct. Students may enroll in one or more modules to complete a course, suggesting
that a mandatory/optional one-to-many (1:N) relationship exists between the Student and Enrollment
entities.
Option 3 is incorrect. If a student wants to complete a course, it is mandatory that they take all
modules associated with that course. However the Optional 1:N constraint suggests that if a student
is taking a course, enrollment for individual modules is optional.
Option 4 is incorrect. The Mandatory 1:N suggests that it is mandatory that students enroll on every
module, which is not the case. Students need only enroll on the modules associated with the course
they are taking.
729

Step 4 of 4
The model includes six entities: Student, Course, Module, Instructor, Enrollment, and Prerequisite.
Choose the logical constraint that defines the relationship between the Module and Enrollment
entities.
Options:
1. Mandatory 1:N
2. Optional 1:N
3. Mandatory/optional 1:N
4. Mandatory/optional N:M
Result
A mandatory/optional one-to-many (1:N) relationship exists between the Module and Enrollment
entities.
Option 1 is incorrect. The Mandatory 1:N suggests that it is mandatory that students enroll on every
module, which is not the case. Students need only enroll on the modules associated with the course
they are taking.
Option 2 is incorrect. The Optional 1:N suggests that it is optional whether or not a student enrolls
on all the modules of a course he/she is taking. However, a student must enroll on all modules
associated with any course they are taking.
Option 3 is correct. Multiple students may take a single module, and all modules must belong to a
specific course. This suggests that a mandatory/optional one-to-many (1:N) relationship exists
between the Module and Enrollment entities.
Option 4 is incorrect. The Mandatory/optional N:M suggests that students can enroll for the same
module multiple times. However, a student can only enroll once on each module.
Task 3: Normalizing the logical model
As a result of resolving the many-to-many (N:M) relationships, you need to remove redundant
attributes from the model.

And you need to move some attributes to more appropriate entities.
You delete the Module attribute from the Student entity and the Prerequisite attribute from the
Course entity because these are resolved by the intersection entities.

730

And you move the Date, Result, Access, and Materials attributes from the Student entity to the
Enrollment entity.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Conceptual ER Model
Study the conceptual ER model for the Brocadero Online University
Step 1 of 2
The logical model is not yet complete because it's not in Third Normal Form (3NF) yet.
Choose the entity that's not in 3NF.
Options:
1. The Student entity, which has the attributes Student ID (PK), Last_Name, First_Name, Address,
Email, and Password.
2. The Enrollment entity, which has the attributes Student ID (PK, FK1), Mo ID (PK, FK2), Date,
Result, Access, and Materials.
3. The Course entity, which has the attributes Co ID (PK), Name, and Description.
4. The Module entity, which has the attributes Mo ID (PK), Co ID (FK1), Instructor ID (FK2), Name,
Objective, Duration, and Subscription.
5. The Instructor entity, which has the attributes Instructor ID (PK), Last_Name, First_Name,
Address, Email, and Password.
6. The Prerequisite entity, which has the attributes Parent Co ID (PK, FK1), Child Co ID (PK, FK2).
Result
The Enrollment entity is not in the 3NF.
Option 1 is incorrect. The Student entity is in 3NF because the Last_Name, First_Name, Address,
Email, and Password attributes are dependent on the Student ID (PK) primary key.
Option 2 is correct. The Materials attribute is dependent on the entity unique identifier (UID) through
the non-UID attribute Access. This indicates a transitive dependency and means that the Enrollment
entity is not in 3NF.
Option 3 is incorrect. The Course entity is in 3NF because the Name and Description attributes are
dependent on the Co ID (PK) primary key.
Option 4 is incorrect. The Module entity is in 3NF because the attributes Co ID (FK1), Instructor ID
(FK2), Name, Objective, Duration, and Subscription are dependent on the Mo ID (PK) primary key.
731

Option 5 is incorrect. The Instructor entity is in 3NF because the attributes Last_Name, First_Name,
Address, Email, and Password are dependent on the Instructor ID (PK) primary key.
Option 6 is incorrect. The Prerequisite entity is in 3NF because the Child Co ID (PK, FK2) attribute is
dependent on the Parent Co ID (PK, FK1) key.
Step 2 of 2
Suppose you define a surrogate key called Ac_ID to serve as the unique identifier (UID) for an entity
called Access. This identifier normalizes the Second Normal Form (2NF) entity Enrollment into 3NF.
Three variations of the relationship between the Enrollment and Access entities are described.
Which option models the requirements correctly?
Options:
1. There is a 1:N relationship between Access and Enrollment. The attributes of the Access entity
are Access (PK) and Materials (PK). The attributes in Enrollment are: Student ID (PK1, FK1) Mo
ID (PK, FK2), Date, Result, Access (FK3), and Materials (FK3).
2. There is a 1:N relationship between Access and Enrollment. The attributes of Access are Ac_ID
(PK), Access, and Materials. The attributes in Enrollment are Student ID (PK, FK1), Mo ID (PK,
FK2) Date, Result, and Ac_ID (FK3).
3. There is a 1:N relationship between Enrollment and Access. The attributes of Enrollment are
Student ID (PK, FK1), Mo ID (PK, FK2), Date, and Result. The attributes of Access are Ac_ID
(PK), Access, Materials, Student ID (FK1), Mo_ID (FK1).
Result
Ac_ID appears as the primary key in Access and as a foreign key in Enrollment. The Enrollment
entity is involved in a three-way ternary relationship.
Option 1 is incorrect. In this example, there is no mention of the Ac_ID key linking the Access and
Enrollment entities, therefore the Access entity is not in 3NF.
Option 2 is correct. In this example, both the Access and Enrollment entities contain the Ac_ID key.
The Ac_ID appears as the primary key in Access, and as a foreign key in Enrollment. The
Enrollment entity is involved in a three-way ternary relationship and therefore the Access entity is in
3NF.
Option 3 is incorrect. In this example, the Ac_ID is the primary key in the Access entity, but is not
mentioned as a foreign key in the Enrollment entity. Therefore there is no relationship between the
Access and Enrollment entities.
By determining self-referencing relationships, resolving N:M relationships, and normalizing the
ER model to 3NF, you have completed the logical database design for Brocadero Online
University database.
732

Implementing the database design
Learning objective
After completing this topic, you should be able to describe how to create the physical database
design based on the logical database model.
1. Determining the tables
In the first stage of physical database design, you transform the entities in the Entity-
Relationship diagram (ERD) into tables.

And you transform the attributes into columns
You can use a database generation tool to automate this process, or you can build the actual
DDL (Data Definition Language) statements that define the physical database manually.
The three types of tables in a relational database include
data tables
join tables
lookup tables
The most common tables in a relational database are data tables. Data tables represent single
classes of information in a database, such as information about an organization's employees,
events, or places.

Each data table has a primary key column that identifies a class of information.

But no columns in a data table are derived from calculations or concatenations.
Join tables or intersection tables are used to resolve many-to-many (N:M) relationships between
two tables.

They are usually defined during the logical design stage.
Users can use lookup tables, also called validation or code tables, to check their input against a
list of permissible datatypes for the fields to which they add data.

A State_Codes table, for example, may serve as a lookup table to validate the state names a
user enters in the State_Names table.

Lookup tables house lists of acceptable values for the columns of other tables.
733

Question
Suppose a database contains the related Employee, Works_On, and Project tables.
See if you can match the tables to their table types.
Options:
1. Data table
2. Join table
3. Lookup table
Targets:
A. Employee Table
B. Works_On Table
Answer
The Employee, and Project tables are data tables. The Works_On table is a join table.
All table types share a similar structure containing a
column
column name
row
table name
column
A column contains a single data value and datatype, so each column is unique to that table.

The data that a column contains is reduced to its smallest logical component. And a column
contains no data derived from calculations involving other columns.
column name
A column name identifies a column and is unique in a table.
row
A row has one value in each column of a table.
table name
A table name identifies a table and is unique in a database.
When you name the tables, you should follow naming conventions as you do when naming
entities for the logical database model.

734

Naming conventions are critical to the success of a database because they ensure table and
column name consistency throughout the database.
The more consistent a database's naming conventions, the more accurate and unambiguous the
developed database.

Naming conventions also eliminate any confusion that might arise during the implementation of
the physical database.
For medium-sized to large databases, you can implement a naming convention where identifiers
distinguish between similar aspects of different departments.

For example, you can distinguish between employees in the human resources department and
those in the sales department by naming the tables HR_Employees and Sales_Employees
respectively.
Common naming conventions result in unique table names throughout an organization.

So you should name the tables in a database descriptively but concisely, omit terms, such as
"table" or "file", and use the plural form, for example Employees.
When imposing table-naming conventions, you should consider the maximum character length
for tables that the Relational Database Management System (RDBMS) imposes.

You should limit the length of table names to a few characters short of the prescribed maximum
length to allow leeway in naming should the database evolve.
You should ensure that the table names do not limit the information the tables can contain.

For example, the table name Western_Region_Orders may restrict users to entering orders from
the western region only.

Instead, you could name the table Orders and include a Region column to enable users to enter
all order information into one table.
Question
Suppose that you are a database designer generating the physical database design for a large
company with several departments.

See if you can identify the table name that meets the naming conventions.
Options:
1. EMPLOYEES
2. PROJECT_SUPERVISOR
735

3. DEPARTMENTS_TABLE
4. HR_INVOICES
Answer
The table name HR_INVOICES meets all the naming conventions.
Option 1 is incorrect. In a large organization, the table name needs an identifier to indicate which
department its employees are from, so creating just an EMPLOYEES table is not sufficient.
Option 2 is incorrect. This table name is not in the plural form, and suggests that a table contains a
single name, for example just PROJECT_SUPERVISOR names. This is not sufficient for a large
company with several departments.
Option 3 is incorrect. This table name contains a redundant generic term table, so it is not concise.
Option 4 is correct. The table name HR_INVOICES meets all the naming conventions. It is plural,
concise and contains no redundant information. The name also meets the recommendation that
large databases distinguish table names by department which is done here using HR to represent
Human Resources.
2. Determining the column specifications
In the logical design phase, you identify keys, optional attributes, and required attributes.

So you determine most of a database's column specifications during the logical design phase.

In the first stage of physical database design, you transform the attributes in the ERD into
columns or fields.
Required attributes become columns that must have an associated NULL or NOT NULL value
for each row in a table.
CREATE TABLE PROJECTS (PROJECT_NAME VARCHAR(20) NOT NULL PRIMARY KEY,
START_DATE DATE NOT NULL,
END_DATE DATE,
DEPARTMENT_NAME VARCHAR(20));
Question
You use three levels of column specification when defining fields in a table.
See if you can match the levels of column specification with their associated field element.
Options:
736

1. Logical
2. General
3. Physical
Targets:
A. Column field
B. Data Type field
C. NULL and Constraint fields
Answer
Column specifications at the general level apply to the column field, at the physical level to the
datatype field, and at the logical level to the NULL Constraint fields.
Column specifications at the general level need to match the associated tables because users
need to access columns via the associated tables.

For example, users must be able to use syntax, such as Employee.First_Name, to access the
first names of employees in the Employees table.
When you specify the columns at the physical level, you refer to the permissible datatypes for a
column.

Datatypes are acceptable character sets and sizes for the values a column will contain, such as
character values, numeric values, and date and time values.

Examples of datatypes include NUMBER and CHAR.

Datatypes are specific to RDBMS software.
The precision of a column is its allowable size.

A column's precision is defined by a value in parentheses after the datatype.

For example, Number (6) in the Data Type column indicates a column that may contain
numerical values up to six characters long only.
Column specification at the logical level indicates whether a column can act as a primary or
foreign key in a database and whether it can allow NULL values.

In other words, it indicates whether a column must be unique, or whether it can have a NULL
value.

A NULL value indicates that a column may contain empty or unknown values.
737


Therefore, the values in the NULL column are N or Y.
Question
The Employees table has four fields: Column, DataType, Null, and Constraint. The values in the last
row are: Hours_Worked, Number (8), and Y.
See if you can identify the column specification level on which you specify that the Hours_Worked
field of the Employees table may contain a numeric value only.
Options:
1. General
2. Logical
3. Physical
Answer
You use the physical level of column specification.
Option 1 is incorrect. Column specifications at the general level apply to column names only; in this
case Hours_Worked is the general column name.
Option 2 is incorrect. Column specifications at the logical level apply to the NULL and other
constraint restrictions only; in this example Hours_Worked can be NULL.
Option 3 is correct. Column specifications at the physical level apply to the datatype field, in this
case the Hours_Worked field.
3. Denormalizing the design
When you generate the physical database design from a logical model, you may need to
denormalize the design.

To denormalize the logical design, you relinquish some of the advantages of the Third Normal
Form (3NF) to improve the database performance.
When you denormalize a database, you allow some of the data redundancy you initially
eliminated to re-enter the database.
Question
The following outlines a database design for a system that manages projects for a consultancy:
PROJECT
(#Proj_ID, Name)
738

PROJECT_TYPE
(#Proj_Type_ID, Proj_ID, Start_Date, End_Date)
PROJ_TYPE_STATUS
(#Proj_ID, #Proj_Type_ID, Status_ID)
STATUS
(#Status_ID, Status)

The design is in 3NF, and keys are identified by the # symbol. Due to performance problems, you
need to denormalize the design.

See if you can select the correct denormalized database design.

Note: # designates a primary key
Options:
1. PROJECT
(#Proj_ID, Name)
PROJECT_TYPE
(#Proj_Type_ID, Proj_ID, Start_Date, End_Date, Status_ID)
STATUS
(#Status_ID, Status)
2. PROJECT
(#Proj_ID, Name, Status_ID)
PROJECT_TYPE
(#Proj_Type_ID, Proj_ID, Start_Date, End_Date)
STATUS
(#Status_ID, Status)
3. PROJECT
(#Proj_ID, Name, Status_ID)
PROJECT_TYPE
(#Proj_Type_ID, Proj_ID, Start_Date, End_Date, Status_ID)
STATUS
(#Status_ID, Status)
4. PROJECT
(#Proj_ID, Name, Status_ID)
PROJECT_TYPE
(#Proj_Type_ID, Proj_ID, Start_Date, End_Date, Status_ID)
PROJ_TYPE_STATUS
(#Proj_ID, #Proj_Type_ID, Status_ID)
STATUS
(#Status_ID, Status)
739

Answer
The correct denormalized database design is

PROJECT
(#Proj_ID, Name, Status_ID)
PROJECT_TYPE
(#Proj_Type_ID, Proj_ID, Start_Date, End_Date,Status_ID)
STATUS
(#Status_ID, Status)
4. Creating indexes and views
You may need to create views and indexes when generating a physical database design from
an ERD.

Views and indexes are essential database components because they allow users an alternative
way to access the data in a database.
Views are virtual tables in a database that contain no data of their own.

Views exist once users use SQL SELECT statements to invoke them.
The only physical storage that views consume is the space required to store the query
containing the view definition.

Tables, on the other hand, consume storage space because they contain data.
Views act as windows that users can use to view base tables in a database.

Views select the columns that users want to view, or they generate new columns using a table,
view, or a combination of a table and a view.
Question
Why do you think views are useful in databases?
Options:
1. They are generally quicker to access than tables
2. They allow users to generate reports from different data perspectives
3. They support data independence
4. They simplify the way users use data
5. They reduce the amount of storage required by the database
740

Answer
Views are usually quicker to access than tables, allow users to generate reports from different data
perspectives, support data independence, and simplify data usage.
You can use views to name columns to display the same tables to groups of users with familiar
column names.

And you can use views as virtual columns to display results from calculations and
concatenations of existing tables.
In addition to views, you use indexes when generating physical database designs from an ERD.

Indexes are secondary access structures that allow users to search for records based on search
conditions.

Search conditions speed up the retrieval of data, and index structures allow users to use
alternative ways to access records, regardless of the placement of records on the disk.
When users search for records using indexes, they access the index first.

The user's search conditions point to areas on the file where the records they require are found.
Note
Index types include single-level ordered indexes, and multilevel indexes, also known as tree data
structures.
Summary
Table design is the first stage of physical database design. During table design, you create join,
data, and lookup tables. Tables consist of rows and columns that have row and column names.
You apply naming conventions when naming tables. For example, table names should be
concise and descriptive and should not contain generic terms, such as "table."

Once you have determined the tables in a database, you need to determine the column
specifications. Column specification can occur on the general, logical, and physical level.

You may need to denormalize the database design when generating the physical model.
Denormalization is the process of relinquishing some of the advantages of the Third Normal
Form (3NF) to improve the database's physical performance.

When generating the physical model, you create indexes and views. These allow users to
access the data in the database.
741

Creating a physical database design
Learning objective
After completing this topic, you should be able to develop the physical database design based on
the logical database model.
Exercise overview
In this exercise, you're required to develop a physical database design based on a logical
database model.
This involves the following tasks:
specifying the columns
denormalizing the design
defining views
Suppose that you're a database designer contracted to develop a database for the Brocadero
Online University. You have created a conceptual database design by identifying entities,
attributes, and relationships. You have also created an initial logical Entity-Relationship (ER)
model by determining relationship optionality, key attributes, and NULL attributes.

And you have completed the logical ER model by specifying recursive relationships, resolving
many-to-many (N:M) relationships, and normalizing the logical model. You now need to develop
the complete physical database design for the Brocodero Online University.

To complete the exercise, you need to read the documentation for Brocadero Online University.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Logical ER model
Display the logical ER model for the Brocadero Online University.
Now read more about the requirements for the Brocadero Online University.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements document
742

Display the requirements document for the Brocadero Online University
Task 1: Specifying columns
To determine the physical table design, you need to determine the column specifications except
those for the Enrollments table.

This involves determining the datatypes, NULL values, and constraints for columns for all tables.

Let's say you've completed all the table specifications except ENROLLMENT.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Logical ER model
Display the logical ER model for the Brocadero Online University.
Step 1 of 3
In the Enrollments table, the Student_ID and Mo_ID rows have NUMBER(8) in their Data Type
columns.
See if you can match the datatypes to the correct column names.
Options:
1. VARCHAR(10)
2. NUMBER(8)
3. DATE
Targets:
A. Date
B. Result
C. Ac_ID
Result
The Date field has a DATE datatype, whereas the Result field has a VARCHAR datatype, and the
Ac_ID field has a NUMBER datatype.
743

The VARCHAR datatype allows characters and numbers to be inserted into the data field. For
example, the result of a module might be "86 B Pass", suggesting that the student achieved a score
of 86, which is a B grade and counts as a pass for the module.
The NUMBER datatype allows only numbers to be inserted into the data field. Access Ids
associated with module materials, for example, might contain only numbers.
The DATE datatype allows only data which is in date format to be entered into the data field. It could
be used to record the date a student enrolled for a module, for example.
The Enrollments table now has NUMBER(8) datatypes in the Student_ID, Mo_ID, and Ac_ID
rows, the DATE dataype in the Date row, and the VARCHAR(10) datatype in the Result row.
Step 2 of 3
In the Enrollments table, the Mo_ID and Ac_ID columns have a NULL value of No.
See if you can match the column names to their correct NULL values.
Options:
1. Student_ID
2. Date
3. Result
Targets:
A. Yes
B. No
Result
Student_ID and Date do not allow NULL values, whereas the Result field does allow NULL values.
The Enrollments table now has NULL values of No for the Student_ID, Mo_ID, Date, and Ac_ID
rows, and a NULL value of Yes for the Result row.
Step 3 of 3
See if you can match the columns to their correct constraints.
Options:
1. Student_ID
2. Mo_ID
3. Ac_ID
744

Targets:
A. FK
B. PK, FK
Result
The Student_ID and Mo_ID columns are primary keys and foreign keys, whereas the Ac_ID column
is a foreign key.
Task 2: Denormalizing the design
One of the requirements for the Brocadero Online University is that it must perform well, so you
need to denormalize the database design where applicable.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements document
Display the requirements document for the Brocadero Online University
Step 1 of 1
See if you can identify the tables that you could denormalize to improve database performance.
Options:
1. Access
2. Enrollments
3. Instructors
4. Students
Result
You could denormalize Enrollment and Access to improve database performance.
Option 1 is correct. To denormalize the logical design, you relinquish some of the advantages of the
Third Normal Form (3NF). In this case you could remove the Access entity, as there is no real need
for it in this instance.
Option 2 is correct. When you denormalize a database, you allow some of the data redundancy that
was initially eliminated from it to re-enter. In this case you could remove the Ac_ID foreign key, and
include the Access and Materials attributes.
745

Option 3 is incorrect. The Instructors entity does not contain any redundant data, so it cannot be
denormalized.
Option 4 is incorrect. The Students entity is similar to the Instructors entity in that it does not contain
any redundant or repeated data, so it cannot be denormalized.
Task 3: Defining views
The requirements for the Brocadero Online University database indicate that creating a view
could be useful for processing information about student enrollments. The students' full names,
module names, and the results obtained are the required information.
Supplement
Selecting the link title opens the resource in a new browser window.
Brocadero: Requirements document
Display the requirements document for the Brocadero Online University
Step 1 of 2
See if you can identify the tables that would make up the Enrollments_View.
Options:
1. Enrollments
2. Modules
3. Prerequisites
4. Students
Result
The Students, Modules, and Enrollments tables make up the Enrollments_View.
Option 1 is correct. The Enrollments table is needed to create the Enrollments_View as it contains
the result the student has achieved in a module.
Option 2 is correct. The Modules table is needed to create the Enrollments_View as it contains the
names of all the modules the student has taken.
Option 3 is incorrect. The Prerequisites table is not required, as the Enrollments_View does not
include any prerequisite information.
746

Option 4 is correct. The Students table is needed to create the Enrollments_View as the full name of
the student is contained within the view.
Step 2 of 2
See if you can identify the fields that will make up the Enrollments_View.
Options:
1. Student_ID: NUMBER (8)
Last_Name: NUMBER (8)
First_Name: NUMBER(8)
Result: VARCHAR(10)
2. Student_ID: NUMBER(8)
Date: DATE
Mo_ID: NUMBER(8)
Name: VARCHAR(20)
3. Name: VARCHAR(20)
Last_Name: VARCHAR(20)
First_Name: VARCHAR(20)
Result: VARCHAR(10)
4. Name: NUMBER(8)
Last_Name: NUMBER (8)
Date: DATE
Result: VARCHAR(10)
Result
The Module_Name, Student_Last_Name, Student_First_Name, and Result fields make up the
Enrollment_View.
Option 1 is incorrect. This option includes the Student_ID from the Student entity, which is not
required for the Enrollment_View.
Option 2 is incorrect. This option only contains one of the required fields to make up the
Enrollment_View the Name from the Modules entity.
Option 3 is correct. The Enrollment_View takes all this data and constructs a condensed table,
where only the relevant information that is needed is shown in the view.
Option 4 is incorrect. This option includes the Date field from the Enrollments entity, which is not
required for the Enrollment_View.
You have now developed the Brocadero Online University's physical database by determining
column specifications and views and denormalizing the logical database design.
747

Databases v. Database Management Systems
Learning objective
After completing this topic, you should be able to differentiate between a database and a
Database Management System (DBMS).
1. What is a database?
A database is a collection of related information and comprises objects.

A database object called a "table" organizes information into a logical structure and provides
access to the information in the database.

For example, all employee numbers, employee names, first names, last names, salaries, benefit
packages, and managers comprise a table.
A database can comprise many related tables that together define all the information about a
"real" world system or model.

Users can modify the information in the database and retrieve information from it.

For example, if an employee is promoted to a new job level, the manager can update the
database to reflect the employee's new salary scale.
The business processes of an organization determine the data and the data processes in a
database.
For example, when Brocadero Online University receives an applicant for a Math course, the
secretary receiving the application has to
create an application number
enter the applicant's details
notify the math department
Database examples include
data warehouses
Geographical Information Systems (GISs)
Online Transactional-Processing (OLTP) databases
data warehouses
A data warehouse is used for extracting and analyzing information from large databases to make
business decisions.
748


Applications, such as an Online Analytical-Processing (OLAP) system, a Decision Support
System (DSS), and a data-mining application are used to gain access to a data warehouse.
Geographical Information Systems (GISs)
A GIS database stores and analyzes maps, satellite images, and weather data.
Online Transactional-Processing (OLTP) databases
An OLTP database processes data regularly from multiple transactions running at the same time.

The transactions usually process the same amount of data.

For example, an OLTP database includes dynamic data, such as the stock in a store, that is
updated regularly.
Question
What do you think are some of the benefits of using a database?
Options:
1. It enforces format and datatype standards
2. It has a flexible structure for updating information
3. It provides available and up-to-date information
4. It reduces the administration costs of an organization
5. It updates fields automatically
Answer
A database enforces format and datatype standards, has a flexible structure for updating
information, provides available and up-to-date information, and reduces the administration costs of
an organization.
Question
What is a data warehouse?
Options:
1. A database that stores maps
2. A database that regularly processes multiple transactions at a time
3. A large database from which you can extract and analyze information.
Answer
A data warehouse is a large database from which you can extract and analyze information.
749

Option 1 is incorrect. A Geographical Information Systems (GIS) database stores and analyzes
maps, satellite images, and weather data.
Option 2 is incorrect. An Online Transactional-Processing (OLTP) database processes data
regularly from multiple transactions running at the same time. The transactions usually process the
same amount of data. For example, an OLTP database includes dynamic data such as the stock
in a store that is updated regularly.
Option 3 is correct. A data warehouse is used for extracting and analyzing information from large
databases to make business decisions. Applications, such as an Online Analytical-Processing
(OLAP) system, a Decision Support System (DSS), and a data-mining application are used to gain
access to a data warehouse.
2. DBMS overview
You use a Database Management System (DBMS), which includes software programs and
applications, to query and update the information in a database.

For example, you can query how many days leave an employee has for the remainder of a year
by specifying this in the DBMS language.
Question
What do you think is the main difference between a database and a DBMS?
Options:
1. A database contains data, whereas the DBMS manages data
2. A database creates queries, whereas a DBMS saves and executes queries
3. A database contains data and creates queries, whereas a DBMS updates a database only
Answer
The main difference between a DBMS and a database is that a database contains data, whereas a
DBMS manages data.
In addition to data, a database contains
a catalog
constraints
a catalog
A catalog contains the definition of a database. This definition includes the database structure,
fields, datatypes, and the data storage format of each data item.
750


DBMS software packages use the catalog to determine the structure of database files for
processing queries.
constraints
Constraints are restrictions that database designers use to ensure data integrity in a database.

For example, if a database designer places a constraint on a column to accept only two-digit
numbers, the DBMS prevents a user from inserting a name into the column.
You use a DBMS to
control redundancy
enforce integrity constraints
provide backup and recovery capabilities
provide multiple user interfaces
manage complex relationships among data objects
restrict user access to parts of a table
control redundancy
You can use a DBMS to control redundancy.

Controlling redundancy ensures that data is stored once only, so it saves storage space and
reduces the time needed to update a database.
enforce integrity constraints
A DBMS enforces integrity constraints, such as datatype integrity.

Datatype integrity ensures that the correct datatype corresponds to the correct data item.
provide backup and recovery capabilities
A DBMS provides backup and recovery capabilities so that you can recover the database
information after a hardware or software failure.

The database must be restored to the state it was in before the hardware or software failure to
ensure that all the information is available.
provide multiple user interfaces
A DBMS provides multiple user interfaces, such as menu-driven interfaces, programming
language interfaces, and query languages.
manage complex relationships among data objects
A DBMS manages complex relationships among data objects in a database. These relationships
can comprise several related tables.

A DBMS enforces the relationship integrity between the related tables.
751

restrict user access to parts of a table
A DBMS restricts user access to parts of a table to secure database information.

Users or groups need authorization to gain access to a database or parts of the database.
Question
Identify the true statements about catalogs.
Options:
1. They are restrictions on the database
2. They contain the definition of a database
3. They determine the structure of database files
Answer
Catalogs contain the definition of a database and determine the structure of database files.
Option 1 is incorrect. Constraints are restrictions that database designers use to ensure data
integrity in a database. For example, if a database designer places a constraint on a column to
accept only two-digit numbers, the DBMS prevents a user from inserting a name into the column.
Option 2 is correct. A catalog contains the definition of a database. This definition includes the
database structure, fields, datatypes, and the data storage format of each data item.
Option 3 is correct. DBMS software packages use the catalog to determine the structure of
database files for processing queries.
Question
Why would you use a DBMS?
Options:
1. To control redundancy
2. To provide backup and recovery
3. To restrict user access
4. To store data such as maps
Answer
Reasons why you use a DBMS include to control redundancy, to provide backup and recovery, and
to restrict user access.
752

Option 1 is correct. Controlling redundancy ensures that data is stored once only, so it saves
storage space and reduces the time needed to update a database.
Option 2 is correct. A DBMS provides backup and recovery capabilities so that you can recover the
database information after a hardware or software failure. The database must be restored to the
state it was in before the hardware or software failure to ensure that all the information is available.
Option 3 is correct. A DBMS restricts user access to parts of a table to secure database information.
Users or groups need authorization to gain access to a database or parts of the database.
Option 4 is incorrect. You use a database such as a Geographical Information Systems (GIS)
database to store and analyzes maps, satellite images, and weather data.
3. Database users
Many people are involved in designing, creating, using, and maintaining a large database.
Database users can be divided into several categories:
database administrators and staff
database designers
end users
system analysts
database administrators and staff
A database administrator (DBA) oversees and manages database resources, which include the
database and DBMS. The DBA acquires software and hardware resources as needed and
authorizes access to the database to coordinate and monitor database use.

A database administrator (DBA) needs to solve problems, such as slow response times to
queries. In large organizations, the employees assist the DBA to carry out functions and run and
maintain DBMS hardware and software.
database designers
Database designers create a database structure to represent and manage resources before the
tables are populated with data. The designers interact with user groups to create views of the
database that meet their requirements.
end users
End users access a database to generate reports, query a database, and update the database.
End users can be casual end users, parametric or naive end users, sophisticated end users, or
standalone end users

Casual end users access a database infrequently by using a sophisticated database query
language to access information. Casual end users include middle-level to high-level managers
and those who browse the database infrequently.
753


Parametric or naive end users query and update a database using canned transactions, which
are standard queries and updates. Administrators, clerks, and personnel can be parametric or
nave users.

Sophisticated end users familiarize themselves with the facilities of a DBMS to implement their
customized applications. Sophisticated end users can comprise business analysts, engineers,
and scientists.

Standalone end users use software packages with GUIs to maintain personal databases. A user
using a financial package to maintain a personal budget is an example of a standalone user.

Nave end users only have to understand the types of standard transactions that they should use.
Casual users only use a few facilities repeatedly. Sophisticated users need to achieve complex
requirements and should therefore try and learn most of the DBMS facilities.
system analysts
System analysts develop specifications for canned transactions that meet the requirements of
parametric end users. System analysts are familiar with the full range of capabilities of a DBMS.

Application programmers use the specifications that system analysts produce to create canned
transactions. Application programmers, who are familiar with the capabilities of the DBMS, debug,
document, and maintain canned transactions.

Tool designers create and implement software packages that you can use to improve database
performance and facilitate the database system design and use. Tool designers are normally
independent software developers.
Each database user is responsible for different database related tasks, and the database
administrator (DBA) oversees the database and DBMS.

Database designers create the structure of the database, application programmers create
programs called canned transactions, and end users query and update the database with the
developed canned transactions.
Question
What type of database user oversees and manages database resources?
Options:
1. Database administrator
2. Database designer
3. Systems analyst
754

Answer
The database administrator oversees and manages database resources.
Option 1 is correct. A database administrator (DBA) oversees and manages database resources,
which include the database and DBMS. The DBA acquires software and hardware resources as
needed and authorizes access to the database to coordinate and monitor database use.
Option 2 is incorrect. Database designers create a database structure to represent and manage
resources before the tables are populated with data. The designers interact with user groups to
create views of the database that meet their requirements.
Option 3 is incorrect. System analysts develop specifications for canned transactions that meet the
requirements of parametric end users. System analysts are familiar with the full range of capabilities
of a DBMS.
Summary
A database contains coherent and logical information, which users can design, build, populate,
query, and update. Examples of databases include data warehouses, Decision Support Systems
(DSSs), Geographical Information Systems (GISs), Online Analytical-Processing (OLAP)
databases, and Online Transactional-Processing (OLTP) databases.

A Database Management System (DBMS) includes software programs and applications that
allow end users to query and update the data in a database. A DBMS controls redundancy,
enforces integrity constraints, provides backup and recovery capabilities, provides multiple user
interfaces, represents complex relationships among data objects, and restricts user access to
parts of a database.

A database administrator (DBA) oversees a database and DBMS. Database designers create a
database with input from potential users. Application programmers create programs that end
users use to query and update a database.






755

Database requirements
Abstract
This article describes the user requirements that a database need to meet. These requirements
include acceptable performance, adequate security, and data availability.
Requirements for a good database
Introduction
A good database needs to be able to retrieve and update information based on user
requirements. The features of a good database include acceptable performance, accurate
data, adequate storage, available data, minimized redundant data, and secure data. The
database needs to meet users requirements.
Acceptable performance
A database should process queries and enable users to update the database in reasonable
times.
Factors that determine the performance of a database include the network hardware, network
speed, application design, and database design. To solve a database performance problem,
you need to isolate the problem. For example, you need to determine realistic expected
response times for queries, and you need to determine how the database performs during
batch operations.
Accurate data
The database data must be accurate. You use constraints to control the accuracy of the data.
You apply these constraints at column level to ensure that users enter the correct datatype,
such as characters or decimals. Users can update the data inaccurately even when the
database manages the data properly.
Precautions that you can take to ensure data accuracy include
applying foreign key constraints for referential integrity
applying data integrity constraints
establishing code tables for common data
Adequate storage
The primary function of a database is storing data. Factors that affect data storage include
hardware, database software programs, types of data stored, and the operating system on
which the database runs.
You need to ensure that you have enough hard-disk space, archive unnecessary online data,
and use a database model that is capable of storing the estimated volume of data.
756

Available data
Data availability refers to the time it takes for a database to process a query and display the
result on screen.
You need to schedule database downtime to ensure that users can access the database
during business hours. To improve data availability, you need to have a well-designed
database, and you can improve the applications that perform the queries and updates.
Minimize redundant data
When you minimize redundant data, you do not have to update the database in different
places. Redundant data can also be inconsistent and inaccurate. Minimizing redundant data
saves storage space, reduces inaccurate and inconsistent data, and saves time. You minimize
redundant data through a process called normalization that you apply to the tables in a
database.
Secure data
You need to ensure the security of data in a database because a database can easily become
corrupt if you do not secure it.
To secure a database, you need to limit access to user groups. Every user should access the
database using a password with specific data-access privileges. You also need to prevent
unauthorized external users from accessing the database.
Summary
When you design a database, you should ensure that it meets the requirements of all the
database users. The database needs to be accurate, have adequate storage, have fast
response times, and have high availability. You also need to minimize redundant data for
better performance and ensure that the data is secure from unauthorized access.










757

A sample database system
Abstract
This case study describes a sample database system comprising tables with rows and columns
that users manipulate by using the Database Management System (DBMS).
An example of a database system
Introduction
A database is a storage system that contains related information, which users can query and
update.

Database system
Users use application programs to access a database and to update or query the database.
The Database Management System (DBMS) software processes the queries. The stored data
contains the definition of the database and the database information. The definition of the
database metadata contains the datatypes, constraints, and the database structure.
Database structure
A database comprises tables. A table is the primary unit of physical storage of data in a
database. A table requires physical storage space hard disk space on the computer
hosting the database.
Employees table
Employee Number First Name Last Name Salary Benefit Package Manager
02456 Sally McMahon 15500 Package C No
758

Employees table
Employee Number First Name Last Name Salary Benefit Package Manager
00764 Keisha Wallace 20200 Package B No
08463 Mark Robinson 10500 Package D No
09562 Brad Clements 34000 Package A Yes
Tables include columns and rows. A column specifies a category of information in a table. For
example, in an Employees table, the Employee Number column can contain employee IDs.
You assign a datatype to columns to ensure that users use that type only to populate the
column. Datatypes can be numeric, alphanumeric, or date and time. For example, in the
Employees table, the datatype of the Employee Number column is numeric. When a user
enters characters or the date and time, the DBMS does not update the field.
A row in a table is a collection of information associated with a specific occurrence. In the
Employees table, a row can contain information, such as employee number, name, salary,
and benefit package for each employee.
You can assign a primary key to a specific column in a table, which uniquely identifies each
row in a table. Primary keys ensure that rows are not duplicated in a table.
Database relationships
Relationships can exist between tables so that a child table can store information referenced
in a parent table. You use foreign keys in the child table to reference the parent table. For
example, the Benefits table is linked to the Employees table by the Benefits Package column,
which is the foreign key. The Benefits table is a child table of the Employees table.
Benefits table
Benefit Package Benefit 1 Benefit 2 Benefit 3 Benefit 4 Days leave
Package A Pension Medical aid Car allowance Travel allowance 20
Package B Pension Medical aid Car allowance 17
Package C Medical aid Car allowance 16
Package D Medical aid 15
To gain more information about the benefit package that Sally McMahon receives, you need to
look it up under Benefit Package C. In this case, Sally McMahon has medical aid and a car
allowance. She also has 16 days leave per annum.
When users manipulate the data, they can either change the structure of the database, which
changes the metadata, or they can change the stored information. Application programmers
create an interface for users to manipulate data. A typical application can comprise forms.
Users can use these forms to create, delete, or modify rows in a table.
Summary
759

A database consists of tables that store information. Tables have columns that contain specific
information and datatypes. Each row contains information about the specific occurrence in the
table, such as an employee's details. Primary keys uniquely identify columns so that users
can't duplicate rows. Relationships can exist between tables so that child tables can store
additional information.

























760

Database models
Learning objective
After completing this topic, you should be able to describe the evolution of database models.
1. The evolution of the database
A database designer can choose one of several database models.
Database types include the
Flat-file database
Hierarchical database
Network database
Relational database
Object-oriented database
Object-relational database
Flat-file database
In the early days of computing, many companies stored their data in flat files on a host computer.
Hierarchical database
The hierarchical database improves on the flat-file database by establishing and maintaining
relationships between groups of data.

The architecture of a hierarchical database is based on relationships between parent and child
tables.
Network database
In a network database, tables are related to one another like those in the hierarchical database,
but the parent tables share relationships with child tables.
Relational database
The relational database is the most popular database model because it simplifies data
management, data retrieval, and change propagation management.

In a relational database, the main storage unit is a table.

To ensure data consistency between related tables, you use constraints.
Object-oriented database
In an object-oriented database, you define, store, and access data using an object-oriented
programming language, such as C++, Visual Basic, or Java.

761

You use a select object-oriented programming language to create an application, which you can
use to interact with a relational database.
Object-relational database
The object-relational database combines the concepts of the relational database with the object-
oriented programming approach.

Because the ISO has integrated object-relational concepts into the SQL3 or SQL99 standard,
vendors can use object-relational concepts in their relational databases.
Question
See if you can rank the database models from the earliest to the most modern.
Options
Option Description
A Network database
B Relational database
C Flat-file
D Hierarchical database
E Object-relational database model
Answer
Correct ranking
Option Description
C Flat-file
The flat-file database is essentially just a text file. In the early days of computing, many
companies stored their data in flat files on a host computer.
D Hierarchical database
The hierarchical database improved on the flat-file database by establishing and maintaining
relationships between groups of data. The architecture of a hierarchical database is based on
relationships between parent and child tables.
A Network database
In a network database, tables are related to one another like those in the hierarchical database,
762

Correct ranking
Option Description
but the parent tables share relationships with child tables.
B Relational database
The relational database is the most popular database model because it simplifies data
management, data retrieval, and change propagation management. In a relational database,
the main storage unit is a table.
E Object-relational database model
The object-relational database combines the concepts of the relational database with the
object-oriented programming approach. In an object-oriented database, you define, store, and
access data using an object-oriented programming language, such as C++, Visual Basic, or
Java.
2. Comparing database models
To compare database models, you can consider their architecture, benefits, and disadvantages.
Flat-file database
Hierarchical database
Network database
Relational database
Object-orientated database
Object-relational database
Flat-file database
A flat-file database consists of one or more files, usually in a text format. Data is stored as fields,
which can have either a constant length or a variable length separated by a delimiter.

In this example of the flat file with constant length fields, the ID number always starts in Column
#1 and ends in Column #4.

An example of a simple 6-row table is shown. The first row reads; 1234, Ernest Hemingway,
Islands in the Stream. The second row reads; 5678, Tom Robbins, Still Life with Woodpecker.
The third row reads; 4321, Ernest Hemingway, To Have and Have Not. The fourth row reads;
8765, Jane Austen, Emma. The fifth row reads; 4523, Jack London, Call of the Wild. Finally the
sixth row reads; 3456, Leo Tolstoy, Anna Karenina.

The table is displayed as a flat file with variable length fields separated by a delimiter a colon in
this example:
763


The table rows now read:
1234 : Ernest Hemingway : Islands in the Stream; 5678 : Tom Robbins : Still Life with
Woodpecker; 4321 : Ernest Hemingway : To Have and Have Not; 8765 : Jane Austen : Emma;
4523 : Jack London : Call of the Wild; 3456 : Leo Tolstoy : Anna Karenina.

The variable length fields could result in ID numbers ending in different columns, followed by a
delimiter, such as a colon. The composer names following the IDs would then start in different
columns.

You should ensure that the delimiter is not a character that can be found in the data.

With a flat-file database, you can experience data access, retrieval, and data integrity problems.

And you need to develop a data management program and store redundant data.
Hierarchical database
In a hierarchical database, a parent table points to child tables containing related data.

For example, an Employment Agencies parent table can have child tables in this case, Job
Sectors and Applicants.

Job Sectors can be a parent table to a Companies table, and Applicants can be a parent table to
Skills and Experience tables.

A three-tier hierachical database is shown. The parent table is Employment Agencies. The child
tables are Job Sectors and Applicants. Companies is the child table of Job Sectors, while Skills
and Experience are the child tables of Applicants.

Although a parent table can have many child tables, each child table can have one parent table
only. And you can access a child table through its parent table only.

In the hierarchical structure, a pointer links related tables by indicating the physical location of a
child record

In a hierarchical database, you can retrieve data quickly and manage data integrity easily, but you
need to store redundant data.
Network database
In a network database, you can enable parent tables to share relationships with child tables, so a
child table can have multiple parent tables.

In this model, you can access data starting with any table in the structure by navigating either up
or down in the hierarchy.

764

A three-tier hierachical database is shown. The parent table is Employment Agencies. The child
tables are Job Sectors and Applicants. Companies is the shared child table of Job Sectors and
Applicants, while Skills and Experience are the child tables of Applicants.

In the network database, the relationship between tables is called a set structure in which one
table is the owner and another is a member.

When an application program accesses a network database, it uses set structures to navigate to
parts of the database.

So if you modify the set structure, you also need to modify application programs that access the
database.

In a network database, you can access data quickly starting with any table, and you can model
complex databases, which can process complex queries.

But in this database, it can be difficult to modify the database structure, and changes to the
structure can adversely affect the applications used to access the database.
Relational database
In a relational database, data is organized in tables comprising rows and columns.

Each row is associated with an individual record, and each column contains values for all the
rows associated with a specific field.

Keys, which are common column values, are used to link tables. Types of table relationships are

one-to-one

one-to-many

many-to-many

A relational database is shown comprising the following tables: Companies, Job Sectors,
Employment Agencies, Applicants, Experience and Skills.

To define table relationships through referential integrity, you use primary key and foreign key
constraints to validate data and manage the relationship between parent and child tables. You
can also create other types of constraints

A relational database has no root or parent table, although parent and child relationships between
tables exist.

A parent table can have multiple child tables and a child table can have multiple parent tables.

765

In a relational database, you can

manipulate data effectively

manage data integrity easily

develop application programs easily

But developers and database administrators (DBAs) need to know the relationships between
tables and to join tables for data retrieval. And they need to know SQL.
Object-orientated database
You use an object-oriented programming language to create a compatible object-oriented
database and end-user application. An object-oriented database management system (DBMS)
links a database and an application.

The basic structures in an object-oriented database are objects and literals.

Objects have identifiers through which you can associate an object with other objects, and
literals, which don't have identities, are values associated with objects.

Two objects are depicted: APPLICANT and ADDRESS. Applicant is a class. Its properties are
LastName, FirstName and Phone, all of type VARCHAR. The objects' operation is
RetrieveAddress(). This operation is the identifier which associates it with the second object
ADDRESS. This object has the following properties: StAddr, City, State, and Zip, all of type
VARCHAR.

Objects and literals are organized by type. All elements of a type have the same set of properties,
which you can modify for an individual object.

A class is the equivalent of a table in a relational database.

You use the object query language (OQL) to manage data in an object-oriented database.

You can manage objects easily in an object-oriented database, and much of the application
program process is automated.

But developers and database administrators (DBAs) need to know object-oriented concepts, the
standards for the database model have not been finalized, and the database model is not yet
completely stable.
Object-relational database
By combining the concepts of the relational database model with object-oriented programming,
the object-relational model combines aspects of relational and object-oriented models.

766

Three objects are depicted: EMP, CONTRACTOR and TERMS. There is a column name and a
corresponding type in the EMP table: EMP_DATA is of type CONTRACTOR, JOB_INFO is of
type TERMS, and PHONE is of type NUMBER. The CONTRACTOR object has the categories
LAST_NAME, FIRST_NAME and E-MAIL, which are all of type VARCHAR. The TERMS object
has the categories DURATION, RATE, and CONTRACT, which are also all of type VARCHAR.

This example is of an object-relational implementation in a Relational Database Management
System (RDBMS).

Two user-defined types have been created Contractor and Terms and each type has columns
that define specific data for a column in the base table.

For example, the Emp_Data column in the Employees table has a type of Contractor. You can
break down Contractor into the categories Last_Name, First_Name, and E-mail.

An object-relational database has a 3-D architecture, and you can create user-defined types in
the database. But developers and database administrators (DBAs) need to understand both
object-oriented and relational concepts. And some vendors, which implement object-relational
concepts, do not support object inheritance.
Most organizations choose the relational database.

The relational database is stable and versatile, and SQL facilitates data management.

Additionally, referential integrity and other constraints ensure data protection.
Question
Identify the true statement about relational databases.
Options:
1. Data is organized in tables comprising rows and columns
2. They consist of one or more files in text format
3. You can have a many-to-many relationship
4. You can make use of a primary key
Answer
In relational databases, data is organized in tables comprising rows and columns, you can have a
many-to-many relationship, and you can make use of a primary key.
Option 1 is correct. Each row is associated with an individual record, and each column contains
values for all the rows associated with a specific field.
767

Option 2 is incorrect. A flat-file database consists of one or more files, usually in a text format.
Option 3 is correct. In many-to-many relationships, many instances of one entity are associated with
many instances of another entity. The classic example of a many-to-many relationship is that of
'orders' and 'parts', with each order consisting of many parts and each part usable in many orders.
Option 4 is correct. To define table relationships through referential integrity in a relational database,
you use primary key and foreign key constraints to validate data and manage the relationship
between parent and child tables.
Question
Identify the true statements about a flat-file database.
Options:
1. They can have fields of constant length
2. They can make use of a primary key
3. They can use delimiters
4. They consist of one or more files in text format
Answer
A flat-file database can have fields of constant length, consist of one or more files in text format, and
can use delimiters.
Option 1 is correct. In a flat-file database, data is stored as fields, which can have a constant length.
For example, the first field in a database can have a length of 25 characters.
Option 2 is incorrect. Relational databases use primary keys to define table relationships through
referential integrity.
Option 3 is correct. In a flat-file database, data is stored as fields, which can have either a constant
length or a variable length separated by a delimiter. A delimiter, such as a colon, separates the
different data columns. You should ensure that the delimiter is not a character that can be found in
the data.
Option 4 is correct. A flat-file database consists of one or more files, usually in a text format. With a
flat-file database, you can experience data access, retrieval, and data integrity problems.
Summary
Database models have developed over the years so that database designers have various types
to choose from. Database models include flat-file, hierarchical, network, relational, object-
oriented, and object-relational databases.
768


Each model has its own architecture, benefits, and disadvantages. However, most organizations
choose the relational database. Relational databases are stable and versatile, and SQL
facilitates data management. Constraints are used to ensure referential integrity, which protect
data.

























769

Database architectures
Learning objective
After completing this topic, you should be able to describe the structure and evolution of
database architectures.
1. Centralized architecture
Early database systems used a mainframe environment.

Early mainframe environments implemented a centralized Database Management System
(DBMS) architecture.
In a mainframe environment, multiple users connect to a powerful mainframe computer through
dumb terminals.

The mainframe computer provides the main processing for all functions of the system, including
user-application programs, user interface programs, and all the DBMS functionality.
Dumb terminals have no processing power they provide display capabilities only. All
processing takes place centrally.

Dumb terminals can communicate with the main computer only.

In the modern mainframe environment, if independent processing is required for tasks like word
processing, a PC with terminal emulation software is used. This PC can be additionally
networked as part of a client/server system.
Question
Which database model do you think was most used on early mainframes?
Options:
1. Flat-file
2. Network
3. Object-relational
4. Relational
Answer
On early mainframes, data was usually stored in flat files.
770

When PC hardware became less expensive, many organizations replaced terminals with PCs
and workstations. And many organizations used terminal emulation software to integrate these
machines into their mainframe networks.

Although database systems initially used these computers in the same way they had used
display terminals, DBMS systems started using processing power at the user side.

This process led to the development of client/server DBMS architectures.
Question
Identify the true statements about mainframe environments and dumb terminals.
Options:
1. Dumb terminals perform all the processing
2. Multiple users can connect to the mainframe
3. The mainframe uses a centralized DBMS
Answer
When using mainframe environments and dumb terminals, multiple users can connect to the
mainframe, and the mainframe uses a centralized DBMS.
Option 1 is incorrect. Dumb terminals have no processing power; they provide display capabilities
only. All processing takes place centrally. Dumb terminals can communicate with the main computer
only.
Option 2 is correct. In a mainframe environment, multiple users connect to a powerful mainframe
computer through the use of dumb terminals.
Option 3 is correct. Early mainframe environments implemented a centralized Database
Management System (DBMS) architecture. The mainframe computer provided the main processing
for all functions of the system, including user-application programs, user interface programs, and all
the DBMS functionality.
2. Client/server architecture
Currently, most organizations implement a client/server environment.

Client/server architecture deals with computing environments in which a large number of PCs,
workstations, file servers, printers, database servers, web servers, and other equipment are
connected via a network.
The main components of a client/server environment are
771

a server
one or more client machines, such as PCs or workstations
The server or main computer contains the database.

You can define dedicated servers, such as file servers, printer servers, web servers, or e-mail
servers.

Users access the database on a server via a client machine.
An application on the client machine enables a user to access the database on the server.

The application transfers requests for data or transactions via the network to the database on
the host server.
A client/server framework is the basis for
relational DBMS (RDBMS) architecture
object-oriented DBMS architecture
relational DBMS (RDBMS) architecture
Many RDBMSs started as centralized systems before the user interface and application programs
were moved to the client side. The query and transaction functionality remained at the server
side. So the server is often called a query or transaction server. In RDBMSs based on SQL, the
server is often called a SQL server.

The Open Database Connectivity (ODBC) standard provides an application programming
interface (API). The API enables client-side programs to call the DBMS on the server side, as
long as both sides have the necessary software installed. The related standard for Java is called
Java Database Connectivity (JDBC.)

The DBMS returns any query results to the client program to process or display.
object-oriented DBMS architecture
An object-oriented DBMS divides its software modules between the client and server in a more
integrated way than RDBMSs.

For example, software on the server level may handle buffering and caching of disk pages,
whereas the client level may handle the user interface and functions, such as query optimization.

In this type of client/server environment, the DBMS modules handle the client/server interaction.
The server is sometimes called a data server because it provides data in disk pages to the client.
The client-side DBMS software can then structure the disk pages into objects for the client
programs.
772

A disadvantage of a client/server environment is that you need to reinstall and reconfigure the
application on each client machine when a new version of an application appears.

The main benefit of a client/server environment is that client machines can perform some of the
application processing, so the clients relieve the overall load on the server.
The ability of PCs to process applications, enhances user productivity.

For example, a user can be connected to a database on a server while working with a document
simultaneously.
Question
Identify the true statements concerning a client / server environment.
Options:
1. An application on the client machine enables access to the database
2. The server contains the database
3. There are a number of computers connected via a network
4. You can use a dumb terminal to connect to the server
Answer
In a client / server environment, there are a number of computers connected via a network, the
server contains the database, and an application on the client machine enables access to the
database.
Option 1 is correct. The application transfers requests for data or transactions via the network to the
database on the host server.
Option 2 is correct. You can define dedicated servers, such as file servers, printer servers, web
servers, or e-mail servers. Users access the database on a server via a client machine.
Option 3 is correct. Client/server architecture deals with computing environments in which a large
number of PCs, workstations, file servers, printers, database servers, web servers, and other
equipment are connected via a network.
Option 4 is incorrect. Dumb terminals are used in a mainframe environment. They have no
processing power and provide display capabilities only. All processing takes place centrally on the
mainframe.
773

3. N-tier architecture
The term "n-tier" means that you can divide an application into any number of logical layers in
multiple configurations.

The concept of n-tier architecture is a development of three-tier client/server architecture, which
comprises a client layer, an application layer, and a server or database layer.
You use programs partitioned into tiers to develop and manage each layer or component
independently.

Additionally, in n-tier frameworks you can simplify and unify a mix of applications, interfaces, and
cross-platform networks.

This ensures a flexible and scalable distributed computing environment.
The Internet-computing environment is an example of an n-tier network-computing model.
Question
In an Internet-computing environment, the application is transparent to end users.
What do you think you need in an Internet-computing environment?
Options:
1. An Internet connection
2. A supported web browser installed on a PC
3. A web server
4. More than one web server
Answer
In an Internet-computing environment, you need to install the application on a single web server
only. You also need an Internet connection and a supported web browser installed on a PC.
You use a web browser to connect to the destination URL of a web server.

The web server accesses the database and returns the information you requested to the web
browser.

The web browser then displays the results on a PC.
774

Because the application needs to be installed, configured, and modified on the web server only,
it reduces the risk of inconsistent configurations and software incompatibility between client and
server machines.
4. Distributed database architecture
A distributed-computing system consists of multiple processing components that can be
heterogeneous.

The components are connected via a computer network, and they work together to perform
assigned tasks.
Multiprocessor system architectures include
shared disk (loosely coupled) architecture
shared memory (tightly coupled) architecture
shared nothing architecture
shared disk (loosely coupled) architecture
In shared disk architecture, multiple processors share secondary (disk) storage. But each
processor has its own primary memory.
shared memory (tightly coupled) architecture
In shared memory architecture, multiple processors share primary memory and secondary (disk)
storage.
shared nothing architecture
In shared nothing architecture, each processor has its own primary and secondary (disk)
memory.

The processors communicate via a high-speed interconnection network a bus or switch.

In a shared nothing multiprocessor system, hardware and operating systems are homogeneous
at each node.
In shared memory and shared disk architectures, processors can communicate without the
overhead of exchanging messages via a network.

DBMSs based on shared memory, shared disk, or shared nothing architecture are called parallel
database management systems.
The sites of a Distributed Database (DDB) may be linked via a LAN, a WAN, or a combination of
the two types.

A Distributed Database Management System (DDBMS) is a software system that manages a
775

DDB.

The design of a DDBMS determines its performance.
DDBMS software needs to provide the following functions in addition to those of a centralized
DBMS:
data tracking
distributed query processing
distributed transaction management
replicated data management
distributed database recovery and security
distributed directory management
data tracking
DDBMS software needs to keep track of data distribution, fragmentation, and replication by
enlarging the DDBMS catalog.
distributed query processing
DDBMS software needs to access remote sites and transmit queries and data among the sites
via a communication network.
distributed transaction management
DDBMS software needs to devise execution strategies for queries and transactions that access
data from multiple sites.

Additionally, the software needs to synchronize the access to distributed data and maintain the
integrity of the whole database.
replicated data management
DDBMS software needs to be able to decide which copy of a replicated data item to access.

The software is responsible for maintaining the consistency of copies of a replicated data item.
distributed database recovery and security
A DDB should be able to recover from individual site crashes and the failure of communication
links.

Additionally, DDBMS software should manage data security and the access user privilege.
distributed directory management
DDBMS software needs to manage the distributed directory, which contains metadata.

The directory may be global for the whole DDB or local for every site.
DDBs are popular because they
776

enable expansion
provide reliability and availability
provide high performance
enable the management of distributed data with different transparency levels
enable expansion
Using a DDB, you can expand a system by adding data or processors or by increasing database
sizes.
provide reliability and availability
Because DDBs distribute data and DBMS software over multiple sites, one site may fail while
other sites continue to operate.

You can also replicate data and software at more than one site.

This provides good database reliability and availability.
provide high performance
Through data localization, a DDBMS keeps data close to where it's needed most. This reduces
the contention for CPU and I/O services and access delays, so small local databases improve
local query and transaction performance.

Additionally, you can execute multiple queries at different sites or break up a query into
subqueries that execute in parallel.
enable the management of distributed data with different transparency levels
A DBMS should hide the details of where files are physically stored in a system. You need to find
a balance between ease of use and the overhead cost of providing distribution transparency.

In network transparency, users are unaware of the operational details of a network, whereas in
replication transparency, users are unaware of the existence of data copies.

And fragmentation transparency makes users unaware of the splitting of global queries into
several fragment queries.
Question
In which multiprocessor system architecture do processors share memory and disk resources?
Options:
1. Loosely coupled
2. Shared nothing
3. Tightly coupled
777

Answer
In tightly coupled architectures, processors share memory and disk resources.
Option 1 is incorrect. In shared disk (loosely coupled) architecture, multiple processors share
secondary (disk) storage. But each processor has its own primary memory.
Option 2 is incorrect. In shared nothing architecture, each processor has its own primary and
secondary (disk) memory. The processors communicate via a high-speed interconnection network
a bus or switch.
Option 3 is correct. In shared memory (tightly coupled) architecture, multiple processors share
primary memory and secondary (disk) storage.
Question
What functions does a DDBMS provide?
Options:
1. Data tracking
2. Distributed transaction management
3. Replicated data management
4. Shared memory
Answer
Among other things, a DDBMS provides data tracking, distributed transaction management, and
replicated data management.
Option 1 is correct. The DDBMS software can be used to keep track of data distribution,
fragmentation, and replication by enlarging the DDBMS catalog.
Option 2 is correct. The DDBMS software can be used to devise execution strategies for queries
and transactions that access data from multiple sites. Additionally, the software can also
synchronize the access to distributed data and maintain the integrity of the whole database.
Option 3 is correct. The DDBMS software can be used to decide which copy of a replicated data
item needs to access. The software is responsible for maintaining the consistency of copies of a
replicated data item.
Option 4 is incorrect. Shared memory is a type of multiprocessor system architecture. In shared
memory architecture, multiple processors share primary memory and secondary (disk) storage.
778

Summary
Early Database Management Systems (DBMSs) implemented a mainframe environment with a
centralized architecture. A mainframe computer processes data and sends the display
information to the requesting terminals.

Most organizations implement a client/server environment often in conjunction with a
mainframe system. Users connect to a database on a server from one or more client machines.
An application on the client provides access to the database on the server via a network.
Relational DBMSs (RDBMSs) and object-oriented DBMSs are both found on a client/server
framework.

In n-tier architecture, you can divide an application into any number of logical layers in multiple
configurations. Internet computing is an example of the n-tier model. You install the application
on a single web server. Additionally, you need an Internet connection and a supported web
browser installed on a PC.
A distributed database (DDB) consists of multiple processing components connected via a
computer network. DDBs enable expansion, as well as the management of distributed data with
different transparency levels. And DDBs provide reliability, availability, and high performance.













779

Designing a database architecture
Learning objective
After completing this topic, you should be able to design a database.
1. Exercise overview
In this exercise, you're required to design client/server and n-tier Distributed Database (DDB)
architecture.
This involves the following tasks:
designing client/server platforms
designing an n-tier DDB architecture
2. Task 1: Designing client/server platforms
Suppose you want to link the clients on your client/server network configuration.
Question
You have a client/server network configuration that is not n-tier and consists of two clients and a
server. How should the clients be linked?
Options:
1. They should not be linked
2. They should be linked to the server
3. They should be linked to one another only
Answer
In a client/server network the client machines should each be linked to the server.
3. Task 2: Designing an n-tier DDB
You have to build an n-tier distributed database architecture. You want one application server to
host all the database servers.
780

Question
Is the following statement true or false?
The application server is positioned between the client and the database server.
Options:
1. TRUE
2. FALSE
Answer
The application server is positioned between the client and the database server.
You have now designed client/server and n-tier DDB architecture.















781

OLTP databases v. data warehousing
Abstract
This article describes Online Transaction-Processing (OLTP) databases and data
warehouses, and it compares the characteristics of an OLTP database with those of a data
warehouse.
Online Transaction-Processing (OLTP) databases
Online Transaction-Processing (OLTP) databases use SQL queries so that users can query
and update the database with real-time responses. OLTP databases are designed for online
data processing with simple storage requirements because data is deleted from the OLTP
database regularly. An OLTP database should also be able to roll back and support the
frequent updating of information because the dynamic data can change frequently.
The components of an OLTP database include normalized tables, which users can query and
update with SQL. The tables are normalized to reduce redundancy, so they use storage space
economically and they improve database performance.
Data warehouses
A data warehouse centrally stores information that is integrated from various databases. Data
warehousing can help provide a competitive advantage to organizations because it enables
business analysts to determine market trends. This analysis can influence the organization's
business goals and operations.
Historic data from different databases is cleaned, reformatted, and merged before data access
tools load the data into the data warehouse. Typically, historic data is taken from OLTP
databases, which recorded all the business transactions.
The changes caused by transformation are mapped in catalogs or dictionaries. Data defining
or describing data in the warehouse is called metadata. Metadata consists of concepts that
users need to know, such as column and table definitions. Metadata also maps data elements
to their original databases.
Business analysts use Online Analytical-Processing (OLAP) applications, such as Executive
Information Systems (EISs), and data mining to analyze the historical data.
An OLTP database v. data warehouse
OLTP database characteristics Data warehouse characteristics
Smaller disk space More disk space for redundancy
Read/write system Read-only system
Runs day-to-day operations of a business Contains data for analyzing the business
Highly volatile data Historic static data
782

An OLTP database v. data warehouse
OLTP database characteristics Data warehouse characteristics
Highly normalized for performance Uses redundancy for performance
Relational or hierarchical model Relational or multidimensional design
Secure data Compromises previously secure data
No integration, cleaning, or uploading Consolidation processes and problems
Data warehouse considerations
Before you create a data warehouse, you need to determine the design costs and ensure that
the organization will receive a return on its investment.
The data warehouse is a high-maintenance information storage system. You need to capture
the changes to the warehouse design and databases, which provide the warehouse with data
continuously. Unless you maintain the data warehouse, the decisions that the business
analysts obtain from the data will be unreliable.
Summary
Online Transaction-Processing (OLTP) databases store day-to-day business transactions,
which users can query and update. Because OLTP database tables are normalized, these
databases use storage space economically and provide fast database read and write
functionality.
A data warehouse stores information from various databases. This information is cleaned,
merged, and uploaded into the data warehouse database. Business analysts analyze the
historic data that the data warehouses store. Executive Information Systems (EISs), data-
mining, and Online Analytical-Processing (OLAP) applications can be used to analyze the
historic data in a data warehouse.








783

Oracle RDBMS and ORDBMS
Abstract
This article describes Oracle9i's roles as a relational database management system and as an
object relational database management system.
Introduction
A relational database management system (RDBMS) allows you to administer the database
objects in a relational database. An object relational database management system
(ORDBMS) extends this functionality to user-defined and large database objects as well.
Relational database management systems (RDBMS)
An RDBMS is the basis of nearly all databases in use today. Relational databases consist of
tables and the relations between these tables. An RDBMS manages the physical
implementation of a database, rather than requiring that a user do this. Users query the
database using a query language such as structured query language (SQL). Relations rely on
the identity of columns, which have headings that indicate the attributes that they represent.
The rows of a column or relation are known as tuples. A relation or table name, together with
the corresponding attributes, make up a relational schema.
Traditional applications consisted of a fixed collection of datatypes, such as characters and
integers. An RDBMS, however, can perform far more complex queries.
Object relational database management systems (ORDBMS)
An ORDBMS allows more complex data representation by extending relational database
systems with object-oriented technology. The main contribution of an ORDBMS is its handling
of complex object-centric, persistent data while continuing to support the RDBMS querying
methods such as SQL for operating on that data. An ORDBMS supports more complex
datatypes and user-defined datatypes, which greatly increases the application domains to
which an ORDBMS can be applied.
Features of Oracle9i
Oracle9i is both a standard relational database management system (RDBMS) and an object
relational database management system (ORDBMS). As an ORDBMS, Oracle9i allows you to
create, store, and manage complex business models, multimedia, and large database objects,
as well as standard database objects such as tables and views. When used as an ORDBMS,
Oracle9i remains compatible with relational databases.
Oracle9i improves the performance of online transaction processing applications by
supporting larger buffer caches and deferrable constraints, as well as the sharing of run-time
data structures.
784

Oracle9i consists of two major products Oracle9i Database and Oracle9i Application Server
which combine to form a complete infrastructure for Internet database applications. In simple
terms, you use Oracle9i Database to store data and Oracle9i Application Server to support
server applications.
Oracle9i Database
In addition to object relational data, Oracle9i Database can store Extensible Markup Language
(XML), multimedia data such as graphics and video, Microsoft Word documents, Microsoft
PowerPoint presentations, and spreadsheets.
The Oracle server also includes security features controlling how the database is accessed
and provides for data consistency and protection with the use of locking mechanisms. Data
warehousing in Oracle9i includes enhancements to parallel execution of data manipulation
operations, partitioning, and parallel-aware query optimization. This makes Oracle9i more
powerful and able to support a wider set of features, datatypes, and applications than earlier
versions of Oracle.
Oracle9i Application Server
Oracle Application Server provides integration between users, applications, and data. It also
supports
Java transactional applications
business intelligence applications
portals and web sites
Oracle9i and the Internet
Because it is able to store and manage Web content, Oracle9i Database can support Internet
development and deployment. It provides the feature set supported by previous versions
including features such as data management, data warehousing, and transaction processing
for the Internet.
Oracle9i offers a wide range of development tools. It allows developers to write packages,
functions, and stored procedures in SQL, PL/SQL, or Java.
The three major components of the Oracle Internet Platform are
databases for processing business logic and to serve data
application servers for processing business logic and presenting server logic to
clients
browser-based clients for processing information presentation
This Oracle Internet technology and Oracle's built-in application development tools allow for
less expensive custom applications
enhanced customer and supplier interaction
information sharing across platforms
785

support of distributed and multitiered client/server and Web-based applications






















786

The Oracle9i database server
Learning objective
After completing this topic, you should be able to describe the main components of an Oracle9i
database server.
1. Features of an Oracle9i database server
access to large amounts of data by multiple concurrent users
high performance, availability, and reliability
data security
compatibility and connectivity
access to large amounts of data by multiple concurrent users
Oracle supports databases that contain terabytes of data.

In addition, Oracle allows administrators full control over space usage in databases, enabling
them to use expensive hardware devices efficiently.

Oracle allows multiple users that operate different database applications to access the same data
at the same time.

This feature reduces data contention and provides data concurrency.

In distributed network environments, Oracle combines the data stored on several computers into
one logical database that all users can access.

A distributed system has the same user transparency and data consistency as a nondistributed
system, and a distributed system has the advantages of local database management.
high performance, availability, and reliability
Oracle provides high availability because normal system operations, such as partial computer
system failures and database backups, do not interrupt database use.

Oracle is consequently suitable for organizations that need to access a database all the time.

Oracle software allows administrators to replicate data to multiple sites, and the software
supports the replication of changes to data and database schemas to these sites.

The Oracle replication technology supports basic primary site replication, as well as advanced
dynamic and shared-ownership replication models.
data security
787

Oracle provides security features that limit and monitor access to data.

These features also facilitate the management of complex designs for data access.

Oracle allows database administrators to control the availability of data in a database.

For example, they can disallow the use of a specific application so that they can reload the
application's data without affecting other users.

Oracle enforces business rules that set standards for acceptable data.

This feature ensures data integrity and therefore reduces the cost of checking data in many
database applications.
compatibility and connectivity
Oracle is an open system it adheres to industry standards for data access language, user
interfaces, network communication protocols, and operating systems.

Because Oracle is compatible with industry standards and operating systems, Oracle applications
are portable the applications work on almost all operating systems with little or no modification.

Oracle software allows different operating systems and types of computers to share information
across networks.

Oracle supports the Simple Network Management Protocol (SNMP) standard for system
management.

SNMP allows administrators to use a single administration interface to manage heterogeneous
systems.
Question
What features does the Oracle9i database server support?
Options:
1. Access to small amounts of data only by a single user
2. Compatibility and connectivity
3. Data security
4. High performance and availability
Answer
The Oracle9i database server supports compatibility and connectivity, data security, and high
performance and availability.
788

Option 1 is incorrect. Oracle allows access to large amounts of data by multiple concurrent users.
Oracle supports databases that contain terabytes of data. Oracle allows multiple users that operate
different database applications to access the same data at the same time.
Option 2 is correct. Oracle provides high performance and availability because normal system
operations, such as partial computer system failures and database backups, do not interrupt
database use.
Option 3 is correct. Oracle provides security features that limit and monitor access to data. Oracle
allows database administrators to control the availability of data in a database. For example, they
can disallow the use of a specific application so that they can reload the application's data without
affecting other users.
Option 4 is correct. Oracle is an open system; it adheres to industry standards for data access
language, user interfaces, network communication protocols, and operating systems. Oracle
software allows different operating systems and types of computers to share information across
networks.
2. The object-relational database model
relational model
object-relational model
relational model
A relational database model stores data in two-dimensional tables.

Database administrators can define the relationships between the tables by linking them to each
other by one or more common fields.

A relational database model has three characteristics structures, operations, and integrity rules.

Structures are objects such as tables, views, or indexes that store or access data.

Operations are clearly defined actions that allow users to manipulate data and structures.

Integrity rules are laws that protect data and structures by dictating the operations that users can
perform.

The benefits of the relational database model include independent physical data storage,
flexibility in database design, easy and variable access to data, and reduced redundancy and
reduced data storage.
object-relational model
789

An object-relational model allows users to define object types and use them in a relational
database.

Users specify both the structure of the data in the object type and the operations that they can
perform on the data in a relational database.

An object type has a unique name, attributes consisting of native or user-defined datatypes, and
methods that implement operations on data.

Object types represent real-world objects and allow users to extend the modeling capabilities that
native datatypes provide.

This enables relational databases to store complex business models.

For example, a user can define an object that represents the invoices or purchase orders that
application programs handle.
Question
What are the features of an object-relational model DBMS?
Options:
1. It allows users to define object types
2. Does not allow user-defined object types
3. Object types represent real-world objects
Answer
The features of an object-relational model DBMS are that they allow users to define object types,
and object types represent real-world objects.
Option 1 is correct. An object-relational model allows users to define object types and use them in a
relational database. Users specify both the structure of the data in the object type and the
operations that they can perform on the data in a relational database.
Option 2 is incorrect. The object-relational model allows users to define object types and use them
in a relational database.
Option 3 is correct. In an object-relational model, object types represent real-world objects and allow
users to extend the modelling capabilities that native datatypes provide. This enables relational
databases to store complex business models. For example, a user can define an object that
represents the invoices or purchase orders that application programs handle.
790

3. Tasks of a database administrator
The tasks of a database administrator include planning and creating an Oracle database.
Planning a database involves evaluating database server hardware, assessing storage and
security needs, and determining a backup strategy.
Creating a database involves installing or upgrading Oracle software, allocating system storage,
and enrolling users.
database availability
physical database structures
logical database structures
storage based on design
security
database availability
To manage database availability, a database administrator needs to plan and create backup and
recovery strategies.
physical database structures
A database administrator implements the physical structure of a database design by creating
datafiles, redo log files, and control files, and managing their size.
logical database structures
A database administrator has to create primary database objects tables, views, and indexes
once developers have designed an application.
storage based on design
A database administrator alters the database structure in response to information received from
application developers.
security
A database administrator has to protect a database from unauthorized access and control and
monitor user access to the database.
The tasks of a database administrator include tuning a database.

This involves monitoring and modifying the database to ensure optimal performance.
Question
What is a database administrator responsible for?
Options:
791

1. Database availability
2. Defining object types
3. Logical database structures
4. Security
Answer
Among other things, a database administrator is responsible for database availability, logical
database structures, and security.
Option 1 is correct. One of the duties of a DBA is to manage database availability; a database
administrator needs to plan and create backup and recovery strategies.
Option 2 is incorrect. A DBA is not concerned with the actual structure of the data in a database.
The database users specify both the structure of the data in the object type and the operations that
they can perform on the data in a relational database.
Option 3 is correct. A database administrator implements the logical structure of database design by
creating tablespaces and managing their size.
Option 4 is correct. A database administrator has to protect a database from unauthorized access
and control and monitor user access to the database.
4. Components of a database server
an Oracle server
processes
key files
an Oracle server
An Oracle server is an Object-Relational Database Management System (ORDBMS).

The server always consists of an instance and a database.

The memory structures, files, and processes on the server execute SQL statements and manage
the database.
processes
A user process and a server process are the primary processes involved when Oracle executes a
SQL statement.

Many other processes are used by Oracle options such as Advanced Queuing and Real
Application Clusters.
key files
792

Key files are nondatabase files that administrators use to configure an instance, recover a
database, and authenticate user privileges.
Users access an Oracle database through an instance, which opens only one database.
An Oracle instance is a combination of a System Global Area (SGA) and background
processes.
Question
What do you think an SGA is?
Options:
1. An area of memory allocated to an instance that stores shared data and control information about
an Oracle server
2. An area of memory allocated exclusively to a process that stores data and control information
about an Oracle server
3. A virtual area of memory reserved by an Oracle server for recording the configuration of an
instance
Answer
When an instance starts up, Oracle allocates an area of memory, known as the SGA, to it. The SGA
stores data and control information about the Oracle server that is shared by the database
processes.
The background processes that comprise an instance perform maintenance tasks for a server.

These tasks include handling input/output and monitoring other processes to optimize
performance and reliability.
data files
redo logs
control files
data files
Data files store all the data in a database. A data file is associated with only one database and
can extend automatically when the database needs more space.

Oracle reads data in the data files in response to user requests, and it stores the data in a
memory cache.

When other users request the same data, Oracle accesses the memory cache.

793

Oracle writes data in response to user operations to a memory cache.

Oracle writes the data in the memory cache to the data files when required.
redo logs
Redo log files record all data modifications to data.

Every Oracle database has two or more redo log files that together comprise the redo log.

Redo log files protect a database against system or media failures that prevent Oracle from
writing new or modified data to data files.

Once the database reopens, Oracle applies the changes in the redo log file to the restored data
files.
control files
Every Oracle database has a control file that stores the information necessary to maintain and
verify database integrity.

Entries in the control file specify the physical structure of the database.

These entries include the database name, the timestamp of database creation, and the names
and locations of data files and redo logs.
An Oracle server uses the following three key files that are not part of the physical database:
the parameter file stores parameters that define the characteristics of an instance
the password file authenticates users to start or shut down an instance
the archived redo log files, which are optional offline copies of redo logs
Question
Within the structure of an Oracle database, which files record all modifications to data?
Options:
1. Data files
2. Control files
3. Redo files
Answer
Within the structure of an Oracle database, redo files record all modifications to data.
Option 1 is incorrect. Data files store all the data in a database. A data file is associated with only
one database and can extend automatically when the database needs more space.
794

Option 2 is incorrect. Every Oracle database has a control file that stores the information necessary
to maintain and verify database integrity. Entries in the control file specify the physical structure of
the database.
Option 3 is correct. Every Oracle database has two or more redo log files that together comprise the
redo log. Redo log files protect a database against system or media failures that prevent Oracle
from writing new or modified data to data files.
Question
An Oracle server uses key files that are not part of the physical database.
What key file allows an administrator to configure an instance?
Options:
1. The archived redo log file
2. The parameter file
3. The password file
Answer
The parameter file allows an administrator to configure an instance.
Option 1 is incorrect. The archived redo log files, which are optional, are offline copies of the redo
logs.
Option 2 is correct. The parameter file stores parameters that define the characteristics of an
instance of Oracle. An instance is an interactive session that a user opens in order to communicate
with an Oracle database.
Option 3 is incorrect. The password file authenticates users to start or shut down an instance of
Oracle.
5. Connecting to a database
a user process
connection
server process
a user process
Applications or tools that access an Oracle database are executed as user processes.
connection
795

A connection acts as a communication pathway between a user process and an Oracle server.

Depending on the configuration of the system in which the Oracle instance is running, the host
operating system, network software, or an application server establishes the connection.
server process
In the most basic configuration, a server process is created on the computer running the Oracle
server when a user logs on to the server.

The server process communicates between the user process and the Oracle instance,
processing requests on behalf of the user.
A session is the connection of a specific user to an Oracle server.

A session starts when an authenticated user connects to the server and ends when the user
logs off.

A user can run multiple concurrent sessions by logging on to the Oracle server using different
tools or computers simultaneously.
Summary
An Oracle database can handle large amounts of data and concurrent users, and it can provide
high performance, availability, and security. An Oracle database also provides ease of
administration and cross-platform compatibility.

Oracle uses the object-relational database model. This model allows a relational database to
store complex business models.

The tasks of a database administrator include the planning and creation of databases and the
management of database availability, structures, storage, security, and performance.

Oracle architecture has several components including the Oracle server, processes, and key
files. An Oracle database server consists of an Oracle instance and an Oracle database. The
physical database consists of control files, redo log files, and data files. Oracle uses key
nondatabase files - the parameter file, the password file, and archived redo log files.

To access an Oracle database, a user must connect to an Oracle instance. This involves a user
process, which communicates via a connection to a server process on an Oracle server. Each
connection of a user to an Oracle instance is known as a session.



796

Relational Database Concepts
Learning objective
After completing this topic, you should be able to describe relational database concepts.
1. An introduction to relational databases
A relational database comprises a collection of related data in tables.

Users can access and modify data in a database, depending on their permissions.
Dr. Edgar Codd introduced the relational database model in a paper entitled "A Relational Model
Data for Large Shared Data Banks" in 1970.

In his paper, Codd identifies 11 rules that provide a standard method for determining whether a
database is relational.

And these rules are designed to reduce data redundancy and ensure data integrity.
Codd's rules are based on the premise that the data in a database should be stored in tables.

According to these rules, you should be able to locate an entry in a table based on the table
name, field name, and primary key value.
Question
What do you think are the advantages of using the relational database model?
Options:
1. It has a 3-D architecture
2. It is stable
3. It comprises a wide selection of relational database products
4. It uses referential integrity and constraints to protect data
Answer
The advantages of a relational database are that it is stable, comprises a wide selection of relational
database products, and uses data referential integrity and constraints to protect data.
2. Fundamental concepts
The relational database model is based on the following concepts:
797

data independence
simple structure
set-oriented processing
To ensure data independence, the relational database model differentiates between the logical
and physical aspects of database management.

Using a simple structure for a relational database enables users to share information about the
data easily.

A set-oriented relational database enables the processing of multiple sets of records for a single
statement query.
The main components of the relational database model include its
structure
manipulations
behavior
The structure of the relational database model is based on a relation or a table of data.

The relational model is not based on relationships or connection between tables.

The relational database model consists of manipulations or a series of operators that you can
use to convert one set of relations to another.
Question
Which of the following do you think regulates the behavior of a relational database model?
Options:
1. A set of operators that transforms relations
2. Integrity rules that protect the consistency of a database
3. The relationships between the data
4. A tabular structure
Answer
The integrity rules, which protect the consistency of the database, regulate the behavior of a
relational database model.
Question
What are the fundamental concepts of the relational database model?
798

Options:
1. Data independence
2. Flat-file structure
3. Set-oriented processing
4. Simple structure
Answer
The fundamental concepts of the relational database model are data independence, set-oriented
processing, and simple structure.
Option 1 is correct. The relational database model differentiates between the logical and physical
aspects of database management to ensure data independence.
Option 2 is incorrect. The flat-file structure is essentially just a text file. In the early days of
computing, many companies stored their data in flat files on a host computer.
Option 3 is correct. A set-oriented relational database enables the processing of multiple sets of
records for a single statement query.
Option 4 is correct. Using a simple structure for a relational database enables users to share
information about the data easily.
3. The relational model
Codd's relational model presents the database as a set of relations.

Each relation represents a table of data that consists of values.
You use the table and column names to understand the values in a row.

The rows in the table represent a set of connected data values.

Whereas all the values in a row are related to each other, all the values in a column include the
same type of data.
On a logical level, the relational model represents information about entities and relationships in
a table.
In the relational model, the parts of a table are labeled and defined as follows:
attribute
domain
tuple
799

relation
attribute
In the relational model, an attribute is the smallest data structure.

An attribute is also known as a field, and gives its name to the column header in a table.

An attribute takes its value from an appropriate domain.

In the example, the Number_of_Publications column heading in the Lecturers relation is
highlighted. The other fields in the relation are: Last_Name, First_Name, Course, and
Qualification.
domain
In the relational model, a domain is a set of atomic values and can be specified by defining a
datatype. The datatype describes the kind of values a column can contain.

You can specify a name and format for a domain or other information that assists with interpreting
the values in a domain.

For example, a domain for an online university could be department_student_numbers.
tuple
In the relational model, a row is referred to as a tuple.

A tuple consists of a collection of attribute and value pairs. Each tuple is linked to an entity.

If the values in a tuple are unknown or don't apply to that tuple, you use a NULL value.

In the example, the single tuple in the Lecturers relation is highlighted. The attributes and their
values for this tuple are as follows: Last_Name Laura, First_Name Wells, Course
Economics, Qualification PHD, and Number_of_Publications 14.
relation
In the relational model, a table is referred to as a relation. Each relation is derived from entities
defined during data modeling.

You use a relation to represent information at a logical level. A table or relation consists of a set
of tuples.

In the example, the entire Lecturers table/relation and its tuples are highlighted.
Some relations (or tables) present information about entities, and others present information
about relationships.
800

Question
Match the different parts of a table to their definition.
Options:
1. Attribute
2. Domain
3. Tuple
Targets:
A. Describes the kind of values a column can contain
B. Known as a field
C. Referred to as a row
Answer
In a table, an attribute is known as a field, a domain describes the kind of values a column can
contain, and a tuple is referred to as a row.
In the relational model, an attribute is the smallest data structure. An attribute is also known as a
field, and gives its name to the column header in a table. An attribute takes its value from an
appropriate domain.
In the relational model, a domain is a set of atomic values and can be specified by defining a
datatype. The datatype describes the kind of values a column can contain. You can specify a name
and format for a domain or other information that assists with interpreting the values in a domain.
In the relational model, a row is referred to as a tuple. A tuple consists of a collection of attribute and
value pairs. Each tuple is linked to an entity. If the values in a tuple are unknown or don't apply to
that tuple, you use a NULL value.
4. Normalizing the relations
When you model existing data, you first need to normalize the data.

When users update data in a database, delete data, or insert data, they may cause this data to
appear in more than one location in the database.
You normalize a relation by removing and reducing redundant data and ensuring that only
related data is stored in a relational database table.

When you normalize data in a database, you need to ensure that the database carries the same
information that it carried before you normalized the data.
801


You can reduce redundancy by breaking down the database into smaller tables so that you can
identify the redundancies.
To start normalization and remove any data that can misrepresent relations, you use a set of
rules comprising Normal Forms 1 through 5.

In most cases, you use the Normal Forms 1 through 3 only.
5. Modeling the database
When you design a relational database system, you use an Entity-Relationship diagram (ERD)
to transform the data requirements of a business into logical data structures.

You use these logical structures to define the relationships between data.

These logical structures become the physical tables, columns, and rows of the actual database.
An ERD consists of data flow diagrams (DFDs) that organize the written requirements into
categories and allow you to map the relationships between categories.
You use an ERD to model data because it is easy for developers and users to understand data
presented in this way.

Data modeling is an iterative process, and you can easily adapt an ERD to accommodate any
required changes to the model or data.
Summary
A relational database consists of a collection of related or associated data stored in tables. Dr.
Edgar Codd introduced the relational database model in a paper in 1970. In the paper, Codd
identifies 11 rules that characterize the relational database.

The relational database model is based on data independence, simple structure, and set-
oriented processing. These concepts ensure that the data is accurate, that information can be
shared easily, and that multiple queries can be processed.

The relational model represents information about entities and relationships in a table of data. In
the relational model, the parts of a table are defined as attributes, domains, relations, and
tuples.

In database design, you need to normalize the relations or tables by removing and reducing
redundant data to ensure that only related data is stored in a relational database table.

When you design a relational database system, you use an Entity-Relationship diagram (ERD)
802

to transform the data requirements of a business into logical data structures. You use these
logical structures to define the relationships between data. These logical structures become the
physical tables, columns, and rows of the actual database.





















803

Relational database characteristics
Abstract
The article briefly covers the structure and the characteristics of relational databases. The
relational database characteristics outlined in the article are derived from Codd's 13 rules
for relational databases.
Introduction
Relational databases are widely used because many users can access a database easily, the
database ensures a high level of data integrity, and users can query the data easily.
Database structure
A relational database comprises a collection of tables or relations. Each table comprises a
number of rows and columns. The information in the columns and rows is expressed as
atomic values. These values exist in their simplest form and can't be subdivided into
subcategories.
Relationships exist between tables sharing data. Tables can be related to each other by a
column value. The column value can by either a primary key or a foreign key. A primary key is
a unique identifier, and a foreign key references a primary key in another table, and it ensures
that parent tables are created before child tables. These keys therefore ensure data integrity.
Relational database characteristics
The characteristics of a relational database distinguish it from other types of databases, such
as the object-related database. These characteristics are derived from Codd's rules, which are
the guidelines for all relational databases.
Codd's rules
Dr. Edgar Codd, who is considered the founder of the relational database, described the
relational database model in a paper entitled, " A relational Model of Data for Large Shared
Data Banks" in 1970. In a subsequent paper, Codd describes 13 rules to which a database
must adhere before it could be considered relational.
Rule 0
This rule states that a database can be called relational only if it adheres to all the guidelines
of a relational database, so the rule ensures a general standard for determining whether a
database is relational. Using this rule decreases the likelihood of manufacturers falsely selling
relational databases that adhere to a few rules only.
Rule 1
804

This rule states that data in a relational database can be stored as values in tables only. This
ensures that data is reduced to its simplest form, and it helps to reduce the redundant entries
in a database.
Rule 2
This rule states that you should be able to locate any entry in a table based on the value in the
primary key value, field name, and table name. This rule ensures that you can access
information in any row in a table without having to know where the data is stored.
Rule 3
This rule states that you should be able to enter NULL values into a relational database
systematically. NULL values may be used to represent inexplicable and unknown data.
Rule 4
This rule states that a relational database should have a database dictionary. This dictionary
should contain the metadata of the database, such as descriptions of the tables, their
structure, relationships between them, and queries.
The database dictionary or system catalog should contain information about the database
structure and types of data stored in the tables.
Rule 5
This rule states that a relational database should have at least one fundamental language.
The language should use character strings that can support authorization, view definition,
integrity constraints, data definition, and data manipulation.
Rule 6
You should be able to edit and change the answer tables in a database.
This rule states that you need to separate answer tables into those that you can update and
those that you can't update. Separating answer tables ensures that updating the answer table
doesn't violate the fundamental rules of the database structure.
Rule 7
This rule states that you should be able to query, insert, and update multiple records in a
database using a single command. This is especially necessary if you're working with a large
database.
Rule 8
This rule states that changes to a database should not affect users and their activities. For
example, if you change the way in which users access data or the data is stored in a relational
database, users should not be aware of the change.
805

Rule 9
This rule states that when you split a table, you should create a view that brings the two tables
together into an entity with its original name. Creating this view ensures that the split does not
affect users and applications.
Rule 6, which supports Rule 9, states that any view you change should be updateable by the
system. This means that if you split a table, users won't be able to use the data unless it is
updated by the system.
Rule 10
This rule states that you should be able to store entity and referential integrity rules in the data
dictionary instead of the application programs where users can change them. This rule also
states that you should be able to define and store any other integrity rule you create in the
data dictionary.
Rule 11
This rule states that you should be able to change the way in which data is circulated without
the users being aware of it, and you shouldn't have to rewrite any applications to redistribute
data, for example between users and a network.
Rule 12
This rule states that a user shouldn't be able to change data in a table if it undermines other
integrity rules that have been applied to tables and stored in the data dictionary.
Conclusion
The aim of Codd's rules is to ensure the integrity of the data in a database and to enable
users to access data easily. Codd's rules also ensure basic guidelines on which to model a
relational database. This ensures that manufacturers can't label and market databases as
relational if they adhere to only a few of Codd's rules.
Summary
This article covers Codd's 13 rules for relational databases. Codd's rules act as a guideline to
developers of modern relational databases. Codd's rules clarify the basic characteristics of a
relational database. According to these rules, a relational database should have a simple
structure so that users and database developers can exchange information about the
database, data independence, and set-orientated processing.



806

The relational database schema
Learning objective
After completing this topic, you should be able to describe how to outline a relational database
schema.
1. Database schema
In a database, a schema is a group of related objects called schema constructs.

You can represent a database schema graphically in a schema diagram.
Metadata describes the schema constructs or constraints.

And these constructs are stored in the data catalog.

A schema construct is also known as the intension, and the database state is known as the
extension.
Question
What do you think the data in a database is known as?
Options:
1. Current set of instances
2. Database index
3. Database procedure
4. Database state
5. Database snapshot
6. Occurrence
Answer
The data in a database is called a database snapshot, database state, current set of instances, or
an occurrence.
The three models associated with the database schema are displayed.
Conceptual model
External model
Internal model
Conceptual model
807

In database design, the conceptual model is also known as the logical model.

The conceptual schema contains information about the structure of the database, and it describes
the tables, entities, constraints, and relationships.

The conceptual schema doesn't display the details of physical storage structures.
External model
In database design, the external model is also known as the application interface.

The external schema includes the ways in which users can access the schema.

You use the external schema to create relationships between a user application and the data
model.
Internal model
In database design, the internal model is also called the physical model.

This internal schema deals with the storage structure of the database, and the ways in which
users can access data.

The internal schema divides the hardware and operating system from the data model.
Question
Match the database schema to its description.
Options:
1. Conceptual model
2. External model
3. Internal model
Targets:
A. Known as the application interface
B. Known as the logical model
C. Known as the physical model
Answer
The conceptual model database schema is known as the logical model, the external model
database schema is known as the application interface, and the internal model database schema is
known as the physical model.
In database design, the conceptual model is also known as the logical model. The conceptual
schema contains information about the structure of the database, and it describes the tables,
808

entities, constraints, and relationships. The conceptual schema doesn't display the details of
physical storage structures.
In database design, the external model is also known as the application interface. The external
schema includes the ways in which users can access the schema. You use the external schema to
create relationships between a user application and the data model.
In database design, the internal model is also called the physical model. This internal schema deals
with the storage structure of the database, and the ways in which users can access data. The
internal schema divides the hardware and operating system from the data model.
2. Database tables
A table is one of the components of a schema, is the basic unit of storage in a database, and
comprises various components.
Columns and rows
Datatypes
Keys
Columns and rows
The vertical structures in a table are called columns.

Each column includes a specific datatype that determines what kind of values you can enter into
the column.

In the example the Lecturer_Name column in the Modules relation is highlighted.

Normally, the attributes in the business model become the column headers in the database
model.

A single record in a table is called a row.

In the example, a row in the Lecturer's relation is highlighted.
Datatypes
The datatype determines what kind of data you can store in a column.

The most frequently used datatypes are the alphanumeric, date and time, and numeric types.

You select an alphanumeric datatype for a column if you want the column to contain alphabetic
characters, special characters, numbers, or a combination of these.

You can't perform calculations in a column with an alphanumeric datatype because the numbers
809

are treated as characters.

You select a numeric datatype for a column if you want to store only numeric values in it. In the
example, the Number_of_Publications field with one of its values 14 is highlighted.

And you select a date and time datatype for a column if you want to store date and time values in
it.
Keys
A key is a column value in a table, which is used to uniquely identify a row. Keys can be used to
create relationships between tables.

A key controls the referential integrity between tables.

The referential integrity ensures that data is consistent between two related tables.

The types of keys include primary keys and foreign keys.

You use a primary key to join related tables, and the key consists of one or more column values.

These values uniquely identify a row of data in a table.

You use a foreign key to reference a primary key in another table.

Referencing the primary key in another table ensures that parent tables are created before child
tables.

A foreign key consists of one or more column values in a table.

In the example Laura Wells' Staff_Number 123 is highlighted in the Lecturers and Modules
tables.
3. Relationships
A relationship is an association between tables that share data.
In relational databases, you
separate data into tables
create relationships between tables to minimize data redundancy
use primary keys or foreign keys to establish relationships between tables
Question
Which process do you think you use to reduce data redundancy in a relational database table?
810

Options:
1. Indexing
2. Normalization
3. Schematization
4. Transactional processing
Answer
You use normalization to reduce data redundancy in a relational database table.
A table can include one of the following relationships:
one-to-one (1:1)
one-to-many (1:N)
many-to-many (N:M)
one-to-one (1:1)
In a one-to-one relationship, a single record in a table is connected to a single record in another
table.

For example, each manager manages one department.
one-to-many (1:N)
In a one-to-many relationship, a single record in a table is connected to multiple records in
another table.

For example, many employees are attached to each department.
many-to-many (N:M)
In a many-to-many relationship, one or more records in one table are related to one or more
records in another table.

For example, a number of different employees might work on a number of different projects.
4. Other database schema components
A database schema includes several objects, such as tables, views, and constraints.
There are several database schema components you can use to access data in a database.
Index
Procedure
Trigger
811

Index
An index is a directory or catalog of the data stored in tables.

You use an index to increase the speed of retrieving data from a table.

The rows in an index correspond to the rows in the table.
Procedure
You use a procedure, which is a program, to manage data and execute batch processing in a
database.

Procedures are stored in the database.
Trigger
A trigger is a piece of code that is executed when certain events occur in a database.

A trigger may be executed when data is accessed or modified.

You use triggers to monitor redundant data.
Question
What database schema component allows you to manage data and execute batch processing?
Options:
1. An index
2. A procedure
3. A trigger
Answer
A procedure allows you to manage data and execute batch processing.
Option 1 is incorrect. An index is a directory or catalog of the data stored in tables. You use an index
to increase the speed of retrieving data from a table. The rows in an index correspond to the rows in
the table.
Option 2 is correct. You can use a procedure, which is a program, to manage data and execute
batch processing in a database. Procedures are stored in the database.
Option 3 is incorrect. A trigger is a piece of code that is executed when certain events occur in a
database. A trigger may be executed when data is accessed or modified. You use triggers to
monitor redundant data.
812

Summary
In a database, a schema refers to a group of related objects. You can represent the schema
diagrammatically in a schema diagram. An object in the schema is called a schema construct.

A table is a basic unit of storage in a database. A table consists of components, such as
columns and rows, keys, and datatypes.

A relationship is an association between tables that share data. In a relational database, you
separate data into tables, and you create relationships between tables to minimize data
redundancy.

A database schema includes various objects, such as tables, views, and constraints. The
schema also contains objects such as an index, trigger, or procedure. You can use these
objects to access database data.















813

Relational database integrity
Abstract
The aim of this article is to discuss referential integrity and the role it plays in keeping data
consistent. You can create referential integrity between tables by creating constraints. You
enforce referential constraints between related tables by using primary and foreign keys. You
use primary and foreign keys to reduce duplication between related tables. Once you've
created these constraints, you store them in the data or system catalog.
Introduction
When you design and create a relational database, you need to ensure that the data entered
into the database is correct and remains consistent. Normally users add new data, modify,
and delete data so that the data in the database changes constantly. To ensure that the data
remains valid and to minimize duplication, you need to build data integrity into the database at
the design stage before you enter data into the database. If you don't implement strategies to
ensure the accuracy of the data, the database will contain inconsistent and unrelated data.
You ensure the integrity of the data in a relational database by using constraints. A constraint
is a rule that controls the types of data you may enter into a column or a table.
In a relational database, you use constraints to
authenticate the values of the data in a database
ensure that the same information is not entered into the database more than once
ensure that new or changed data support the business rules
To ensure that the many constraints in a database are carried out, you need to enter the
constraints into the system catalog or database dictionary.
Referential integrity
Because a database consists of many related tables, you need to ensure that the data is
consistent between these tables. You ensure that data is consistent between related tables by
using constraints that ensure referential integrity. You use referential integrity constraints to
ensure that data entered into the parent table is entered into the related child tables. You use
referential integrity constraints to keep the data between the rows of two tables consistent.
You establish relationships between tables to minimize the amount of duplicate data in a
database. A key is defined as a value that uniquely identifies a row in a table. Keys can be
used to create a relationship with another table. Keys are related to specific tables. A
relational database model includes primary and foreign keys.
A primary key can be defined as single or multiple column values in a table. This key identifies
a row of data in the table uniquely. You also use a primary key to create a relationship
between tables and to prevent users from entering duplicate data into a table. To maintain the
integrity between tables, the primary key can't have a NULL value because NULL values are
814

not considered unique identifiers. A NULL value is data that is unknown or inexplicable but
which should be entered into the table.
A foreign key can be defined as single or multiple column values in a table used to reference a
primary key in another table. Using foreign keys ensures that parent records are created and
deleted before child records.To maintain data integrity when deleting parents records, you
should always ensure that deletes cascade to any child records.

Primary and foreign keys
Conclusion
You use referential integrity to ensure that the data in a database remains valid and
consistent. The referential integrity of the database will be challenged on a daily basis. Users
need to delete, add, or change data entries in the database, so you need to create primary
and foreign key constraints before data is entered into the database.
Summary
This article discusses the importance of database integrity. You create reliable data in a
database by setting constraints to govern which type of data can be entered into a column.
You create reliable tables by setting referential integrity constraints to keep the data in tables
consistent and valid. You use primary or foreign keys to identify a row of data in a table or
create a relationship with a table.



815

Operations in a relational database
Learning objective
After completing this topic, you should be able to manage operations in a relational database.
1. Relational operations
The main function of an information system is to process and update the data in a database.

For example, the information system retrieves data from a database and aggregates the data.
Relational database languages, such as SQL, are developed from relational algebra.

You can use these languages to manipulate the data in a database.

The retrieval result produces a new relation, which you can manipulate further.
Active operators change the data stored in a database and insert and delete tuples, which are
sets of data.

The active operators can also modify tuple values.
Passive operators permit information retrieval when data values are associated with relations.
The passive operators specifically created for relational databases include:
DIVISION
JOIN
PROJECT
RESTRICTION
SELECTION
Question
Relational algebra operators include mathematical set theory operators and those specifically
designed for relational databases.
Which of the following do you think are mathematical set theory operators?
Options:
816

1. CARTESIAN PRODUCT
2. DIVISION
3. INTERSECTION
4. SET DIFFERENCE
5. UNION
Answer
CARTESIAN PRODUCT, INTERSECTION, SET DIFFERENCE, and UNION are mathematical set
theory operators.
2. Querying a relational database
You can query relational database by using the following conventional operators:
UNION
DIFFERENCE
INTERSECTION
PRODUCT
UNION
You use the UNION operator to select all the tuples from either or both relations.

Both relations must contain the same number of attributes, but the attribute names can differ. You
must define the attributes as pairs on the same domain.

For example, when you combine two tables, you can eliminate the duplicates.

UNION (Finance Department, Human Resources Department)

All tuples in the Finance Department relation are selected, and all the tuples in the Human
Resources relation are selected, except those that appear in the Finance Department relation as
well.
DIFFERENCE
You use the DIFFERENCE operator to select tuples of one relation but not the other.

For example:

DIFFERENCE (Finance Department, Human Resources Department)

The following tuples from the Finance Department relation are highlighted:

817

00764, Keisha, Wallace, 20200, Package B, No
008463, Mark, Robinson, 10500, Package D, No
3325, Lila, Cabricci, 24000, Package B, Yes
00567, Alex, Chung,14000, Package D, No

The following tuples from the Human Resources Department relation are highlighted:

003452, Erika, Schiller, 16500, Package D, No
01767, Jennifer, Wang, 22200, Package B, No
09463, Samual, Gates, 12500, Package D, No
02563, Tom, Herwig, 32000, Package A, No
07325, Riley, Jones, 23500, Package B, Yes
INTERSECTION
You use the INTERSECTION operator to select the common tuples of two compatible relations.

For example, you can select the common tuples from both the Finance Department and the
Human Resources Department tables using the following command:

INTERSECT(Finance Department, Human Resources Department)

The following tuples from the Finance Department relation are highlighted:

03456, Lori, Phan, 19700, Package C, No
01246, Steven, Rios, 18500, Package C, No
00893, Jennifer, Westlein, 17000, Package C, No

The following tuples from the Human Resources Department relation are highlighted:

00893, Jennifer, Westlein, 17000, Package C, No
01246, Steven, Rios, 18500, Package C, No
03456, Lori, Phan, 19700, Package C, No
PRODUCT
You use the PRODUCT operator to combine two relations to create a new relation that contains the
tuples of two tables.

For example, if you combine the Benefits table with the Finance Department table, the benefit
rows are appended to each row in the Finance Department table.

PRODUCT (Finance Department, Benefits [Benefit_Package = Benefit_Package])

The following tuples from the Finance Department relation are highlighted:

01246, Steven, Rios, 18500, Package C, No
818

00893, Jennifer, Westlein, 17000, Package C, No

The following tuple from the Benefits relation is highlighted:

Package C, Medical aid, Car allowance, NULL, NULL
You can query a relational database using the following algebra operators:
PROJECT
RESTRICT
SELECT
JOIN
DIVIDE
PROJECT
You use the PROJECT operator to select columns from a table and discard all duplicate values.

For example, you can use the statement shown here to list an employee's last name and salary in
the Last Name and Salary columns in a new table.

For example:

PROJECT (Finance Department: [Last_Name, Salary])

The Last_Name and Salary for each member of the Finance Department is selected:

Clements,34000
Wallace,20200
Robinson,10500
Rios,18500
Cabricci,24000
Seva,28950
Westlein,17000
RESTRICT
You use the RESTRICT operator to remove tuples from a given relation that do not conform to the
condition in the restriction clause.

You can build up the restriction clause from elementary conditions connected by logical
operators, such as AND or NOT.

For example, you can show all the employees that are managers in a department.

RESTRICT (Finance Department: [Manager])
819


The results of the query are as follows:

03325, Lila, Cabricci, 24000, Package B, Yes
SELECT
You use the SELECT operator to select a subset of tuples.

For example, you can use the statement below to list employees earning a salary higher than
$25,000 per annum.

SELECT (Finance Department: [Sal >25000])

In this case, the query result shows that Clements earns $34,000, and Seva earns $28,950 per
annum.
JOIN
The JOIN operator is the product of two tables followed by a restriction based on the condition
specified in the restriction. Tuples are joined across a number of attributes.

For example, you can combine tuples of both the Finance Department table and the Benefits
tables where the Benefits Package is equal.

JOIN (Finance Department, Benefits: [Benefit_Package =
Benefit_Package])

In this case, the condition of the restriction is an equality condition called an "equi-join."

The following tuple in the Benefits table is highlighted:

Package B, Pension, Medical Aid, Car allowance, NULL

The following tuples from the Finance Department are selected:

03325, Lila, Cabricci, 24000, Package B, Pension
00764, Keisha, Wallace, 20200, Package B, Pension
DIVIDE
You use the DIVIDE operator to extract fields from a relation.

For example, you can query which employees have Package A.

DIVIDE (Finance Department, Salary Table: [Benefit_Package] |
[Benefit_Package])

The result of the query indicates that Brad and Michael qualify for Package A.
820


09562, Brad, Clements, 34000, No
08832, Michael, Seva, 28950, No
Question
Which operator would you use to select all the tuples from either or both relations?
Options:
1. DIFFERENCE
2. INTERSECTION
3. UNION
Answer
You use the UNION operator to select all the tuples from either or both relations.
Option 1 is incorrect. You use the DIFFERENCE operator to select tuples of one relation but not the
other. For example:
DIFFERENCE (Finance Department, Human Resources Department)
Option 2 is incorrect. You use the INTERSECTION operator to select the common tuples of two
compatible relations. For example, you can select the common tuples from both the Finance
Department and the Human Resources Department tables using the following command:
INTERSECT (Finance Department, Human Resources Department)
Option 3 is correct. You use the UNION operator to select all the tuples from either or both relations.
Both relations must contain the same number of attributes, but the attribute names can differ. You
must define the attributes as pairs on the same domain. For example, when you combine two
tables, you can eliminate the duplicates.
Question
You can aggregate the operators to form more complex operations when you first do one operation
and then another.
Which operators do you use to obtain the names of the employees earning a salary higher than
$20,000 per annum in two tables?
Options:
1. DIFFERENCE and SELECT
2. JOIN and INTERSECTION
3. UNION and SELECT
821

Answer
You use the UNION and SELECT operators to obtain the names of the employees earning a salary
higher than $20,000 per annum in two tables.
Option 1 is incorrect. You use the DIFFERENCE operator to select tuples of one relation but not the
other and the SELECT operator to select a subset of tuples.
Option 2 is incorrect. You use the JOIN operator to produce the product of two tables followed by a
restriction based on the condition specified in the restriction, and the INTERSECTION operator to
select the common tuples of two compatible relations.
Option 3 is correct. You use the UNION operator to select all the tuples from either or both relations
and the SELECT operator to select a subset of tuples.
3. Updating a relational database
In addition to relational algebraic operators, you can use the active operators DELETE, INSERT,
and UPDATE to update a database
DELETE
INSERT
UPDATE
DELETE
You use the DELETE operator to delete tuples when you make a selection on the attribute
condition of a relation.

The DELETE operator can violate the referential integrity when foreign keys from other tuples in
the database reference the deleted tuples.

When the deletion causes a violation, you can

cascade the deletion, which deletes the tuples referencing the deleted tuples
modify the referencing attribute values causing the violation, which sets the value to NULL or
changes the value to reference valid tuples
reject the deletion

In the example, all values in the Benefit_Package field of the Finance Department table are
deleted and replaced with NULL values.
INSERT
You use he INSERT operator to select attribute values from a list for a new tuple for insertion in
the relation.
822


The INSERT operator can violate the

domain constraints if the attribute value does not appear in the domain

key constraints if a key value in the new tuple already exits in another tuple in the same relation


entity integrity if the primary key of the new tuple is NULL

referential integrity if the value of any foreign key refers to a tuple that doesn't exist in the
referenced relation

In the example, a new tuple is added to the Benefits table as follows: Package E, Medical Aid.

When the INSERT operator causes a violation, you use the default option to reject the insertion.
UPDATE
You use the UPDATE operator to modify the values of one or more attributes in the tuples of a
relation.

When you update an attribute that is not a primary key or a foreign key, the Database
Management System (DBMS) checks whether the value corresponds to the datatype and
domain.

Modifying a primary key is the same as deleting a tuple and inserting another in its place because
the primary key identifies the tuple.

When you modify a foreign key, the Database Management System (DBMS) needs to ensure that
the new value refers to an existing tuple in the referenced relation or that it is NULL.

The UPDATE operator in this case can violate domain constraints, key constraints, entity integrity,
and referential integrity.
You use the DELETE, INSERT, and UPDATE operators to update a relational database.

The Database Management System (DBMS) ensures that the tuples you add, delete, or modify
do not violate the domain constraints, key constraints, entity integrity, and referential integrity.
Summary
To insert, modfiy, and retrieve information from a database, you need to use relational algebra
operators. Some relational algebra operators are from mathematical set theory, and other
operators are specifically designed for relational databases.

823

You can query a relational database using the DIFFERENCE, DIVIDE, INTERSECT, JOIN,
PRODUCT, PROJECT, RENAME, SELECT, and UNION operators. You can aggregate the operators
to form more complex operations.

You can update the relational database using active operations in addition to relational algebraic
operators. These operators are the DELETE, INSERT, and UPDATE operators. The Database
Management System (DBMS) ensures that the tuples that you add, delete, or modify do not
violate the domain constraints, key constraints, entity integrity, and referential integrity.



















824

Formulating algebraic operations in a database
Learning objective
After completing this topic, you should be able to formulate algebraic operations in a database.
Exercise overview
In this exercise, you're required to formulate algebraic operations in a database.
This involves the following tasks:
selecting rows from a table
selecting columns from a table
combining related tuples
creating an aggregated operation
Suppose that you're a developer for an international freight-forwarding company called
InterSwift.

InterSwift has a database comprising an Employees table and a Benefits table. The Employees
table contains salary information and is linked to the Benefits table via a foreign key called
Benefits Package.

You want to determine the algebraic operations that define how information can be accessed
from the tables displayed.
Supplement
Selecting the link title opens the resource in a new browser window.
Table details
View some of the table details in the InterSwift database.
Task 1: Selecting rows from a table
You need to obtain the records of employees earning less than $20,000 per year.
Supplement
Selecting the link title opens the resource in a new browser window.
Table details
825

View some of the table details in the InterSwift database.
Step 1 of 1
Which statement do you think you use to obtain the records of employees earning less than $20,000
per annum?
Options:
1. INTERSECT (Employees)
2. PROJECT (Employees:[Salary < 20000])
3. SELECT (Employees:[Salary < 20000])
4. SELECT (Salary < 20000)
Result
You use the SELECT (Employees:[Salary < 20000]) statement to obtain the records of
employees earning less than $20,000 per annum.
Option 1 is incorrect. The INTERSECTION operator is used to select the common tuples of two
compatible relations. In the example
INTERSECT (Employees)
only one table is supplied.
Option 2 is incorrect. You use the PROJECT operator to select columns from a table and discard all
duplicate values. The example
PROJECT (Employees:[Salary < 20000])
would not work, as there should also be a field name supplied in the expression.
Option 3 is correct. The SELECT (Employees:[Salary < 20000]) statement uses the
SELECT operator to query the Employee table in the database and return those employees whose
salary is less than 20,000.
Option 4 is incorrect. The SELECT (Salary < 20000) statement will not work, as you need to
state in the expression the table from which to select the salary field. In this case the table is
Employee.
Task 2: Selecting columns from a table
You need to retrieve employees' last names and employee IDs from the Employees table.
Supplement
Selecting the link title opens the resource in a new browser window.
826

Table details
View some of the table details in the InterSwift database.
Step 1 of 1
Which statement do you think you use to retrieve employees' last names and employees' IDs from
the Employees table?
Options:
1. JOIN (Employees,Employee_ID)
2. PROJECT (Employees: [Last_Name, Employee_ID])
3. PROJECT (Last_Name, Employee_ID)
4. UNION (Last_Name, Employee_ID)
Result
You use the PROJECT (Employees: [Last_Name, Employee_ID]) statement to retrieve
employees' last names and employees' IDs from the Employees table.
Option 1 is incorrect. You use the JOIN operator to produce the product of two tables based on the
condition specified in the restriction.
Option 2 is correct. The PROJECT (Employees: [Last_Name, Employee_ID]) statement
uses the PROJECT operator to select columns from a table, in this case the last name and employee
ID, and it discards all duplicate values.
Option 3 is incorrect. The PROJECT (Last_Name, Employee_ID) statement will not work
because you have not specified the table to select the columns from. In this case the table is
Employees.
Option 4 is incorrect. You use the UNION operator to select all the tuples from either or both
relations, but in this example duplicates can be returned.
Task 3: Combining related tuples
Suppose that you want to retrieve a list of all employees and their benefits from a table.
Supplement
Selecting the link title opens the resource in a new browser window.
Table details
827

View some of the table details in the InterSwift database.
Step 1 of 1
Which statement do you think you use to retrieve a list of all employees and their benefits from a
table?
Options:
1. JOIN (Employees, Benefits: [Benefits_Package = Benefits_Package])
2. PROJECT (Employees, Benefits)
3. SELECT (Employees, Benefits: [Benefits_Package = Benefits_Package])
4. JOIN (Employees, Benefits)
Result
You use the JOIN (Employees, Benefits: [Benefits_Package =
Benefits_Package]) statement to retrieve a list of all employees and their benefits.
Option 1 is correct. The JOIN (Employees, Benefits: [Benefits_Package =
Benefits_Package]) statement uses the Join operator to merge the Employee and Benefits
tables where the Benefits packages are the same in both tables.
Option 2 is incorrect. You use the PROJECT operator to select columns from a table and discard all
duplicate values. The example
PROJECT (Employees, Benefits)
would not work, as there should also be a field name supplied in the expression rather than two
tables' names.
Option 3 is incorrect. The SELECT (Employees, Benefits: [Benefits_Package =
Benefits_Package]) statement will not return the list required as the expression is incorrect.
Option 4 is incorrect. The JOIN (Employees, Benefits) statement will not work, as the Join
operator requires a condition for merging the two tables.
Task 4: Creating an aggregated operation
You want to determine which benefits Jennifer Westlein receives.
Supplement
Selecting the link title opens the resource in a new browser window.
Table details
828

View some of the table details in the InterSwift database.
Step 1 of 1
Which operator do you think you use to establish the benefits Jennifer Westlein receives?
Options:
1. SELECT (JOIN (Employees, Benefits: [Benefits_Package =
Benefits_Package]): [Last_Name])
2. SELECT (UNION (Employees, Benefits: [Benefits_Package =
Benefits_Package]): [Last_Name = Westlein])
3. SELECT (JOIN (Employees, Benefits: [Benefits_Package =
Benefits_Package]): [Last_Name = Westlein])
4. PROJECT (SELECT (Employees, Benefits: [Benefits_Package =
Benefits_Package]): [Last_Name = Westlein])
Result
To establish which benefits Jennifer Westlein receives, you use the SELECT (JOIN (Employees,
Benefits: [Benefits_Package = Benefits_Package]): [Last_Name = Westlein])
statement.
Option 1 is incorrect. The SELECT (JOIN (Employees, Benefits: [Benefits_Package =
Benefits_Package]): [Last_Name]) statement does not have a condition for the last name in
the Select operator expression.
Option 2 is incorrect. This statement would not work because the UNION operator is used to select
all the tuples from either or both relations.
Option 3 is correct. The SELECT (JOIN (Employees, Benefits: [Benefits_Package =
Benefits_Package]): [Last_Name = Westlein]) statement uses the Join operator to
merge the Employee and Benefits tables where the Benefits packages are the same in both tables;
and then uses the Select operator to select the employee with the last name Westlein.
Option 4 is incorrect. This statement would not work because the PROJECT operator is used to
select columns from a table and discard all duplicate values.




829

Using SQL in a relational database
Learning objective
After completing this topic, you should be able to describe how to use SQL in a relational
database.
1. Introduction to SQL
Users use SQL, which is a standardized language, to request information from a database.

The IBM Research Laboratory created SQL, which was previously known as Structured English
Query Language (SEQUAL).

SQL replaces relational database languages, such as Data Sub Language (DSL) and Relational
Calculus.
The American National Standards Institute (ANSI) and the ISO standardized SQL into
SQL1
SQL2
SQL3
SQL1
SQL1 was first called SQL86.

SQL86 is the first standardized version of a database programming language that you can use to
query databases.
SQL2
SQL2 was created to support primary keys, foreign keys, and domains.

SQL2 contains ANSI and ISO-standardized integrity enhancements.

So you can't delete a table's foreign key unless you also delete its related database attributes.
SQL3
SQL3 was released in 1999 and renamed SQL99 to incorporate object relational facilities.
Hundreds of differing implementations of SQL retain the fundamental concepts of relational
processing.
These implementations include
Microsoft SQL Server
830

Oracle SQL
UNIX SQL Server
Using SQL, a user can formulate expressions to query or update data in a database.

The DBMS executes the query using Relational Calculus.
Question
You use SQL statements to define, query, and update a database.
See if you can match the SQL command language to its function in a database.
Options:
1. Data Definition Language (DDL)
2. Data Manipulation Language (DML)
Targets:
A. Create tables
B. Query and update tables
Answer
You use DDL to create tables and DML to query and update tables.
You can use SQL to define views on a database, create integrity constraints, and create
transactional controls in a database.

SQL statements can also be embedded in programming languages, such as C and Pascal.
2. Using SQL
To retrieve data from a database, you use the SELECT statement.
The SELECT statement combines the PROJECT, SELECT, and JOIN relational algebraic
operators in the following syntax:

SELECT attribute list
FROM table list
[WHERE condition];
SELECT attribute list
FROM table list
831

[WHERE condition];
SELECT attribute list
SELECT attribute list refers to the attributes that the query needs to retrieve.
FROM table list
FROM table list refers to the relation names that the query uses for processing.
[WHERE condition];
WHERE condition refers to the Boolean expression that identifies the tuples the query needs to
retrieve.
You use the following statement to retrieve an employee's dependants from a table.
SELECT dependants
FROM employees
WHERE first_name = 'Brad' AND
last_name = 'Clements';
To modify data in a database, you can use the following SQL statements:
DELETE
INSERT
UPDATE
The syntax for the DELETE statement is:

DELETE FROM table
[WHERE condition];
DELETE FROM table
[WHERE condition];
DELETE FROM table
DELETE FROM table refers to the table from which you want to delete tuples.
[WHERE condition];
WHERE condition refers to the Boolean expression that identifies the tuples the query needs to
delete.
The extended syntax for the DELETE statement is:

DELETE FROM table
[WHERE condition IN (SELECT attribute list
FROM table list
WHERE condition];
832

DELETE FROM table
WHERE condition IN
SELECT attribute list
FROM table list
WHERE condition
DELETE FROM table
DELETE FROM table refers to the table from which you want to delete tuples.
WHERE condition IN
WHERE condition IN refers to the tuples the query should delete within a specific range.
SELECT attribute list
SELECT attribute list refers to the attributes that the query needs to select.
FROM table list
FROM table list refers to the tables from which the query needs to delete the tuples.
WHERE condition
WHERE condition refers to the tuples the query needs to delete within the specific table list.
Question
Suppose that four employees have been promoted from the finance department, and they
subsequently joined the marketing department.
What do you think is the last line of the command that you execute to delete the four employees
from the finance department?

DELETE FROM employees_finance
WHERE employees_id IN
(SELECT employees_id
FROM employees_marketing MISSING CODE
Options:
1. WHERE employees_marketing.employees_id > employess_finance.employees_id);
2. WHERE employees_marketing.employees_id = employess_finance.employees_id);
3. WHERE employees_marketing.employees_id = 100);
4. WHERE employees_marketing.employees_id );
Answer
To delete the four employees from the finance department, you use the command
DELETE FROM employees_finance
WHERE employees_id IN
833

(SELECT employees_id
FROM employees_marketing
WHERE employees_marketing.employees_id = employees_finance.employees_id);
The syntax for the INSERT statement is as follows:

INSERT INTO table (attribute-name, [attribute-name])
VALUES (value, [value]);
INSERT INTO table (attribute-name, [attribute-name])
VALUES (value, [value]);
INSERT INTO table (attribute-name, [attribute-name])
INSERT INTO table refers to the table into which you want to insert the data.

Attribute-name refers to the column information that you want to add to the table, such as first
name and last name.
VALUES (value, [value]);
VALUES (value, [value]) refers to the information you want to add to the corresponding
columns, such as Mark Robinson.
Suppose that the organization has recently appointed a new employee named Brad Clements
and assigned him the employee number of 09562.

You use the statement shown here to update the database with the new information.
INSERT INTO employees (employee_number, first_name, last_name)
VALUES (09562, 'Brad', 'Clements');
The syntax for the UPDATE statement is as follows:

UPDATE table [correlation value]
SET attribute-name = attribute expression
[attribute-name = attribute expression]
[WHERE condition];
UPDATE table [correlation value]
SET attribute-name = attribute expression [attribute-name = attribute expression]
[WHERE condition];
UPDATE table [correlation value]
UPDATE table refers to the table that you want to update.

834

Correlation value refers to the fields within the table that you want to update, such as the salary or
address field.
SET attribute-name = attribute expression [attribute-name = attribute expression]
SET attribute-name = attribute expression refers to the attributes that the query needs to modify
and their respective new values.
[WHERE condition];
WHERE condition refers to the Boolean expression that identifies the tuples that the query needs
to update.
Suppose that you need to change an employee's surname from McMahon to Jones and her
salary from $15,000 to $18,000. Her employee number is 02456.

To do this, you use the statement shown here.
UPDATE employees
SET last_name='Jones', salary=18000
WHERE employee_number = 02456;
Question
What command do you use to retrieve data from a database?
Options:
1. CREATE
2. INSERT
3. SELECT
Answer
The SELECT command allows you to retrieve data from a database.
Option 1 is incorrect. You use the CREATE command to create a new table or other database
objects, such as indexes, in which you can define the attributes with values such as characters or
integers.
Option 2 is incorrect. You use the INSERT command to insert data into a table. For example
INSERT INTO table where table refers to the table into which you want to insert the data.
Option 3 is correct. To retrieve data from a database, you use the SELECT statement. The SELECT
statement combines the PROJECT, SELECT, and JOIN relational algebraic operators.
835

3. Managing database objects
You can use the following DDL commands to manage database objects:
ALTER
CREATE
ALTER
You use the ALTER command to change a table definition and other database objects, such as
indexes.

You also use this command to add attributes to a table, delete an attribute from the table, or
modify an attribute.

The changes and updates are dynamic, which means that after you use the ALTER command,
the database is immediately updated.
CREATE
You use the CREATE command to create a new table or other database objects, such as indexes,
in which you can define the attributes with values, such as characters or integers.

You can also use the CREATE command to define constraints in an existing table to ensure data
integrity and reliability.
The syntax for adding an attribute to a table is as follows.

ALTER TABLE table
ADD (attribute [data type]);
ALTER TABLE table
ADD (attribute [data type]);
ALTER TABLE table
ALTER TABLE table refers to the table in the database that you want to alter.
ADD (attribute [data type]);
ADD attribute [data type] refers to the attribute and the datatype, such as decimal, alphanumeric,
or numeric, that you want to add to the table.
To add a 15-character job title to the Employees table, you use the statement displayed.
ALTER TABLE employees
ADD (job_title (VARCHAR(15));
836

The syntax for modifying an attribute in a table is as follows.

ALTER TABLE table
MODIFY (attribute [data type] [default expression] [column-constraint]);
ALTER TABLE table
MODIFY (attribute [data type] [default expression] [column-constraint]);
ALTER TABLE table
ALTER TABLE table refers to the table in the database that you want to alter.
MODIFY (attribute [data type] [default expression] [column-constraint]);
MODIFY (attribute [data type] [default expression] [column-constraint]) refers to how the
column attribute will change, such as changing the datatype of a column.
To add five characters to the Last_Name attribute, you use the statement displayed.
ALTER TABLE employees
MODIFY (last_name VARCHAR(21));
The syntax for deleting an attribute from a table is as follows:

ALTER TABLE table
DROP attribute
[CASCADE][RESTRICT];
ALTER TABLE table
DROP attribute
[CASCADE][RESTRICT];
ALTER TABLE table
ALTER TABLE table refers to the table in the database that you want to alter.
DROP attribute
DROP attribute refers to the attribute that you want to delete, such as salary scale and employee
address.
[CASCADE][RESTRICT];
CASCADE refers to all the views and constraints that are referenced to the column that will be
dropped.

RESTRICT is used when there are no views or constraints referenced to the column.

You have to specify either CASCADE or RESTRICT.
837

The syntax for deleting a constraint from a table is as follows:

ALTER TABLE table
DROP constraint
[CASCADE][RESTRICT];
ALTER TABLE table
DROP constraint
[CASCADE][RESTRICT];
ALTER TABLE table
ALTER TABLE table refers to the table in the database that will be altered.
DROP constraint
DROP constraint refers to the constraint that will be deleted, such as NOT NULL.
[CASCADE][RESTRICT];
CASCADE refers to all the views and constraints referenced to the column that you want dropped.

RESTRICT refers to no views or constraints referenced to the column that you want dropped.

You have to choose CASCADE or RESTRICT when dropping a column.
Question
Suppose that you want to remove from the Employees table the foreign key constraint on the
Benefits attribute.
What command do you think you use to remove this constraint permanently?
Options:
1. ALTER TABLE benefits
DROP
employees;
2. ALTER TABLE employees
DROP
benefits
CASCADE;
3. ALTER TABLE employees
DROP
benefits
RESTRICT benefits;
838

Answer
To remove the benefits constraint permanently, you use the following command:

ALTER TABLE employees
DROP
benefits
RESTRICT benefits;
Option 1 is incorrect. In this example the wrong table is being altered. You want to alter the
employees table.
Option 2 is incorrect. In this example you are using CASCADE. CASCADE refers to all the views and
constraints referenced to the column that you want dropped.
Option 3 is correct. In the
ALTER TABLE employees
DROP
benefits
RESTRICT benefits;
example, the RESTRICT refers to the views or constraints referenced to the column that you want
dropped.
The syntax for the CREATE statement is as follows.

CREATE TABLE table
(column_names attribute_values)
PRIMARY KEY (attribute)
[FOREIGN KEY (attribute)];
CREATE TABLE table
(column_names attribute_values)
PRIMARY KEY (attribute)
[FOREIGN KEY (attribute)];
CREATE TABLE table
(column_names attribute_values)
CREATE TABLE table refers to the new table name, the column names, the datatypes, and the
constraints of the columns.
PRIMARY KEY (attribute)
PRIMARY KEY (attribute) refers to the attribute that will make up the primary key of the relation,
which is a unique identifier.
[FOREIGN KEY (attribute)];
FOREIGN KEY (attribute) refers to the referential integrity.
839

Suppose that you want to create a table named Employees. The table must include columns for
the employees' first name, last name, employee number, and salary.

The primary key for the table is employee number. To do this, you use the statements displayed.
CREATE TABLE employees
(employee_number CHAR(5),
first_name VARCHAR(15),
last_name VARCHAR(15),
salary DECIMAL(10,2),
PRIMARY KEY employee_number);
Summary
Users use SQL to request information from a database. The IBM Research Laboratory created
SQL. SQL is a Data Definition Language (DDL) and a Data Manipulation Language (DML) that
can define, query, and update data in a table.

You use the SELECT statement that combines PROJECT, SELECT, and JOIN relational
operators to retrieve data from a database. And you use the DELETE, INSERT, and UPDATE
commands to modify data in a SQL database.

You can manage the SQL database objects using the CREATE and ALTER DDL commands. To
add attributes to a table, delete an attribute from the table, or modify an attribute name, you use
the ALTER command. Using the CREATE command, you can create a table with specific
attributes, and you can create constraints to ensure integrity and reliability checks.










840


Writing basic SQL statements
Learning objective
After completing this topic, you should be able to discuss and write basic SELECT SQL
statements.
1. The basic SELECT statement
Structured query language (SQL) is a programming language that you use to define and
manipulate relational databases.
The SQL language has several subsets. You use SQL's data definition language (DDL) to
create and modify the structures of databases and database objects. And you use SQL's data
manipulation language (DML) to fetch and alter data stored in tables.
SQL is a very flexible language it isn't case sensitive and you can split SQL statements into
multiple lines. However, you can't split or abbreviate SQL keywords.
Note
SQL statements are made up of clauses, each of which begins with a SQL keyword. It's common
practice to enter each SQL clause on a separate line and to use indenting to enhance readability.
You retrieve information from a database using a SELECT SQL statement.
You can use a SELECT statement to create SQL queries that return specific rows or columns
from a table. You can also use a SELECT statement to link data stored in different tables.
The basic SELECT syntax is
SELECT {column|expression}
FROM table;
In this syntax, column|expression is the information you want to retrieve and table is the
table that contains the information. You need to terminate SQL statements with a semi-colon,
although this isn't necessary in iSQL.
Question
You can add a WHERE clause to a SELECT statement.
What do you think you use the WHERE clause to do?
841

Options:
1. To specify the database in which a table resides
2. To specify search criteria for a query
3. To specify a network node to search on
4. To specify the disk in your computer that contains the table you want to query
Answer
You use the WHERE clause to specify search criteria for a query. The system will then return only
those results that meet with the criteria.
To display all the columns in a table, you can use an asterisk (*) instead of entering each
column name. To display all columns in the jobs table, for example, you execute the following
code.
SELECT * FROM Jobs;
Let's say that you want to display only the job_title and max_salary columns from the jobs table.
To do this, you enter each column name separated by a comma.
SELECT job_title, max_salary
FROM jobs;
2. Displaying table structure
If you need to view the structure of a table, you use the DESCRIBE command.
The DESCRIBE command lists all the columns in a table, as well as the specified data type for
each column.
Let's say that you want to view the structure of a table called employees. To do this, you execute
the following code.
DESCRIBE employees
Note
The abbreviation DESC is accepted by iSQL*Plus.
Question
What command do you use to list all the columns in a table?
Options:
842

1. DESCRIBE
2. SELECT
3. WHERE
Answer
The DESCRIBE command allows you to list all the columns in a table.
Option 1 is correct. You use the DESCRIBE command if you need to view the structure of a table.
The DESCRIBE command lists all the columns in a table, as well as the specified data type for each
column.
Option 2 is incorrect. You use a SELECT SQL statement to retrieve information from a database.
You can use a SELECT statement to create SQL queries that return specific rows or columns from a
table. You can also use a SELECT statement to link data stored in different tables.
Option 3 is incorrect. You use the WHERE clause within a SELECT statement to specify search
criteria for a query. The system will then return only those results that meet with the criteria.
3. Arithmetic expressions
You can use arithmetic operators to modify the way data is displayed or to perform calculations.
You can use column names and constant numeric values to build arithmetic expressions.
+ Add
Subtract
* Multiply
/ Divide
+ Add
This code adds 100 to whatever value the salary column returns.

SELECT salary, salary+100
FROM employees;
Subtract
This code subtracts 500 from whatever value the salary column returns.

SELECT salary, salary500
FROM employees;
* Multiply
843

This code multiplies the value returned by the salary column by 1.2, effectively increasing it by 20
percent.

SELECT salary, salary*1.2
FROM employees;
/ Divide
This code divides the value returned by the salary column in half.

SELECT salary, salary/2
FROM employees;
In expressions that contain more than one operator, multiplication and division take a higher
priority than addition and subtraction.
If two operators with the same priority appear in an expression, SQL evaluates and executes
them from left to right.
However, you can force an expression to be evaluated first by putting it in parentheses.
If a row of data is missing a value for a specific column, that value is null.
Null is an unavailable, unassigned, unknown, or inapplicable value. Null is not the same as zero
which is a number or as a space which is a character.
If an arithmetic expression encounters a null value, the result is always null.
You can designate a column in a table as NOT NULL. This means that Oracle won't accept a
row of data for insertion into the table if the NOT NULL field doesn't contain a value.
Summary
You use Structured Query Language (SQL) to define and manipulate relational databases. You
can retrieve data from tables in a database using a SELECT SQL statement.

You can use the DESCRIBE command to view the structure of a table. The output of this
command lists the name of each column alongside the type of data that the column contains.

SQL supports standard arithmetic operators for addition, subtraction, multiplication, and division.
Multiplication and division are evaluated before addition and subtraction. If an arithmetic
expression encounters a null value, the result will always be null.


844

Manipulating data in Oracle9i databases
Learning objective
After completing this topic, you should be able to describe how to insert, update, and delete data
in an Oracle9i database.
1. Adding rows to a table
To add a new record to a database, you add a row to the relevant table.
You use an INSERT statement with this syntax to add a new row to a table.
INSERT INTO table [(column [, column])]
VALUES (value [, value]);
You can specify the columns you want to populate or you can list the values in the same order in
which columns occur in a table.
You specify the values for insertion into the specified columns using the VALUES keyword. You
enclose character and date values in single quotation marks.
Note
When you add a row to an existing table, you need to ensure that you specify the names of the
columns correctly and that you include the values you want to insert in the correct sequence.
You can view the names, datatypes, and lengths of each column in a table using the DESCRIBE
command. This is useful if you want to add records to a table but don't know the names of the
columns in the table.
The following code, for example, retrieves the names, datatypes, and lengths of columns in the
employees table.
DESCRIBE employees;
Let's say that you want to add information about a new employee called Marcia Smith to the
employees table.
You specify the columns with the INSERT INTO clause and you specify Marcia Smith's details
in the VALUES clause.
INSERT INTO employees
(employee_id, first_name,
last_name, email, hire_date, job_id)
845

VALUES (209, 'Marcia', 'Smith',
'MSMITH', '01-FEB-02', 'SA_REP');
When you execute the statement, Oracle confirms that it has inserted the required row into the
table.
1 row created
Question
When you insert a new row into a table, you need to specify values for all mandatory columns.
What do you think happens to nonmandatory columns for which you don't specify values when you
execute an INSERT statement?
Options:
1. Oracle enters null values in the columns
2. Oracle leaves the columns empty
3. The INSERT statement fails
4. Oracle enters default values in the columns
Answer
If you don't specify values for nonmandatory columns in an INSERT statement, Oracle enters null
row values in the columns.
You can use iSQL functions such as SYSDATE and USER to retrieve system information and
to enter this information in new rows you insert into a table.
The SYSDATE function inserts the current date and time and the USER function inserts the
username of the person currently logged on.
For instance, if you enter a new employee record on the employee's hire date so that the hire
data is the same as the current date you can specify SYSDATE for the row value in the
hire_date column.
INSERT INTO employees (employee_id, first_name,
last_name, email, hire_date, job_id)
VALUES (209, 'Marcia', 'Smith',
'MSMITH', 'SYSDATE', 'SA_REP');

1 row created.
You can obviously insert dates other than the system date into a table. The default display and
input format for dates is DD-MON-RR for example 31-Mar-50.
846

You may want to store date values for centuries other than the current one. Oracle uses a
formula discussed in a later topic to identify which century the RR section of the date refers to.
For example 1950 or 2050.
INSERT INTO employees (employee_id, first_name,
last_name, email, hire_date, job_id)
VALUES (209, 'Marcia', 'Smith',
'MSMITH', 'SYSDATE', 'SA_REP');

1 row created.
As an administrator, you can use substitution variables in a script so that users can run the
script whenever they need to perform batch inserts. In this case, the script will prompt users to
enter the appropriate input for each record when it runs.
To include substitution variables in a script, you prefix the relevant variables with an ampersand
(&).
INSERT INTO employees
(employee_id, first_name,
last_name, email, hire_date, job_id)
VALUES (&employee_id, &first_name,
&last_name, &email, &hire_date, &job_id)
When the script runs, Oracle prompts the user to enter a value for each substitution variable
you've included. As a result, users can run the script any number of times and enter different
values thereby creating a new row each time the script runs.
You can use a subquery in an INSERT statement to retrieve data from one table for insertion
into another table.
Let's assume that you want to create a new employee, "Ronan Collins" and assign him to the
"IT" department. ,
To insert this record into the employees table using the appropriate department id from the
departments table, you specify a SELECT subquery within a VALUES clause in an INSERT
statement.
INSERT INTO employees (employee_id, first_name,
last_name, email, job_id, hire_date,
department_id)
VALUES (300, 'Ronan', 'Collins', 'rcollins',
'IT_PROG',
SYSDATE
(SELECT department_id
FROM departments
WHERE department_name =
847

'IT'));

1 row created.
When you insert rows from one table into another table, you need to ensure that the number of
columns and their datatypes in the main INSERT statement match the values you specify in
the subquery.
In this example , you add a row to a table by specifying a SELECT subquery instead of a
VALUES clause in an INSERT statement.
INSERT INTO dept_backup
(department_id, department_name,
manager_id, location_id)
(SELECT department_id, department_name,
manager_id, location_id
FROM departments
WHERE department_name =
'IT');

1 row created.
You can insert rows containing values for all columns from a source table directly into the target
table using an asterisk wildcard in the subquery. In this case, the code will insert all rows from
the departments table into the dep_backup table.
INSERT INTO dep_backup
SELECT *
FROM departments;

27 rows created.
2. Updating data in a table
You can modify the data in one column of multiple rows using the UPDATE statement using the
following syntax.
UPDATE table
SET column = value [, column =
value, ]
[WHERE condition];
In the syntax, the values you specify in the SET clause replace the existing values with new
values for all rows that match the criterion you specify in the WHERE clause.
For example, this code changes the department_id of the employee named "Fay" to department
50.
848

UPDATE employees
SET department_id = 50
WHERE last_name = 'Fay';

1 row updated.
To update data in two or more columns of multiple rows, you can write a subquery for each
column in the SET clause of an UPDATE statement.
For example, the following statement updates both the hire_date and salary columns for the
employee record with the employee_id of 205.
UPDATE employees
SET hire_date = (SELECT hire_date
FROM employees
WHERE employee_id = 150),
Salary = (SELECT salary
FROM employees
WHERE employee_id = 150)
WHERE employee_id = 205;

1 row updated.
You can use a SELECT subquery in an UPDATE statement to transfer values directly from a
source table into a target table.
In this example, the statement changes the department ID of employees with the same job as
employee 206, to the department ID of employee 204.
UPDATE employees
SET department_id = (SELECT department_id
FROM employees
WHERE employee_id = 204)
WHERE job_id = (SELECT job_id
FROM employees
WHERE employee_id = 206);

1 row updated.
You can avoid integrity constraint errors when updating records by ensuring that records exist
before attempting to update them.
For instance, an attempt to update a department id in the employees table from 50 to 500 will
fail if department 500 does not exist in the departments table.
UPDATE employees
SET department_id = 500
849

WHERE department_id = 50;


UPDATE employees
*
ERROR at line 1:
ORA-02291: integrity constraint
(HR.EMP_DEPT_FK) violated -
parent key not found
For this reason, it is sound practice to update a parent table before updating the child table to
prevent parent key violation errors errors that generate ORA-02291 error messages.
3. Deleting rows from a table
You use the DELETE statement to remove unwanted records from a table using the following
syntax.
DELETE [FROM] table
[WHERE condition];
In the syntax, the condition specifies the rows to be deleted and can contain expressions,
constants, column names, comparison operators, and subqueries.
In the example, the DELETE statement will delete the row that contains data about the
employee whose first name is Marcia from the employees table.
DELETE FROM employees
WHERE first_name = 'Marcia';

1 row deleted.
You can also specify more than one condition in the WHERE clause for example using the
multiple-row comparison operator.
DELETE FROM employees
WHERE employee_id IN
(202, 203);

2 rows deleted.
You remove all rows from a table by leaving out the WHERE clause in a DELETE statement.
DELETE FROM employees;
850

Before deleting rows from a table, you need to ensure that there are no constraints defined on
the table.
If a table includes foreign-key constraints, for example, you need to remove the constraints
before deleting rows.
In the example, the attempt to delete the location ID 1700 failed because there are employees
and departments allocated to location 1700.
DELETE FROM locations
WHERE location_id = 1700;


DELETE FROM locations
*
ERROR at line 1
ORA-02292: integrity constraint
(HR.DEPT_LOC_FK) violated - child
record found
You can delete rows from one table based on rows in another table.
For example, let's say that you need to delete employees who are purchasing clerks from the
employees table.
The employees table contains job IDs but not job titles, so the query you use needs to reference
the jobs table to find the job ID of purchasing clerk.
DELETE FROM employees
WHERE job_id =
(SELECT job_id
FROM jobs
WHERE jobs_title = 'Purchasing Clerk');

5 rows deleted.
None of the insert, delete, or update transactions you carry out are permanent until you execute
a COMMIT statement.
If you delete or change a row in error, you can return the row to its original state using the
ROLLBACK command, providing you have not issued a COMMIT.
4. Additional DML functionality
You can use the WITH CHECK OPTION in the WITH clause of a subquery to specify that, when
a subquery is used in place of a table in an INSERT, UPDATE, or DELETE statement, Oracle will
851

not allow any changes to the table that would produce rows that are not included in the
subquery.
In the example, the WITH CHECK OPTION clause prevents the statement from changing rows
that are not included in the subquery. In this case, department 41 cannot be inserted because it
is not less than 20.
INSERT INTO (SELECT * FROM departments
WHERE department_id <20 WITH CHECK OPTION)
VALUES (41, 'Software', null,
null);


INSERT INTO (SELECT * FROM
departments
*
ERROR at line 1
ORA-01402: view WITH CHECK
OPTION where-clause violation
To comply with the SQL: 1999 standard, Oracle9i provides an explicit default facility that allows
you to fill columns with default values rather than automatically filling them with null values.
You define the default value for a column when you create a table, or you can use the ALTER
TABLE statement to define defaults for existing tables.
If you specify defaults that haven't been defined during table creation, Oracle automatically
inserts null values in their place.
You can use the explicit default facility when performing INSERT and UPDATE operations.
The example statement here will insert the specified department ID and department name but a
default manager_id in a new row in the departments table.
INSERT INTO departments (department_id, department_name,
manager_id)
VALUES (250, 'Services', DEFAULT);

1 row created
The MERGE statement allows you to write code that either inserts a new row if a relevant row
does not already exist or updates the existing row.
The MERGE facility makes it unnecessary to check whether a row already exists before you enter
new data.
852

MERGE statements also prevent duplication in cases in which a database is updated from
various sources.
The MERGE statement uses table aliases and a join condition to search for existing rows, then
update them or insert them, as the case may be.
MERGE INTO table_name table_alias
USING (table l view l sub_query) alias
ON (join condition)
WHEN MATCHED THEN
UPDATE SET
col1 = col_val1
col2 = col2_val,
WHEN NOT MATCHED THEN
INSERT (column_list)
VALUES (column_values);
The statement contains the following syntax elements:
INTO table_name table_alias
USING (table|view|sub_query) alias
ON (join condition)
WHEN MATCHED THENWHEN NOT MATCHED THEN
INTO table_name table_alias
You use the INTO clause to specify the target table you need to update.
USING (table|view|sub_query) alias
You use the USING clause to specify the source of the new data you want to enter in a table. This
source can be a table, view, or subquery.
ON (join condition)
You use the ON clause to specify the condition that the MERGE statement uses to decide whether
to update a row or to create a new row.
WHEN MATCHED THENWHEN NOT MATCHED THEN
If the target table already contains a row that is the same as the row in the source table, a MERGE
statement performs the UPDATE operation specified after the WHEN MATCHED THEN keywords.
However, if the target table doesn't contain a matching row, the MERGE statement performs the
INSERT operation specified after the WHEN NOT MATCHED THEN keywords.
In the example, tableA is the source table and tableB is the target. They are joined on a
common column called column1.

If the record already exists in the target but is not an exact match, it is updated to match the
source table.
853


If no record is found, the record is inserted from the source table to the target.
MERGE INTO tableB b
USING tableA a
ON (a.column1 = b.column1)
WHEN MATCHED THEN
UPDATE SET
a.column1 = b.column1,
a.column2 = b.column2
WHEN NOT MATCHED THEN
INSERT (column1, column2)
VALUES (column1, column2);
ON (a.column1 = b.column1)
Question
What syntax element in the MERGE statement allows you to specify the source of the new data you
want to enter in a table?
Options:
1. ON
2. USING
3. WHEN MATCHED THEN
Answer
The USING element in the MERGE statement allows you to specify the source of the new data you
want to enter in a table.
Option 1 is incorrect. You use the ON clause to specify the condition that the MERGE statement uses
to decide whether to update a row or to create a new row.
Option 2 is correct. You use the USING clause to specify the source of the new data you want to
enter in a table. This source can be a table, view, or subquery.
Option 3 is incorrect. A MERGE statement performs the UPDATE operation specified after the WHEN
MATCHED THEN keywords, If the target table already contains a row that is the same as the row in
the source table.
Summary
You can add a row to a table using the INSERT command. iSQL*Plus allows you to create a
script containing an INSERT command that uses substitution variables. Whenever the script
runs, it prompts the user to enter new values for the substitution variables.
854


You update row values using the UPDATE command. You can specify the values or transfer
them from other sources, such as views, subqueries, and other tables.

You use the DELETE command to delete one or more rows from a table. If a table includes
integrity constraints, the DELETE command allows you to delete a row only if data in another
table does not depend on that row

Oracle9i allows you to define default values for columns when you create a table, which you can
then reference when inserting or updating rows by entering DEFAULT as a value. The MERGE
command allows you to update an existing row or if the relevant row doesn't exist in a table
to insert a new row in a table.

















855

Using DML statements in an Oracle9i database
Learning objective
After completing this topic, you should be able to use DML statements to insert, update, and
delete data from an Oracle9i database.
Exercise overview
In this exercise, you're required to work with data in an Oracle9i database table.
This involves the following tasks:
inserting a row
updating a row
deleting a row
Task 1: Inserting data into a table
You are first required to insert data into a table.
Step 1 of 4
Let's say that your company adds a new department called Production and you need to add this
department to the departments table.
Type the next part of the INSERT statement.

INSERT MISSING CODE
Result
You type INTO departments next to identify the table into which the record is to be inserted.
Step 2 of 4
You need to specify the columns in the departments table into which you want to insert data. These
columns include the department_id, department_name, manager_id, and location_id columns.
Choose the correct notation for listing the required columns.

INSERT INTO departments MISSING CODE
856

Options:
1. (department_id, department_name, manager_id, location_id)
2. department_id department_name manager_id location_id
3. department_id, department_name, manager_id, location_id
Result
You specify the columns into which you need to insert data using the code
(department_id, department_name, manager_id, location_id)
Option 1 is correct. You specify the columns into which you need to insert your data enclosed in
parentheses, with each column name separated by a comma.
Option 2 is incorrect. This notation is incorrect. In this example the column names are listed but not
enclosed in parentheses or separated by commas, as they should be.
Option 3 is incorrect. This notation is incorrect. In this example the column names are listed and
separated by commas, but they are enclosed not in parentheses, as they should be.
Step 3 of 4
Choose the keyword you enter before specifying the values you want to insert in the new row.
Select an option and then click Done.

INSERT INTO departments
(department_id, department_name,
manager_id, location_id)

MISSING CODE
Options:
1. WHERE
2. SET
3. VALUES
4. FROM
Result
You use the VALUES keyword before entering the values you want to insert in a new row.
Option 1 is incorrect. The WHERE clause is used to create conditional statements to use with
commands such as SELECT, DELETE, and UPDATE.
857

Option 2 is incorrect. The values you specify in the SET clause replace the existing values with new
values for all rows that match the criterion you specify in the WHERE clause.
Option 3 is correct. This clause assigns the values of expressions to corresponding columns in the
column list. If there is no column list, the first value is inserted into the first column defined by the
CREATE TABLE statement, the second value is inserted into the second column, and so on.
Option 4 is incorrect. The FROM clause lets you specify the objects from which data is selected.
Step 4 of 4
Let's say that you've entered the appropriate values for the department_id and the
department_name columns. You now need to specify that the statement insert a value that you
defined when you created the departments table for the manager_id column.
Enter the keyword to specify a previously defined value for the manager_id column.

INSERT INTO departments (department_id,
department_name,
manager_id,
location_id)
VALUES (300,
'Production' , MISSING CODE
Result
You specify the value as DEFAULT to insert the default value defined during table creation in the
manager_id column.
You specify the appropriate value for insertion into the location_id column to complete the
required code. When you execute the INSERT statement, Oracle confirms that it has created the
required row.
INSERT INTO departments (department_id,
department_name,
manager_id,
location_id)
VALUES (300,
'Production', DEFAULT, 2400);

1 row created.
Task 2: Updating data in a table
Later the location_ID for the Production department changes from 2400 to 1700 and you need to
update the departments table with this change.
858

Step 1 of 3
Type the code to specify that you want to update the departments table.

MISSING CODE
Result
You enter UPDATE DEPARTMENTS to specify that you want to update the department table.
Step 2 of 3
Choose the keyword you enter before specifying the values you want to insert in the new row.

UPDATE departments
MISSING CODE
Options:
1. VALUES
2. WHERE
3. SET
Result
You use the SET keyword before specifying the new values for insertion into the departments table.
Option 1 is incorrect. You use the VALUES keyword to assign values to a new row, not to update an
existing row.
Option 2 is incorrect. You use the WHERE clause to specify which rows will be updated. If you do not
include a WHERE clause, all rows will be updated.
Option 3 is correct. You use the SET keyword to specify the column that is to be updated and the
new value.
Step 3 of 3
Let's say that you've entered the new location_id value for the database table and now need to
specify which row the statement must update with this data.
Type the keyword you use before specifying where the new value must be inserted.

859

UPDATE departments
SET location_id = 1700
MISSING CODE
Result
You use the WHERE keyword to specify the condition of the UPDATE statement.
When you execute the UPDATE statement, Oracle confirms that it has changed the location ID to
1700 for department 300.
UPDATE departments
SET location_id = 1700
WHERE department_id = 300
Task 3: Deleting data from a table
You must now delete data from the departments table.
Step 1 of 2
Suppose that you need to remove a row from the departments table.
Choose the notation you use to do this.

MISSING CODE
Options:
1. DELETE departments(department_id)
2. UPDATE departments(department_id = 0)
3. DELETE FROM departments
Result
To delete a specified row from a table, you need to supply the keyword DELETE and the name of the
table from which to remove the row.
Option 1 is incorrect. When using the DELETE statement to remove rows in a specified table you
must include the FROM keyword. You don't need to include the primary key for the table.
Option 2 is incorrect. You only use the UPDATE statement if you want to insert new values into a
row, rather than deleting it.
860

Option 3 is correct. You use the FROM keyword in conjunction with the DELETE statement to specify
the table that contains the row you want to delete. If you do not include a WHERE clause, all of the
rows in the table will be deleted.
Step 2 of 2
Let's say that you now need to specify that the row containing the Stores department details must be
deleted.
Complete the WHERE clause by specifying the department name as Stores.

DELETE FROM departments
WHERE MISSING CODE
Result
You complete the WHERE clause by enclosing the department name in quotes in this case
DEPARTMENT_NAME = 'STORES'; and including a semicolon at the end of the line to signal the
end of the query.
When you execute the DELETE statement, Oracle confirms that it has deleted a row.
DELETE FROM departments
WHERE department_name = 'Stores';

1 row deleted










861

Database transactions and concurrency problems
Learning objective
After completing this topic, you should be able to outline database transaction processing and
the related problems.
1. Transaction processing
A transaction is a logical unit of work that the Database Management System (DBMS)
processes.

A transaction must be completed in its entirety or not at all.
Only one user can access a database in a single-user DBMS.

And in a multiuser system, many users can access a database at the same time concurrently
to query or update the database.
In response to a query, a DBMS reads data, and in responding to an update command, it writes
data.

You can specify a transaction within BEGIN TRANSACTION and END TRANSACTION
statements in an application program.
Suppose that you want to view an item video (x) in a video table.
In responding to a query, the DBMS
finds the disk block address containing video (x)
copies the disk block into a buffer in the main memory
copies the value in video (x) from the buffer to the program variable x
The buffers in the main memory of a DBMS store database disk blocks containing the database
items for processing.

The buffer replacement policy determines which buffers to replace when all the buffers are filled
with data items.
Suppose that you want to update an item video (y) in a video table.
In response to a update query, the DBMS
finds the disk block address containing video (y)
copies the disk block into a buffer in the main memory
862

copies the value of video (y) from the program variable y to the correct buffer location
stores the updated block from the buffer to the hard disk
When a transaction ends, it may enter a partially committed state.

Recovery protocols write the changes in the system log to ensure that data is not lost due to a
system failure. The transaction reaches its commit point after the system log is updated.

In the committed state, the DBMS records the transaction permanently in the database.
Question
When a transaction fails, it goes into a failed state. You can restart a failed transaction as a new
transaction later.
Which processes do you think can cause a transaction failure?
Options:
1. A buffer failure
2. A system failure
3. A transaction failure
4. A user aborting a transaction
Answer
A system failure, transaction failure, and a user aborting a transaction can cause a transaction
failure.
A transaction enters the terminated state after it has committed or after it has failed.

To undo a written transaction, you can roll back the transaction.
Question
What does the DBMS do in response to an update query?
Options:
1. It copies the disk block into a buffer in main memory
2. It copies the new value from the program variable to the hard disk
3. It finds the disk block address containing the value to be updated
4. It copies the original block from the buffer into the program variable
863

Answer
The DBMS, in response to an update query, finds the disk block address containing the value to be
updated, and copies the disk block into a buffer in main memory.
Option 1 is correct. This stores the original value and enables the update to be undone, if
necessary. It also helps to provide read consistent data.
Option 2 is incorrect. It copies the new value from the program variable to the correct buffer location.
Option 3 is correct. This ensures that the correct value in the table is selected for update.
Option 4 is incorrect. It stores the updated block from the buffer to the hard disk.
2. Concurrency control
In a shared database system, users may share individual data items.
Question
Users can access the same data in a shared database at the same time, which is known as
concurrent access.
What do you think happens to the data when users modify the same data at the same time?
Options:
1. The data is corrupted
2. The data is duplicated
3. The data becomes inconsistent
4. The data is rejected
Answer
When users modify the same data at the same time, the data becomes inconsistent.
A database with good concurrency allows many users to access the database simultaneously
without reducing the performance of the database.

And the DBMS must be able to exercise concurrency control to eliminate data inconsistency,
and to ensure that transactions are completed.
864

3. Concurrency control problems
When many users access a database simultaneously, concurrency control problems can result.
Incorrect aggregate problems
Lost update problems
Temporary update problems
Incorrect aggregate problems
An incorrect aggregate problem occurs when a transaction calculates the sum of a number of
records while these records are being updated.

Suppose that a centralized warehouse supplies three video stores with a specific video.

When the manager views the stock, he finds that Store 1 has 5 videos, store 2 has 18 videos,
and store 3 has 12 videos.

While the manager is reading the information, a clerk transfers 4 videos to Store 1 and updates
the database.

The database shows that Store 1 has 5 videos, Store 2 has 18 videos, and Store 3 has 8 videos.

The stock displayed does not include the 4 videos that the clerk transferred.
Lost update problems
When two transactions attempt to read, use, and update a table, the database allows only one
transaction to run, so a lost update problem occurs.

Let's say that two clerks attempt to update a row containing a quantity of 15videos
simultaneously.

Clerk A wants to add three videos, while Clerk B wants to add five videos to the row at the same
time.

When Clerk B updates the number of videos, the row contains 18 instead of 15 videos.

The database updates the quantity from 15 to 20 so that the last updated quantity reads 20
instead of 23 videos.

Because the previous entry is overwritten, the database doesn't reflect the actual stock in the
warehouse.
Temporary update problems
865

When a record is not written committed to a database, and another transaction retrieves and
updates the same record, a temporary update problem occurs.

Let's say that Clerk A updates a video record containing the quantity for a specific video in a
warehouse.

Clerk A incorrectly updates the video field to 30 instead of 40, so Clerk A issues a ROLLBACK
command.

While Clerk A is updating the stock, Clerk B starts a separate transaction to input a shipment of
20 videos for the same record.

The second transaction does not see the new value of 40 and instead updates the field from 30 to
50.

The database consequently shows 10 videos fewer than the 60 videos the warehouse actually
contains.
Question
Let's say a record is not written committed to a database, and a second transaction retrieves
and updates the same record.
What type of concurrency problem is this?
Options:
1. Incorrect aggregate problem
2. Lost update problem
3. Temporary update problem
Answer
When a record is not written committed to a database, and another transaction retrieves and
updates that same record, a temporary update problem will occur.
Option 1 is incorrect. An incorrect aggregate problem occurs when a transaction calculates the sum
of a number of records while these records are being updated.
Option 2 is incorrect. When two transactions attempt to read, use, and update a table, the database
allows only one transaction to run, so a lost update problem occurs
Option 3 is correct. In this case the second transaction sees what it believes to be the correct value
at the beginning of the transaction and the database shows an incorrect value for the record when
the transaction completes.
866

Summary
A Database Management System (DBMS) processes units of work called transactions so that
users can query and update a database. A single-user system allows one user to work on a
database, whereas a multiuser system allows many users to access and update a database
simultaneously.

Users may share access to data items in the same database. Users then have concurrent
access, so they can access the data in the database at the same time. The DBMS has to deal
with several users attempting to access and modify the same data at the same time.

Concurrency control problems include incorrect aggregate problems, lost update problems, and
temporary update problems. These problems occur because users execute transactions on the
same records simultaneously so that data in the database differs from the data in the real world.
















867

Resolving concurrency problems in a database
Learning objective
After completing this topic, you should be able to outline how to resolve concurrency problems
in a database.
1. Locking data
Locking is the most popular mechanism for implementing concurrency controls in commercial
Database Management Systems (DBMSs).
To ensure that a database object remains stable during a transaction, the transaction needs to
obtain a lock on the object typically a record.
A lock prevents other transactions from accessing an object and changing it.

A transaction can then be executed on an object, and the object remains stable for the duration
of the transaction.

When a transaction is completed, it releases the lock.
If a transaction requests a lock on an object that is already locked, the requesting transaction is
placed in a Wait state.
Question
A DBMS uses exclusive (X) locks and share (S) locks.
See if you can match the functions to each lock type.
Options:
1. Allows a transaction to update data in a database
2. Allows concurrent transactions to read the same data
3. Allows transactions to read data from a database
4. Prevents other transactions from accessing the data or placing a lock on the data
Targets:
A. Exclusive (X) lock
B. Share (S) lock
868

Answer
An exclusive (X) lock allows a transaction to update data in a database, and it prevents other
transactions from accessing the data or placing a lock on the data.

A share (S) lock allows transactions to read data from a database, and it allows concurrent
transactions to read the same data.
Locking data can cause a deadlock, which prevents both transactions from updating a record.
Let's say that a transaction wants to update a specific record, and another transaction needs to
read the same record to update another record.

Both users access the same record at the same time and are unable to complete their
transactions, so the transactions remain in a Wait state.
The Transaction Manager must be able to detect and resolve deadlocks.

Once the Transaction Manager detects a deadlock, it must force one or both transactions to
release their locks and start the transaction again.
A potential deadlock can be avoided if the Transaction Manager issues a ROLLBACK command.

This command forces both transactions to discontinue and start again.
Question
Which of these statements about locking are true?
Options:
1. A transaction typically locks a record
2. A lock prevents other transactions from changing an object
3. Locking data can cause a deadlock
4. When a transaction completes, it applies a lock
Answer
A transaction typically locks a record. A lock prevents other transactions from changing an object,
and locking data can cause a deadlock.
Option 1 is correct. It does this to ensure that a database object remains stable during a transaction.
Option 2 is correct. For example, you would not have data integrity in your database if two users
could update the same record with different values at the same time.
869

Option 3 is correct. When a deadlock occurs neither transaction can complete so the transactions
remain in a Wait state.
Option 4 is incorrect. When a transaction completes it releases the lock, so every effort should be
made to commit transactions quickly.
2. Resolving concurrency problems
When two transactions read data from a database, use the information, and then try to update
the data simultaneously, a lost update problem occurs.

You can solve a lost update problem by configuring the DBMS to use exclusive locks.

An exclusive lock prevents a transaction from updating data that another application is updating.
When a record is not written committed to a database, and another transaction retrieves and
updates the same record, a temporary update problem occurs.

You solve a temporary update problem using exclusive locks.

If a transaction updating a record has an exclusive lock, no other transaction can access the
record until it is committed or rolled back.
When a transaction sums a number of records while these records are being updated, an
incorrect aggregate problem occurs.

You can solve an incorrect aggregate problem by assigning a higher priority level to write
operations than read operations.

This means that a transaction that is updating data can do so before the transaction that is
reading the data.
The database administrator (DBA) can set the following locking parameters to solve
concurrency problems:
lock sizes
lock limits
lock escalation
lock timeouts
lock sizes
A DBA can set the lock size such as row, column, table, or page lock, in a database.

For example, a row lock enables concurrent users to access and update all the rows on a page
except the locked row.
870

lock limits
A DBA can set a finite limit on the number of locks.

This limit can be raised to allow more complex transactions, which lock various data objects, to
process a query or update a database.

The DBA can lower the limit to permit earlier lock escalation with fewer restrictions.
lock escalation
Lock escalation enables a DBMS to combine several smaller locks into a single larger lock.

The DBMS can then escalate multiple record-level locks into a page-level lock.

Lock escalation minimizes the amount of tracking that a DBMS has to do to manage busy user or
application locks.
lock timeouts
A DBA can set a time limit for a lock on a record.

Setting a time limit for a lock can increase concurrency and throughput because it allows the
DBMS to resolve deadlocked transactions quickly.
Question
You need to solve concurrency problems to improve the performance of a database.
See if you can match the solutions to the concurrency problems.
Options:
1. Prioritizing write operations
2. Using exclusive locks
3. Using shared locks
Targets:
A. A lost update problem and a temporary update problem
B. An incorrect aggregate problem
Answer
You use exclusive locks to solve a lost update problem and a temporary update problem. You
prioritize write operations before read operations to solve an incorrect aggregate problem.
871

Question
Why would you set lock escalation parameters?
Options:
1. It allows you to set a time limit for a lock on a record
2. It enables you to set a lock size such as row, column, table or page lock, in a database
3. It minimizes the amount of tracking that a DBMS has to do to manage busy user or application
locks
Answer
You set lock escalation parameters to minimize the amount of tracking that a DBMS has to do to
manage busy user or application locks.
Option 1 is incorrect. Lock timeout parameters can be used to set a time limit for a lock on a record.
Setting a time limit for a lock can increase concurrency and throughput because it allows the DBMS
to resolve deadlocked transactions quickly.
Option 2 is incorrect. Lock size parameters can be used to set lock sizes. For example, a row lock
enables concurrent users to access and update all the rows on a page except the locked row.
Option 3 is correct. Lock escalation enables a DBMS to combine several smaller locks into a single
larger lock. The DBMS can then escalate multiple record-level locks into a page-level lock.
3. Locking granularity
A database consists of named data items.

The size of a data item is called its granularity.

Granularity can be field in a record, a record, or a whole disk block.
Locking can occur at the following granularity levels:
fine or row level
page or block level
coarse or table level
fine or row level
Fine or row-level granularity is the lowest granularity level.

Locking a row level means that only the row being updated is locked until the update is
872

completed.

Not all the DBMSs can lock data at row level.
page or block level
Page or block-level locking is the medium level of granularity.

All the rows on the same page as the one row that the user updates are also locked.
coarse or table level
Coarse or table-level granularity occurs when the full table is locked.

Coarse granularity has fewer locks, which means less testing, setting up, and maintenance costs.

However, coarse granularity can lead to less concurrency because it locks more data, which can
reduce transaction-processing performance.
The lower the granularity level of locking, the higher the throughput in multiuser database
systems.

A lower granularity level also involves higher costs because the Lock Manager needs to perform
more lock and unlock operations.
Question
Suppose that you are a DBA, and a database currently has low data availability.
What granularity locking level do you think you need to implement so that the database can have
higher data availability?
Options:
1. Page-level
2. Row-level
3. Table-level
Answer
You use fine or row-level granularity locking to increase the performance of the database for higher
data availability.
Question
What is the lowest granularity level?
Options:
873

1. Coarse or table level
2. Fine or row level
3. Page or block level
Answer
Fine or row level granularity is the lowest granularity level.
Option 1 is incorrect. Coarse or table-level granularity occurs when the full table is locked. Coarse
granularity has fewer locks, which means less testing and setting up, and lower maintenance costs.
Option 2 is correct. Locking a row level means that only the row being updated is locked until the
update is completed. Not all DBMSs can lock data at row level.
Option 3 is incorrect. Page or block-level locking is the medium level of granularity. All the rows on
the same page as the one row that the user updates are also locked.
Summary
You lock data to solve concurrency problems. The two types of locks are exclusive locks and
shared locks. A deadlock results when two transactions cannot complete because they are both
attempting to update the same record simultaneously.

A database administrator (DBA) can set locking parameters. Exclusive locks can solve a lost
update problem or temporary update problem. When prioritizing write operations before read
operations, you can solve an incorrect aggregate problem.

The granularity level refers to the size of a locked data item, such as a record, a disk block, or a
table. A DBA can set the granularity level. The finer or lower the granularity level of locking, the
higher the throughput because you lock only the rows being used.







874

Database security
Learning objective
After completing this topic, you should be able to describe database security and access issues.
1. Database security issues
A database administrator (DBA) implements security measures to ensure data security and
confidentiality.
To secure data, a DBA uses
passwords
privileges
A DBA assigns users passwords to prevent unauthorized users from gaining access to a
database.

And the DBA assigns users privileges to prevent authorized users from performing unauthorized
activities in a database.
A DBA can implement discretionary or mandatory access control.

The DBA assigns users discretionary privileges to allow them to access specific files, fields, or
records in a database.

The DBA also needs to specify whether users can delete, insert, read, or update the files or
fields they can access.
The DBA classifies data and users into security levels and assigns users mandatory privileges
according to these categories.
Question
What do you think are the security mechanisms inherent in a database protect?
Options:
1. The database
2. The database and hardware
3. The database and operating system
4. The database and applications
875

Answer
Inherent database security mechanisms protect the database only.
2. Database access
Because a DBA has a System or Superuser account, the DBA has full control over the database
and its contents.

The DBA creates and implements security and policies to ensure that only authorized users can
gain access to it.
A DBA manages the security and access to a database by
assigning users security access
creating user accounts
denying users privileges
granting users privileges
assigning users security access
A DBA classifies data into security classes or levels. For example, sensitive data has a high level
of classification and only a few users can access this data.

Most users can access less restricted data in a database.

Assigning users security access is an example of mandatory authorization.
creating user accounts
Only a DBA or a user who has similar privileges can create new user or group accounts.

The DBA assigns each user or group an individual password.
denying users privileges
A DBA can restrict a user's access to a database by using a policy or by changing the level of
access on the user's account.

For example, the DBA can change the privileges of a user who could previously update and enter
data into a database to read-only privileges.
granting users privileges
A DBA can grant certain user accounts access to data in a database as they require it.

For example, the DBA can assign users working on a project permission to read, insert, or update
data for the duration of the project.
876

Many Database Management Systems (DBMSs) provide some form of a logging mechanism to
keep track of the number of times users access or attempt to access specific database tables.

The logging mechanism records all updates, the users who made them, from which device they
were made, and at what time they were made.

This mechanism also records whether users accessed a database successfully.
A transaction log is a permanent record of important events occurring in a database system.

The log is produced automatically each time such an event occurs.

The transaction log should be stored in a protected area of the database system so that it can
remain intact if anything happens to the database.
A transaction log may be used to ensure the validity of data by reviewing the sequence of
operations performed on the data.

This review is called an audit trail.

A DBA can perform regular audits to maintain the integrity of a database, and the DBA can
perform periodic audits to catch intruders off guard.
Question
Match each security method to its description.
Options:
1. Assigning users security access
2. Creating user accounts
3. Denying users privileges
4. Granting users privileges
Targets:
A. The DBA assigns each user a password.
B. The DBA can change a user's privileges to read-only.
C. The DBA gives users access to data as they require it.
D. This is an example of mandatory authorization.
Answer
Assigning users security access is an example of mandatory authorization. The DBA assigns each
user a password when creating user accounts. The DBA can change a user's privilege to read-only,
877

thereby denying users privileges. And the DBA gives users access to data as they require it by
granting users privileges.
A DBA classifies data into security classes or levels. For example, sensitive data has a high level of
classification and only a few users can access this data. Most users can access less restricted data
in a database.
Only a DBA or a user who has similar privileges can create new user or group accounts.
A DBA can restrict a user's access to a database by using a policy or by changing the level of
access on the user's account.
For example, the DBA can assign users working on a project permission to read, insert, or update
data for the duration of the project.
3. Discretionary database access
A DBA enforces discretionary access control by granting or revoking user access permissions.
SQL provides two commands for authorization control:
GRANT
REVOKE
The DBA uses these commands to assign or cancel privileges on accounts or relations in a
database.
When a DBA grants privileges to an account, these privileges are independent of the database
tables.

Account privileges may permit a user the right to create or alter a schema, table, or view. And
these privileges may permit a user the right to delete relations or views.

The details of users and their privileges are stored in the data dictionary or system catalog.
Question
What do you think a DBA uses to prevent users from accessing sensitive data?
Options:
1. An entity
2. A tuple
3. A value
4. A view or virtual table
878

Answer
A DBA can use views to prevent users from accessing information they have no right to see or use.
A view can restrict some users to certain columns in a database.

For example, employees may be allowed to view each other's telephone extension numbers in
the Personnel table.

The employees would probably be excluded from viewing other data in the same table, such as
another employee's date of birth or salary.
Question
Identify the true statements regarding database security.
Options:
1. A DBA can implement discretionary or mandatory access controls
2. A transaction log is a permanent record of important events occurring in a database system
3. Details of all users and their privileges are stored in the audit trail
4. SQL provides commands for authorization control
Answer
A DBA can implement discretionary or mandatory access controls. A transaction log is a permanent
record of important events occurring in a database system. And SQL provides commands for
authorization control.
Option 1 is correct. The DBA assigns users discretionary privileges to allow them to access specific
files, fields, or records in a database. The DBA also must specify whether users can delete, insert,
read, or update the files or fields they can access.
Option 2 is correct. The transaction log should be stored in a protected area of the database system
so that it can remain intact if anything happens to the database.
Option 3 is incorrect. Details of all users and their privileges are stored in the data dictionary or
system catalog.
Option 4 is correct. SQL provides the GRANT and REVOKE commands for authorization control. The
DBA uses these commands to assign or cancel privileges on accounts or relations in a database.
879

Summary
A database administrator (DBA) implements security measures to keep data in a database
confidential or secure. These security measures involve providing users with different levels of
access to the database and preventing unauthorized persons from gaining access to a
database.

A DBA controls access to a database to ensure that only authorized users have access to it.
And the DBA manages access to a database by creating and implementing security and
organizational policies. Because a DBA has a System or Superuser account, the DBA has full
control over a database and its contents.

A DBA enforces discretionary access control by granting or revoking user privileges on accounts
or relations in a database. And a DBA can use views to prevent users from accessing
information they have no right to see or use.















880

Oracle9i database users
Learning objective
After completing this topic, you should be able to describe Oracle9i database users, how to
authenticate them, and their relationship to schemas.
1. Users and security
A database administrator controls access to a database by creating users and specifying their
security domains.

A security domain contains a user's settings, roles, privileges, and space quotas.
Users have to authenticate themselves before they can access a database.
Methods of authentication include
data dictionary authentication
operating system authentication
network authentication
2. User settings
To create a user, you begin by assigning the user a unique name.

A user's name cannot be the same as any existing role.
You use the DEFAULT TABLESPACE parameter to specify where Oracle should store objects
that a user creates.
You use the TEMPORARY TABLESPACE parameter to specify which tablespace Oracle should
use when a user executes SQL statements requiring temporary segments.
If you don't specify a temporary tablespace, Oracle stores these statements in the SYSTEM
tablespace.
You use direct privileges to control which actions a user can perform.

For example, to enable a user to create a table, you need to grant the user the CREATE TABLE
privilege.

You can grant a user privileges indirectly by assigning the user a role.
881

You can use a profile to specify parameters for automatic account locking.

When a user fails to log onto a database within the specified number of attempts, Oracle locks
the account.

You can also lock or unlock an account manually.
You use resource limits to control a user's access to the physical resources of your system.

For example, you can specify the amount of CPU time that a user may consume per cycle, or
the number of sessions that a user may open concurrently.
Question
Which of these statements are true about database users?
Options:
1. A profile can be used to specify parameters for automatic account locking
2. Users have to authenticate themselves before they can access a database
3. You use direct privileges to control which actions a user can perform
4. You use the TEMPORARY TABLESPACE parameter to specify where Oracle should store objects
that a user creates
Answer
Users have to authenticate themselves before they can access a database and a profile can be
used to specify parameters for automatic account locking. In addition, you use direct privileges to
control which actions a user can perform.
Option 1 is correct. You can set a profile so that when a user fails to log onto a database within the
specified number of attempts, Oracle locks the account.
Option 2 is correct. Methods of authentication include data dictionary authentication, operating
system authentication, and network authentication.
Option 3 is correct. To control which actions a user can perform, you use direct privileges. For
example, to enable a user to create a table, you need to grant the user the CREATE TABLE
privilege. You can also grant a user privileges indirectly by assigning the user a role.
Option 4 is incorrect. You use the DEFAULT TABLESPACE parameter to specify where Oracle
should store objects that a user creates. You use the TEMPORARY TABLESPACE parameter to
specify which tablespace Oracle should use when a user executes SQL statements requiring
temporary segments.
882

3. User authentication methods
Only authenticated users can access a database.
You can authenticate a user using the
data dictionary
operating system
network
data dictionary
You can authenticate users by storing their passwords in the data dictionary.

Users enter their passwords when they connect to a database, and they can change their
passwords at any time.

Oracle verifies new passwords to ensure sufficient complexity.

New passwords should be at least four-characters long and should contain at least one letter, one
number, and one punctuation mark.

New passwords should differ from previous passwords by at least three characters.

These rules are not enforced by default but are recommended for added security.
operating system
Users can log onto Oracle without specifying a password by using operating system
authentication.

When you use operating system authentication, Oracle does not manage or store passwords. It
maintains a list of usernames instead.

Unauthenticated users can't access Oracle.
network
You can authenticate users by accepting authentication from a network.

Oracle can accept public keys, digital certificates, and third-party authentication technology.
Question
Which authentication method stores user passwords?
Options:
883

1. Data Dictionary
2. Network
3. Operating System
Answer
Users' passwords are stored in the data dictionary and it is possible for them to change their
password at any time.
Option 1 is correct. Oracle uses the data dictionary to store user's passwords and to verify new
passwords to ensure sufficient complexity. New passwords should be at least four characters long
and should contain at least one letter, one number, and one punctuation mark.
Option 2 is incorrect. The Network does not store users' passwords. However you can authenticate
users by accepting authentication from a network. Oracle can accept public keys, digital certificates,
and third-party authentication technology.
Option 3 is incorrect. Users can log onto Oracle without specifying a password by using operating
system authentication. When you use operating system authentication, Oracle does not manage or
store passwords. It maintains a list of usernames instead.
4. Users and schemas
A schema is a named collection of objects that a user has access to.

When you create a user, Oracle creates a schema for that user.

Because a database user can have only one schema, users and schemas are often referred to
interchangeably.
Users can add objects to their schemas at any time, provided they have sufficient privileges to
create those object types.

Users cannot access objects contained in schemas that do not belong to them.
Question
Which of the following do you think are examples of schema objects?
Options:
1. Constraints
2. Indexes
3. Tables
4. Views
884

Answer
Examples of schema objects include constraints, indexes, tables, and views.
Question
Which of these statements are true?
Options:
1. A profile is another name for a schema
2. A schema is a collection of objects that a user has access to
3. A user can create objects in his schema
4. A user can have many schemas
Answer
A schema is a collection of objects that a user has access to and a user can create objects in it.
Option 1 is incorrect. A profile is a set of limits on a database. You can assign a profile to a user in
which case the limits will apply to that user.
Option 2 is correct. When you create a user, Oracle creates a schema for that user.
Option 3 is correct. Users can create objects in their schema, provided that they have the
permissions to do so. Schema objects include tables, views indexes, and constraints.
Option 4 is incorrect. A user can have only one schema and can only access object in that schema.
Summary
A database administrator controls access to a database by creating users and specifying their
security domains.

When you create users, you can specify their settings, including their default tablespaces,
privileges, and resource limits.

You can authenticate users using the data dictionary, the operating system, or network
authentication.

When you create a user a corresponding schema is created. A user is associated with a schema
of the same name.
Username and schema are usually referred to as the same thing.

885

Privileges in an Oracle9i database
Learning objective
After completing this topic, you should be able to describe system and object privileges in an
Oracle9i database.
1. Privileges
A privilege is a right a user is assigned to run a specific SQL statement or to access an object
owned by another user.
Oracle provides the following types of user privileges:
system privileges
object privileges
system privileges
A system privilege allows a user to execute a specific database operation or set of database
operations.
object privileges
An object privilege allows a user to execute a specific action on a specific object, such as a
function, package, procedure, sequence, table, or view.
You can manage privileges by granting
a user the right to perform a specific operation
privileges directly to a role or user
privileges to all users
and revoking access to execute system functions
2. System privileges
System privileges include privileges that enable users to
administer objects in their own schemas, for example to create tables
administer objects in any schema, for example to create any table
perform system-wide operations, for example to create tablespaces
You assign a system privilege to a role or user using the GRANT command.
GRANT CREATE TABLE TO "HR"
886

To specify that the role or user should have the privilege in any schema, you add the ANY
keyword.
GRANT CREATE ANY TABLE TO "HR"
You use the REVOKE command to remove a system privilege from a role or user.
REVOKE CREATE ANY TABLE FROM "HR"
Question
From this list of options, select the ones that you need to keep in mind when managing system
privileges.
Options:
1. A user requires the DROP ANY TABLE privilege to truncate a table in another schema
2. A CREATE command for a specific object does not include the DROP command for that object
3. The CREATE TABLE command includes the ANALYZE and CREATE INDEX commands
4. You cannot grant the UNLIMITED TABLESPACE privilege to a role
5. You cannot assign a user a privilege for creating indexes
Answer
A user requires the DROP ANY TABLE privilege to truncate a table in another schema, and the
CREATE TABLE command includes the ANALYZE and CREATE INDEX commands. In addition, you
cannot grant the UNLIMITED TABLESPACE privilege to a role, and you cannot assign a user a
privilege to create indexes.
A CREATE command for a specific object, such as a cluster, procedure, or table, includes the
DROP command for that object.
To use a CREATE TABLE command, a user requires the UNLIMITED TABLESPACE privilege or
a quota for the tablespace.
Only database administrators should be assigned the SYSDBA and SYSOPER system
privileges.
The SYSDBA system privilege grants an administrator unlimited control over a database and
includes the following privileges:
SYSOPER PRIVILEGES WITH ADMIN OPTION
CREATE DATABASE
ALTER DATABASE BEGIN/END BACKUP
RECOVER DATABASE UNTIL
RESTRICTED SESSION
887

The SYSOPER system privilege includes the following privileges:
STARTUP
SHUTDOWN
ALTER DATABASE OPEN | MOUNT
ALTER DATABASE ARCHIVELOG
ALTER DATABASE BACKUP CONTROLFILE TO
RECOVER DATABASE
The SYSDBA and SYSOPER system privileges allow an administrator to access the data
dictionary objects of a database.
To allow users who have system privileges, other than SYSDBA and SYSOPER, to access data
dictionary objects, you need to set the 07_DICTIONARY_ACCESSIBILITY parameter to TRUE.

Users with system privileges can consequently access objects in the SYS schema.
Note
The default value of the 07_DICTIONARY_ACCESSIBILITY parameter is FALSE, disallowing data
dictionary access.
3. Object privileges
Every database object has a set of object privileges that you can grant to a role or user.
Specific privileges exist for a number of database objects, including tables, views, packages,
and procedures.
For example, the available object privileges for the COUNTRIES table are
ALTER
DELETE
INDEX
INSERT
REFERENCES
SELECT
UPDATE
Other database objects are managed via system privileges only.
Object privileges apply equally to the object on which they are granted and to a synonym
defined for the object.
888

Question
What is a synonym?
Options:
1. A name defined for an object
2. An object privilege
3. A system privilege
Answer
A synonym is a name defined for an object.
Option 1 is correct. A synonym can be used to make working with objects with awkward names
easier. For example, you could create a synonym called pers for a table that is actually called
personnel_details.
Option 2 is incorrect. An object privilege is a right that a user is assigned to perform actions on
specific objects. These include INSERT, ALTER, DELETE, and UPDATE.
Option 3 is incorrect. System privileges include privileges that enable users to administer objects in
their own schemas, administer objects in any schema, and perform system-wide operations.
Summary
A privilege is a right that a user is assigned to run a specific SQL statement or to access an
object owned by another user. Oracle provides object privileges and system privileges.

System privileges include privileges that enable users to administer objects in their own
schemas, administer objects in any schema, and perform system-wide operations. Only
database administrators should be assigned the SYSDBA and SYSOPER system privileges.

Every database object has a set of object privileges that you can grant to a role or user.





889

Programming languages
The Evolution of Computers and Software Programming
Learning Objectives
After completing this topic, you should be able to
identify stages in the evolution of software programming languages
recognize the main types of programming languages that evolved
1. The evolution of programming
Computers aren't capable of thought in the same way that humans are. They can do only what
they're told to do. A program is a set of step-by-step instructions that tells a computer what to
do.
Programs are written in various programming languages, which differ in complexity and function.
The language used to create a program depends on what the program will be used for, as well
as other factors.
Programming languages have generally evolved with the goal of making it easier for developers
to read and write programs. However, the easier a programming language is to read and write,
the slower and larger it tends to be. Today, the goal is to create programs that are easy to write
and modify, and that run faster and take up less space.
Drill Down Home Page
The evolution of programming languages can be described in four stages.
Page 1 of 4: The first stage - binary code
The only language that computers actually understand is binary code. Binary code consists of
two numbers 1 and 0. Using this language is known as binary arithmetic.
A computer's processor consists of millions of tiny electronic switches that are either on or off. In
binary code, the number 1 represents an on state and the number 0 represents an off state. A
typical instruction to a computer consists of a long string of 1s and 0s.
Page 2 of 4: The first stage - binary code
Binary language was developed to communicate with first-generation computers. These
computers consisted of large components joined by cables. They were so huge that they filled
entire rooms.
890

At first, scientists reprogrammed these computers by physically rearranging their cables and
switches. Later they developed ways of rearranging the instructions given to a computer using
binary code. This was much easier, and could make the computer behave in different ways.
Page 3 of 4: The first stage - binary code
Binary language isn't ideal for programming, for the following reasons:
it's extremely tedious and time-consuming to write
it's very easy to type the wrong value by mistake, and
programs written in binary language can't be transferred between different processors
Page 4 of 4: The first stage - binary code
Because of the difficulties associated with binary language, many new programming languages
have evolved. However, all instructions written in other languages have to be converted into
binary code before a computer can understand them.
Page 1 of 3: The second stage assembly languages
Assembly languages use short commands made up of abbreviated words, such as MOV and
ADD, and hexadecimal numbers. Each of these commands can replace more than ten binary
commands and they're much easier to read, write, and modify than binary code.
Code
.model small
.stack 100h

.data
msg db 'Hello, world!$'

.code
start:
mov ah, 09h ; Display the message
lea dx, msg
int 21h
mov ax, 4C00h ; Terminate the executable
int 21h

end start
891

Page 2 of 3: The second stage assembly languages
A processor retrieves data from a source such as a hard disk and temporarily stores it in a part
of the processor called a register. The processor then edits the data and sends it back to the
hard disk or to another location.
Assembly language can be used to tell the processor which data to retrieve, which register to
store it in, how to manipulate it, and when to send it back. For example, this code tells the
processor to move the hexadecimal number 09h into the register ah.
Code
.model small
.stack 100h

.data
msg db 'Hello, world!$'

.code
start:
mov ah, 09h ; Display the message
lea dx, msg
int 21h
mov ax, 4C00h ; Terminate the executable
int 21h

end start
Assembly language can be translated and converted into binary code by a special program
known as an assembler. Because computers understand only binary code, each program
written in assembly language has to be fed through an assembler before it can work.
Page 3 of 3: The second stage assembly languages
Assembly language programs have the following disadvantages:
Code
.model small
.stack 100h

.data
msg db 'Hello, world!$'

.code
892

start:
mov ah, 09h ; Display the message
lea dx, msg
int 21h
mov ax, 4C00h ; Terminate the executable
int 21h

end start
they run more slowly than binary language programs
they take up more hard-disk space and use more memory than binary programs
they're system-specific and therefore can't be transferred from one computer to another, and
they're extremely tedious to write
Page 1 of 4: The third stage high-level languages
High-level languages were developed to solve one of the major problems with assembly
language which is that assembly language programs aren't portable.

High-level languages are also easier to understand than assembly language because they make
use of recognizable words such as BEGIN, END, and IF.
Code
IF age < 12 THEN
Classification := "child";
ENDIF
Page 2 of 4: The third stage high-level languages
Just like assembly language, high-level languages can't be understood by processors. Programs
written in these languages have to be translated into binary code by either compilers or
interpreters.
Compilers translate large chunks of code into binary at a time. However, the act of compiling
can be time-consuming.
Interpreters, on the other hand, translate code into binary line by line when a program is run,
making it unnecessary to wait until all code has been translated. The disadvantage of
interpreters is that program execution can be slow.
893

Page 3 of 4: The third stage high-level languages
Various commonly used languages are examples of high-level languages:
Java

Code
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}


Pascal

Code
program HelloWorld;
begin
writeln('Hello, world');
end.


BASIC, and

Code
10 PRINT "Hello, world!"
20 END


C

Code
main( ) {
printf("hello, world");
}


Page 4 of 4: The third stage high-level languages
C is probably the most widely used programming language in history. This is because it can give
the programmer access to hardware, and is easier to read and write than assembly language. C
894

has evolved over time, and has laid the groundwork for derivative languages such as C++ and
C#.
Code
main( ) {
printf("hello, world");
}
Page 1 of 3: The fourth stage fourth-generation languages
Fourth-generation programming languages were developed to speed up the application
development process by automating tasks and providing tools based on graphic user interfaces,
or GUIs. One command in a fourth-generation language can replace up to 50 binary-code
commands.
Many fourth-generation languages are designed for specific business purposes. For example,
Structured Query Language or SQL is used to work with data in databases. For example,
the SQL command shown can be used to retrieve the names of all full-time employees from a
database.
Code
Select *
From Employees
Where Full_Time = 'Yes'
Fourth-generation languages make more frequent use of words found in human languages than
earlier programming languages. For example, you can use the word Select when retrieving
specific records from a database using SQL.
Code
Select *
From Employees
Where Full_Time = 'Yes'
Page 2 of 3: The fourth stage fourth-generation languages
These are two widely used examples of fourth-generation languages:
SQL, which is used for database queries, and

Code
895

Select *
From Employees
Where Full_Time = 'Yes'

ColdFusion, which is used for web development

Code
<cfset message = "Hello World!">
<cfoutput>#message#</cfoutput>


Page 3 of 3: The fourth stage fourth-generation languages
Various GUIs for generating code using fourth-generation languages are available. For example,
you can use a report painter to specify the data required from a database and click a single
button to generate the code necessary to compile a report.
Fourth-generation languages also make use of libraries that provide code for common functions.
Question
Sequence the stages in the evolution of software programming languages.
Options:
A. Binary code
B. Assembly language
C. High-level languages
D. Fourth-generation languages
Answer
Correct answer(s):
Binary code is ranked the first stage.
Binary code consists of 1s and 0s. It was the very first programming language, and is still the
only language that a computer processor can understand.
Assembly language is ranked the second stage.
Assembly language uses short commands made up of abbreviated words and hexadecimal
numbers. It's simpler for people to use than binary code, and so represents a second stage in
the evolution of programming.
High-level languages is ranked the third stage.
896

High-level languages were developed to make programs portable, and to simplify
programming by including recognizable words in code. They overcame some of the limitations
associated with assembly language and so represent a third stage in the evolution of
programming.
Fourth-generation languages is ranked the fourth stage.
Fourth-generation languages enable programmers to generate code using high-level
commands and, in some cases, a GUI. They represent the fourth, or current stage, in the
evolution of programming.
2. Programming languages
Many programming languages have been developed over the years, partly because different
development situations call for different languages.

For example, JavaScript is best when you want to implement interactive features or add
functionality to a web site, whereas Java is best when you need to develop a program quickly
and easily. The choice of programming language also depends on the system that will be used
and the types of tasks that a program must perform.
Specialized programming languages can be divided into five categories:
high-level languages
There are several specialized languages within the category of high-level languages. One of
these is FORTRAN, which stands for Formula Translator. This language is best used for creating
programs for mathematical or scientific work. Another example is COBOL, which stands for
Common Business-Oriented Language and is used primarily in commerce.
Rapid Application Development or RAD languages
RAD languages were developed to enable developers to create powerful graphic user interfaces,
or GUIs, with objects like mouse pointers, windows, scrollbars, and buttons. Examples of RAD
languages are Visual Basic, Delphi, and Visual C#.
web programming languages
Web programming languages assist programmers in creating web sites. Web programming
languages such as PHP and JavaScript enable developers to add interactivity or functionality to
web sites.
database programming languages, and
Database programming languages were developed to fulfill one of the core functions of
computers, namely systematic storage of data. Database languages such as SQL can be used to
manipulate, retrieve, and store data in a database.
scripting programming languages
As users have become more knowledgeable and demand more from software, scripting
programming languages were developed. They enable users to modify or build features in
existing applications.
897


Scripting programming languages are based on high-level languages, but aren't exactly the same
and typically take longer to master. An example of a scripting language is Visual Basic for
Applications, or VBA, which is supported by most Microsoft programs.
The evolution of programming languages has primarily been driven by technological
improvements in computers. These improvements have been made in leaps and bounds since
the first computer was designed in the 1940s.
The evolution of computers can be described in five stages:
first generation
The first generation of computers began in 1945 with the invention of the Electronic Numeric
Integrator and Calculator, also known as ENIAC. This computer weighed 30 tons and failed once
every seven minutes. Computer programming was first invented to work with the ENIAC.
second generation
The second generation of computers began in 1948, when AT&T Bell Telephone Labs developed
transistors that could replace the vacuum tubes used in ENIAC. Computers became more widely
available, which prompted the development of better programming languages.
third generation
The third generation of computers began with the invention of integrated circuits, which grouped
all the essential components of a computer into one unit. Computers in this generation took up
less space and were more reliable than earlier computers.
fourth generation, and
The fourth generation of computers began in 1974, when the first microcomputers were invented.
These computers were also known as personal computers, or PCs. The cost of computers
decreased, which made them available to more people, and they also became much more
powerful with the invention of semiconductor memory.
fifth generation
The fifth generation of computers began with chip technology including technology associated
with superconductors, quantum computing, and nanotechnology. It also involved the development
of Very Large Scale Integration, or VLSI.

Computers in this generation continue to get smaller and more powerful. They also display some
signs of artificial intelligence. An example is games that let users play against the computer.
Question
Match each programming language to the corresponding category.
Options:
898

A. Delphi
B. JavaScript
C. SQL
D. VBA
Targets:
1. RAD languages
2. Web programming languages
3. Database programming languages
4. Scripting languages
Answer
RAD languages are used to develop GUIs with objects such as buttons and scrollbars. An example
is Delphi.
Web programming languages are used to add interactivity and functionality to web sites. An
example is JavaScript.
Database programming languages are used to retrieve and manipulate data in databases. An
example is SQL.
Scripting languages enable users to modify existing programs. An example is VBA.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Summary
Computers can only do what they're told to do. They only understand binary code. Assembly
language consists of abbreviated words and hexadecimal numbers, but its programs aren't
portable. High-level languages make programs portable and use recognizable words. Fourth-
generation languages also use recognizable words. All programs must ultimately be translated
into binary code before a computer can understand them, and this is done by compilers and
interpreters.

Many languages have evolved to fulfill different needs. The technological evolution of computers
899

has also driven the evolution of programming languages. The first generation of computers were
extremely large and unreliable, but each subsequent generation has improved on this through
the invention of transistors, integrated circuits, and technology such as nanotechnology, artificial
intelligence and VLSI.


























900

Software Development Life Cycle
Learning Objectives
After completing this topic, you should be able to
recognize the steps in the software development life cycle
identify the differences between the waterfall and extreme programming software development
methodologies
1. Development methodologies
Creating a large software program is a complicated process. The size and intricacy of software,
as well as the nature of the Information Technology industry, has made it necessary for this
process to involve many people.
Various software development methodologies have been developed in an attempt to establish a
systematic method for creating software that can be followed by all programmers.
It's advisable to adopt one of these methodologies and follow it throughout the lifetime of a
software development project. Doing this helps programmers write software that not only works
reliably but can be developed within a reasonable time.
Two very different software development methodologies have emerged as common
approaches:
the waterfall model, and
extreme programming
The waterfall model divides the software development process into four distinct phases. The
idea is that all focus is placed on only one phase at a time. Each part of a phase should be fully
completed before a programming team moves on to the next phase.
The four phases in the waterfall model are
analysis
Analysis is the first step and involves analyzing requirements to determine exactly what a
program is supposed to do.

Customers specify what they require of the program. Programmers then interpret these
requirements to create a comprehensive list of program specifications. Once the list is complete
and customers and programmers are in agreement, the analysis phase is signed off and won't be
revisited.
design
901

In the design phase, programmers plan how they're going to create a program. They decide
which programming language, compiler, and other tools to use. They break down the program
into sections that can be assigned to individual programmers to create. They also decide on the
communication procedures they'll use to ensure completeness and consistency, and to prevent
duplication of work.

Once a program has been designed on paper and a deadline has been set, the design phase is
complete.
implementation, and
The implementation phase is when a program is actually written. The programmers write code for
the sections they've been assigned, following the plan created in the Design phase. Once all the
sections have been written, they're put together to form the whole program. This is the end of the
implementation phase.
testing
In the testing phase, the entire program is tested to check if it works properly. The programmers
fix any problems they find and test again to ensure that the fixes haven't created new problems in
other areas.

The process of fixing and testing continues until all identifiable bugs have been fixed. The testing
phase is then over. The program is complete and can be delivered to the customer.
The waterfall model looks good in theory, but in practice its rigidity often causes problems. If one
phase is stalled or not completed properly, it has a serious knock-on effect on the following
phases.
In particular a maintenance phase is missing from the waterfall model. It should be added to the
waterfall model to make a more complete software development life cycle.
The extreme programming method was developed to address the problems associated with the
waterfall model. In this method, the phases in the process are integrated instead of distinct and
isolated. The process flows back and forth through the phases until a program emerges,
complete and free of bugs.
Extreme programming includes four overlapping phases:
Coding
Testing
Listening, and
Designing
902

Extreme programming is an adaptive and people-oriented process. Because it's difficult for
customers to envision all aspects and features of a program at the start, they're involved
throughout the process.

A program slowly evolves as the programmers work and communicate both with each other and
the customer. The process constantly adapts according to the customer's needs.
The general process followed in extreme programming includes four main steps:
the customer communicates requirements
The customer defines initial requirements for the program. This is a starting point only the
requirements may change as the process continues.
programmers build a prototype
A small team of programmers creates a simple prototype version of the program as a model for
the customer to study and comment on. This helps the programmers determine whether they've
understood the customer's requirements and whether they're on the right track.
the actual program is built, and
The team of programmers creates the actual program, constantly testing it, communicating with
the customer, and incorporating necessary changes.
additional features are added
Once the basic program is complete and working, the team may add additional features
requested by the customer.
Question
Match each of the phases to the corresponding methodology. More than one phase may match to
each of the methodologies.
Options:
A. Analysis
B. Design
C. Implementation
D. Coding
E. Listening
Targets:
1. Waterfall model
2. Extreme programming
Answer
903

The four phases in the waterfall model are analysis, design, implementation, and testing.
The four overlapping phases in the extreme programming method are coding, testing, listening, and
designing.
Correct answer(s):
Target 1 = Option A, Option B, Option C
Target 2 = Option B, Option D, Option E
2. Development life cycle
Each of the software development methodologies has both advantages and disadvantages.
Different models are followed in different organizations, and one model may be modified to suit
different needs.
Although different models are used and these are constantly evolving and being adapted, the
modern software development life cycle follows a similar course in most cases.
Drill Down Home Page
Typically, the modern software development life cycle includes five phases.
Page 1 of 2: Analysis
In the Analysis phase of the software development life cycle, developers list the tasks that
software must perform. They study the problems to be solved, and their causes and effects.
Page 2 of 2: Analysis
The specific task that a program is required to perform is derived from a problem statement,
which is a concise description of the problem that a customer needs to address. The software
must provide a workable solution to this problem.
Page 1 of 3: Design
In the Design phase, a program is designed. The aim is to meet the goals identified during the
Analysis phase in a logical, efficient, and economical manner.
The designers consider the existing software and hardware resources they can use to achieve
the goal. If these are unsuitable, new software and hardware components may have to be
designed.
904

The overall structure of the program is designed first. This is then broken down into smaller
components of a manageable size, known as modules.
Page 2 of 3: Design
To ensure that everyone involved can understand the design and visualize the necessary
components of a planned software program, it's necessary to model the design. Some of the
common modeling methods include flowcharts and process diagrams.
Page 3 of 3: Design
Once the visual design of the program has been completed, the developers can continue the
design process using pseudocode.
Code
If student's grade is >= 60
Print "passed"
else
Print "failed"
Pseudocode is used to bridge the gap between algorithms and programming languages. It
provides an outline of a computer program, written in a format that can be easily converted into
programming statements.
Pseudocode isn't a specific programming language but is used to mimic any number of
computer languages. It's especially useful if the software planners and programmers haven't yet
decided which language to use to create software, or if they plan on porting the software to
several languages or operating systems.
Page 1 of 3: Implementation
During the Implementation phase, a program is written in a particular programming language.
Each language has different advantages and disadvantages. For example, FORTRAN is a good
language to use for processing numerical data, whereas LISP is good for artificial intelligence
applications.
Program code should perform the required tasks, and it must be readable so that other
programmers can maintain it.
Programs are often written in separate modules, with each module performing a particular task.
Each module must function properly, both independently and in relation to the rest of the
program.
905

Page 2 of 3: Implementation
Computer programs often grow to be quite large and the code they contain may include a
variety of dependencies.

Because of this, the Implementation phase is often considered to have three functional steps
that are cyclical. They are
coding
testing and debugging, and
optimizing code
Page 3 of 3: Implementation
The coding step involves writing actual code.
Testing and debugging is on-going. Programmers frequently compile their code while they're
creating it to ensure that it uses the proper syntax and functions correctly. This ensures that they
detect small code errors before they become larger problems.
During testing and in the process of writing code, bugs are often found and then remedied on
the fly. Programmers may also detect inefficiencies or identify more effective ways of making
code work. So the process of optimizing code is also on-going.
Page 1 of 2: Testing
Once all components of a program have been written and integrated, the software development
life cycle reaches the testing phase.
Page 2 of 2: Testing
The entire program is tested as whole to check if it runs smoothly and to detect any bugs. Any
problems found are fixed and the program is tested again to ensure that the fixes didn't
accidentally cause problems in other parts of the program.
This process of fixing and testing continues until all the bugs that can be detected have been
fixed.
Page 1 of 3: Maintenance
During the maintenance phase, any errors and deficiencies in a program are identified and the
necessary improvements are made, while preserving the program's integrity.
906

The use of design notes, well-commented code, and meaningful variable names can all
contribute to easier maintenance of a program.
Page 2 of 3: Maintenance
The improvements and fixes made during on-going maintenance often mean that new versions
of a program are released.
Programs can be developed in minor or sub-versions, each addressing particular bugs or
inconsistencies. Or they can be upgraded in major versions that include new functionality and
involve code rewrites. These major modifications are often designed to take advantage of new
hardware or other compatible software and operating systems that have become available.
Version control is the process of tracking and controlling the major and minor versions of a
program. An important aspect of software development is understanding when the different
kinds of version updates are necessary.
Page 3 of 3: Maintenance
When a software program is released, it's usually packaged with certain software documentation
that includes, for example, descriptions, comments, and help files.
The release of new versions of the program should then also be accompanied by the release of
new documentation. In the case of minor updates, documents or release notes identifying any
changes should be provided. Major upgrades may require completely updated software
documentation, with new help files and comments.
Question
Sequence the phases in the software development life cycle.
Options:
A. Analysis
B. Design
C. Implementation
D. Testing
E. Maintenance
Answer
Correct answer(s):
Analysis is ranked the first phase.
907

The Analysis phase is the first step and involves determining exactly what a program is
supposed to do.
Design is ranked the second phase.
The Design phase is the second phase. It involves determining how a program must be built to
meet the goals set in the Analysis phase.
Implementation is ranked the third phase.
Implementation is the third phase, when a program is written in a particular programming
language.
Testing is ranked the fourth phase.
Testing is the fourth phase, during which an entire program is tested to check that it works
properly.
Maintenance is ranked the fifth phase.
Maintenance is the fifth phase. During this phase, any errors and deficiencies in the program
are identified and the necessary improvements are made.
Summary
Various software development methodologies have been developed. Two of the main
approaches include the waterfall method and extreme programming. In the waterfall method,
analysis, design, implementation, and testing are sequential and completely separate phases. In
extreme programming, the phases of coding, testing, listening, and designing all overlap.

A general software development life cycle includes a series of five phases Analysis, Design,
Implementation, Testing, and Maintenance.











908

Programming Basics
Learning Objectives
After completing this topic, you should be able to
recognize the features of common programming methodologies
recognize the features of a good program
1. Common programming methodologies
As customers' demands for program functionality continue to increase, software designers look
for methodologies that enable them to create cheap but efficient programs quickly.
Like natural languages, which develop in response to social needs, programming methodologies
are developed in response to market needs.
Applications don't only have to perform to specification they must also be developed in the
shortest possible time on the smallest possible budget.
There are two common programming methodologies:
structured programming, and
object-oriented programming, or OOP
The structured programming approach was developed after it was discovered in 1966 that any
program can be written using just three structures:
sequence
The sequence structure is the execution of a set of statements in order.
selection, and
The selection structure is the selection of one particular statement, depending on a particular
program state.
repetition
The repetition structure is the repetition of a statement until a particular program state is detected.
With this discovery came the notion that program code can be thought of as a collection of
related components rather than as a long and linear sequence of commands that must be
processed from beginning to end.
Distinctive components of an application can be re-used, making it unnecessary to repeat code.
One core component might be used by a number of ancillary components.
909

Grouping components that perform similar functions also enables modular development of an
application, with development of each component constituting a separate development step.
Third-generation programming languages are procedural languages, which means they process
instructions step-by-step to arrive at a result.
Procedural languages are considered suitable for a structured programming approach because
they support sequence, selection, and repetition, while still representing a linear structure.
OOP was developed in the 1980s. It takes structured programming's notion of modular
components further by creating computer abstractions, or objects, to represent real-world
objects. So OOP seeks to align the programming logic of an application with its associated real-
world logic. This makes code easier to understand and debug.
Each object in OOP has a set of properties that describe it. For example a car_aerial object
might have extended or retracted as a property value.
Each object also has a number of operators or methods associated with it. For example, the
car_aerial object might have two methods extend and retract.
OOP retains the modular development principle from structured programming to enable easy
debugging. Modular development is useful for OOP and structured programming because
program errors tend to be associated with a single module.
Structured programming and object-oriented programming can be used by themselves or in
combination.
Using a combination of the methods can help overcome shortcomings associated with each of
the separate methods.
Question
What are some of the features of structured programming?
Options:
1. Any program can be written using just three structures
2. Statements are processed one after the other, from the beginning of a program to the end
3. Each component constitutes a development step
4. Components of the program reflect real-world objects
Answer
Option 1: Correct. Structured programming is based on the theory that any program can be written
using just three structures sequence, selection, and repetition.
910

Option 2: Incorrect. Structured programming overcame the limitation of viewing processing as
having to occur in a linear fashion.
Option 3: Correct. Structured programming enables developers to plan a project using the
development of each component, or module, as a separate development phase.
Option 4: Incorrect. OOP takes modularity further than structured programming by mapping
components and their logic to real-world objects.
Correct answer(s):
1. Any program can be written using just three structures
3. Each component constitutes a development step
2. Features of good programs
Regardless of whether a structured or object-oriented approach is taken, programming involves
providing a computer with step-by-step instructions.
A compiler processes the entire program and converts it into executable binary code. This can
take some time.
Alternatively, an interpreter executes instructions sequentially line by line returning the
results for each line as a program runs.
You can read the code for a very small program and follow its logic to determine how it works.
However, most programs are large and can therefore be difficult to decipher. If you aren't the
original programmer, this task becomes even more difficult.
A good program has five features:
it's complete
it's efficient
it's usable
it's easy to maintain, and
it's readable
A program is complete if all functionality planned in the design phase has been developed and is
working properly.
Programs should be written efficiently and sensibly.
911

Different computers have different hardware specifications, and inefficient or poorly-written code
that worked on one computer may produce unexpected results on another.
It's easy to write excessive amounts of code without taking into account how it will affect the
performance and stability of a program.
Usable programs are those that the intended end users find easy to operate. Usability depends
on factors such as ease of input, interface design, and speed. Informative error messages and
help files can also improve usability.
Offline user documentation, such as a printed manual, is often preferred by users because it's
easier to read than online help. However, online help files can be distributed and searched more
easily, so they're commonly included with software.
Maintaining a program involves making changes to a program after its implementation.
A computer system seldom satisfies the needs of its users indefinitely they'll soon think of
ways to improve it. So any software should be easy to adjust and build on.
Programmers other than those who originally designed a program should be able to understand
and modify it, provided they're familiar with the programming language used.
Readable code is easy to follow. You can use indentation to make code clearer. For example, a
simple practice like indenting part of an IF statement to the right can make code easier to read.
Code
(indented version)
IF age < 12 THEN
Classification := "child";
ENDIF

(unindented version)
IF age < 12 THEN
Classification := "child";
ENDIF
When programs contain hundreds or even thousands of lines of code, indentation or lack of it
will significantly affect readability.
Comments also increase the readability of a program. In all languages, you can ensure that text
you add as comments won't be executed as actual code.
Designers insert comments, code hints, or remarks to explain sections of code. For example,
you might use a comment to explain the purpose of a section of code, to note where a new
approach was tested, or to indicate that a portion of the code can be disabled for testing.
912

Different languages use different tags to indicate comments. Also, some languages such as
C++ and Java differentiate between single-line comments and comment blocks.
Code
// This is a comment on a single line.
...MISSING CODE...
/* This is a comment of multiple lines.
The compiler will ignore everything between the slash on the preceding
line and the slash on this line. */
...MISSING CODE...
It's important to know how to identify comments in the programming language you're using. In
C++, for example, braces {} indicate a block of commands whereas in PASCAL, they indicate
comments.
Question
What are the features of a good program?
Options:
1. It's complete
2. It's efficient
3. It's usable
4. It's easy to maintain
5. It's code is easy for other programmers to read
6. Its code is as short as possible
7. It has a small file size
Answer
Option 1: Correct. A good program is one in which all functionality planned in the design phase has
been developed and is working properly.
Option 2: Correct. Coding should be efficient so that programs perform the required tasks quickly
and are stable.
Option 3: Correct. Usable programs are those that the intended end users find easy to operate.
Option 4: Correct. A good program has code that's easy for any programmer familiar with the
programming language to read and follow.
913

Option 5: Correct. A good program has code that's easy for any programmer familiar with the
language that was used to read and follow.
Option 6: Incorrect. If the other characteristics of a good program are present, a program can be
considered good even if its code is very long. Also, practices like adding explanatory comments to
code are recommended even if they add to overall code length.
Option 7: Incorrect. It isn't always necessary for a program to have a small file size. This will
depend on how the program will be distributed and used.
Correct answer(s):
1. It's complete
2. It's efficient
3. It's usable
4. It's easy to maintain
5. It's code is easy for other programmers to read
Summary
The first major programming methodology structured programming was developed in the
late 1960s. It's based on three steps sequence, selection, and repetition. OOP was developed
in the 1980s as the second major programming methodology. It aims to align the programming
logic of an application with associated real-world logic.

Computer programs should be complete, efficient, usable, maintainable, and readable. You can
help make code more readable by using suitable indentation and comments.











914

Program Development Tools
Learning Objective
After completing this topic, you should be able to
recognize the functions of common program development tools
1. Tools for program development
Programmers can use a range of development tools to simplify essential programming tasks.
An Integrated Development Environment, or IDE, is a set of tools for software development
that's integrated in one package.
An IDE can have several functions:
it can help you write and edit a program's source code
it may display color-coded syntax for code
it may display relevant error notifications while you type
it can automate certain repetitive tasks
it can help you browse through code modules
it may compile code, and
it may enable you to use drag-and-drop functionality to create visual features and connect to databases
Some IDEs provide templates for commonly used modules, objects and code blocks, and
include context-sensitive shortcut menus that let you perform common tasks quickly. Some also
include auto-complete functions, which can predict and complete functions and methods while
you type.
A popular IDE is Microsoft Visual Studio, which supports among others, development in C#,
Java, and Visual Basic. Visual Studio also enables you to integrate testing of an application into
the development life cycle, which improves overall productivity.
Various tools are considered important in any software development cycle:
editors
compilers and interpreters
a debugger
915

help file generators
an installation program
a profiler, and
binary, decimal, and hex converters
Editors may be simple text editors that are like word-processing applications but don't wrap
words to the next line.
Source code can be saved in ASCII files and you can even use Microsoft Word to write these
files. However, word processors usually include formatting features and other hidden characters
that aren't needed in the source files.
Dedicated programming editors include additional features. For example, many code editors
include line numbers that help you navigate through code. They may also offer automatic
tabulation, color-coding of various elements, pop-up help information, and auto-complete
functions.
The first editors that were used were line editors. These were simple editors that accepted one
line of code at a time. This had advantages on systems with limited amounts of memory, but
programmers weren't able to navigate through and change existing code. An example of this
kind of editor can be found in UNIX.
Full-screen editors followed the line editors. These enable navigation and alteration of code.
They're still in use today and are considered standard for software development.
Some of the features offered by dedicated editors are
syntax auto-completion
Some editors can recognize a programming language and suggest possible commands,
methods, or functions to complete entries you've started to type. You can then select the correct
option to complete a command or statement. For example, if you choose an IF-THEN statement,
a generic structure is created for you.
syntax highlighting
Some editors highlight completed commands, methods, or functions to help you distinguish them
from the rest of your code. This makes the source much easier to read, understand, and
navigate.
the ability to view and edit multiple files
Some editors enable you to open a number of files that form part of the same project at the same
time. You can then switch between the open files, editing and saving them.
stacked undo and redo commands
916

Most editors create a stack of changes that you've made and let you undo or redo these changes
so you can test different code.
support for macros, and
Some editors enable you to create macros to automate tasks you perform often. For example if
you want certain commands to be shown in uppercase, you can create a macro that will do this
automatically.
project management
Large application projects usually consist of a number of files containing source code. Most
editors have features that enable you to manage these files by showing them in a hierarchical
tree structure. This organizes large projects and can help you manage and keep track of the files.
Computer hardware can understand only machine language that consists of a set of binary
instructions. Programming languages have evolved to the point where they're very natural and
very much like human languages. But they still have to be translated into machine language
before computer hardware can use them.
To facilitate this, you can use either a compiler or interpreter to translate the program into
machine language. Of the two, interpreters are less commonly used, although they still perform
an important role in modern programming.
A compiler reads the entire source code and translates it as a whole into machine language. It
then stores this in a single file, usually an executable or .exe file. At this point you can distribute
the program to users who can simply run the file to use the program.
One reason that compilers are a more popular choice than interpreters is that the source code is
hidden from users. Once a program is compiled you can use the program without needing the
source code, but you'll have to recompile the program if you make any changes to the code.
It's important to note that a program compiled for a Windows-based system will not work on a
Macintosh-based system. This is because the compiled machine language contains instructions
specific to the microprocessor. If you need a Mac version of the program, you'll need to
recompile it specifically for Mac.
An interpreter reads and converts code to machine language one line at a time. The interpreted
code is stored in a computer's memory. Because computer memory is volatile, the interpreted
code is discarded whenever the computer is shut down.
This means that whenever you want to run the program, the source code has to be re-
interpreted. So when you want to distribute a program to users, you have to give them access to
the source code. This is the main reason why interpreters are rarely used commercially.
Interpreters are popular in web programming, however. For example, web browsers use
interpreters to read JavaScript. The reason for this is that not all web users use the same
systems, so programs compiled in a specific machine language won't be accessible to
everyone.
917

Debugging code involves removing errors from it. All errors must be removed before a program
can be said to be complete.
The two main types of errors in code are
syntax errors, and
Syntax errors occur when a programmer writes code that doesn't conform to the rules of the
programming language. These are like grammar errors in human languages.

If a compiler or an interpreter detects a syntax error, it will cease operation and report the error.
logic errors
Logic errors are errors in the design of a program. They occur when a line of code conforms to
the rules of the language, but the code is based on flawed logic.

Logic errors are less obvious than syntax errors, so programs may compile or be interpreted
without these types of errors being reported. The errors are often discovered only when a
program runs and it performs incorrectly or halts unexpectedly.
A debugger runs a program one line at a time so that the programmer can examine it for errors.
This is particularly useful for picking up and repairing logical errors.
Code should be readable and easy to understand so that it can be maintained. Comments can
be written into the code to ensure that it meets these requirements.
You can use various methods to debug a program, one of which is called stepping. When you
step through a program, each line is executed and you can also see which line of code is being
read. If an error occurs, you can see which command caused it.
You can step through code at the source level, but also view the machine code for each line as
it executes. Stepping line by line is a practical way of debugging small programs that don't
contain a lot of source code.
For larger programs, you can use different methods to save time or to focus on particular parts
of the source code.
You can use breakpoints to skip over parts of code you know to be working correctly. You add a
breakpoint to the first part of code where you suspect the problem could lie. When you do this
and run a debugger, the debugger skips over the first part of the program and halts at the first
breakpoint. You can then step through the next section of the program line by line.
When you're debugging a large program with multiple subprograms, you can use two techniques
to handle the source code more efficiently:
step over, and
918

When you mark a subprogram with a step over command, the debugger executes the
subprogram without debugging it line by line. You can use this method when you're confident the
subprogram is working correctly.
step out
When you're stepping through a subprogram line by line and want to stop, you can use the step
out command to do so. The debugger will then immediately stop stepping through the
subprogram and continue with the code that follows it.
The step method of debugging enables you to check the logical and working structure of a
program. However, when you want to focus on checking the data used by a program, you can
use the watching method.
The watching method enables you to check the variables used in the program and to change the
variable data to manipulate or test the results.
This is especially helpful if a program is designed to handle and manipulate user data or
calculate mathematical expressions.
Creating good help files is an essential step in the development of most software. Help files are
generally more accessible than user manuals because they're modeled as miniature web pages.
This makes information and solutions to problems much easier to find.
Programs similar to word processors can help in the creation of help files. These programs let
you write, edit, organize, and format text, and create hyperlinks to different parts of a help file.
To help users set up and run the programs you create, you can use installation programs to
create installers for software.
Programs often contain a number of different files, which, if bundled together, would prove
cumbersome for users. You can use installation programs to specify exactly which files are
needed by your program and where these files should be stored on disk. An installer configures
the registry settings a user's computer will need to find and access all these files, and stores the
files in the correct folders.
You can also use a program installer to display user license agreements and graphics promoting
your company's brand to users.
You can use a profiler to optimize a program that consists of a number of parts. A profiler
examines a program and identifies the parts of it that are used most frequently.
These are the parts that should be optimized.
Say a program accepts users' login credentials and then allows them to sort and search through
a number of records. The login procedure will occur only once in a session but the search and
919

sort procedures may be called a number of times. So it's the search and sort procedures that
should be optimized.
Profilers use two methods to examine a program:
sampling, and
Sampling involves examining a program at fixed intervals and flagging the parts of the program
that are used most often. These parts are called hotspots.
instrumentation
After sampling finds the hotspots, you use instrumentation to check each line of code in the
hotspots in detail. You then concentrate on optimizing them to speed up the overall performance
of the program.
Binary, decimal, and hexadecimal converters are often required during program development.
For example, color references are often in hexadecimal format, so a converter is useful in
design applications. Similarly, a converter that converts between binary and decimal numbers
may be useful in scientific applications.
Graphic
Binary: 11111010000000011000
Decimal: 1024024.24
Hexadecimal: FA018
You can change the calculator bundled with Windows to Scientific view to access these types of
converters. Similar tools are also available to Mac and Linux users.
Graphic
The Windows calculator includes Hex, Dec, Oct, and Bin radio buttons.
Question
Match each programming tool to its function.
Options:
A. Editor
B. Compiler or interpreter
C. Debugger
D. Help file generators
E. Profiler
920

Targets:
1. A program for typing instructions for computers
2. Converts programming languages to binary code or machine language
3. Helps find and remove errors
4. Provides guidance to users
5. Examines code for the purpose of optimization
Answer
You use editors to type and edit code instructions, which you save to a file.
You use compilers and interpreters to convert programming code to binary or machine language so
that it can be understood by computers.
You use a debugger to find and fix or remove erroneous code from a program.
You create help files to guide users in using a particular program.
You use a profiler to examine code to determine which parts are executed most often. You can then
focus on optimizing these parts of the code.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
Summary
Programmers can use a number of tools to simplify the development process. A programming
environment that provides a set of these tools is called an IDE. You use an editor to write source
code, and convert programming language to machine language using a compiler or interpreter.
You can run a debugger to check code for errors and use a program similar to a word processor
to create help files for users. You can also create an installation for a program and use a tool
called a profiler to optimize frequently used parts of the program.


921

Understanding Programming Basics
Learning Objectives
After completing this topic, you should be able to
demonstrate basic knowledge of computer languages, programs and programmer tools
demonstrate knowledge of software methodologies and programming approaches
Exercise overview
To perform this exercise you need to understand the basics of software programming.
This involves the following tasks:
understanding computer languages, programs and programmer tools and
understanding software methodologies and programming approaches
Understanding programming basics
Question
Computers have continued to evolve since they were first introduced. With this, programming
languages have also evolved.

Sequence the stages in the evolution of programming languages.
Options:
A. Binary code
B. Assembly language
C. High-level languages
D. Fourth-generation languages
Answer
Correct answer(s):
Binary code is ranked the first stage.
Binary code, which consists of 1s and 0s, represents the first stage in the evolution of
programming languages. It's the basic code that computers understand.
Assembly language is ranked the second stage.
Assembly language consists of abbreviated words and hexadecimal numbers, and represents
the second stage in the evolution of programming languages.
922

High-level languages is ranked the third stage.
High-level languages represent the third stage in the evolution of programming languages.
They use recognizable words, and they solved the non-portability problem associated with
assembly language.
Fourth-generation languages is ranked the fourth stage.
Fourth-generation languages represent the fourth stage in the evolution of programming
languages. They contain recognizable words and can be used to generate code based on
high-level specifications.
Question
Match each type of programming language to its description.
Options:
A. Rapid Application Development, or RAD languages
B. Web programming languages
C. Database programming languages
D. Scripting languages
Targets:
1. Used to create applications with graphic user interfaces
2. Used to create graphics and interactivity for web sites
3. Used to manipulate and retrieve data
4. Used by users to modify existing applications
Answer
RAD languages such as Visual C can be used to create powerful graphic user interfaces or GUIs
for applications.
Web programming languages such as JavaScript and PHP were developed to add graphics and
interactivity to web sites.
Database programming languages such as SQL were developed for storing, manipulating, and
retrieving data in databases.
Users can use scripting languages to add or modify features in an existing application.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
923

Target 3 = Option C
Target 4 = Option D
Question
What are the features of a good program in any language?
Options:
1. It's complete
2. It's efficient
3. It's easy to use
4. It's easy to maintain
5. It's readable
6. It's basic
7. It's short
Answer
Option 1: Correct. A good program is a program that includes all the required functionality and that
has been completely tested.
Option 2: Correct. Programs should be written so that they perform efficiently. Poorly designed
code can hamper performance.
Option 3: Correct. Usable programs are those that the intended users find easy to operate.
Option 4: Correct. Good programs are easy to maintain. So programmers can easily make changes
to them after their implementation.
Option 5: Correct. Good code is easy for other programmers to read and follow.
Option 6: Incorrect. Complicated programs can still be considered good if they're complete,
efficient, usable, maintainable, and readable.
Option 7: Incorrect. If the other characteristics of a good program are present, a program can be
considered good even if it's long.
Correct answer(s):
1. It's complete
2. It's efficient
3. It's easy to use
924

4. It's easy to maintain
5. It's readable
Question
Match commonly used development tools with their functions.
Options:
A. Editor
B. Compiler or interpreter
C. Debugger
D. Help file creator
E. Profiler
F. Installer
Targets:
1. Used for typing code instructions into a computer
2. Converts a programming language to binary code
3. Helps identify incorrect code
4. Assists in creating user guides
5. Studies source code for the purpose of optimization
6. Creates a file users run to set up the program on their computers
Answer
You can use an editor to type and edit code instructions into a computer, and also save the code to
a file.
You use compilers and interpreters to convert programming code to binary to make the code
understandable to the computer.
You use a debugger to identify and correct or remove code errors in a program.
You use a help file creator to generate help files to guide users in using a program.
You use a profiler to examine source code and determine which parts are executed most often. You
can then focus on optimizing these parts of the code.
You use an installer to create a single file with a set of instructions and program files that will store a
program in the correct folders on a user's hard drive.
Correct answer(s):
925

Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
Target 6 = Option F
Understanding programming methodologies
Question
Which of these are phases in extreme programming?
Options:
1. Coding
2. Testing
3. Listening
4. Designing
5. Implementation
6. Analysis
Answer
Option 1: Correct. Coding is the phase in extreme programming when programmers write the code.
Option 2: Correct. Testing is the phase in extreme programming when programmers test a program
and fix errors. This occurs at various stages throughout development.
Option 3: Correct. Listening is the phase in extreme programming when programmers get feedback
from the customer. It occurs at various stages throughout development.
Option 4: Correct. Designing is the phase in extreme programming when programmers design the
final program.
Option 5: Incorrect. Implementation is a phase in the waterfall model, rather than in extreme
programming.
Option 6: Incorrect. Analysis is a phase in the waterfall model, rather than in extreme programming.
926

Correct answer(s):
1. Coding
2. Testing
3. Listening
4. Designing
Question
Sequence the phases in the waterfall model.
Options:
A. Analysis
B. Design
C. Implementation
D. Testing
Answer
Correct answer(s):
Analysis is ranked the first step.
Analysis is the first phase. It involves determining exactly what a program is supposed to do.
Design is ranked the second step.
Design is the second phase. It's when programmers plan how they're going to develop a
program.
Implementation is ranked the third step.
Implementation is the third phase, when a program is actually written.
Testing is ranked the fourth step.
Testing is the fourth phase, when an entire program is tested to see if it works properly.
Question
Which step is often added to the waterfall model to make a more complete software development
life cycle?
Options:
1. Debugging
2. Maintenance
3. Coding
927

4. Listening
Answer
Option 1: Incorrect. Debugging is part of the Testing phase in the waterfall model.
Option 2: Correct. The Maintenance phase was added to the waterfall model to make a more
complete software development life cycle.
Option 3: Incorrect. Coding is a phase in extreme programming.
Option 4: Incorrect. Listening is a phase in extreme programming.
Correct answer(s):
2. Maintenance
Question
What are some of the features of structured programming?
Options:
1. Any program can be written using just three structures
2. Each component constitutes a development step
3. Statements are processed one after the other from the beginning of a program to the end
4. Components of the program reflect real-world objects
Answer
Option 1: Correct. Structured programming breaks all programming into three basic structures
sequence, selection, and repetition.
Option 2: Correct. The development of each component of a program in structured programming
can serve as a separate development step.
Option 3: Incorrect. Structured programming overcomes the need to process an entire program
from beginning to end.
Option 4: Incorrect. Object-oriented programming, or OOP, uses objects that reflect real-world
objects.
Correct answer(s):
928

1. Any program can be written using just three structures
2. Each component constitutes a development step
Question
What are some of the features of object-oriented programming or OOP?
Options:
1. Programming logic is aligned with its associated real-world logic
2. Objects consist of properties and methods
3. Statements are processed one after the other from the beginning of a program to the end
4. The entire application is consumed by a compiler at runtime
Answer
Option 1: Correct. OOP takes modularity further than structured programming by mapping
components and their logic to real-world objects.
Option 2: Correct. Objects in OOP consist of properties that describe it and methods that perform
actions.
Option 3: Incorrect. Structured programming overcame the need to process an entire document.
Option 4: Incorrect. Interpreters can test single objects within an application without consuming the
entire program.
Correct answer(s):
1. Programming logic is aligned with its associated real-world logic
2. Objects consist of properties and methods








929

Algorithms Explained
Learning Objectives
After completing this topic, you should be able to
recognize factors to consider when writing an algorithm using the top-down approach
recognize how to structure algorithms
1. The top-down approach
A computer is essentially an unintelligent machine. It can't perform tasks by itself instead it
simply processes sets of instructions. It steps through the instructions one at a time.
The set of instructions followed by the computer to resolve a particular problem is known as an
algorithm.
A computer is a system that receives input, processes it, and generates output. To use an
analogy, consider the process for making a cake. The problem to solve would be needing a
cake for someone's birthday. You take an ingredient mix and bake it in an oven to create a cake.
Graphic
Three part process:
1. input
2. process
3. output
The input in the baking system is the ingredient mix, the process is baking the ingredient mix in
the oven, and the output is a cake. If the input or the process isn't correct, a suitable cake won't
be made and the problem of needing a birthday cake will persist.
Graphic
Three part process:
1. input - ingredients
2. process - bake
3. output - cake
The algorithm is the part that performs the processing for example, combining the ingredients
and then baking at 350 degrees for 40 minutes.
The algorithm for making cake is simple. However, an algorithm can become extremely complex
if a system must be able to accept a lot of input, perform a complicated process, and return
output. It might consist of thousands of lines of code.
930

The top-down approach to algorithm writing addresses this problem by segmenting an algorithm
into manageable parts, or modules.
Each part is then further distilled into a number of subparts. This continues until the steps in the
algorithm can't be further broken down into constituent steps.
There are a number of important points to remember when writing algorithms:
you should include all the steps
all input conditions should be addressed
no step should be ambiguous, and
steps should result in output at some point
First it's crucial to ensure that you include all the required steps in an algorithm. After the steps
are divided into modules, you must ensure that no module or constituent step has been
accidentally left out.
Some valid output should always be rendered for any input, even if it's merely a message
indicating that the input is insufficient.
The process should take into account all the possible input conditions. So in an algorithm for
boiling water, for example, you would include sub-steps for what to do if the kettle is already full
or if the water is already hot.
No step in an algorithm can be ambiguous or it won't be clear whether the step has been
performed properly.
Code
if X=10
then A
if X=9+1
then B
The steps should account for what to do when the desired output is generated. This means you
need to put an end point in the list of instructions.
Consider a text-based description of the steps in an algorithm for printing invoices.
Graphic
The listed steps include retrieve customer details, retrieve all order details for that customer, and
calculate the total invoice amount.
931

You need to ensure you include all the steps. So you need to further distill the calculating step
into its constituent steps.
Graphic
You add four sub-steps to the calculate the total invoice amount step: add 5% interest to orders one
month or more overdue, add 10% to orders two months and over overdue, sum the orders, and add
sales tax.
You also need to ensure there is an end point. So you add the final step to print the invoice.
Graphic
You add print the invoice as the final step.
The two steps related to adding interest include some ambiguity. Should orders that are two
months overdue be charged an extra 10%, or an extra 15%?
Graphic
The first sub-step of calculate the total invoice amount is indicated: add 5% interest to orders one
month or more overdue.
So you change the step to add 5% only where the order is one month overdue, and 10% only
when the order is two or more months overdue.
Graphic
The first sub-step of the calculate the total invoice amount step is changed to add 5% interest to
orders one month overdue.
All input conditions have been considered. For example an account that is three months
overdue is handled as well as an account that isn't overdue.
Question
What are some of the guidelines for writing algorithms?
Options:
1. All the constituent steps should be present
2. All input conditions should be considered
3. Only particular inputs should be anticipated
932

4. No end point to the instruction should be defined
Answer
Option 1: Correct. You should distill the steps into their constituent parts until you can no longer
break them up.
Option 2: Correct. You should aim to receive valid output for any input condition.
Option 3: Incorrect. All input conditions should be addressed.
Option 4: Incorrect. An end point should be defined in the instruction for when the output conditions
are met.
Correct answer(s):
1. All the constituent steps should be present
2. All input conditions should be considered
2. Pseudo-code and algorithms
After breaking down the steps of an algorithm to their most basic form, you can begin to think
about converting the algorithm into a programming language.
Pseudocode is a way to start converting your natural language instructions into a programming
language.
It can't be executed by a computer but it provides a framework on which to start writing the
program code.
Pseudocode uses natural language that conforms to certain broad rules of syntax.
Guidelines for writing pseudocode are to
use simple English
use a new line for each instruction
use indentation
provide one entry and one exit point for the algorithm, and
group instructions into modules
933

You should use simple English to make pseudocode clear and concise. For example, the
algorithm instruction find the difference between numbers A and B could be
rewritten as difference = A-B in pseudocode.
You should also use only one line for each instruction. Putting multiple instructions on one line
makes the algorithm harder to follow. This should be re-written.
Code
BEGIN GET A GET B CALCULATE difference = A-B PRINT difference END
Each step should start on a new line.
Code
BEGIN
GET A
GET B
IF B EQUALS 10
THEN CALCULATE THE DIFFERENCE BETWEEN A AND B
END
You should use indentation to indicate the logical hierarchy between the instructions. For
example, a THEN statement should be indented from its corresponding IF statement.
Code
BEGIN
GET DAY
ASSIGN DISCOUNT VALUE
IF DAY = MONDAY
DISCOUNT = 15%
IF DAY = TUESDAY
DISCOUNT = 10%
IF DAY = WEDNESDAY
DISCOUNT = 5%
ELSE DISCOUNT = 0%
END ASSIGN DISCOUNT VALUE
END
Instead of using BEGIN and END tags to indicate the start and end of an algorithm, you can
provide other entry and exit points.
Code
934

INPUT A
INPUT B
IF B = 10
THEN C = A - B
ENDIF
In this case, INPUT A is the entry point and ENDIF is the exit point.
You should group instructions into modules that can each perform a distinct operation. You
could also use indentation to mark appropriate modules.
Graphic
This code is indicated:
IF B = 10
THEN C = A - B
ENDIF
Code
INPUT A
INPUT B
IF B = 10
THEN C = A - B
ENDIF
Instead of re-writing modules when they're needed again, you can write them just once and
simply call them as reusable objects when they're needed.
Once you've written the pseudocode for a program, you can start to turn each instruction into
actual code.
Code
INPUT A
INPUT B
IF B = 10
THEN C = A - B
ENDIF
In this example, the C programming language is used.
Code
935

int a = 15;
int b = 10;
if (b == 10) {
c = a - b;
}
Note
In this case, the = sign is an assignment operator, and == is a comparison operator.
Question
What are some of the guidelines for writing pseudocode?
Options:
1. Use simple programming language
2. Use a new line for each module
3. Use indentation
4. Provide one entry and one exit point for the algorithm
5. Group instructions into modules
Answer
Option 1: Incorrect. You should use simple natural language to write pseudocode.
Option 2: Incorrect. You should use a new line for each instruction, rather than for each module.
Option 3: Correct. You make pseudocode easier to read by using indentation.
Option 4: Correct. The pseudocode should provide for single entry and exit points.
Option 5: Correct. You should group related instructions into modules, which can be called in other
parts of the code if they're needed more than once.
Correct answer(s):
3. Use indentation
4. Provide one entry and one exit point for the algorithm
5. Group instructions into modules
Most programming languages use certain conventions. You can apply these to pseudocode to
make it easier to convert into actual executable code.
936

In particular, conventions relate to
getting input
performing operations and assigning values, and
providing output
There are a number of common commands for handling input. You can use the GET command
to acquire input from the keyboard.
Code
BEGIN
GET A
GET B
IF B EQUALS 10
THEN CALCULATE THE DIFFERENCE BETWEEN A AND B
END
And you can use the READ command to acquire input from other sources, such as a file.
Processing of instructions in an algorithm involves arithmetic functions and assigning values to
variables. In the case of pseudocode, values are assigned to nouns.
Graphic
Two examples of assigning values to pseudo-code nouns are indicated:
t=100
temperature=100
For example, in this pseudocode A and B were the nouns. You now give values to the variables
A and B.
Code
INPUT A
INPUT B
IF B = 10
THEN C = A - B
ENDIF
You can use the common arithmetic operator conventions in pseudocode:
+
937

You can use the plus sign to add values. For example, the code total=total+1 adds 1 to the
value of total and assigns the new value to the total variable.
-
You can use the minus sign to subtract values. For example the code total=total-1 subtracts
1 from the value of total and assigns the new value to the total variable.
*
You can use the asterisk to multiply values. For example, the code total=total*2 multiplies
the value of total by 2 and assigns the new value to the total variable.
/
You can use the forward slash to divide values. For example, the code total=total/2 divides
the value of total by 2 and assigns the new value to the total variable.
()
You can use parentheses to indicate the order of precedence, where the content of the brackets
is calculated first. For example, in the code total=3*(2+4), the addition will be performed
before the multiplication function, resulting in total of 18 rather than 10.
There are a number of ways to assign values to variables. Depending on the programming
language used, you could use VAR or LET statements, or simply assign values.
Code
total = 10
Note
You use the = arithmetic operator to assign a value to a variable.
For example, this BASIC programming language command stores the value 10 in the total
variable.
Code
LET total = 10
This JavaScript programming language command stores the value 4 in the total variable.
Code
var total = 4
938

There are a number of ways to handle output, depending on which language you use. Each
language uses its own syntax. in BASIC for example, you can use PUT, OUTPUT, DISPLAY,
WRITE, and PRINT statements to handle output.
The PUT, OUTPUT, and DISPLAY statements send output to the computer screen.
Code
DISPLAY total
You use the WRITE statement to store data in a file on the computer.
Code
WRITE total
In BASIC, you can use the PRINT statement to output data to the display. This statement will
print the total variable.
Code
PRINT total
To print the word "total" instead of the value of the variable that has that name, you enclose the
word in single quotation marks.
Code
PRINT 'total'
Question
Match the examples of commands to their functions.
Options:
A. GET
B. READ
C. PRINT
D. WRITE
E. LET
F. VAR
939

Targets:
1. Input
2. Output
3. Assign values and arithmetic operations
Answer
GET and READ are input statements.
PRINT and WRITE are output statements.
LET and VAR assign values to variables.
Correct answer(s):
Target 1 = Option A, Option B
Target 2 = Option C, Option D
Target 3 = Option E, Option F
3. Evaluating pseudocode
Say you've written an algorithm in pseudocode that calculates the discount offered at a
restaurant depending on the day of the week.
Code
BEGIN
GET DAY
ASSIGN DISCOUNT VALUE
IF DAY = MONDAY
DISCOUNT = 15%
IF DAY = TUESDAY
DISCOUNT = 10%
IF DAY = WEDNESDAY
DISCOUNT = 5%
ELSE DISCOUNT = 0%
END ASSIGN DISCOUNT VALUE
END
The algorithm should include all the steps and can be broken into modules. This includes
distilling each step into its constituent parts. In this case, there appears to be no way to further
940

distill the restaurant algorithm. The ASSIGN DISCOUNT VALUE block can be considered a
module, as can the entire code sample.
Code
BEGIN
GET DAY
ASSIGN DISCOUNT VALUE
IF DAY = MONDAY
DISCOUNT = 15%
IF DAY = TUESDAY
DISCOUNT = 10%
IF DAY = WEDNESDAY
DISCOUNT = 5%
ELSE DISCOUNT = 0%
END ASSIGN DISCOUNT VALUE
END
All possible input conditions need to be addressed and there should be a single entry point. The
possible input conditions are the days of the week, or an empty value. In all these cases, the IF
statements handle each eventuality and a catch-all ELSE statement handles any other condition.
The entry point is the GET DAY statement.
Code
BEGIN
GET DAY
ASSIGN DISCOUNT VALUE
IF DAY = MONDAY
DISCOUNT = 15%
IF DAY = TUESDAY
DISCOUNT = 10%
IF DAY = WEDNESDAY
DISCOUNT = 5%
ELSE DISCOUNT = 0%
END ASSIGN DISCOUNT VALUE
END
Each instruction should be free of ambiguity. All possible inputs should be accommodated,
leading to valid error-free output.
Code
BEGIN
GET DAY
941

ASSIGN DISCOUNT VALUE
IF DAY = MONDAY
DISCOUNT = 15%
IF DAY = TUESDAY
DISCOUNT = 10%
IF DAY = WEDNESDAY
DISCOUNT = 5%
ELSE DISCOUNT = 0%
END ASSIGN DISCOUNT VALUE
END
The steps in an algorithm need to terminate at some point to result in output, and there should
be a single point of output. In this case, each output is generated by populating the DISCOUNT
variable with a value. This variable is the termination point of the algorithm.
Code
BEGIN
GET DAY
ASSIGN DISCOUNT VALUE
IF DAY = MONDAY
DISCOUNT = 15%
IF DAY = TUESDAY
DISCOUNT = 10%
IF DAY = WEDNESDAY
DISCOUNT = 5%
ELSE DISCOUNT = 0%
END ASSIGN DISCOUNT VALUE
END
Pseudocode should use simple, natural language. In this case, basic English words have been
used.
Code
BEGIN
GET DAY
ASSIGN DISCOUNT VALUE
IF DAY = MONDAY
DISCOUNT = 15%
IF DAY = TUESDAY
DISCOUNT = 10%
IF DAY = WEDNESDAY
DISCOUNT = 5%
ELSE DISCOUNT = 0%
942

END ASSIGN DISCOUNT VALUE
END
A new line should be used for each step in the instruction, and sub-instructions should be
indented. In the example, each instruction is on a new line and the child elements are indented.
Code
BEGIN
GET DAY
ASSIGN DISCOUNT VALUE
IF DAY = MONDAY
DISCOUNT = 15%
IF DAY = TUESDAY
DISCOUNT = 10%
IF DAY = WEDNESDAY
DISCOUNT = 5%
ELSE DISCOUNT = 0%
END ASSIGN DISCOUNT VALUE
END
Case Study: Question 1 of 2
Scenario
For your convenience, the case study is repeated with each question.
You're writing an algorithm that calculates the tip amount that should be given at a restaurant,
depending on the level of service. To do this, you need to get the total bill, subtract the sales tax
from the total before establishing the tip percentage which is determined based on the level of
service, and calculate the tip amount based on the subtotal and level of service.
Answer the questions in order.
Question
How is this pseudocode deficient?
Code
BEGIN GET BILL TOTAL GET SUBTOTAL BY SUBTRACTING TAX FROM BILL TOTAL
INPUT "How was the service (poor, good or excellent)?"
IF SERVICE WAS POOR
THEN TIP AMOUNT EQUALS 10%
IF SERVICE WAS GOOD
THEN TIP AMOUNT EQUALS 15%
943

IF SERVICE WAS EXCELLENT
THEN TIP AMOUNT EQUALS 20%
Options:
1. Each instruction should be on a new line
2. The instruction shouldn't be ambiguous
3. Instructions should be grouped in modules
4. Input should be handled
Answer
Option 1: Correct. GET BILL and GET SUBTOTAL should be on separate new lines.
Option 2: Incorrect. The pseudocode handles all possible input conditions without ambiguity.
Option 3: Incorrect. The full pseudocode sample is itself a module.
Option 4: Incorrect. The pseudocode handles all possible input conditions.
Correct answer(s):
1. Each instruction should be on a new line
Case Study: Question 2 of 2
Scenario
For your convenience, the case study is repeated with each question.
You're writing an algorithm that calculates the tip amount that should be given at a restaurant,
depending on the level of service. To do this, you need to get the total bill, subtract the sales tax
from the total before establishing the tip percentage which is determined based on the level of
service, and calculate the tip amount based on the subtotal and level of service.
Answer the questions in order.
Question
How is this pseudocode deficient?
Code
BEGIN
GET BILL TOTAL
GET SUBTOTAL BY SUBTRACTING TAX FROM BILL TOTAL
944

INPUT "How was the service (poor, good or excellent)?"
IF SERVICE WAS POOR
THEN TIP AMOUNT EQUALS 10%
IF SERVICE WAS GOOD
THEN TIP AMOUNT EQUALS 15%
IF SERVICE WAS EXCELLENT
THEN TIP AMOUNT EQUALS 20%
Options:
1. The pseudocode should use indentation
2. There is no end point
3. Each instruction should be on a new line
4. Instructions should be grouped in modules
Answer
Option 1: Correct. You should indent instructions that are sub-steps of a parent line. THEN
statements should be indented from their IF statements.
Option 2: Correct. The pseudocode still needs to calculate and print the tip amount, which is the
subtotal divided by the tip amount.
Option 3: Incorrect. Each new instruction is already on a new line.
Option 4: Incorrect. The entire sample constitutes a single module.
Correct answer(s):
1. The pseudocode should use indentation
2. There is no end point
Summary
A computer program receives input, processes it, and generates output to solve a problem. The
algorithm is what performs the processing. When there is a lot of input and a system has to
perform a complicated process, keeping track of the output can be challenging. The top-down
approach to algorithm writing addresses this problem. Algorithms should include all the steps, all
input conditions should be addressed, no step should be ambiguous, and steps should
terminate to result in output at some point.

You can use pseudocode to start converting natural language instructions into an algorithm in
preparation for a programming language. Pseudocode should use simple language, use a new
line for each instruction, use indentation, provide one entry and one exit point for the algorithm,
945

and group instructions into modules. You can apply conventions that most programming
languages use to make pseudocode easier to convert into executable code.






















946

Creating an Algorithm
Learning Objectives
After completing this topic, you should be able to
create a letter-counting algorithm
create a tax-calculating algorithm
Exercise overview
In this exercise, you're required to identify the input, process, and output elements of problem
statements in order to construct an algorithm.
This involves the following tasks:
using a defining table to create a letter-counting algorithm, and
using a defining table to create a tax-calculating algorithm
Creating a letter-counting algorithm
You want to write an algorithm that asks the user to enter two words and then adds the number
of letters in the first word to the number of letters in the second word, and then displays total
number of letters in both words.
Question
To help create the algorithm, you decide to use a table to identify the input and output elements and
the order in which they should appear. The algorithm has to be designed to display a result as
output immediately after a user enters a word. It also has to return the total number of characters in
two words.

Assign each step, which is explained using pseudocode, to the appropriate column.
Options:
A. word1_length
B. total
C. word2_length
D. word1
E. word2
Targets:
1. Input
947

2. Output
Answer
The word1 step is the first input parameter. The word2 step is the second input parameter. These
are all the inputs that the process requires.
The word_length1 step corresponds to the number of letters in the first input , word1. The
word_length2 step is the number of letters in the second input , word2. And total is the sum of
the number of letters in both words. These are the three outputs of the process.
Correct answer(s):
Target 1 = Option D, Option E
Target 2 = Option A, Option C, Option B
In the algorithm, the numbers of characters are the required output. In this case, the algorithm is
symmetric meaning that you can re-order the inputs to get the same total.

If the algorithm is well designed, it will shut down if it encounters a problem such as invalid or
missing input. A good algorithm doesn't assume the availability of required elements.

You could extend the algorithm to receive a variable number of words.
Code
Input 1: word1
Input 2: word2
...PROCESS...
Output 1: word1_length
Output 2: word2_length
Output 3: total
Question
Next you want to structure the processes that change the input elements to the desired output
elements.

Place the processes which are described in pseudocode in the order in which they should
appear in the algorithm.
Options:
948

A. GET word1
GET word2
B. CALCULATE word_length1
CALCULATE word_length2
C. ADD word_length1+word_length2=total
D. PRINT total
Answer
Correct answer(s):
GET word1
GET word2 is ranked the first step.
The first step is to retrieve, or "GET", the relevant parameters in this case, the two words
entered by a user.
CALCULATE word_length1
CALCULATE word_length2 is ranked the second step.
As the second step, the algorithm must calculate the length of each of the two words entered
by the user.
ADD word_length1+word_length2=total is ranked the third step.
As the third step, you add the number of characters in each of the two words to calculate a
total. You can do this using an ADD operation. Note that this operation can easily be expanded
to accept more than two inputs, making the algorithm more dynamic and flexible.
PRINT total is ranked the fourth step.
The final step is to print the result, which is the total number of characters in the two words a
user has entered. Every programming language has an equivalent of a PRINT operation that
prints to the standard output device usually the screen. Standard output can be redirected to
a printer, a file, or some other device.
The defining table has been completed and you can now create the algorithm.
Graphic
A table with three columns and one row is labelled Defining table: the column headers are Input,
Process, and Output. The input is GET word1 and
GET word2, the process is CALCULATE word_length1, CALCULATE word_length2, and ADD
word_length1+word_length2=total, and the output is PRINT total.
Question
Which is the correct algorithm for the defining table you just created?
949

Options:
1. GET word1
GET word2
CALCULATE word1_length
CALCULATE word2_length
ADD word1_length TO word2_length
PRINT total
2. GET word1
CALCULATE word1_length
CALCULATE word2_length
ADD word1_length TO word2_length
PRINT total
3. GET word1
GET word2
CALCULATE word1_length and word2_length
ADD word1_length TO word2_length
PRINT total
Answer
Option 1: Correct. You GET the input, CALCULATE and ADD the numbers of characters as the
process, and print the total as the output.
Option 2: Incorrect. Input for word2 has not been handled in this example.
Option 3: Incorrect. There is ambiguity here about whether the CALCULATE function applies to the
word2_length.
Correct answer(s):
1. GET word1
GET word2
CALCULATE word1_length
CALCULATE word2_length
ADD word1_length TO word2_length
PRINT total
Creating a tax-calculating algorithm
You now want to create an algorithm that calculates and prints the tax payable on an invoice
total. The tax and total should then be passed back to the calling routine.
Question
950

To create the algorithm, you use a defining table to identify the input and output elements and the
order in which they should appear.

Match each option with the correct column.
Options:
A. GET invoice total
B. CALCULATE tax
final_amount = invoice total + tax
C. PRINT tax
PRINT final_amount
Targets:
1. Input column
2. Process column
3. Output column
Answer
GET invoice total is an input command. The invoice total is required for the process to
work.
CALCULATE tax and final_amount = invoice total + tax are process commands. The
invoice total is added to a tax value to result in the final_amount.
PRINT tax and PRINT final_amount are output commands. The process results in values for
tax and for the final_amount.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Question
Identify the correct algorithm for the defining table you created.
Options:
951

1. GET invoice total
CALCULATE tax
final_amount = invoice total + tax
PRINT tax
PRINT final_amount
RETURN tax AND final_amount TO CALLING ROUTINE
2. GET invoice total
CALCULATE tax
final_amount = invoice total + tax
RETURN tax AND final_amount TO CALLING ROUTINE
PRINT tax
PRINT final_amount
Answer
Option 1: Correct. This is the correct algorithm to calculate and print the tax payable on an invoice
total.
Option 2: Incorrect. RETURN tax AND final_amount TO CALLING ROUTINE will finish before
the algorithm is complete. This code is written using the spaghetti programming method.
Correct answer(s):
1. GET invoice total
CALCULATE tax
final_amount = invoice total + tax
PRINT tax
PRINT final_amount
RETURN tax AND final_amount TO CALLING ROUTINE
Two algorithms have been created one to count letters in words and the other to calculate tax.









952





















Structuring an Algorithm
Learning Objectives
After completing this topic, you should be able to
recognize examples of sequence, selection, and repetition
express inputs, processes and outputs as an algorithm
1. Sequence, selection, and repetition
In the early 1960s, the coding method used by programmers was less logical and linear than it's
today. This led to the method being called spaghetti code.
953

Spaghetti code relied on the GOTO command to skip unnecessary lines of code in a program.
The GOTO command recognized lines of code by a name or number, depending on the
programming language.

For example, if a certain criterion was met in a line of code, the GOTO command could then
move the program along to a later line of code.
Graphic
Five lines of code are shown, code skips from 3 to 5 as follows:
1: CODE
2: CODE
3: CODE GO TO 5
4: CODE
5: CODE
The GOTO command resulted in a lot of movement backwards and forwards through the code,
which was difficult to follow logically. If a program used too many GOTO commands, it would end
up with a complex structure that was prone to errors.
Consider writing a program to print address labels. You would need the program to understand
the difference between a mailbox and a street address.
The example code shows how spaghetti code would rely on the GOTO statement to differentiate
between the two address types.
Code
21: PRINT name
22: IF address IS empty GOTO 25
23: PRINT address
24: GOTO 26
25: PRINT postbox
26: PRINT city
27: PRINT state
28: GOTO 17
Structured programming on the other hand would use IF, THEN, and ELSE statements in a
linear and logical sequence.
Code
IF street IS empty
THEN
954

PRINT postbox
ELSE
PRINT address
ENDIF
PRINT city
PRINT state
The end result of both methods is the same, but it's far easier to follow the structured
programming method due to its linearity.
Structured programming uses three control structures as the basis for writing a program:
sequence
The sequence control structure ensures that a program runs instructions in sequence and
performs each instruction once only. Instructions aren't repeated or skipped, unless repetition
control is applied.
selection, and
The selection control structure is used when a choice has to be made. These choices depend on
the conditions defined by the programmer.
repetition
The repetition control structure is used to repeat a certain section of code until a specific condition
is met.
Consider sequence control in an example of code for printing information. Each command runs
only once to perform the necessary print action.

The sequence of the printed address in this case is the sequence the programmer specifies
the recipient's name, followed by the recipient's street address, and so on.
Code
21: PRINT name
22: PRINT address
23: PRINT postbox
24: PRINT city
25: PRINT state
The most commonly used commands for capturing information for selection control are IF,
THEN, and ELSE.
Code
955

IF street IS empty
THEN
PRINT postbox
ELSE
PRINT street
Some programming languages require that you end any IF statement with a keyword, such as
ENDIF.
Code
IF street IS empty
THEN
PRINT postbox
ELSE
PRINT street
ENDIF
PRINT city
PRINT state
In certain scenarios, you may not need to use the ELSE statement if there is no alternative
action to take.
Code

ELSE

In this example, you're creating a list of adults. Persons under the age of 18 shouldn't be added
to the list. There is no ELSE statement because there is no action to take if a person's age is
under 18.
Code
IF age >= 18 THEN
STORE name IN adult_list
ENDIF
This is known as a null ELSE statement.
The repetition control structure is used to repeat a section of code until a specific condition is
met. This is also known as looping.
956

The commands used to create a loop are FOR, WHILE, and DO. FOR is the most common of
these commands and is used across multiple languages.

In this example, a WHILE loop is terminated using the ENDWHILE command. Different
programming languages may use different methods to terminate loops.
Code
seats_allocated = 0
WHILE seats_allocated < 5 DO
GET booking
PRINT ticket
ADD 1 to seats_allocated
ENDWHILE
This code is used to book seats on a minibus. The seats_allocated value is defined before
the loop starts because the loop needs a value to compare seats_allocated to. The code
runs until the value of seats_allocated reaches 5, at which point the ENDWHILE command
runs.
Question
Consider the code example.

Which type of control structure is being used?
Code
GET name
PRINT name
GET address
PRINT address
GET postbox
PRINT postbox
GET city
PRINT city
GET state
PRINT state
Options:
1. Sequence
2. Selection
3. Repetition
Answer
957

Option 1: Correct. The sequence control structure ensures that instructions are run once in
sequence. No instructions are repeated or skipped.
Option 2: Incorrect. Selection control is used when a choice needs to be made. This code
represents a sequence control in which instructions are run one at a time in the specified order.
Option 3: Incorrect. Repetition control repeats a certain part of the code until a specific condition is
met. This code represents a sequence control in which instructions are run one at a time in the
specified order.
Correct answer(s):
1. Sequence
2. Inputs, processes, and outputs
An algorithm is a set of instructions used to solve a problem. Creating this is the first step a
programmer will take when developing a computer program. The programmer constructs
algorithms using simple language before beginning to use any actual computer code.
An algorithm takes an input, processes it, and produces an output. These different parts of an
algorithm are written using different types of words. The processing in an algorithm is usually
described using verbs such as "find", "calculate", or "sort." The inputs or outputs are described
using nouns, adjectives, or adverbs. Examples are "time", "speed", or "distance."
It's common to use a defining table, or input-process-output table, as the basis for developing an
algorithm.
Graphic
A table with three columns and one row is labelled Defining table: the column headers are Input,
Process, and Output. The row details are Input: Get booking, Process: Add 1 to seats allocated, and
Output: Print ticket.
The process elements become statements in the algorithm.
The input and output elements become arguments for the statements in the algorithm. An
argument is similar to the object of a sentence. In this example, "booking" is an argument.
Say you need to calculate the speed that a courier must drive in order to cover a certain
distance in a specific time. You have to take time, speed, and distance into account, and then
create an algorithm that will process all these variables.
958

To create a defining table, you'd need to identify what your input, process, and output are. In this
case, the inputs are distance and time, the process can be defined as "calculate", and the output
is speed. Using this table, you can create your algorithm.
Once you have calculated the output, you need to specify a process or operation to make the
output visible. An example is an instruction to display the speed.
Code
BEGIN
Convert kilometers_to_miles
DISPLAY 'Enter the distance in kilometers.'
GET kilometers
miles = kilometers * 0.625
DISPLAY kilometers 'kilometers = ' miles 'miles.'
END
Once you've defined your input, process, and output using the defining table, you can start to
create the algorithm.
Question
You're developing an algorithm to print shipping labels for certain packages in a post office.

Match each statement to the correct column in an input-process-output table.
Options:
A. INPUT "More [Y/N]?"
B. WHILE answer = "Y"
C. PRINT Label
Targets:
1. The input column
2. The process column
3. The output column
Answer
INPUT "More [Y/N]?" is an input statement. Users have to input Y or N, depending on whether
they want to print labels.
959

After confirming that the label is needed, the algorithm processes any statements inside the WHILE
command. So the WHILE command belongs in the process column.
A label is created as output using the PRINT statement.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
An algorithm usually follows a certain structure. It begins with a name that describes the
algorithm's function.
Code
CALCULATE overdraft_interest
Once the algorithm has been named, any instructions that occur between the name and the END
statement must be indented. This makes it easier to identify each of the instructions.
Code
WHILE answer="Y" DO
READ name
READ address
PRINT label
DISPLAY "Print another?"
ENDWHILE
You need to indent every new control structure that is introduced. The indentation will return to
its previous level at the end of a control structure.
Code
CALCULATE overdraft_interest
WHILE answer="Y" DO
READ name
READ address
PRINT label
DISPLAY "Print another?"
ENDWHILE
960

The different components of the defining table can be broken down into one or more
pseudocode instructions.
Graphic
A table with three columns and one row is labelled Defining table: the column headers are Input,
Process, and Output. The row details are Input: GET info, Process: Do action, and Output:
DISPLAY result.
The components of the input and output columns are used as arguments for the instructions in
an algorithm.
Say you need to convert kilometers to miles. You can create an algorithm to express this.
You begin by defining the inputs, processes, and outputs.
The input is the distance in kilometers, the process is the conversion of miles to kilometers, and
the output is the distance in miles.
Graphic
A table with three columns and one row is labelled Defining table: the column headers are Input,
Process, and Output. The input is "GET kilometers", the process is "CALCULATE miles = kilometers
* 0.625", and the output is "DISPLAY enter distance in km" and
"DISPLAY miles."
You can then use the table to create an algorithm that converts kilometers to miles.
Graphic
A table with three columns and one row is labelled Defining table: the column headers are Input,
Process, and Output. The input is "GET kilometers", the process is "CALCULATE miles = kilometers
* 0.625", and the output is "DISPLAY enter distance in km" and
"DISPLAY miles."
Code
BEGIN Convert kilometers_to_miles
DISPLAY 'Enter the distance in kilometers.'
GET kilometers
miles = kilometers * 0.625
DISPLAY kilometers 'kilometers = ' miles 'miles.'
END
961

Even with a defining table to help you create the algorithm, you'll probably need to refine it
several times.
Question
You need to calculate the speed a courier must drive to cover a given distance within a given time.

Identify the correct pseudocode algorithm to express this.
Options:
1. Get distance
Get time
Calculate speed by dividing distance by time
Display speed
2. Get distance
Calculate speed by dividing distance by time
Display speed
3. Get distance
Get time
Calculate speed by adding distance to time
Display speed
Answer
Option 1: Correct. This algorithm can correctly calculate speed as it has the requisite distance and
time as inputs.
Option 2: Incorrect. This algorithm can't calculate speed without a value input for time.
Option 3: Incorrect. This algorithm can't correctly calculate speed as it uses the incorrect process of
adding distance to time.
Correct answer(s):
1. Get distance
Get time
Calculate speed by dividing distance by time
Display speed
Summary
You can use the three control structures sequence, selection, and repetition to help structure
an algorithm you're creating.

962

An algorithm can also be broken down into three different components input, output, and
process. Once you've identified the different components, you can begin to build the algorithm.



























963

IF Statements
Learning Objectives
After completing this topic, you should be able to
recognize the features of IF statements
recognize how programming languages process IF statements
1. The features of IF statements
Structured programming includes three control structures repetition, sequence, and selection.
The repetition control structure represents the process whereby a series of commands are
executed until specified criteria are met. The sequence control structure represents the order in
which statements in a program are executed. The selection control specifies when and how a
statement is chosen to execute, depending on what the programmer requires.
In code, IF statements are part of the selection control structure. Statements like these, which
are part of the selection control structure, are also known as conditional statements.
Programmers use IF statements to select which statements to execute based on whether
conditions are true or false.

IF statements come in a variety of forms. The most basic form is IF...THEN, which instructs a
program to check whether a specified condition is true before running a specified statement
block.
If the condition in an IF...THEN statement is met - is true - the statement block associated with
the THEN keyword will be executed. If the condition isn't met is false the statement block
associated with the THEN keyword is ignored and the program moves to the next line of code
after the IF..ENDIF structure.
Syntax
IF [condition is true] THEN
[statement block]
END IF
Note
In the BASIC language, the IF structure is terminated with the END IF statement.
964

An IF statement compares one value or variable to another to determine whether a condition is
true or false. For example, it may check whether the amount a customer spends is greater than
$1000, and if it is, will apply a discount of 5% because the condition is true.
Code
IF purchases > 1000 THEN
total = purchases * 0.95
END IF
This makes the statement a binary decision. Either the statement is true, with a binary value of
1, or it's false, with a binary value of 0.
In IF statements, you can use six different comparison operators to compare items:
=
The equal sign (=) is the equals operator and is used to evaluate whether two values are the
same. For example, 5 = 9 results in false.

The equals operator can also be indicated by two equal signs (==), as is the case in "squiggly
bracket" languages such as C and Java.
<
The less than operator is indicated by the less than sign (<) and is used to evaluate whether one
value is less than another. For example, the statement 5 < 9 results in true.
>
The greater than operator is indicated by the greater than sign (>) and is used to evaluate
whether one value is higher than another. For example, 5 > 9 results in false.
<=
The less than or equal to operator is indicated by the less than sign combined with the equal sign
(<=) and is used to evaluate whether one value is equal to or lower than another value. For
example, 5 <= 9 results in true.
>=, and
The greater than or equal to operator is indicated by the greater than sign combined with the
equal sign (>=) and is used to evaluate whether one value is equal to or higher than another
value. For example, 5 >= 9 results in false.
<>
The not equal to operator is indicated by the less than and greater than signs together (<>) and is
used to evaluate whether one value is not equal to another value. Whereas 5 = 9 results in
false, 5 <> 9 results in true.

In "squiggly bracket" languages such as C and Java, the not equal to operator is indicated by !=.
965

A selection condition can compare multiple factors to another factor, as in the expression
(a+b)>c.
Consider an example of an IF statement written in the BASIC programming language. It will
print a specified message on the receipts of customers only if they spend $1000 or more at a
store.
Code
IF client_purchases >= 1000 THEN
PRINT "We value your generous patronage."
END IF
PRINT client_name
If a customer spends less than $1000, the program ignores the code after the THEN statement
and prints only the client's name. In other words, when the IF statement is false, the program
will continue to run the code after the END IF keyword, which marks the end of the IF...THEN
statement.
You can include an ELSE clause to run alternative code if the condition in an IF statement
evaluates as false. This type of statement is referred to as an IF...THEN...ELSE statement.
Graphic
In the image there is a question box which asks :Is condition 1 met? Then there are two branches
the top branch will execute if the value is true or the bottom branch will execute if the statement is
false.
Syntax
IF [condition is true]
THEN
[statement1 block]
ELSE
[statement2 block]
END IF
If the condition in the IF statement is met - is true, statement1 block will run. If the condition isn't
met is false, statement2 block included after the ELSE keyword will run.
Syntax
IF [condition is true]
THEN
966

[statement1 block]
ELSE
[statement2 block]
END IF
If you manage an online store, you might want to let your customers know when a specific item
is in stock. You can create an IF...THEN...ELSE statement that checks if there is stock of an
item and then displays a different message depending on whether the item is or isn't available.
Code
IF Stock >= 1 THEN
PRINT "Stock available"
ELSE
PRINT "Out of stock"
END IF
Note
The code shows a BASIC language example of the IFTHENELSE construct.
This is an example of an IF...THEN...ELSE statement written in Pascal. It specifies that if the
price of an item plus tax is equal to or greater than 120, a program must execute the first
WRITELN command. If the sum of the price and the tax is less than 120, the second WRITELN
command will execute.
Code
if (price+tax) >= 120 then
writeln ('total price is equal to or more than 120')
else
writeln ('total price is less than 120');
This example of an IF...THEN...ELSE statement is written in C. It specifies that if a client's
balance is negative, a computer program must print the message "overdrawn." If the balance is
positive, the program will print "in credit."
Code
if (balance < 0)
{
printf("overdrawn \n");
}
else
967

{
printf("in credit \n");
}
Note
Note that IF statements written in C don't end with the END IF keyword.

The \n used in the printf statement is called an escape sequence - after printing something to
the screen you usually want to print something on the next line. If there is no \n then a next printf
command will print the next string on the same line.
An IF statement that doesn't include an ELSE clause is also sometimes referred to as a null
ELSE statement.
Code
IF [purchases are more than $1000] THEN
[apply a discount of 5%]
END IF
Question
Which descriptions of IF statements are correct?
Options:
1. An IF statement tells a program which code to execute based on whether a condition is true or false
2. The statement block in an IF...THEN statement will execute only if a specific condition is met
3. An IF...THEN...ELSE statement will run alternative code if a specified condition isn't met
4. All statement blocks in an IF...THEN...ELSE will run if a condition is met
5. A null ELSE statement is a statement that includes an ELSE command
Answer
Option 1: Correct. IF statements are part of the selection control structure. They enable a program
to select code to execute based on whether a condition is true or false.
Option 2: Correct. In an IF...THEN statement, the statement block after the THEN keyword runs
only if the condition specified after the IF keyword is met.
Option 3: Correct. If the condition in an IF...THEN...ELSE statement isn't met, the statement
block after the ELSE command will run.
968

Option 4: Incorrect. If the specified condition is met, only the first statement block in an
IF...THEN...ELSE statement will run.
Option 5: Incorrect. A null ELSE statement is an IF statement that doesn't include an ELSE
statement. It's the same as a simpleIF...THEN statement.
Correct answer(s):
1. An IF statement tells a program which code to execute based on whether a condition is true or
false
2. The statement block in an IF...THEN statement will execute only if a specific condition is met
3. An IF...THEN...ELSE statement will run alternative code if a specified condition isn't met
2. Processing IF statements
Sometimes you may need to include more than one condition in an IF statement. This is known
as a compound condition.
Graphic
In this diagram representing an IF statement, a compound condition is created, which first tests
Requirement 1 AND Requirement 2 then another AND is used to join the condition to a second
condition which tests Requirement 3 OR Requirement 4. Then based of the results of the compound
condition either the true or false branch will be executed.
Compound conditions use the logical operators AND or OR.
The AND operator joins two conditions so that an expression evaluates as true only if both those
conditions are met. If only one or other of the conditions is met, the expression evaluates as
false.
The OR operator specifies that an expression is true if either of two conditions is true. So if one
condition is true and the other is false, the result of the expression is true.
Another operator that can be used in an IF statement is the NOT operator. It is used to specify
that an expression is true only if a condition is actually false.
Consider an IF...THEN...ELSE statement with a condition that uses the AND operator to
check whether a cup of coffee meets each of four conditions.
Code
IF coffee AND cream AND sugar AND (Jamaican OR Javanese)
THEN
969

accept coffee
ELSE
decline coffee
END IF
The cup of coffee has to have cream, coffee, and sugar, and to be either Jamaican or Javanese
to be accepted.
Graphic
The relevant code is:
coffee AND cream AND sugar AND (Jamaican OR Javanese)
Here is the code again.
Code
IF coffee AND cream AND sugar AND (Jamaican OR Javanese)
THEN
accept coffee
ELSE
decline coffee
END IF
The final condition uses the OR operator to specify that the coffee can be either Jamaican or
Javanese.
Graphic
The relevant code is:
(Jamaican OR Javanese)
Here is the code again.
Code
IF coffee AND cream AND sugar AND (Jamaican OR Javanese)
THEN
accept coffee
ELSE
decline coffee
END IF
Consider an IF...THEN...ELSE statement written in Pascal to check air pressure and wind
direction.
970

Code
if ((air_pressure > 1000) and (wind = 'nw')) then
writeln ('It is likely to rain.')
else
writeln ('It probably won't rain.') ;
The statement is considered true only if the conditions for air pressure and for wind direction are
both met. If both conditions are met, the message "It is likely to rain" will display. If one or both
conditions fail, the message "It probably won't rain" will display.
A nested IF statement is an IF statement within another IF statement. You can use this type of
statement to specify multiple, separate conditions.
Graphic
In the image there is a question box which asks: Is condition 1 met? Then there are two branches
the top branch will execute if the value is true or the bottom branch will execute if the statement is
false.

The true branch then has a question box which asks: Is condition 2 met? If condition 2 is met, then a
second set of true conditions will execute. If the condition is not met, then a different set of
conditions will execute.
Say you need to write a C++ program that checks the overdraft charges for savings and
checking accounts. The program first checks whether an account has a positive balance. If it
does, the first printf statement will run.
Graphic
The relevant code is:
if (balance >= 0)
{
printf ("Account in credit");
Code
if (balance >= 0)
{
printf ("Account in credit");
}
else
{
if (account_type == 'c')
971

{
printf ("Checking account overdraft charge is $15 \n");
}
else
{
printf ("Savings account overdraft charge is $12 \n");
}
}
If the account has a negative balance, the program needs to check what type of account it is. So
the nested if statement after the else keyword will run.
Graphic
The relevant code is:
else
{
if (account_type == 'c')
Code
if (balance >= 0)
{
printf ("Account in credit");
}
else
{
if (account_type == 'c')
{
printf ("Checking account overdraft charge is $15 \n");
}
else
{
printf ("Savings account overdraft charge is $12 \n");
}
}
The program will then check the type of account that has the overdraft. If the account type is "c",
the first printf statement in the nested if statement will run. If the account type isn't "c", the
second printf statement will run.
Graphic
The relevant code is:
printf ("Checking account overdraft charge is $15 \n");
972

}
else
{
printf ("Savings account overdraft charge is $12 \n");
}
}
Code
if (balance >= 0)
{
printf ("Account in credit");
}
else
{
if (account_type == 'c')
{
printf ("Checking account overdraft charge is $15 \n");
}
else
{
printf ("Savings account overdraft charge is $12 \n");
}
}
Consider a BASIC program that calculates interest earned on positive credit card balances. It
uses a nested IF statement to determine the interest calculated for three types of credit cards.
Code
IF (card_type = "gold") THEN
IF (account_type = "business") THEN
print "Interest calculated at 6%"
ELSE
print "Interest calculated at 5%"
END IF
ELSE
print "Interest calculated at 4%"
END IF
This statement first checks the type of card. If it's a gold card, the account will earn 5% or 6%
interest, depending on whether it's a standard gold card or a business gold card. If it isn't a gold
card, the account will earn 4% interest.
Code
973

IF (card_type = "gold") THEN
IF (account_type = "business") THEN
print "Interest calculated at 6%"
ELSE
print "Interest calculated at 5%"
END IF
ELSE
print "Interest calculated at 4%"
END IF
If the card is a gold card, the first nested IF statement is run. The nested IF statement
determines if the account is a business account. If it is then the interest is set to 6%. If the
account isn't a business account, the ELSE statement is run, which sets the interest at 5%.
Graphic
The relevant code is:
IF (card_type = "gold") THEN
IF (account_type = "business") THEN
print "Interest calculated at 6%"
ELSE
print "Interest calculated at 5%"
END IF
Code
IF (card_type = "gold") THEN
IF (account_type = "business") THEN
print "Interest calculated at 6%"
ELSE
print "Interest calculated at 5%"
END IF
ELSE
print "Interest calculated at 4%"
END IF
If the card isn't a gold card, the nested IF statement is skipped. The interest is then set at 4%.
Graphic
The relevant code is:
ELSE
print "Interest calculated at 4%"
END IF
974

Code
IF (card_type = "gold") THEN
IF (account_type = "business") THEN
print "Interest calculated at 6%"
ELSE
print "Interest calculated at 5%"
END IF
ELSE
print "Interest calculated at 4%"
END IF
Question
You've written a simple program in C that uses IF statements.

What does the nested IF statement accomplish?
Code
if (numDozens < 12)
{
numDozens = numDozens + 1;
gross = gross + 1;
if (countToADozen < 12)
{
countToADozen = countToADozen + 1;
} else
{
num = num + 1;
cout << numDozens << " dozen.\n";
countToADozen = 0;
}
} else
{
cout << "12 dozen.\n";
done = true;
cout << "TOTAL = " << gross << "\n";
cout << "One gross has been counted\n";
}

Options:
1. It will increment the variable countToADozen by 1 until the value of countToADozen equals 12
2. It will increment the variable numDozens by 1 until the value of numDozens equals 12
3. It will increment the variable countToADozen by 1 if the value of countToADozen is greater than 12
975

4. It will set the value of countToADozen to 0 until the value of numDozens is greater than 12
Answer
Option 1: Correct. Until the value of countToADozen equals 12, 1 will be added to the value for
countToADozen. As soon as the value of countToADozen is equal to 12, the nested IF
statement will break.
Option 2: Incorrect. The nested IF statement is used to determine the value of countToADozen,
not numDozens.
Option 3: Incorrect. Once the value of countToADozen is equal to 12, the nested IF statement will
break and control will pass back to the first IF statement, so no more values will be added to
countToADozen.
Option 4: Incorrect. countToADozen will be set to 0, only if the value of countToADozen is
already 12 or more when the nested IF statement starts executing.
Correct answer(s):
1. It will increment the variable countToADozen by 1 until the value of countToADozen equals 12
Summary
Programmers use IF statements to select which code statements to execute based on whether
specified conditions are met. In an IF...THEN statement, a statement block after the THEN
keyword executes only if the condition is true. An IF...THEN...ELSE statement works in the
same way, but if the condition is false, a statement block after the ELSE keyword is executed.

You can use the AND and OR logical operators in IF statements to create compound conditions.
You can also use the NOT operator to specify that a statement block must execute if a condition
is false. You can use nested IF statements to include multiple conditions and associated
statement blocks.






976

CASE Statements
Learning Objective
After completing this topic, you should be able to
identify the features of CASE statements
1. How to use CASE statements
Although an IF statement is useful for making simple decisions, using IF statements for more
than two options can become unnecessarily complicated.
Graphic
In the diagram, when processing starts, an IF condition is tested. If it's false, the ELSE code
executes and the program ends.

If the condition is false, then another IF condition is tested. If this condition is false, the ELSE code
executes and the program ends.

If the condition is true, then the true code statements execute and the program will end.
Nested IF statements can be used to deal with code that requires three or more options.
However, the more options there are, the harder it becomes to understand and follow multiple
nested IF statements. This can make it difficult to debug code.
You can use CASE statements to replace complicated nested IF statements.
Syntax
SELECT CASE variable
CASE value_1
first statement block
CASE value_2
second statement block
CASE value_x
xth statement block
CASE ELSE
optional ELSE clause/statement block
END SELECT
A CASE statement consists of comparison options in a list, only one of which can be valid. Each
option condition is unique and has an associated statement block. If a particular option is
matched to the case variable, its associated statement block is executed or run.
977

Graphic
In this diagram, there is a Start command, then there are three boxes, one below the other, with
conditions for testing. Each of these conditions is tested and will execute code according to the
result of the condition. After a condition is met the CASE statement ends. If no condition is met, it
will default to the OTHER block.
Each CASE option can evaluate as many expressions as necessary. The final CASE ELSE
statement caters for all other possibilities not handled by a specific option.
In this example, if a value falls within the range defined for value_1, the first statement block will
run. If a value falls within the range defined for value_2, the second statement block will run. The
same applies to value_x and the xth_statement block.
Syntax
SELECT CASE variable
CASE value_1
first statement block
CASE value_2
second statement block
CASE value_x
xth statement block
END SELECT
You might use a selection statement, for example, to define student's grades based on their test
results. The code for doing this can be written using one of two methods.
You can use IF statements, which use Boolean variables, such as IF (result = F), to
determine if statements are true or false. This example is correct, but is lengthy and hard to
follow.
Code
IF result = "F"
THEN
PRINT "You got an F"
END IF
IF result = "D"
THEN
PRINT "You got a D"
END IF
IF result = "C"
THEN
PRINT "You got a C"
978

END IF
IF result = "B"
THEN
PRINT "You got a B"
END IF
IF result = "A"
THEN
PRINT "Good job! You got an A"
END IF
Alternatively, you can use a CASE statement, which is much shorter and easier to follow. Each
CASE statement must have an option for every possible result. Each result is checked to
determine which range it falls into. If a result falls within a specific range, the statement
associated with that range is executed.
Code
SELECT CASE result
CASE F
PRINT "You got an F"
CASE D
PRINT "You got a D"
CASE C
PRINT "You got a C"
CASE B
PRINT "You got a B"
CASE A
PRINT "Good job! You got an A"
END SELECT
CASE statements aren't limited to checking that a variable matches a single value. You can
check for multiple values in a case line using the SELECT CASE statement.
Code
SELECT CASE Result
CASE F
PRINT Failure is not an option
CASE D, C, B
PRINT Try harder next time
CASE A
PRINT Excellent work!
END SELECT
979

For example, you can write code that prints different messages depending on the result. In this
example, if a learner gets a B, C, or D, the message "Try harder next time" will print. This
demonstrates how multiple conditions can be incorporated into one CASE statement.
You can also check for number variables using a SELECT CASE statement. If you have a list of
numbers in sequence, you can specify the number for each case.
Graphic
The relevant code is
CASE 1,2,3,4,5,6,7,8,9,10,11
Code
SELECT CASE Dozen
CASE 1,2,3,4,5,6,7,8,9,10,11
Result = Less than a dozen
CASE 12
Result = One dozen
CASE 13
Result = A bakers dozen
END SELECT
You can also write a list of sequential numbers using the TO command. For example, you have
11 potential results for the first CASE statement. Instead of specifying each CASE number, you
can simply list them as CASE 1 TO 11.
Code
SELECT CASE Dozen
CASE 1 TO 11
Result = Less than a dozen
CASE 12
Result = One dozen
CASE 13
Result = A bakers dozen
END SELECT
You can use comparison operators, such as >, <, or <>, to expand the ways that the CASE
statement can be used.
Code
980

SELECT CASE Age
CASE IS < 12
ageStatus = "Pre-teen"
CASE 13 TO 19
ageStatus = "Teenager"
CASE 20
ageStatus = "Unsure"
CASE IS > 20
ageStatus = "Adult"
END SELECT
In many programming languages, you can use comparison operators by using the IS or TO
keywords. The IS keyword checks the tested variable against the expression listed after it. The
TO keyword checks the tested variable using a range of values.
Code
SELECT CASE Age
CASE IS < 12
ageStatus = "Pre-teen"
CASE 13 TO 19
ageStatus = "Teenager"
CASE 20
ageStatus = "Unsure"
CASE IS > 20
ageStatus = "Adult"
END SELECT
Note
Curly bracket languages, like C and C++, don't allow you to use comparison operators in a switch
statement.
In this SELECT CASE example, a different status message displays depending on the age group
into which the value of the Age variable falls.
When you've created a range of CASE statements and need to use a variable that doesn't fit into
any of the specified ranges, you can use the ELSE statement.
In this example, a final case determines that if the value of Age is 65, the corresponding status
is retired.
Graphic
981

The relevant code is:
CASE 65
ageStatus = Retired
Code
SELECT CASE workStatus
CASE IS < 12
ageStatus = "Cant work"
CASE 13 TO 19
ageStatus = "Student"
CASE 20 TO 64
ageStatus = "Time to find a job"
CASE 65
ageStatus = "Retired"
END SELECT
In another example, the ELSE command defines the status of anyone who falls outside of the
defined categories, which cover people up to the age of 64. If someone is 65 years or older, the
ELSE command will run and the status will be set as retired.
Graphic
The relevant code is:
CASE ELSE
ageStatus = Retired
Code
SELECT CASE workStatus
CASE IS < 12
ageStatus = "Cant work"
CASE 13 TO 19
ageStatus = "Student"
CASE 20 TO 64
ageStatus = "Time to find a job"
CASE ELSE
ageStatus = "Retired"
END SELECT
Question
Identify the features of CASE statements.
982

Options:
1. They can be used to replace complicated nested IF statements
2. They work by choosing a single option from a list of options
3. They can only evaluate a limited number of expressions
4. They need to cater for every possible result
Answer
Option 1: Correct. Nested IF statements can become unnecessarily complicated when you're
dealing with multiple options. You can use a CASE statement in this situation to replace the IF
statements.
Option 2: Correct. The option that's chosen determines which statement block will run.
Option 3: Incorrect. A CASE statement can be used to evaluate as many expressions as necessary.
Option 4: Incorrect. In many programming languages, CASE statements don't have to have options
for every possible result.
Correct answer(s):
1. They can be used to replace complicated nested IF statements
2. They work by choosing a single option from a list of options
2. Implementing CASE statements
Not all programming languages use the CASE syntax. Instead they may use different syntax to
serve the same function.
Say you want to print descriptions of three comparison operators <, >, and = using both
Pascal and C.
Pascal uses the CASE statement to display the description of each operator.
Code
case comparator of
'<' : writeln ("less than");
'>' : writeln ("greater than");
'=' : writeln ("equal");
else
writeln ("invalid");
end
983

C uses the switch and break statements to select and display a description of a specific
comparison operator.
Code
switch (comparator)
{
case '<': printf ("less than");
break;
case '>': printf ("greater than");
break;
case '=': printf ("equal");
break;
default: printf ("invalid");
}
Keyboard Sequence
By convention, most keywords in C are written using lowercase.
Like SELECT CASE, the switch statement is used to select a result from a set of options.
In languages like C, the break statement ends the execution of the switch block.
The switch statement processes case statements until it finds a match. After a case
statement runs, the break statement halts further processing of case statements.

In this example, if the value is the greater than operator (>), the printf command will print
"greater than." The break command will then halt processing of any other commands in the
switch statement, and processing will resume after the closing brace (}).
Code
switch (comparator)
{
case '<' : printf ("less than");
break;
case '>' : printf ("greater than");
break;
case '=' : printf ("equal");
break;
default : printf ("invalid");
}
984

Question
Which line of code executes when the value of ageStatus is 70?
Code
SELECT CASE ageStatus
CASE IS < 12
workStatus = Cant work
CASE 13 TO 19
workStatus = Student
CASE 20 TO 64
workStatus = Time to find a job
CASE ELSE
workStatus = Retired
END SELECT
Options:
1. workStatus = Retired
2. workStatus = Time to find a job
3. workStatus = Student
4. workStatus = Cant work
Answer
Option 1: Correct. If a value falls outside the ranges defined by case statements, as it does if
ageStatus is equal to any value greater than 64, the code after the else keyword will execute.
Option 2: Incorrect. This code will execute only if the value of ageStatus falls in the range from 20
to 64. In this example, the value of the variable is 70.
Option 3: Incorrect. This code will execute only if the value of ageStatus falls in the range from 13
to 19.
Option 4: Incorrect. This code will execute only if the value of ageStatus is less than 12.
Correct answer(s):
1. workStatus = Retired
Summary
Instead of using potentially complex nested IF statements to handle three or more options in
code, you can use CASE statements. Using this type of statement, you can provide a list of
985

options and instruct a program to run a statement block associated with whichever option
applies. In many programming languages, you use the keywords SELECT CASE at the
beginning of a range of CASE statements to identify the variable being checked.

Some programming languages use different syntax for the same purpose as SELECT CASE. For
example, C uses switch statements, with break statements to halt processing once an option
has been selected.
























986

Solving a Problem using Branching Statements
Learning Objectives
After completing this topic, you should be able to
identify the steps in solving a basic programming problem
complete branching statements in C code
1. Solving a basic programming problem
To simplify the programming process, which can be defined as the process of solving a
programming problem, you can follow four main steps:
analyze the problem, which is typically captured in a problem statement
create a defining table
create an algorithm in pseudocode, and
write the algorithm code
To understand the problem completely, you might need to start by doing some research to put
the problem in context.
Once you fully understand the problem, you can define its functional requirements by analyzing
it in terms of its input, processing, and output elements.
The second step is to create a defining table that determines which data the program should
process and what the result should be.
After identifying the input, process, and output elements, you can compile a table that lists the
elements under the relevant headings.
Graphic
A table includes Input, Process, and Output columns.
Input and output elements are generally nouns in a problem statement, and processes are
identified using verbs. It's processes that will transform the input into the output.
Every input element has an associated process to acquire the data associated with it. And every
output element has a process to display or otherwise act on the data that has been processed.

Some elements may not be explicitly mentioned in the problem statement, so you need to
determine these from the context and the expected results.
987

Graphic
In the first line of this diagram an Input flows into a process and on the second line a Process flows
to an Output.
There isn't necessarily a one-to-one mapping of processes to input and output elements. This is
because many different procedures or functional elements may be required to act on a single
input element or to produce a single output element.
Graphic
In this diagram there are 3 Inputs, the first two flows into one process and the 3rd flows into one
process. The two processes then flow out into one Output.
In large modern object-oriented programs, such as those created using C++ or Java, hundreds
of functional elements known as classes may be needed to model and implement the required
behavior.
Graphic
A large circle is in the center and four smaller circles are attached to it.
The third step is to create an algorithm in pseudocode that outlines how the program will
function. This should take the form of a detailed, ordered set of instructions that have to be
carried out. But it doesn't implement these in any specific programming language.
Instead of using a specific programming language, a pseudocode algorithm uses clear and
precise language to describe the instructions that have to be carried out, and in what order.
Code
IF x > y THEN
PRINT "X is: "; x
END IF
The fourth and final step is to convert the pseudocode into a programming language.
Pseudocode algorithms should be written in such a way that they can be encoded into any
programming language.
Each programming language has different strengths and weaknesses, so you may have to
consider the purpose of the program you're designing before choosing the language you'll use to
create it.
Question
988

Sequence the steps for solving a programming problem.
Options:
A. Analyze the problem statement
B. Create a defining table
C. Create an algorithm in pseudocode
D. Write the algorithm in a programming language
Answer
Correct answer(s):
Analyze the problem statement is ranked the first step.
The first step is to create and analyze a problem statement, defining its input, processing, and
output elements.
Create a defining table is ranked the second step.
After analyzing the problem statement, you compile a table that defines the relevant input,
processing, and output elements.
Create an algorithm in pseudocode is ranked the third step.
After compiling a defining table you create an algorithm in pseudocode. This involves writing a
detailed, ordered set of instructions that the program will have to execute.
Write the algorithm in a programming language is ranked the fourth step.
As the last step, you convert the pseudocode you've created into a programming language
that's suitable given the purpose of the program.
2. Branching statements in C code
You work for a theater that's developing a program to manage bookings and ticket sales.
You've been asked to write the part of the program that calculates the total price of tickets
bought by customers. The theater has three sections, each represented by a code, and each
section has a limited number of seats. When tickets are requested, the program must check
seat availability before printing the tickets.
After a ticket sale, it must update the number of allocated seats to prevent over-booking.
The theater includes three sections:
the front section, which has 50 seats costing $30 each
the center section, which has 100 seats costing $20 each, and
989

the back section, which has 50 seats costing $10 each
You start by considering the problem statement. There are two inputs you'll need to use the
number of seats requested and where they are located.
Graphic
The Input column of the table has two entries no_of_seats and theater_section. The rest of the
table is still empty.
Next you consider the required processes. The program needs to retrieve the number of
requested seats and the theater section from the customer's input. Then it needs to match the
customer's section to the code that represents it. It also has to check for seat availability and
calculate the total price of a ticket.
Graphic
The Process column of the table now contains the following pseudocode:
GET no_of_seats
GET theater_section
SELECT code for relevant theater_section
CHECK available_seats
CALCULATE price
PRINT tickets
Last the program has to print the ticket, update the number of seats allocated for that section,
and calculate and display the total cost of the ticket to the customer.
Graphic
Two additional processes have been added to the Process column CALCULATE seats_allocated
and DISPLAY total_price.
There are two outputs for this problem. The program must display the total cost of the ticket to
the customer and print the ticket. Both outputs involve a process and should be indicated in the
table as such.
Graphic
Two entries have been added to the Output column total_price and tickets.
Once you've finished creating a defining table, you can use it to guide you through the rest of the
process.
990

You can now start preparing the pseudocode algorithm for the program. The program must
branch to the code that deals with each of the theater sections front, center, and back
depending on which one the customer wants.
The program must also check that enough seats are available in that section, calculate the ticket
price, and update the number of seats allocated.
You start the algorithm by creating statements that represent the processing needed to capture
the input data.
There are three sections in the theater, so you use a CASE statement to branch to the relevant
code for each theater section.
Graphic
The relevant code is

CASE theater_section IS
Code
GET no_of_seats
GET theater_section
CASE theater_section IS
front :
center :
back :
ENDCASE
The IF statement first checks how many seats are currently available by subtracting the number
of seats already allocated from the maximum capacity of the section, which is 50 in this case.
The IF statement then compares the difference to the number of seats requested.
Graphic
The relevant code is

IF no_of_seats <= (50-front_allocated) THEN
Code
GET no_of_seats
GET theater_section
CASE theater_section IS
991

front : IF no_of_seats <= (50 - front_allocated) THEN
ticket_price = no_of_seats * 30
PRINT ticket
front_allocated = front_allocated + no_of_seats
ELSE
OUTPUT "Not enough seats left in this section"
ENDIF
center :
back :
ENDCASE
The program continues processing a ticket request only if tickets in the relevant section are
available. It then calculates the ticket price and prints the ticket.
Graphic
The relevant code is

ticket_price = no_of_seats * 30
PRINT ticket
Code
GET no_of_seats
GET theater_section
CASE theater_section IS
front : IF no_of_seats <= (50 - front_allocated) THEN
ticket_price = no_of_seats * 30
PRINT ticket
front_allocated = front_allocated + no_of_seats
ELSE
OUTPUT "Not enough seats left in this section"
ENDIF
center :
back :
ENDCASE
Once the tickets have been printed, the number of seats sold is added to the total number of
seats already allocated in the section. This ensures that the number of seats listed as available
is kept up to date.
Graphic
992

The relevant code is

front_allocated = front_allocated + no_of_seats
Code
GET no_of_seats
GET theater_section
CASE theater_section IS
front : IF no_of_seats <= (50 - front_allocated) THEN
ticket_price = no_of_seats * 30
PRINT ticket
front_allocated = front_allocated + no_of_seats
ELSE
OUTPUT "Not enough seats left in this section"
ENDIF
center :
back :
ENDCASE
If the number of seats requested exceeds those available, the ELSE statement is triggered and
the program prints a message stating that there are not enough seats left in the section.
Graphic
The relevant code is

ELSE OUTPUT "Not enough seats left in this section"
Code
GET no_of_seats
GET theater_section
CASE theater_section IS
front : IF no_of_seats <= (50 - front_allocated) THEN
ticket_price = no_of_seats * 30
PRINT ticket
front_allocated = front_allocated + no_of_seats
ELSE
OUTPUT "Not enough seats left in this section"
ENDIF
center :
back :
ENDCASE
993

You can adjust the code for the front theater section to reuse it for the center and back sections.
You simply replace the number of seats and the ticket price per section in each case.
Code
GET no_of_seats
GET theater_section
CASE theater_section IS
front : IF no_of_seats <= (50 - front_allocated) THEN
ticket_price = no_of_seats * 30
PRINT ticket
front_allocated = front_allocated + no_of_seats
ELSE
OUTPUT "Not enough seats left in this section"
ENDIF
center : IF no_of_seats <= (100 - front_allocated) THEN
ticket_price = no_of_seats * 20
PRINT ticket
front_allocated = front_allocated + no_of_seats
ELSE
OUTPUT "Not enough seats left in this section"
ENDIF
back : IF no_of_seats <= (50 - front_allocated) THEN
ticket_price = no_of_seats * 10
PRINT ticket
front_allocated = front_allocated + no_of_seats
ELSE
OUTPUT "Not enough seats left in this section"
ENDIF
ENDCASE
You can now write the algorithm pseudocode in a programming language C in this case.
You can convert the pseudocode to a programming language one section at a time.
Code
no_of_seats = scanf ("%d",&no_of_seats);
theater_section = scanf ("%c",&theater_section);
switch (theater_section){
case 'F' :
if (no_of_seats <= (50 - front_allocated))
{ticket_price = no_of_seats * 30;
printf("Front seats cost $%d", ticket_price, "\n");
front_allocated = front_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
994

break;
case 'C' :
if (no_of_seats <= (100 - center_allocated))
{ticket_price = no_of_seats * 20;
printf("Center seats cost $%d", ticket_price, "\n");
center_allocated = center_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'B' :
if (no_of_seats <= (50 - back_allocated))
{ticket_price = no_of_seats * 10;
printf("Back seats cost $%d", ticket_price, "\n");
back_allocated = back_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;}
GET no_of_seats
GET theater_section
To input the number of seats and the theater section requested by the user, you use the scanf
statement, which reads information from an input device like a keyboard. Because the number of
seats is an integer, you use the %d option in the scanf statement. This accepts an integer as
input and then writes this to the variable no_of_seats. The value of the variable
theater_section will be a character, so you use the %c option to read it.

Code
no_of_seats = scanf ("%d",&no_of_seats);
theater_section = scanf ("%c",&theater_section);
switch (theater_section){
case 'F' :
if (no_of_seats <= (50 - front_allocated))
{ticket_price = no_of_seats * 30;
printf("Front seats cost $%d", ticket_price, "\n");
front_allocated = front_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'C' :
if (no_of_seats <= (100 - center_allocated))
{ticket_price = no_of_seats * 20;
printf("Center seats cost $%d", ticket_price, "\n");
center_allocated = center_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'B' :
if (no_of_seats <= (50 - back_allocated))
{ticket_price = no_of_seats * 10;
995

printf("Back seats cost $%d", ticket_price, "\n");
back_allocated = back_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;}
CASE theater_section IS
front:
The switch statement is used to perform conditional logic with case statements in C. After the
case statement, the theater_section variable follows in parentheses to indicate that the
value of this variable determines the code that executes next. The theater_section variable
can equal one of the three values F, C, or B.

Code
no_of_seats = scanf ("%d",&no_of_seats);
theater_section = scanf ("%c",&theater_section);
switch (theater_section){
case 'F' :
if (no_of_seats <= (50 - front_allocated))
{ticket_price = no_of_seats * 30;
printf("Front seats cost $%d", ticket_price, "\n");
front_allocated = front_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'C' :
if (no_of_seats <= (100 - center_allocated))
{ticket_price = no_of_seats * 20;
printf("Center seats cost $%d", ticket_price, "\n");
center_allocated = center_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'B' :
if (no_of_seats <= (50 - back_allocated))
{ticket_price = no_of_seats * 10;
printf("Back seats cost $%d", ticket_price, "\n");
back_allocated = back_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;}
IF no_of_seats <= (50-front_allocated) THEN
Before processing the ticket request, the program checks that there are enough seats left in the
selected section. If the condition is true it enters the if code block.

Code
no_of_seats = scanf ("%d",&no_of_seats);
996

theater_section = scanf ("%c",&theater_section);
switch (theater_section){
case 'F' :
if (no_of_seats <= (50 - front_allocated))
{ticket_price = no_of_seats * 30;
printf("Front seats cost $%d", ticket_price, "\n");
front_allocated = front_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'C' :
if (no_of_seats <= (100 - center_allocated))
{ticket_price = no_of_seats * 20;
printf("Center seats cost $%d", ticket_price, "\n");
center_allocated = center_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'B' :
if (no_of_seats <= (50 - back_allocated))
{ticket_price = no_of_seats * 10;
printf("Back seats cost $%d", ticket_price, "\n");
back_allocated = back_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;}
ticket_price = no_of_seats * 30
PRINT ticket
front_allocated = front_allocated - no_of_seats
Next the program calculates the total price of the tickets and prints a message to the output
device to show this total. The code inside the printf statement, /n, is the new line character,
which moves the cursor to the next line on the output device. Lastly, it adjusts the number of the
seats already allocated in the selected section.

Code
no_of_seats = scanf ("%d",&no_of_seats);
theater_section = scanf ("%c",&theater_section);
switch (theater_section){
case 'F' :
if (no_of_seats <= (50 - front_allocated))
{ticket_price = no_of_seats * 30;
printf("Front seats cost $%d", ticket_price, "\n");
front_allocated = front_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'C' :
997

if (no_of_seats <= (100 - center_allocated))
{ticket_price = no_of_seats * 20;
printf("Center seats cost $%d", ticket_price, "\n");
center_allocated = center_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'B' :
if (no_of_seats <= (50 - back_allocated))
{ticket_price = no_of_seats * 10;
printf("Back seats cost $%d", ticket_price, "\n");
back_allocated = back_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;}
ELSE OUTPUT "Not enough seats left in this section"
When there are not enough seats left, the if condition is false. The program then prints an error
message to the output device.

Code
no_of_seats = scanf ("%d",&no_of_seats);
theater_section = scanf ("%c",&theater_section);
switch (theater_section){
case 'F' :
if (no_of_seats <= (50 - front_allocated))
{ticket_price = no_of_seats * 30;
printf("Front seats cost $%d", ticket_price, "\n");
front_allocated = front_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'C' :
if (no_of_seats <= (100 - center_allocated))
{ticket_price = no_of_seats * 20;
printf("Center seats cost $%d", ticket_price, "\n");
center_allocated = center_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'B' :
if (no_of_seats <= (50 - back_allocated))
{ticket_price = no_of_seats * 10;
printf("Back seats cost $%d", ticket_price, "\n");
back_allocated = back_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;}
ENDCASE
998

The break statement causes the program to exit the switch statement. If it is omitted, the
program will continue to evaluate the remaining case conditions.

Code
no_of_seats = scanf ("%d",&no_of_seats);
theater_section = scanf ("%c",&theater_section);
switch (theater_section){
case 'F' :
if (no_of_seats <= (50 - front_allocated))
{ticket_price = no_of_seats * 30;
printf("Front seats cost $%d", ticket_price, "\n");
front_allocated = front_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'C' :
if (no_of_seats <= (100 - center_allocated))
{ticket_price = no_of_seats * 20;
printf("Center seats cost $%d", ticket_price, "\n");
center_allocated = center_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;
case 'B' :
if (no_of_seats <= (50 - back_allocated))
{ticket_price = no_of_seats * 10;
printf("Back seats cost $%d", ticket_price, "\n");
back_allocated = back_allocated - no_of_seats;}
else printf("Not enough seats left.\n");
break;}
Question Set
You've now been given an algorithm in pseudocode that keeps track of customers' purchases.

Each customer is categorized as belonging to "Bronze", "Silver", or "Gold" categories depending on
the value of their purchases. Silver and Gold customers qualify for discounted purchases.

The algorithm can be implemented in any programming language, but you decide to use C.
Question 1 of 3
Question
To start, you want to read the value of the customer's total purchases, which is an integer value,
from the keyboard.
999


Complete the code to do this.
Code
totalPurchases = INSERT THE MISSING CODE("%d",&totalPurchases);
...
Answer
The scanf method reads data from the keyboard.
Correct answer(s):
1. scanf
Question 2 of 3
Question
Next you want to find out if the customer qualifies as a Bronze, Silver, or Gold customer. These
levels are represented by the B, S, and G characters. You read this information from the keyboard
using the scanf method.

Complete the code that instructs scanf to receive data in the form of characters.
Code
totalPurchases = scanf ("%d",&totalPurchases);
preferredDiscount = scanf (INSERT THE MISSING CODE,&preferredDiscount);
Answer
The "%c" parameter indicates to the scanf method that a character is expected from the keyboard.
Correct answer(s):
1. "%c"
Question 3 of 3
Question
You have written the CASE block for the Bronze customer level.

Complete the code to ensure the program doesn't execute the Silver and Gold code after running
the Bronze processes.
1000

Code
totalPurchases = scanf ("%d",&totalPurchases);
preferredDiscount = scanf ("%c",&preferredDiscount);
switch (preferredDiscount)
{
case 'B' : if (totalPurchases < 1000)
{
discount = 0;
printf("Sorry, no discount. Spend $1000 or more to
receive a discount.\n");
}
else
{
printf("Welcome back, preferred customer!\n");
}
INSERT THE MISSING CODE;
Answer
You use the break command to exit the switch statement once a case statement has been
executed.
Correct answer(s):
1. break
Summary
You can follow four steps to simplify the process of solving a programming problem. You
analyze the problem statement, create a table defining the required inputs, processes, and
outputs, use the table to guide you in writing a pseudocode algorithm, and finally convert the
pseudocode into a programming language.

If program inputs are limited to a number of specific possibilities, you can use branching
statements to create the program. You can use CASE statements to decide on the number of
actions to take. You can also nest IF and ELSE block statements to further branch the
processes, as required.





1001

Completing Selection Statements
Learning Objectives
After completing this topic, you should be able to
complete IF statements in a given example
complete CASE statements in a given example
complete a program based on a defining table in a given example
Exercise overview
In this exercise, you're required to recognize how to use selection statements in programming.
This involves the following tasks:
completing IF statements
completing CASE statements, and
using a defining table to complete an algorithm
Completing IF statements
Question
You are coding registration software for a university. The university is offering $1,000 discounts to
the first 100 students to register.

Complete the IF statement so that the discount is correctly applied.
Code
IF student_no INSERT THE MISSING CODE THEN
Discount = 1000
Options:
1. <= 100
2. >= 100
3. < 100
Answer
Option 1: Correct. The code <=100 will ensure that the first 100 students get the $1,000 discount.
1002

Option 2: Incorrect. The code >=100 would cause the students with the $1,000 discount to overlap
with the students getting the $500 discount.
Option 3: Incorrect. The code <100 would cause the hundredth student to register to be excluded
from the discounts.
Correct answer(s):
1. <= 100
Question
Another $500 discount is offered to the next 100 students to register.

Complete the ELSE IF statement to ensure that the students from 101 to 200 are given the $500
discount.
Code
IF student_no <= 100 THEN
Discount = 1000
ELSE
IF student_no > 100 AND student_no INSERT THE MISSING CODE THEN
Discount = 500
ELSE
Discount = 0
END IF
END IF
Answer
Correct. The code <= 200 ensures that the students from 101 to 200 are given the $500 discount.
Correct answer(s):
1. <= 200
Completing CASE statements
Question
There are a variety of student discounts, which are classified according to category. The student
categories are P for part-time, F for full-time, and X for extra-mural.

Which discount does a part-time student receive?
1003

Code
CASE student category of :

X: discount = 1500

P: discount = 3750

F: discount = 6500

other: discount = 0

ENDCASE
Options:
1. $3,750
2. $1,500
3. $6,500
Answer
Option 1: Correct. If a student is part-time, they fall into category P. The discount for category P is
$3,750.
Option 2: Incorrect. The discount for category X is $1,500. This discount is applied to extra-mural
students. If a student is part-time, they fall into category P, which has a discount of $3,750.
Option 3: Incorrect. The discount for category F is $6,500. This discount is applied to full-time
students. If a student is part-time, they fall into category P, which has a discount of $3,750.
Correct answer(s):
1. $3,750
Using a defining table
You want to write the section of the program that calculates the total course fees and prints a
receipt that specifies the discounted price.
Question
You have created the defining table and have already added the inputs and outputs. Identify the first
process that will be added to the Process column.
1004

A defining table contains course_fee and student_category in the Input column, and total_ price and
receipt in the output column. The processes column is blank.
Options:
1. SELECT category_discount
2. PRINT receipt
3. CALCULATE total_price
4. GET course_fee, student_category
Answer
Option 1: Incorrect. SELECT category_discount will be performed after retrieving the
course_fee and student_category values.
Option 2: Incorrect. PRINT receipt will be the final process in the table.
Option 3: Incorrect. CALCULATE total_price will be performed after the course_fee,
student_category, and category_discount values are created.
Option 4: Correct. GET course_fee, student_category will be the first process in the
defining table to retrieve data inputs from the user.
Correct answer(s):
4. GET course_fee, student_category
Question
Identify the first process that will use input to produce the desired outputs.
GET course_fee, student_category
has been added to the first row in the Process column.
Options:
1. CALCULATE total_price
2. PRINT receipt
3. SELECT category_discount
Answer
1005

Option 1: Correct. CALCULATE total_price will use the two user inputs with the
category_discount value to calculate the total price.
Option 2: Incorrect. PRINT receipt is the final process in the defining table and will print all
necessary information to the output device.
Option 3: Incorrect. SELECT category_discount is the second process in the defining table and
forms part of the calculation that outputs total_price.
Correct answer(s):
1. CALCULATE total_price
Question
The student categories are P for part-time ($3,500), F for full-time ($5,000), and X for extra mural
($1,250), which form part of a CASE statement.

Match each category with the algorithm used to calculate the total price.
Options:
A. X:
B. P:
C. F:
D. Other:
Targets:
1. total_price = course_fee - 1250
2. total_price = course_fee - 0
3. total_price = course_fee - 5000
4. total_price = course_fee - 3500
Answer
Extra-mural students get a discount of $1,250.
Students who don't fall into these categories get no discount on their course fees.
Full-time students get a discount of $5,000.
Part-time students get a discount of $3,500.
1006

Correct answer(s):
Target 1 = Option A
Target 2 = Option D
Target 3 = Option C
Target 4 = Option B
IF and CASE statements have been completed, and a defining table has been used to complete
an algorithm.
Code
GET discount

CASE student category OF

X: total_price = course_fee 1250
PRINT receipt
P: total_price = course_fee 3500
PRINT receipt
F: total_price = course_fee 5000
PRINT receipt
other: total_price = course_fee 0
PRINT receipt

ENDCASE










1007

FOR Loops
Learning Objectives
After completing this topic, you should be able to
sequence the operations in a FOR loop
recognize how to use the FOR loop in computer programs
1. Introducing FOR loops
You may need to execute either single or compound statements a number of times in a
program. If you want to create a piece of code to print five address labels, you could write a print
statement and repeat it five times, for example.
Code
GET name_and_address
PRINT name_and_address
PRINT name_and_address
PRINT name_and_address
PRINT name_and_address
PRINT name_and_address
This is a rather inefficient method, especially if you are printing a large number of labels. The
amount of duplicated code is time-consuming to write, and difficult for other programmers to
read. Also, overly large programs use up memory and processing resources. The leaner a
program is, the better its performance.
Code
GET name_and_address
PRINT name_and_address
PRINT name_and_address
PRINT name_and_address
PRINT name_and_address
PRINT name_and_address
To avoid creating unwieldy code, you can use a programming procedure called a loop to avoid
using the same statement repeatedly.
Graphic
1008

In this diagram, the program is told to print a statement 5 times. At the beginning of the FOR loop,
the variable count equals 0. Each time a statement is printed the program adds 1 to count and
checks to see if count is greater than 4 (i.e., has looped 5 times). If it hasnt then the program loops
again, printing another statement. Once 5 iterations have been processed, count will equal 5 and
the program will end the loop.
A FOR loop lets you run a task a predetermined number of times. It removes the need to repeat
code, making the code shorter.
Conditions in a program can be used to determine a variable for the number of times the task
has to be executed.
A FOR loop can contain only one command or encompass an entire program that needs to be
run several times before terminating. Each time the code in a FOR loop runs, the cycle is known
as an iteration.
A FOR loop performs specific steps in sequence:
the counter is set to an initial value
The counter value is set before code in the FOR loop is executed. You set the increment or
decrement value, which is usually one.
if the counter value hasn't reached its limit, the instructions included in the loop are
executed
The loop will continue to repeat as long as the counter value remains inside the range set by the
loop limit.
the counter is incremented or decremented, and
Because the counter is used to control the number of times the loop is executed, it's incremented
or decremented after the instructions included in the loop are executed.
the loop is terminated when the counter reaches its limit
The loop stops executing as soon as the counter exceeds the limit.
You can write a program so that when it executes, it asks the user to set the number of times a
FOR loop must run. The user can be prompted to specify a number as the limit of the counter
value for example, to set how many copies of an invoice to print.
Code
INPUT "How many copies of the Invoice do you need printed? "; number$
FOR count = 1 to number$
'the code to print the invoice details
NEXT count
1009

Question
Identify the order of the steps a program takes when it executes a FOR loop.
Options:
A. Initialize the counter in the loop to an initial value
B. If the counter hasn't reached its limit, execute the instructions included in the FOR loop
C. Increment or decrement the counter
D. Terminate the loop when the counter reaches its limit
Answer
Correct answer(s):
Initialize the counter in the loop to an initial value is ranked the first step.
Before the code in a FOR loop is executed, the counter in the loop is initialized, with the
increment or decrement value usually set to one.
If the counter hasn't reached its limit, execute the instructions included in the FOR loop is
ranked the second step.
The loop will continue to repeat as long as the counter remains inside the range set by the
counter limit.
Increment or decrement the counter is ranked the third step.
Because the counter is used to control the number of times the loop is executed, it's
incremented or decremented after the instructions included in the loop are executed.
Terminate the loop when the counter reaches its limit is ranked the fourth step.
Once the counter exceeds the specified value, the loop will stop running.
2. Using FOR loops
In a FOR loop to print a specific number of address labels, the first line of code receives the
required input details. Then the address details are specified, and finally the labels are printed.
Code
Name$ = "Joe Bloggs"
Address$ = "12 Basic Language Avenue"
FOR count = 1 to 5
PRINT "Name: "; Name$; " Address: "; Address$
NEXT count
1010

You don't have to repeat the code for each statement because the single FOR loop can be set to
make the program print five labels.
Code
Name$ = "Joe Bloggs"
Address$ = "12 Basic Language Avenue"
FOR count = 1 to 5
PRINT "Name: "; Name$; " Address: "; Address$
NEXT count
The loop is created by using a counter variable called count, with a starting value of one. The
number of iterations is set to five. The count is incremented by one every time the loop is
executed.
Code
Name$ = "Joe Bloggs"
Address$ = "12 Basic Language Avenue"
FOR count = 1 to 5
PRINT "Name: "; Name$; " Address: "; Address$
NEXT count
The counter is used to terminate the loop once the specified number has been reached. So
once the count exceeds five, the loop will terminate.
Code
Name$ = "Joe Bloggs"
Address$ = "12 Basic Language Avenue"
FOR count = 1 to 5
PRINT "Name: "; Name$; " Address: "; Address$
NEXT count
You want to write a program to calculate the total mass of the cargo in a shipping container,
which varies according to the number of parcels in the container.
You first need to retrieve the input details. So you list the number of packages and the package
mass in each container as input elements in a defining table.
Graphic
A table contains Input, Process, and Output columns. The Input column contains no_of_packages
and package_mass.
1011

Processes that must run to generate a result include getting the number of packages in each
container, calculating the individual mass of the packages, and calculating the sum of their
mass.
Graphic
The Process column contains GET no_of_packages, CALCULATE package_mass, and
CALCULATE total_package_mass.
The total package mass is the output value.
Graphic
The Output column contains total_package_mass.
You begin this pseudocode algorithm with a request for the number of packages in the
container.
Code
PRINT 'How many packages are in the container?'
GET no_of_packages
You can use a FOR loop to get the mass of each package and add it to the mass total.
Code
FOR i = 1 to no_of_packages
GET package_mass
total_package_mass = total_package_mass + package_mass
ENDFOR
The number entered by the user determines how many times the loop will execute.
Code
GET no_of_packages
FOR i = 1 to no_of_packages
GET package_mass
total_package_mass = total_package_mass + package_mass
ENDFOR
PRINT total_package_mass
In most languages, the default loop control variable increment step is 1.
1012

You can change this by adding the STEP statement and specifying the step size as any number.
Code
FOR count = 1 TO 10 STEP 2
PRINT count
NEXT count
When executed, the result displays every second number from one to nine.
Graphic
The output in the example is 1 3 5 7 9.
You can also decrement the control variable by replacing to with downto.
Code
FOR count = 10 DOWNTO 1
PRINT count
NEXT count
When executed, the code produces the numbers ten down to one.
Graphic
The output is 10 9 8 7 6 5 4 3 2 1.
Question
You're creating a FOR loop to print labels containing clients' contact details. The variable
numberOfClients will be used to determine how many labels to print.

Identify the pseudocode that will enable the loop to run for the required number of iterations.
Code
GET numberOfClients
FOR printClientInfo = INSERT THE MISSING CODE
GET clientName
GET clientPhoneNumber
GET clientAddress
PRINT clientName
PRINT clientPhoneNumber
1013

PRINT clientAddress
ENDFOR
Options:
1. 1 to numberOfClients
2. GET printClientInfo
3. NEW printClientInfo
Answer
Option 1: Correct. You use 1 to numberOfClients to begin the loop and specify the number of
times that the FOR loop will execute.
Option 2: Incorrect. The correct way to begin a loop is to provide the loop count variable range.
Option 3: Incorrect. The correct way to begin a loop is to provide the loop count variable range.
Correct answer(s):
1. 1 to numberOfClients
3. Nesting FOR loops
A loop can run within another loop. Loops that appear inside other loops are known as nested
loops.
Graphic
The diagram has a Nested loop contained in an Outer loop. The Outer loop code is: FOR X = 1 TO
3 PRINT "Outer loop run #"; X and NEXT X. The Nested loop code is FOR Y = 1 TO 5 PRINT "
Nested loop run #"; Y and NEXT Y.
Every time the outside loop runs through an iteration, the inside loop is processed, running all its
iterations.
For each iteration of the outside loop, the inner loop goes through all its iterations. So nested
loops process more iterations than outer loops.
It can be very difficult to follow the code for a program if you include a large number of nested
loops within one loop. So as a general rule, nest only one loop inside another.
This pseudocode example is designed to generate reports for three students, each with five
different test grades that are stored in the grades array. The program gets a student's name
once and then processes that student's five grades.
1014

Code
FOR X = 1 to 3
GET studentName from the array
PRINT "Student " studentName " grades"
FOR Y = 1 to 5
GET gradeAmount from the array
PRINT "Grade #" Y " for student " studentName " is " gradeAmount
NEXT Y
NEXT X
As defined by the pseudocode, each time the outer loop is run, the inner loop runs five times.
Ultimately, the nested loop will run 15 times, whereas the outer loop will run only three times
once per student.
Code
FOR X = 1 to 3
GET studentName from the array
PRINT "Student " studentName " grades"
FOR Y = 1 to 5
GET gradeAmount from the array
PRINT "Grade #" Y " for student " studentName " is " gradeAmount
NEXT Y
NEXT X
The final output includes students' names and their grades.
Code
Student John Sands grades
Grade #1 for student John Sands is 86
Grade #2 for student John Sands is 62
Grade #3 for student John Sands is 90
Grade #4 for student John Sands is 75
Grade #5 for student John Sands is 78

Student Amy Smith grades
Grade #1 for student Amy Smith is 91
Grade #2 for student Amy Smith is 88
Grade #3 for student Amy Smith is 91
Grade #4 for student Amy Smith is 82
Grade #5 for student Amy Smith is 78

Student Elaine Evans grades
1015

Grade #1 for student Elaine Evans is 77
Grade #2 for student Elaine Evans is 79
Grade #3 for student Elaine Evans is 83
Grade #4 for student Elaine Evans is 70
Grade #5 for student Elaine Evans is 84
Summary
You can use FOR loops to execute statements a set number of times, for a predetermined
number of cycles.

Each time a FOR loop runs, the commands it contains execute and a counter is incremented or
decremented by a set value usually one, although you can change this. Once the value of the
counter reaches a specified limit, the loop terminates.

Loops that appear inside other loops are called nested or inner loops. Each time an outer loop
runs, the inner loop iterates a specified number of times.

















1016

WHILE Loops
Learning Objective
After completing this topic, you should be able to
recognize how to use the WHILE loop in computer programs
1. Using WHILE loops
When you write a computer program, it may be necessary to test a single condition multiple
times. However, it may not always be feasible to add lines of code for every instance because
you may not know in advance how many times the condition will be tested.
For example, you may want to process numbers from a list of unspecified length. Because you
don't know how many numbers there are to be processed, you don't know how many times the
loop should be executed. You can use a WHILE loop to resolve this problem.
The WHILE statement is an entry-condition or loop pre-test. This means that a program won't
execute the statement block within the loop unless the specified condition is met.
In this pseudocode example, the condition is that the number entered in the algorithm must be
less than 3.
Code
NUM = 2
WHILE NUM < 3
PRINT NUM
NUM = NUM + 1
ENDWHILE
If the condition is immediately false, as it is in this example, the loop won't execute at all.
Code
NUM = 7
WHILE NUM < 3
PRINT NUM
NUM = NUM + 1
ENDWHILE
A WHILE loop runs indefinitely unless the loop condition becomes false. In this case, the value
of NUM will never change so the WHILE loop will never stop iterating.
1017

Code
NUM = 1
WHILE NUM < 3
PRINT NUM
ENDWHILE
PRINT "The final number is", NUM
To ensure that this doesn't happen, a WHILE loop should include a statement that changes the
value of the conditional expression. In this example, the value of NUM is incremented by 1, so at
some point in the loop's execution, it should fail the tested condition.
Graphic
The relevant code is:

NUM = NUM + 1
Code
NUM = 1
WHILE NUM < 3
PRINT NUM
NUM = NUM + 1
ENDWHILE
PRINT "The final number is", NUM
To determine whether the loop should be executed again, the loop condition is queried after
each iteration. When the loop condition becomes false, the loop terminates and the program
moves on to the statements following the loop. In this example, the value of NUM will be printed
until its value is greater than 2. After processing two iterations, NUM will equal 3 and the WHILE
loop will terminate.
Graphic
The relevant code is:

PRINT "The final number is", NUM
Code
NUM = 1
WHILE NUM < 3
1018

PRINT NUM
NUM = NUM + 1
ENDWHILE
PRINT "The final number is", NUM
To write an algorithm that uses a WHILE loop to print several labels, you first complete a
defining table for the problem statement.
Graphic
The table has three columns: INPUTS, PROCESSES, and OUTPUTS. In the INPUTS column there
is one row with the value answer.

In the PROCESSES column, there are four rows: PRINT name and address, PRINT " Do you wish
to print another label?", GET answer, and PRINT "Thank you".

In the OUTPUTS column, there are two rows: name and address, and End message.
You then create this pseudocode algorithm to capture the user's details, print a label, and ask
whether another label is required.
Code
answer = "yes"
WHILE answer = "yes"
PRINT name and address
PRINT "Do you wish to print another label?"
GET answer
ENDWHILE
PRINT "Thank you"
The loop condition is answer = "yes". As long as this condition is true, the loop will continue
to execute.
Code
answer = "yes"
WHILE answer = "yes"
PRINT name and address
PRINT "Do you wish to print another label?"
GET answer
ENDWHILE
PRINT "Thank you"
1019

Because the variable answer is set to yes as the loop begins its execution, the loop will execute
at least once.
Graphic
The relevant code is

answer = "yes"
WHILE answer = "yes"
Code
answer = "yes"
WHILE answer = "yes"
PRINT name and address
PRINT "Do you wish to print another label?"
GET answer
ENDWHILE
PRINT "Thank you"
After the first label has been printed, the user will have the option to end the process by entering
a response other than yes, when prompted about printing more labels.
Graphic
The relevant code is

PRINT "Do you wish to print another label?"
GET answer
Code
answer = "yes"
WHILE answer = "yes"
PRINT name and address
PRINT "Do you wish to print another label?"
GET answer
ENDWHILE
PRINT "Thank you"
The user response is then evaluated against the loop condition. If the answer is yes, the loop
will iterate again.

1020

Because the answer is no in this case, the loop won't execute again. Instead the next line of the
program will execute.
Graphic
The relevant pieces of code are

WHILE answer = "yes"
and
PRINT "Thank you"
Code
answer = "yes"
WHILE answer = "yes"
PRINT name and address
PRINT "Do you wish to print another label?"
GET answer
ENDWHILE
PRINT "Thank you"
Question
In this pseudocode example, how many times will this WHILE loop execute?
Code
num = 7
WHILE num < 3
num=num+1
PRINT num
ENDWHILE
PRINT num
Options:
1. Never
2. After a single iteration
3. After seven iterations
4. After three iterations
Answer
Option 1: Correct. The condition is immediately false so the loop won't execute at all. Because the
WHILE loop is an entry condition loop, a condition must be met or the loop won't execute.
1021

Option 2: Incorrect. The loop won't execute at all as the condition will be immediately false.
Option 3: Incorrect. The loop won't execute at all because the initial tested condition will evaluate to
false.
Option 4: Incorrect. The loop will never be executed because the initial tested condition is false.
Correct answer(s):
1. Never
Depending on the programming language you're using, the syntax of the WHILE loop may be
slightly different.
In this example, BASIC has been used to create a program to print labels. The loop ensures that
labels will continue to print until the user enters 'N' or anything other than 'Y'.
Graphic
The relevant code is:

WHILE answer$ = 'Y'
Code
answer$ = "Y"
WHILE answer$ = "Y"
PRINT name$
PRINT address$
PRINT "Do you want to print another? Y/N"
INPUT answer$
WEND
In this example, the program to print labels is written in Pascal. Unlike in the BASIC example,
the WHILE statement includes a condition followed by the keyword DO.

Also, the statements that make up the loop are placed between BEGIN and END tags.
Code
while answer = "Y" do
begin
writeln (name);
writeln (address);
writeln ("Do you want to print another ? Y/N");
1022

read (answer)
end;
This is the same program written in C. In the tested condition, the relational operator "==" means
equal to.
Graphic
The relevant code is:

(answer == 'Y')
Code
while (answer == 'Y')
{
printf ("%s\n" , name);
printf ("%s\n" , address);
printf ('Do you want to print another? Y/N');
scanf ("%s\n" , answer);
}
The statement is followed by the looped print and scanf statements, which are placed
between opening and closing curly braces.
Code
while (answer == 'Y')
{
printf ("%s\n" , name);
printf ("%s\n" , address);
printf ('Do you want to print another? Y/N');
scanf ("%s\n" , answer);
}
You can nest WHILE loops in the same way that you nest FOR loops.
Graphic
The algorithm starts and tests choice 1. If it is false then the loop ends. If it is true, then a second
loop condition (choice 2) is tested. If choice 2 is false he loop ends. If it is true, the code will execute
and the condition will be tested again. When the second loop condition is false, it will test choice 1
again.
1023

However, it's generally best to avoid doing this because it increases the risk that you'll include a
WHILE loop that will continue executing indefinitely and so cause a program to hang or crash.
It also isn't a good idea to nest too many loops because this can make the structure of a
program very complex.
You can also nest WHILE loops inside FOR loops, or nest FOR loops inside of WHILE loops.

This is an example of a BASIC program that uses a WHILE loop nested inside a FOR loop. It's a
counting program designed to output five grades for each of three students in a database.
Code
FOR X = 1 to 3
'write code to get the studentName from the array
PRINT "Student "; studentName " grades"
Y = 1
WHILE Y <= 5
'write code to get the gradeAmount from the array
PRINT "Grade #"; Y " for student " studentName " is "
gradeAmount
Y = Y + 1
WEND
NEXT X
In this program, the FOR loop specifies that the data will be retrieved for three students.
Graphic
The relevant pieces of code are

FOR X = 1 to 3
and
NEXT X
Code
FOR X = 1 to 3
'write code to get the studentName from the array
PRINT "Student "; studentName " grades"
Y = 1
WHILE Y <= 5
'write code to get the gradeAmount from the array
PRINT "Grade #"; Y " for student " studentName " is "
gradeAmount
1024

Y = Y + 1
WEND
NEXT X
When the program begins its execution, the first student's name is retrieved from the array. The
name will also appear on screen.
Graphic
The relevant code is:

'write code to get the studentName from the array
PRINT "Student " studentName " grades"
Code
FOR X = 1 to 3
'write code to get the studentName from the array
PRINT "Student "; studentName " grades"
Y = 1
WHILE Y <= 5
'write code to get the gradeAmount from the array
PRINT "Grade #"; Y " for student " studentName " is "
gradeAmount
Y = Y + 1
WEND
NEXT X
Because the WHILE loop doesn't count in the same way as a FOR loop, the variable Y has to be
set to 1 before the WHILE loop starts its execution for each increment of the FOR loop. The value
of Y is also manually incremented inside of the WHILE loop.
Graphic
The relevant pieces of code are:

Y = 1
and
Y = Y + 1
Code
FOR X = 1 to 3
'write code to get the studentName from the array
1025

PRINT "Student "; studentName " grades"
Y = 1
WHILE Y <= 5
'write code to get the gradeAmount from the array
PRINT "Grade #"; Y " for student " studentName " is "
gradeAmount
Y = Y + 1
WEND
NEXT X
The WHILE loop will read and store values for the student grades until the value of Y equals 6.
Even though only five grades are being entered, the value of Y has to be 6 before the loop can
break.
Graphic
The relevant code is:

WHILE Y <= 5
'write code to get the gradeAmount from the array
PRINT "Grade #"; Y " for student " studentName " is " gradeAmount
Y = Y + 1
Code
FOR X = 1 to 3
'write code to get the studentName from the array
PRINT "Student "; studentName " grades"
Y = 1
WHILE Y <= 5
'write code to get the gradeAmount from the array
PRINT "Grade #"; Y " for student " studentName " is "
gradeAmount
Y = Y + 1
WEND
NEXT X
When this happens the WHILE loop will break and return control to the loop, executing the FOR
loop again until the value of X equals 3 or end the program as soon as X is equal to 3.
Graphic
The relevant code is:

1026

FOR X = 1 to 3
Here is the code again
Code
FOR X = 1 to 3
'write code to get the studentName from the array
PRINT "Student "; studentName " grades"
Y = 1
WHILE Y <= 5
'write code to get the gradeAmount from the array
PRINT "Grade #"; Y " for student " studentName " is "
gradeAmount
Y = Y + 1
WEND
NEXT X
When the program runs, this is an example of the expected output. There are three students
listed, with five grades listed for each student.
Code
FOR X = 1 to 3
'write code to get the studentName from the array
PRINT "Student "; studentName " grades"
Y = 1
WHILE Y <= 5
'write code to get the gradeAmount from the array
PRINT "Grade #"; Y " for student " studentName " is "
gradeAmount
Y = Y + 1
WEND
NEXT X
Question
When will this WHILE loop stop executing?
Code
answer$='Y'
WHILE answer$ ='Y'
PRINT name$
PRINT address$
PRINT "Would you like to print another ticket? Y/N"
1027

INPUT answer$
WEND
Options:
1. When a user enters the value N
2. When a user enters the value Y
3. After it has completed a specified number of iterations
4. It will never stop
5. It will never execute
6. Having any input except Y for answer
Answer
Option 1: Correct. Once the input stored in the answer variable is N, the loop condition will be false
and the loop will terminate. The next instruction after the loop will be processed.
Option 2: Incorrect. If the input for answer is Y, the WHILE loop will continue executing because the
loop condition will still be true.
Option 3: Incorrect. There is no value specified for the number of iterations of the loop. It will
continue executing until its tested condition evaluates as false.
Option 4: Incorrect. The loop isn't infinite because it has a condition that can be evaluated to false.
Option 5: Incorrect. The loop has an initial tested condition that evaluates to true. This ensures that
the loop will execute at least once.
Option 6: Correct. The loop will terminate if the value input is any value other than Y. N is used as
the preferred value to indicate the response is No.
Correct answer(s):
1. When a user enters the value N
6. Having any input except Y for answer
Summary
In a program, you may need to test a condition a number of times that will be specified only
when the program runs. You can use a WHILE loop to do this. The WHILE loop will iterate as
long as its test condition evaluates to true. Once the condition is false, the loop terminates.
WHILE loop syntax is similar in Pascal, BASIC, and C.

1028

Solving a Repetition Problem
Learning Objectives
After completing this topic, you should be able to
recognize where to use the WHILE loop
analyze the use of a WHILE loop in PASCAL code in given examples
1. When to use WHILE loops
You can use a WHILE loop to repeat a process as many times as necessary, without having to
write long, time-consuming code.

For example, you might be collecting cash donations for a charity and want to print a receipt
every time a donation is received. You may also need to calculate the number of donations, the
average donation, and the total donations. You can use a WHILE loop to repeat required
processes for each donation you receive.
There are four steps you need to follow to create your program:
1. analyze the problem statement
2. create a defining table
3. create an algorithm in pseudocode, and
4. convert the pseudocode into an appropriate programming language
Once you've analyzed the problem statement, you can break it down into a defining table that
identifies the relevant inputs, processes, and outputs.
Graphic
The table has three columns: INPUTS, PROCESSES, and OUTPUTS. In the INPUTS column there
is one row with the value donation_amount.

In the PROCESSES column, there are four rows: GET donation_amount, CALCULATE
no_of_donations, CALCULATE total_donations, and CALCULATE average_donations.

In the OUTPUTS column, there are four rows: receipt, no_of_donations, total_donations, and
average_donations.
Inputs and outputs in the problem statement are usually indicated by nouns, while process tasks
are usually indicated by verbs.
1029

Graphic
There is a table with three columns labeled Input, Process, and Output.
Input
The amount of the donation received goes in the Input column. This is the basic data that will be
processed to get results, or output.
The Input column contains donation_amount
Process
The Process column contains the calculations that need to be done in order to get an output
result. These include the calculations for the total donations and the number of donations, as well
as the statement to get the source donation amounts.
The Process column contains GET donation_amount, CALCULATE average_donation,
CALCULATE total_donations, and CALCULATE no_of_donations.
Output
The Output column contains the outputs from the calculations in the Process column, which
include the results for the total number of donations and the average donation. It also contains
the statement to issue a receipt after the amount of the donation is processed.
The Output column contains statements for receipt, no_of_donations, total_donation, and
average donation.
You can use the defining table as the basis for writing a pseudocode algorithm, which can then
be coded.
You're first prompted by the algorithm to enter the amount for the first donation. It then prints a
receipt for that amount.
Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
The number of donations counter is initialized to one, and the total donations amount is set to
equal the value of the first donation.
Graphic
The relevant code is

no_of_donations=1
1030

Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
The algorithm then asks if there are further donations to be entered. If the answer is YES, the
first iteration of the WHILE loop is processed.
Graphic
The relevant code is

WHILE other_donations=YES
Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
GET other_donations
WHILE other_donations=YES
The compound statement for the WHILE loop performs four steps:
Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
GET other_donations
WHILE other_donations=YES
GET donation_amount
PRINT receipt
total_donations=total_donations+donation_amount
no_of_donations=no_of_donations+1
PRINT 'Are there any more donations to accept?'
1031

GET other donations
ENDWHILE
it gets the amount for each donation
The relevant code is

GET donation_amount.

Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
GET other_donations
WHILE other_donations=YES
GET donation_amount
PRINT receipt
total_donations=total_donations+donation_amount
no_of_donations=no_of_donations+1
PRINT 'Are there any more donations to accept?'
GET other donations
ENDWHILE

it prints a receipt
The relevant code is

PRINT receipt

Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
GET other_donations
WHILE other_donations=YES
GET donation_amount
PRINT receipt
total_donations=total_donations+donation_amount
no_of_donations=no_of_donations+1
PRINT 'Are there any more donations to accept?'
GET other donations
ENDWHILE

1032

it adds each donation received to the donations total, and
The relevant code is
total_donations=total_donations+donation_amount

Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
GET other_donations
WHILE other_donations=YES
GET donation_amount
PRINT receipt
total_donations=total_donations+donation_amount
no_of_donations=no_of_donations+1
PRINT 'Are there any more donations to accept?'
GET other donations
ENDWHILE

it increases the total number of donations by one
The relevant code is

no_of_donations=no_of_donations+1

Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
GET other_donations
WHILE other_donations=YES
GET donation_amount
PRINT receipt
total_donations=total_donations+donation_amount
no_of_donations=no_of_donations+1
PRINT 'Are there any more donations to accept?'
GET other donations
ENDWHILE

The WHILE loop then asks if there are any more donations to accept. If the answer is YES, it
continues to execute. The WHILE loop terminates if the user types anything other than YES.
1033

Graphic
The relevant code is

PRINT 'Are there any more donations to accept?'
Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
GET other_donations
WHILE other_donations=YES
GET donation_amount
PRINT receipt
total_donations=total_donations+donation_amount
no_of_donations=no_of_donations+1
PRINT 'Are there any more donations to accept?'
GET other donations
ENDWHILE
When the WHILE loop terminates, the total donations are divided by the number of donations to
calculate the average donation.
Graphic
The relevant code is
average_donation=total_donation/no_of_donations
Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
GET other_donations
WHILE other_donations=YES
GET donation_amount
PRINT receipt
total_donations=total_donations+donation_amount
no_of_donations=no_of_donations+1
1034

PRINT 'Are there any more donations to accept?'
GET other donations
ENDWHILE
average_donation=total_donation/no_of_donations
PRINT no_of_donations
PRINT 'the total amount donated is'
PRINT total_donation
PRINT 'the average amount donated is'
PRINT average donation
The algorithm then displays the number of donations, the average donation, and the total
amount donated.
Graphic
The relevant code is

PRINT no_of_donations
PRINT 'the total amount donated is'
PRINT total_donation
PRINT 'the average amount donated is'
PRINT average donation
Code
PRINT Enter the donation
GET donation_amount
PRINT receipt
no_of_donations=1
total_donations=donation_amount
GET other_donations
WHILE other_donations=YES
GET donation_amount
PRINT receipt
total_donations=total_donations+donation_amount
no_of_donations=no_of_donations+1
PRINT 'Are there any more donations to accept?'
GET other donations
ENDWHILE
average_donation=total_donation/no_of_donations
PRINT no_of_donations
PRINT 'the total amount donated is'
PRINT total_donation
PRINT 'the average amount donated is'
PRINT average donation
1035

Question
You've created an algorithm to count the number of logs placed on a logging truck. Once the truck is
full of logs, it can leave and an empty truck can take its place.

Which type of loop is it most appropriate to use in your program?
Options:
1. WHILE
2. FOR
3. IF
4. CASE
Answer
Option 1: Correct. A WHILE loop allows processing to continue as long as a tested condition is true,
once the condition is false, the loop will end. In this instance as long as the truck can be loaded, the
loop will execute.
Option 2: Incorrect. When you use a FOR loop, you generally need to know how many times you
want the loop to execute. In this instance, the number of logs that can go on a truck is unknown, so
a FOR loop is unsuitable.
Option 3: Incorrect. IF is a statement, not a loop. It's most often used as a selection statement in
programming.
Option 4: Incorrect. CASE is a statement, not a loop. It commonly replaces nested IF statements.
Correct answer(s):
1. WHILE
Question
Sequence the lines in the pseudocode algorithm.
Options:
A. GET numLogsOnTruck
B. WHILE numLogsOnTruck < 50
C. PUT another log on the truck
numLogsOnTruck = numLogsOnTruck + 1
D. ENDWHILE
1036

E. DO THIS
Send truck on its way
Receive an empty truck
Answer
Correct answer(s):
GET numLogsOnTruck is ranked the first step.
You first have to determine the input you need to base your calculations on. This is the first line
of the algorithm
WHILE numLogsOnTruck < 50 is ranked the second step.
You set the initial condition to be executed to begin running the loop. This is the second line of
the algorithm
PUT another log on the truck
numLogsOnTruck = numLogsOnTruck + 1 is ranked the third step.
The counter is set to increment the number of logs on the truck once for each iteration. These
are the third and fourth lines of the algorithm.
ENDWHILE is ranked the fourth step.
You close the WHILE loop. This is the fifth line of the algorithm.
DO THIS
Send truck on its way
Receive an empty truck is ranked the fifth step.
Once the conditions in the loop are met to indicate the truck is full, it can leave and be replaced
by an empty truck. This is the sixth and final line of the algorithm.
2. Using a WHILE loop in Pascal
Once you've written the algorithm for collecting donations in pseudocode, you can code the
algorithm for example, in Pascal. The program starts by performing six actions:
Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);
1037

prompting the user to enter the first donation
The relevant code is

writeln ('Enter the first donation');

Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);

reading the donation amount
The relevant code is

read (donation_amount);

Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);

printing a receipt
The relevant code is

print ('Thank you for your donation of', donation_amount);

Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);

initializing the number of donations to one
The relevant code is
1038


no_of_donations := 1;

Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);

assigning the initial donation amount to total donations, and
The relevant code is

total_donations := donation_amount;

Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);

asking for and accepting input for more donations
The relevant code is

writeln ('Are there any more donations to accept? Y/N');
read (other_donations);

Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);

The entry condition of the WHILE loop is decided by the value of the other_donations
variable.
1039

Graphic
The relevant code is

read (other_donations);
Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);
Adding do to the while loop requires the loop to run once and check if the conditions are met to
return a value of 'Y'.
Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);
while other_donations = 'Y' do
If a 'Y' value is returned, the while loop will run and will continue to execute for as many times
as the 'Y' value is returned.
Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);
while other_donations = 'Y' do
1040

begin and end tags are used to contain the statements within the loop.
Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);
while other_donations = 'Y' do
begin
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := no_of_donations + 1;
total_donation := total_donation + donation_amount;
writeln ('Are there any more donations to accept? Y/N') ;
read (other_donations)
end;
average_donation := total_donation/no_of_donations;
So that the loop doesn't run indefinitely, the entry condition other_donations has a new
value read at the end of the loop. The loop terminates when the other_donations variable no
longer contains the value 'Y'.
Graphic
The relevant code is

Y/N
Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);
while other_donations = 'Y' do
begin
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
1041

no_of_donations := no_of_donations + 1;
total_donation := total_donation + donation_amount;
writeln ('Are there any more donations to accept? Y/N') ;
read (other_donations)
end;
average_donation := total_donation/no_of_donations;
The average donation is calculated once the loop has terminated.
Graphic
The relevant code is

average_donation := total_donation/no_of_donations;
Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);
while other_donations = 'Y' do
begin
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := no_of_donations + 1;
total_donation := total_donation + donation_amount;
writeln ('Are there any more donations to accept? Y/N') ;
read (other_donations)
end;
average_donation := total_donation/no_of_donations;
Finally the program displays output, including the number of donations, total amount of the
donations, and average donation amount.
Graphic
The relevant code is

writeln ('The number of donations is ', no_of_donations);
writeln ('The total amount donate is ', total_donation);
writeln ('The average amount donated is ', average_donation);
1042

Code
writeln ('Enter the first donation');
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := 1;
total_donations := donation_amount;
writeln ('Are there any more donations to accept? Y/N');
read (other_donations);
while other_donations = 'Y' do
begin
read (donation_amount);
print ('Thank you for your donation of', donation_amount);
no_of_donations := no_of_donations + 1;
total_donation := total_donation + donation_amount;
writeln ('Are there any more donations to accept? Y/N') ;
read (other_donations)
end;
average_donation := total_donation/no_of_donations;
writeln ('The number of donations is ', no_of_donations);
writeln ('The total amount donate is ', total_donation);
writeln ('The average amount donated is ', average_donation);
Question
What is the error in this example of Pascal code?
Code
program loop;
var i, limit : integer;

begin
writeln ('Please enter a limit.');
readln (limit);
while i <= limit
begin do
write(i, ' ');
i := i + 1
end;
end
Options:
1. The keyword do is in the wrong place
2. The begin and end tags around the while loop's statements are optional
3. The writeln statement should come after the while loop
1043

Answer
Option 1: Correct. The keyword do should be on the while line, not the begin line.
Option 2: Incorrect. Statements in the while loop require a begin and end tag.
Option 3: Incorrect. The while loop comes after the writeln statement as a value needs to be
entered before the loop can execute.
Correct answer(s):
1. The keyword do is in the wrong place
Summary
A while loop is useful for repeating processes a required number of times. The loop can be
designed to execute as long as there is information to process. It will stop executing once an
entry condition statement returns a false value when queried at the beginning of an iteration.

In Pascal, you use begin and end tags to enclose the statements in a while loop.















1044

Using Loops
Learning Objectives
After completing this topic, you should be able to
create a defining table to determine inputs, processes, and outputs
structure an algorithm containing a FOR loop
complete a WHILE loop in an algorithm
Exercise overview
In this exercise, you're required to use loops in a program.
This involves the following tasks:
creating a defining table to determine inputs, processes, and outputs
structuring an algorithm containing a FOR loop, and
completing a WHILE loop in an algorithm
Creating defining tables
You are starting to create a program that accepts donation amounts as input and then generates
output such as total donations and average amount donated. You can use a defining table to
assist you in your planning.
Question
Match each defining table heading with the element contained in its column.
Options:
A. Input
B. Process
C. Output
Targets:
1. Amount of each donation
2. Calculate the total donations
3. Total donations
Answer
1045

The value amount of each donation should go into the Input column.
The calculation to determine the total donations should go into the Process column.
The final value for the total donations should go into the Output column.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Question
Which process task would be carried out first?
Options:
1. Get the donation amount
2. Calculate the average donation
3. Calculate the total amount donated
4. Calculate the number of donations
Answer
Option 1: Correct. The statement processed first should be the GET pseudocode statement.
Option 2: Incorrect. You can only calculate the average donation once you have totaled the
donation amounts and determined the number of donations.
Option 3: Incorrect. The statement processed first should be the GET statement because it retrieves
the data for calculations. You can only calculate the total once you have had all the donation
amounts input.
Option 4: Incorrect. You can only calculate the number of donations after the donation amounts
data has been processed.
Correct answer(s):
1. Get the donation amount
1046

Structuring a FOR loop
A FOR loop removes the need to repeat code because it allows you to run a task a
predetermined number of times.
Code
GET value
FOR i = 1 TO value
Process
ENDFOR
Question
Identify correct statements about the operations in a FOR loop.
Options:
1. The counter is initialized before code in the FOR loop is executed
2. After an iteration, the value of the counter is tested against the loop limit
3. When it's initialized, the amount being incremented or decremented always has a starting value of zero
4. The loop terminates before the counter exceeds a set limit
Answer
Option 1: Correct. The counter in the loop is initialized before code in the FOR loop is executed.
Option 2: Correct. After each iteration, the counter is compared to the set limit value. The loop will
continue to repeat as long as the counter remains within the range set by the loop limit.
Option 3: Incorrect. The amount being incremented or decremented has a default starting value of
one, which is then incremented or decremented as the loop executes.
Option 4: Incorrect. The loop stops executing only when the counter exceeds the range set by the
limit.
Correct answer(s):
1. The counter is initialized before code in the FOR loop is executed
2. After an iteration, the value of the counter is tested against the loop limit
1047

Using WHILE loops
You are writing an algorithm that converts weights from pounds to kilograms. Because you want
the algorithm to run as long as there is a valid input for the weight in pounds, you use a WHILE
loop.
Code
value = Y
WHILE
value = Y
Process
ENDWHILE
Question
You have completed most of the code for a pseudocode algorithm. You're not sure how many
iterations are required, so you need to include a conditional statement.

Which conditional statement should you use in the WHILE loop?
Code
more_weights="Y"
WHILE INSERT THE MISSING CODE
GET pounds
PRINT pounds
kilograms=pounds*0.4536
PRINT 'The weight in kilograms is'
PRINT kilograms
GET 'more_weights? Y/N'
ENDWHILE
Options:
1. more_weights = "Y"
2. pounds > 20
3. more_weights = 0
Answer
Option 1: Correct. The more_weights variable is assigned an initial value of "Y" before the loop.
This ensures that the loop executes at least once.
1048

Option 2: Incorrect. This option requires the input weight to be greater than 20 pounds. However,
there shouldn't be any restriction on the weights that can be converted.
Option 3: Incorrect. If you use this conditional expression, the loop would never run because the
more_weights variable will never be 0. The loop has an initial value of "Y" and with every loop the
user enters either "Y" to continue the loop or "N" to terminate it.
Correct answer(s):
1. more_weights = "Y"
Question
In your algorithm, the code inside the WHILE loop ends with a prompt asking whether there are
more weights.

What happens if the highlighted statement is omitted?
The highlighted statement is GET 'more_weights =?Y/N'
Code
more_weights="Y"
WHILE more weights = "Y"
GET weights
PRINT weight_in_pounds
Kilograms=pounds*0.4536
PRINT 'The weight in kilograms is'
PRINT kilograms
INPUT 'more_weights Y/N?' more_weights
ENDWHILE
Options:
1. The loop runs indefinitely
2. The loop ends after one iteration
3. The loop can't not function, failing to start
Answer
Option 1: Correct. Without the closing statement which asks whether there are more weights
the condition variable more_weights will never be updated. Consequently, it will always have a
value of "Y" and the loop will continue iterating indefinitely.
Option 2: Incorrect. The while condition is evaluated before each iteration. It completes one
iteration because the more_weights variable is assigned an initial value of "Y". The loop would
1049

only end after one iteration if the more_weights variable was set to something other than "Y"
during the first iteration.
Option 3: Incorrect. The more_weights variable is assigned an initial value of "Y" outside the
loop. Consequently, the while condition is true when it's initially evaluated and the loop will
execute.
Correct answer(s):
1. The loop runs indefinitely
A defining table has been created, a FOR loop algorithm has been written, and WHILE loops
have been used in a program.
Code
value = Y
WHILE
value = Y
Process
ENDWHILE















1050

The history of computers
Learning objective
After completing this topic, you should be able to discuss the history of computers and describe
the different types of computers
1. The evolution of computers
Many people attempted to build mechanical computers before electricity was discovered.
500 BC
1625 AD
1642
1822
1935
500 BC
The abacus is considered the oldest calculating machine. It was invented in Asia Minor about
5000 BC to allow users to add and subtract large numbers using a system of sliding beads
arranged on a rack.
1625 AD
The slide rule was developed in England around 1625. This mechanical calculator used physical
distances to multiply and subtract numbers.
1642
In 1642, Blaise Pascal invented the first working machine that could add numbers. This brass
rectangular box, called a Pascaline, contained eight movable dials that could add figures up to 8-
digits in length. Unfortunately, the Pascaline was limited to addition.
1822
In 1822, Charles Babbage designed a steam-powered machine that could automatically compute
mathematical tables and functions. However, Babbage's Difference engine was never built.
1935
George Boole created Boolean algebra in 1847 with his mathematical analysis of logic. The first
working binary machine was built in 1935 and represented the concepts of true and false using
only the 1s and 0s in Boolean algebra.
The first electric computers were created during the 1920s and 1930s. This heralded the age of
electronic computing.
The electronic computer has evolved in generations, with a technical or material breakthrough
usually acting as a catalyst to start a new generation.
1051

The electronic computer has evolved in generations, with a technical or material breakthrough
usually acting as a catalyst to start a new generation.

The first generation of electronic computers began in 1945 and lasted until approximately 1956.
The Electronic Numeric Integrator and Calculator (ENIAC) was built in 1945. It was created at
the University of Pennsylvania's Moore School of Electrical Engineering to compute ballistic
charts during World War II.
The main problems with first-generation computers were their
size
price
power consumption
unreliability
size
First-generation computers were extremely large. The ENIAC weighed 30 tons and had to be
housed in a special building. It contained 18,000 vacuum tubes, 70,000 resistors, and 5,000,000
soldered joints.
price
First-generation computers, such as the ENIAC, were extremely expensive.
power consumption
First-generation computers used vast amounts of electricity. When it was running, the ENIAC
consumed around 200 kilowatts of electrical power per hour and caused brownouts in
Philadelphia when it was switched on.
unreliability
First-generation computers were unreliable. On average, the ENIAC failed every seven and a half
minutes.
In 1946, John von Neumann pioneered computer programming. The main threads of his theory
of programming were that
data and instructions were stored in a read-write memory
memory was addressable by location
programs were executed sequentially by themselves
The second generation of computers began in 1958 with the development of transistors by
AT&T Bell Telephone Laboratories.
Transistors were faster, more reliable, and needed less power than the vacuum tubes used in
first-generation computers.
1052

Second-generation computers were cheaper than their predecessors. More businesses and
universities could afford to have computers.
As computers' availability increased, so did their rate of development. With many more people
working on computers, the second generation saw the development of the first computer
programming languages.
The invention of integrated circuits brought the second computer generation to an end in the
mid-1960s.
Integrated circuits grouped all the essential elements of a computer into one unit. They saved
space and eliminated the need to connect components with wires, making these computers
more reliable than their predecessors.
Computer memory became very compact, so more data could be stored in less space than
before.
The fourth generation of electronic computers started in 1974.
Around this time, the first microcomputers became available on the market. Microcomputers
later became known as personal computers or PCs.
Question
Computers today are very different to first-generation computers.
Which statements are true of computers as they evolve?
Options:
1. They become more robust
2. They become more powerful
3. They become more expensive
4. They become more proprietary
Answer
Computers are continually becoming more powerful and more robust. More households can afford
them as they become less expensive. In contrast to early computers, which could run only custom-
designed software, modern computers are more open and can use hardware and software from
many different vendors.
Option 1 is correct. As integrated circuits become smaller and more lightweight thanks to
nanotechnology they become increasingly easy to maintain and replace. This results in more
power, reduced overhead, and a greater robustness, due to fewer mechanical failures.
1053

Option 2 is correct. Moore's law states that computer processing power effectively doubles every
eighteen months. This is due to increased rate of development and advances in material design and
infrastructure.
Option 3 is incorrect. On the contrary, computers become smaller, cheaper, and more powerful at
the advent of each new generation. As components become streamlined in a factory production
environment, manufacturing costs decrease accordingly. This saving is passed on to the end
consumer.
Option 4 is incorrect. Early computers were proprietary, with companies developing their own
hardware and software standards. As hardware components become standardized and the OMG
(Object Model Group) promotes open software standards, computer systems become less
proprietary.
The price of PCs, which are thousands of times more powerful than the ENIAC, is decreasing all
the time.
Technological advancement, such as the development of integrated circuits and semiconductor
memory, is the main reason for the inverted power-to-cost relationship in computers.
Computers have now reached their fifth generation. Advances in computer design and
technology, such as the development of superconductors, have made this latest step forward
possible.
The fifth-generation computers will continue to get smaller and will display some artificial
intelligence. For example, a computer in the future may be able to make medical diagnoses
when given a patient's symptoms.
2. Basic computer features and functions
To compute means to process data into information.
Information has meaning whereas data does not.

For example, the figure 20,000 has no meaning when it resides as raw data inside the
computer. But, when a program reads the data and tells you the value in dollars of your
overdraft, it becomes information.
When the ENIAC was switched off in 1954, it was supposed to have done more arithmetic in
nine years than the entire human race had done before 1945.
Computers perform tasks such as calculations, comparisons, and searches faster and more
efficiently than humans.
And they do not get fatigued or bored with repetitive tasks they can repeat the same task in
exactly the same manner.
1054

The mathematician Alan Turing devised a test in which a person types questions on a terminal.
The person does not know whether the responses to their questions come from a computer or
another human being.
If a computer is answering, and its answers are indistinguishable from a human's, the computer
passes the Turing test. Computers that pass this test can be regarded as exhibiting artificial
intelligence or being sentient like humans.
No computer has yet managed to pass the Turing test because humans are better than
computers at performing unpredictable tasks such as answering questions they haven't
previously seen.
Computer systems consist of both hardware and software.
Question
Hardware refers to the physical components of the system, whereas software refers to the intangible
parts of a computer system.
See if you can match each of these options to their correct category.
Options:
1. Keyboard
2. Hard drive
3. Operating system
4. Programs
Targets:
A. Software
B. Hardware
Answer
The software components of a computer system are operating systems and programs, while the
hardware components of a computer system are the keyboard and hard drive.
Without software, hardware is useless.
Programs are basically lists of instructions for a computer to carry out.
They are detailed and exact because, unlike humans, computers cannot work out anything for
themselves.
Apart from specially written applications, the most common software packages used today are
1055

word processors
spreadsheets
database managers
word processors
Word-processing programs, such as Microsoft Word, have replaced typewriters in producing text-
based documents.

They can contain various letter fonts, colors, and graphics, so you can produce professional
looking documents very easily with them.
spreadsheets
Spreadsheets are mostly used to analyze numerical data. They resemble tables that comprise
many cells with every cell holding some data or function.

Spreadsheets are more suited to numerical data than to text, but you can sort small amounts of
textual data in a spreadsheet.
database managers
You can use database managers to create new database structures and process data already
present in databases. Users can view their data in different ways with a database manager.

For example, database managers can easily produce two reports of customer information from
the same data. One may be sorted according to customers' names, whereas the other is sorted
according to customers' addresses.
Software packages are becoming more and more integrated, and the boundaries between their
functions are becoming blurred.
Spreadsheets can be used to perform database functions, and word processors can be used to
do calculations.
Databases, spreadsheets, and word processors are popular because they are very easy to use,
and you do not need programming skills to use them.
However, most incorporate a programming language in case more advanced users want to
automate some tasks.
Often no off-the-shelf program does exactly what a user wants it to do.

So many computer programmers are needed to enable software companies to create custom-
designed programs for their clients. Computer programmers are also required to produce off-
the-shelf applications.
1056

3. Computer types
There are five main types of computers:
supercomputers
mainframes
personal computers
servers
portables
Supercomputers are typically thousands of times faster than the fastest personal computers.
Supercooled liquids run through the circuits of super computers, so the electrical resistance in
their circuitry becomes very low, enabling their components to operate at high speeds.
Supercomputers operate specialized programs, such as weather prediction, fluid-dynamics
modeling, animated graphics, nuclear energy research, and petroleum exploration.
The main concern of supercomputers is fast program execution, not the number of programs
running concurrently.
Supercomputers are unexpectedly small they are smaller than mainframe computers.
The dominant corporation in the supercomputer field is the Cray Research Company.
Mainframe computers support many users, who can run many programs simultaneously.
Mainframes accept input from terminals, personal computers, and other mainframe computers.
Note
A terminal is normally a screen with a keyboard. It does not have any processing power and is
sometimes called a dumb terminal.
Mainframes are usually housed in special rooms where only cooled and dust-filtered air is
allowed to circulate.
Banks, governments, large corporations, and universities are the main users of mainframes
because they need to give thousands of users simultaneous access to the same information.
Personal computers (PCs) are small and inexpensive. They generally have only one processor.
They were first known as microcomputers because they were complete computers built on a
smaller scale than the huge systems being used by most businesses.
1057

Many application software packages such as word processors, spreadsheets, and games
run specifically on PCs.
A desktop computer, also known as a workstation, fits comfortably on a desk and is the most
popular from of PC.
It consists of a computer case that houses the processor and disk drives, a display screen, and
a keyboard. PCs can communicate with peripheral equipment, such as printers, scanners, and
modems.
Most businesses now connect personal computers together to form a network.
Local area networks (LANs) and wide area networks (WANs) effectively distribute processing
power across all the PCs on the network.
Network servers, which are similar to PCs but much more powerful, manage the network
security, shared files, and shared printers.
A server is a computer that is optimized to provide services to other computers over a network.
Servers generally have powerful processors, a lot of memory, and large hard drives.
Computers are becoming smaller and more portable.
Laptops
Personal digital assistants (PDAs)
Wearable computers
Laptops
Laptop computers are also called notebooks. They are more expensive than desktop computers
because of the technology needed to fit the same processing power and storage space into a
small unit. The advantage of a laptop over a desktop computer is that it is completely portable.
Mains power or batteries can drive a laptop, but the batteries have to be recharged every few
hours.
Personal digital assistants (PDAs)
A PDA fits into your hand, and so it is also known as a hand-held computer. It usually acts a
personal organizer, but some models can download e-mails, play music, or do word processing.
PDAs can communicate with other devices, such as disk drives and modems, to increase their
functionality. Some PDA models take input from a special pen rather than a keyboard.
Wearable computers
Wearable computers have recently been developed. In these computers, common applications,
such as e-mail and name and address databases, are integrated into watches, mobile phones,
visors, and even clothing.
1058

Summary
Many mechanical computing devices have been created throughout history, but the first
generation of electronic computers began only in 1945. Computers have evolved, and we now
use fifth-generation machines that are much more powerful and affordable than their
predecessors.

Computers can perform repetitive tasks more quickly and accurately than humans. They are
often used to manage databases and spreadsheets and for word processing.

Supercomputers, mainframes, PCs, servers, and portables are the main types of computers
available today.




















1059

Programming princples
Learning objective
After completing this topic, you should be able to discuss the basic principles of programming.
1. Classical programming
Because computers cannot think, they need instructions to tell them what to do.
A program contains a set of instructions that a computer can use to perform a task.
Computers understand only a language of 1s and 0s. This language is called machine
language, machine code, or binary code.

A typical machine language instruction is 0000010000010111.
Computers use millions of solid-state electronic switches that represent 0 when they are off and
1 when they are on.
Punch cards work on the same principle, with a hole representing 1 and the absence of a hole
representing 0.
The on and off states of a switch enable computers to use Boolean algebra, which was invented
by the mathematician George Boole.
Binary systems operate according to the rules of Boolean logic. These rules are used to perform
calculations on data.
Humans find it difficult to understand machine language, so assembly language was invented in
the 1950s.
Assembly language involves the translation of the number combinations in machine language
into instructions written with letters.
This is the assembly language instruction to add the value of variable "B" to variable "A."
Add A, B
Each of the different computer types has a different assembly language.
The same range of commands is available in assembly languages and in machine languages.
A special program, called an assembler, translates the assembly-language program into
machine language so that the computer can understand it and execute the instructions.
1060

Both assembly and machine languages are low-level languages, and they are processor
dependent.
Note
A processor, also known as a central processing unit (CPU), performs logical and arithmetic
operations. It also controls memory and the execution of instructions.
Because every processor type has its own architecture, an assembly-language program written
for one processor will not run on a different processor type.
High-level programming languages include
FORTRAN
Pascal
COBOL
BASIC
C
FORTRAN
FORTRAN is an acronym of FORmula TRANslation. It is used for mathematical and scientific
applications. It was the first high-level programming language and was published by IBM in 1950.
Pascal
Pascal was created around 1970 and is named after the mathematician Blaise Pascal. It was
designed for simplicity and intended as a teaching language.

Pascal has been influential in programming language design.
COBOL
COBOL is an acronym for Common Business Oriented Language. It was created in 1960, and it
can process simple computations of large amounts of data.

Programs written in COBOL tend to be longer than those written in other languages, but this
wordiness makes COBOL easier to follow.

COBOL was a popular language for business applications that ran on large computers, although
it is not as widely used today as it was in previous decades.
BASIC
BASIC stands for Beginner's All-purpose Symbolic Instruction Code. It was first run in 1964 and
is, as its name suggests, a quick and easy programming language for students and beginners.
C
C was created in 1972 as a system implementation language for the first UNIX operating system.

1061

Along with C++, Java, and C#, which are all to varying degrees based on it, C is the most widely
used programming language for software implementation.
High-level languages are closer to human languages than assembly languages because they
use words based on spoken language, such as BEGIN, END, and IF.
Compilers and interpreters are used to make machine-level versions of high-level language
programs.

Each high-level language instruction translates into five to ten machine-level instructions.
Fourth-generation computer programming languages (4GLs) have commands that are very
close to human languages.
Fourth-generation computer programming languages (4GLs) have commands that are very
close to human languages. SQL (Structured Query Language) is a fourth-generation language.
Most fourth-generation languages manage databases. For example, this SQL command would
return database details of all full time employees.
Select *
From Employees
Where Full_Time = 'Yes'
Question
Let's say that you want to compare how different programming languages implement an instruction
to set the value of a variable called "A" equal to "3."
See if you can match each code example to its language type.
Options:
1. A := 3
2. 1000100011100110
3. Set A equal to 3
4. MOV A,3
Targets:
A. Machine language
B. Assembly language
C. High-level language
D. Fourth-generation language
1062

Answer
A := 3 is in high-level language, 1000100011100110 is in machine language, Set A equal to 3 is
in fourth-generation language, and MOV A,3 is in assembly language.
The further away a programming language moves from machine language, the more complex its
translation becomes.
So high-level programs demand more from computer resources to execute their instructions
than low-level programs.
High-level programs are easier to write, maintain, and understand than low-level programs. This
is especially true when programs run into thousands of lines of code.
Each programming language has its own strengths and weaknesses.
For example, COBOL is very good at financial and business applications, whereas FORTRAN
performs best with scientific calculations.
If you intend to become a professional programmer, you will probably learn several languages
during your career.
Most people start off with an easy-to-learn but less powerful language. They then move on to
more complex and powerful languages such as C, C++, or Java.
2. Programming trends
Two mathematicians published a paper in 1966 to show that you can write any program using
only three types of control structures:
sequence
selection
repetition
The paper led to an approach to programming called structured programming.
Large programs are often too complex to handle by just starting at the beginning and working
your way sequentially through to the end.

So structured programming has evolved to include top-down development and modular design.
Top-down development involves breaking a problem into components of a manageable size,
resulting in more precise and reliable programs.
Modular design groups tasks that perform the same function.
1063

For example, a calculation on overdraft interest will form one module in a program.

Any other part of the program can use that module, so it may be called several times by other
modules.
Modular program design complements the top-down development approach because the
substeps in the development process become modules in the program.
Third-generation programming languages, such as Pascal, C, and BASIC, suit a structured-
programming approach because they are procedural languages that need step-by-step
instructions to arrive at a desired result.
Fourth-generation languages were first developed in the late 1970s. They use one instruction to
generate 30 to 50 machine-language instructions.
Programs written using these languages can therefore be written quickly and easily maintained.
Fourth-generation languages are considered nonprocedural because the programmer asks for a
result without providing the steps to get there.
For example, this SQL statement results in the Products table from the Inventory database
being displayed.
GET Products FROM Inventory
Most fourth-generation languages are used to access databases, which use the following
components:
database management system (DBMS)
database query language
screen generator
report generator
database management system (DBMS)
The database management system ensures that the language can read the database properly.
database query language
The database query language allows users to specify exactly what they want from the database.
screen generator
The screen generator provides an easy-to-use graphical interface to quickly generate user-input
forms.
report generator
The report generator creates customized reports within seconds.
1064

Fourth-generation languages are user-friendly, so people who are not trained as programmers
can quickly learn to use them.
Programs written in fourth-generation languages are good for extracting data and presenting it in
a specific format.
However, fourth-generation languages have compilers that are very large and slow when
compared with those for third-generation languages.
Examples of DBMSs that use fourth-generation languages include
Informix
Oracle
Informix
Informix provides relational database management systems that run on several UNIX platforms.

Relational databases store data in the form of related tables. They are very powerful because
data can be viewed in many ways.
Oracle
The Oracle database was the first database management system to incorporate the SQL
language and to be used with a wide variety of platforms.

SQL (Structured Query Language) is the industry's standard interactive and programming
language that is used to extract information from and maintain databases.

Oracle offers a variety of application development tools and is a major promoter of the network
computer.
Object-oriented programming (OOP) became an alternative to structured programming during
the late 1980s.

OOP creates computer abstractions from real-world objects.
Each computer object has a set of properties and operations or methods associated with it.
For example, the object "car_aerial" may have the property status "extended" or "retracted."

And the methods "extend" and "retract" are also associated with the object.
Object-oriented programs are modular. Modular programs are easy to debug because
programming errors are usually limited to within a module.
At first, mainly real-time and embedded software programs were written with OOP languages.
1065

Note
Embedded software is normally used by very specialized applications. Appliances with a digital
interface, such as microwave ovens and washing machines, employ embedded software.
But these days many new information systems, of all types, are written using this methodology.
Examples of OOP languages include
Smalltalk
Java
C++
C#
Smalltalk
Smalltalk was the first language developed according to OO principles. Smalltalk has more
rigorously enforced rules than C++.
Java
Developed by Sun Microsystems, Java is an object-oriented language that is similar to C++ but
has been clarified to eliminate language features that cause common programming errors.

Java has a number of features that make it suitable for use on the Internet.
C++
C++ is a superset of the C language. It is generally considered to be one of the best languages
for designing large-scale applications.
C#
Developed by Microsoft, C# (pronounced C sharp) is a hybrid of C and C++ that was developed
to compete with Java.

It was designed to improve productivity in the development of web applications while retaining the
flexibility of C and C++.
3. The principles of good programming
A good program is robust, efficient, usable, and maintainable.
Robust
Efficient
Usable
Maintainable
Robust
1066

A program is said to be robust when it is fault tolerant. You should test your program extensively
to indicate faults it cannot handle yet.

You need to find a balance between the cost of testing a program and the need for error handling.
You cannot feasibly test all programs for all faults, just as it is not possible to make all programs
100 percent error free.
Efficient
Programs should make efficient use of the system they run on.

In aircraft, for example, the size and weight of computer hardware are limited. So the software will
also be limited with regard to the storage space, memory, and processor speed.

Programs that waste resources can grind the whole system to a halt when data volumes
increase.
Usable
Usable programs are those that the end-user finds easy to operate. Usability depends on such
factors as input forms, the menu system design, and information presentation.

Informative error messages and help files improve usability.

Offline user documentation, such as a printed manual, is often preferred by users, as it can be
easier to read.

However, online help files can be distributed and searched more easily, so they are more often
included with software.
Maintainable
Maintaining a program involves making changes to a program after its implementation.

A computer system seldom satisfies the needs of its users indefinitely they will soon think of
ways to improve it. So any software should be easily adjusted, altered, and developed.

A programmer should understand and be able to modify programs, provided they are familiar with
the programming language used.
You have now learnt about the features of a good program
Question
When writing a program, programmers should ensure that future users can understand and maintain
their code.
Which of these options do you think a programmer can use to make a program more maintainable?
1067

Options:
1. Comments within code
2. Code bookmarks
3. Numerical code
4. Well-structured code
Answer
Programmers can use well-structured code and documentation including manuals, well-
commented code, and design notes to make programs readable and maintainable.
You can use indentation to make code clearer and easier to follow.
You can use indentation to make code clearer and easier to follow. For example, you can indent
each subpart of an IF statement to the right. You can see the difference indentation makes to
readability.
(indented version)

IF age < 12 THEN
Classification := "child";
ENDIF

(unindented version)

IF age < 12 THEN
Classification := "child";
ENDIF
When programs contain hundreds or even thousands of lines of code, indentation or lack of it
will significantly affect readability.
Comments increase the readability of a program.
All languages have a way of inserting text into code that will not be executed as part of the
program.

For example, C treats text between /* */ as comments.
/*This is program that demonstrates the IF statement*/
IF age < 12 THEN
Classification := "child";
ENDIF
1068

It takes effort to think of meaningful variable names, but they greatly enhance a program's
readability.
You can compare these two pieces of Pascal code that print a list of employees and their
salaries to see the difference that meaningful variable names make.

The first section of code is easier to understand because the reader does not have to guess the
meaning of the variables.
(meaningful variables)

FOR employee := 1 TO
Number_of_employees DO
BEGIN
PRINT (employee_name);
PRINTLN (employee_salary);
END

(not meaningful variables)

FOR I := 1 TO num DO
BEGIN
PRINT (n);
PRINTLN (s);
END
Variable names should be descriptive without being too long. So "average_temperature" is
preferable to "average_temperature_for_the_week."
You do not need to capture all the information about a variable in its name. You can use
comments in your code instead.
You should be consistent in naming variables to improve a program's readability.
Say you have declared the variable "employee_name."

So you should use "employee_salary" rather than "salary_of_employee" to be consistent with
your first declaration.
Question
What features should a good program possess?
Options:
1069

1. Efficiency
2. Maintainability
3. Robustness
4. Small size
Answer
A good program should be robust, efficient, and easy to maintain.
Option 1 is correct. Programs should make efficient use of the systems on which they run. In
aircraft, for example, storage space for software is limited with regard to the memory, and processor
speed. Programs that waste resources can grind the overall system to a halt when data volumes
increase.
Option 2 is correct. The hallmark of a good programmer is being able to create programs that are
easily maintained by programmers coming after him or her. Easy maintenance makes for faster time
to market and increased customer satisfaction.
Option 3 is correct. The best programming is defensive programming allowing for as many
potential failovers as possible, without exploding the codebase. For example, if an entry field is
designed to accept only textual input, you should ensure that the system doesn't crash when a
control key sequence is pressed.
Option 4 is incorrect. It is not always possible to limit the size of a program, due to the vagaries of
different applications. So long as the codebase is consistent, concise, and controlled, size is not a
primary issue.
Summary
A program contains the instructions needed for a computer to perform a task. The computer
understands these instructions in machine code only 1s and 0s.

Programming languages are becoming more like natural languages. SQL is a fourth-generation
language. Object-oriented programming (OOP) has become an alternative to structured
programming.

Computer programs should be maintainable. This can be done by using indentation, comments,
and easily understood variable names within the program.




1070

&lt;p&gt; This page contains a JavaScript function that prints out the current frame document.
To print out the document without using JavaScript, you need to press Control P.&lt;br /&gt;&
lt;/p&gt;
| Print | Contents | Close |
Software life cycle phases
Learning objective
After completing this topic, you should be able to describe the phases of the software life cycle.
1. Introducing the software life cycle
Software varies in complexity depending on what it is required to do. Most software packages
consist of many modules, with each module responsible for performing a different task.
Each module must be planned, written, and tested before it can be integrated with the other
modules to form the complete package.
To simplify software development, a continuous series of logical steps called the software life
cycle is followed throughout the lifetime of the software.
Question
The software life cycle can be represented as a circle.
See if you can match each step of the software life cycle to its position in the diagram if 1 is the first
step
Options
Option Description
A Coding the program
B Testing the program
C Understanding the problem
D Maintaining the program
E Designing the program
1071

Answer
Correct ranking
Option Description
C Understanding the problem
E Designing the program
A Coding the program
B Testing the program
D Maintaining the program
There are typically five steps involved in the software life cycle.
Step 1: Understanding the problem
Step 2: Designing the program
Step 3: Coding the program
Step 4: Testing the program
Step 5: Implementing and maintaining the program
Step 1: Understanding the problem
In the first phase of the software life cycle, the tasks that the software must perform are listed.
The problems to be solved, and their causes and effects, are studied in this phase.

The specific task that is required from the program is derived from the problem statement, which
is a concise description of the problem being addressed. The software must provide a usable
solution to this problem.
Step 2: Designing the program
In the design phase, the program is designed to fulfill the required goal. The aim of the design
phase is to meet the required goals of the program in a logical, efficient, and economical manner.

The designers consider the software and hardware resources that are available to achieve the
goal. If the existing hardware and software are unsuitable, new software and hardware
components may have to be designed.

The overall structure of the program is designed first. This is then broken down into smaller and
smaller tasks until the tasks are of a manageable size.
1072


These individual components are called "modules."
Step 3: Coding the program
During the coding phase, the program is written in a programming language. A variety of
languages can be used, each with their own advantages and disadvantages.

For example, FORTRAN is a good language to use for processing numerical data, whereas LISP
is good for artificial intelligence applications.

Program code should perform the required tasks, and it must be readable so that other
programmers can maintain it.

Programs are often written in separate modules, with each module performing a particular task.
Each module must function properly independently and in relation to the rest of the program.
Step 4: Testing the program
During the testing phase, the program is run and checked. It must accomplish the tasks required
of it, and it must run without errors.

Defects in programs are commonly called "bugs." Individual modules and procedures are first
examined for bugs independently of each other, and then the entire program is tested to find bugs
that appear when the modules interact.

When a bug is found, its causes are isolated so that they can be resolved. This process is called
debugging. The programmer must ensure that solving one particular bug does not create other
bugs elsewhere in the program.
Step 5: Implementing and maintaining the program
During the maintenance phase, any errors and deficiencies in the program are identified and any
necessary improvements are made, while preserving the program's integrity.

The use of design notes, well-commented code, and understandable variable names can aid
future maintenance of the program.
You have now learned about the five steps involved in the software life cycle.
2. Programming development roles
One person on their own can guide simple programs through each stage in the software life
cycle. But this is usually the exception, as most programs today are large and complex.
A software company usually employs a number of different teams, each of which is responsible
for a different phase in a program's development.

1073

A programming development team typically consists of several programmers, as well as a
programmer analyst and a systems analyst.
An assistant programmer is usually an inexperienced, entry-level programmer.

Assistant programmers do not write any new programs. Instead, they perform routine
maintenance tasks on other programs.
A programmer will initially perform the same tasks as an assistant programmer.

When the programmer has gained some experience, they may then be asked to write new
programs. The specifications for these programs would already have been created.
Senior programmers are given the program specifications and write the new programs. They
don't maintain any old code but focus on generating new code.
A programmer analyst works closely with the program designers.

In addition to programming new code, programmer analysts begin to learn the techniques and
skills of program design.
Question
Systems analysts and programmers have different roles within a development team.
See if you can complete the statement about these different roles.
Options:
1. Programmers
2. System analysts
Targets:
A. Programs are designed by
B. But they are written by
Answer
Programs are designed by system analysts, but they are written by programmers.
A systems analyst is an intermediary between the client and the programmers.

Clients communicate their needs to the systems analyst. The analyst translates these
requirements into program designs and communicates these to the programmers, who then do
the actual programming.
1074

Question
Match the programming development roles with the relevant responsibilities.
Options:
1. Programmer
2. Programmer analyst
3. Systems analyst
Targets:
A. This person liaises with clients
B. This person designs programs
C. This person codes the design
Answer
A systems analyst analyses client requirements. A programming analyst designs a code-based
architecture, while programmers actually write the code.
Programmers are responsible for developing code, often in several different languages like C, C++,
and Java. This is because most companies must maintain codebases in all the popular languages.
Programmers are often involved in unit-testing the code they write. Unit tests are basic tests,
performed before an application goes for full-scale testing with the QA (Quality Assurance) team.
A programming analyst develops a high-level architecture, based on client requirements. In so
doing, he or she must consider the language used and the abilities of the programming team. While
a particular task may be technically possible, it may be practically impossible due to the
implementation language.
A systems analyst is a senior role. This person must liaise with clients at a high level and yet be
capable of translating their requirements at the technical level. Moreover, a systems analyst should
possess a low-level overview of the completed system.
Summary
To simplify software development, a series of logical steps known as the software life cycle is
followed. This life cycle involves understanding the problem that needs to be solved, designing
the program, coding and testing the program, and then maintaining the program.

Programs are usually large and complex, so they are guided through each stage in the software
life cycle by a development team. The team consists of several programmers, a programmer
analyst, and a systems analyst.
1075

Program development
Learning objective
After completing this topic, you should be able to describe the phases of program development.
1. Coding a program
Writing a program involves a series of separate processes.
Question
The process of writing a program involves six steps.
See if you can place these steps in the correct order.
Options
Option Description
A Compiling the program
B Running the program
C Understanding the program specification
D Coding the program
E Designing the program
F Debugging the program
Answer
Correct ranking
Option Description
C Understanding the program specification
E Designing the program
1076

Correct ranking
Option Description
D Coding the program
A Compiling the program
B Running the program
F Debugging the program
When writing a program, the programmer must complete each of these steps.
Understanding the program specification
Designing the program
Coding the program
Compiling the program
Running the program
Debugging the program
Understanding the program specification
The programmer must understand the program's input data, output data, and the logical
processing of this data, including all calculations.
Designing the program
The programmer designs the program using design tools, such as pseudocode or a structured
flowchart.

These tools detail the program's logical tasks and the order in which they must be executed. The
programmer must thoroughly analyze the design to ensure that it yields the correct results.
Coding the program
A programmer codes a program by writing it in a particular computer language. Code can first be
written on paper recommended for novice programmers or it can be written directly on the
computer using an "editor."

The programmer checks the code's logic and syntax to ensure that they are correct. They do this
by desk-checking manually checking the code for errors. Desk-checking usually uncovers
several errors that can be corrected before the code is compiled.

Sometimes programmers review each other's code. This encourages good programming practice
and double-checks the code for errors.
1077

Compiling the program
Computers can execute machine language code only. The process of translating higher-level
programming language code into machine language code is called compiling or interpreting the
program.

Special programs, called compilers and interpreters, perform this task. Compilers are more
commonly used than interpreters.

Code that has errors in it cannot be compiled. The compiler will flag the error, and the
programmer must fix the error before trying to compile the code again.
Running the program
Once a program is compiled, it can be executed.
Debugging the program
The programmer checks the program's output to ensure that it is correct. Even though there may
not be any syntactical errors in the code, logical errors in the program's design can produce
incorrect output.

There are many possible errors in a program, from more serious design errors or incorrect syntax
to simple typing errors.

Any errors prevent a program doing what it is supposed to do.

The debugging process should continue until all the bugs have been removed.
You have now learned about the steps involved in writing a program.
2. Editors
Editors are software applications that allow programmers to type the text for programs into a
computer.
Unlike word processors, editors don't allow words to "wrap" onto the next line because word
wrapping could cause problems in the program code.
The two types of editors are
line editors
full-screen editors
Line editors predate full-screen editors. They allow only one line of code to be edited at a time.
The programmer must specify which line will be edited.
Two popular line editors are
1078

vi
Edlin
vi
Short for "visual," vi is a UNIX-based editor.
Edlin
Short for "edit lines," Edlin is an editor for MS-DOS.
Question
Word processors can be used to write code.
Which of the following formats do you think you should use to save code created in a word
processor?
Options:
1. Word
2. Rich text
3. Text only (ASCII)
Answer
Word-processed documents contain formatting information that can create errors in code, so
program files should be saved as text only or ASCII files. These files contain only the text that is
typed.
Full-screen editors are easier to use than line editors because they allow the programmer to edit
any line at any time.
They may provide a number of tools to make editing the code easier:
drop-down menus
integration with compilers and interpreters
colored text
IntelliSense
drop-down menus
Full-screen editors make commands available through drop-down menus, so the programmer
doesn't have to memorize them.
integration with compilers and interpreters
The integration of program compilers and interpreters with editors offers major advantages for
programmers. It means that code can be typed, edited, compiled or interpreted, and executed
from within the same program.
1079


This differs from line editors, in which a separate program performs each function.
colored text
Some editors can display specified words in a particular color to distinguish them from the
remaining code. These words are called reserved words, for example, "BEGIN" in Pascal.

Color-coded reserved words are easy to locate improving the readability of the program.
IntelliSense
IntelliSense enables the programmer to begin typing a command and the editor "senses" which
command the user requires and completes the remainder of the word.

For example, when the programmer types be, the editor may complete this to "begin." If this word
is not the command required, the programmer continues by typing over it.
3. Compilers and interpreters
A source file contains the code written by the programmer. Computers can execute only
instructions in machine language, so source files cannot be executed directly.
A compiler first converts a source file into an intermediate file called an object file or object code
file.

The object file contains a translation of the program code in machine language, but it is not yet a
complete program.
A linker program combines the modules in the object file to form an executable file.

An executable file is complete in itself and does not need to refer to the original source code.
This means that it runs quickly.
An interpreter translates program code into machine language.
It differs from a compiler in that it executes each statement as it is translated. This process can
slow down a program significantly, so interpreters are not as widely used as compilers.
Question
What does a compiler do?
Options:
1. It creates executable binary code
2. It enables you to write source code
3. It links object modules
1080

4. It translates source code into object code
Answer
A compiler translates source code, written in a programming language, into binary object code that
the machine can interpret.
Option 1 is incorrect. A compiler creates binary code, but this code is not directly executable by the
machine. In particular, the machine still needs to be told how the object modules interact and where
the memory starting point for the program lies.
Option 2 is incorrect. A compiler is not a source code editor. The source code must exist before a
compiler can be invoked. You can write source code using any text editor, like Notepad, or a
specialized programming editor like those found in Visual Studio or Netbeans for Java.
Option 3 is incorrect. The final stage in creating an executable program involves running a linker
against the object modules created by a compiler. For example, you can use Blinker a fast,
compact linker to link C, C++, or Clipper object files.
Option 4 is correct. A compiler is usually a command line utility that runs against existing source
modules. It outputs files in binary code. For large systems, you can include multiple source files in a
script file. You can then invoke a utility like Ant to orchestrate the compilation process.
4. Debuggers, code errors, and comments
Debugging code involves removing errors from it. All errors must be removed before the
program can be said to be complete.
The two main types of errors in code are
syntax errors
logic errors
syntax errors
Syntax errors occur when a programmer writes code that does not conform to the rules of a
computer language. They are like errors of grammar in English.

Unless the syntax of a line of code is correct, it cannot be translated into machine language.
logic errors
Logic errors are errors in the design of the program. The line of code conforms to the necessary
rules of the language, but the code is based on flawed logic.

Logic errors are less obvious than syntax errors, so programs can be compiled or be interpreted
1081

without reporting this type of error. The errors are often discovered only when the program is run
and the output studied.
A debugger runs a program one line at a time so that the programmer can examine it for errors.
This is particularly useful for picking up and repairing logical errors.
Code should be readable and understandable in order to be maintained. Comments can be
written into the code to ensure that it meets these requirements.
Question
It is good practice to insert comments into program code.
For whose benefit do you think comments are written into the program code?
Options:
1. The programmer
2. The systems analyst
3. The vendor of the program
4. The end-user of the program
Answer
Comments help programmers to understand the code when they want to maintain or change the
program code.
Comments are used to provide explanatory notes to the programmer about the function of
specific parts of the program code.
Comments are placed between opening and closing tags, such as /* and */ in C. Everything
in comments is ignored by the computer.
Summary
The process of writing a program involves a number of steps, from first understanding the
program's specification and designing the program, to coding and compiling the program, and
finally running and debugging the program.

A programmer can use a line editor or a full-screen editor to enter the text for a program into a
computer. Code can also be typed into a word processor and saved in ASCII format.

Compilers and interpreters convert program code into executable files. Compilers are more
popular because they create faster-running executable files than interpreters.

1082

Debuggers are better at finding syntax errors such as spelling mistakes than errors in a
program's logic. However, the logic errors in a program must be removed before it can run
properly. The program code can be made more understandable by adding comments.


























1083

Defining algorithms
Learning objective
After completing this topic, you should be able to define algorithms and explain how they are
constructed.
1. Introducing algorithms
An algorithm is a set of instructions for solving a problem.
It takes input, processes it according to a set of instructions, and generates output.
A cake recipe is an example of an algorithm. In this example, the problem is that you want to
bake a cake and the input is the list of ingredients. You follow the instructions to generate the
cake as output.
The problem defines the desired output, which in turn determines the inputs and instructions.
For example, you decide what type of cake you want, which in turn determines the ingredients
and the directions.
Suppose that you decide to write an algorithm to boil water. The input is a quantity of water at
any temperature below boiling point and the output is boiling water.
An algorithm must provide correct output for every possible input condition.
Question
Say you want to write an algorithm to boil water.
Rank the steps of this algorithm in the correct order.
Options
Option Description
A When the kettle is boiling, switch off the kettle
B Switch on the kettle
C Plug in the kettle
D Check that the kettle contains at least 1 quart of water
1084

Options
Option Description
E If the kettle contains less than 1 quart of water, fill it with water
Answer
Correct ranking
Option Description
D Check that the kettle contains at least 1 quart of water
E If the kettle contains less than 1 quart of water, fill it with water
C Plug in the kettle
B Switch on the kettle
A When the kettle is boiling, switch off the kettle
You can write algorithms in ordinary English. To produce consistent results, the language used
must be free from ambiguities.
A statement such as

Check that the kettle has enough water

is ambiguous because "enough water" has different meanings in different situations.
The statement

Check that the kettle contains at least 1 quart of water

is preferable because it defines what "enough" water is.
In the following example in the algorithm box, you must include a step to fill the kettle with water
under specific conditions.
Check that the kettle contains at least 1 quart of water
If the kettle contains less than 1 quart of water, fill it with water
And you add instructions to plug in the kettle and switch it on.
1085

Plug in the kettle
Switch on the kettle
An algorithm must have a definite end point so that when the input has been processed and the
desired output achieved, the process stops. You add the final instruction to complete the
algorithm.
When the water is boiling, switch off the kettle
2. Top-down design
The solution to a problem can be complex and the detail involved overwhelming. For programs
that are thousands of lines long, it is impossible to keep all the program details in mind when
developing an algorithm.
The top-down design approach is a well-known algorithm design tool that first presents a
solution to an overall problem using three or four steps only.
Each step in the first solution is then broken down into further substeps.
The process is repeated several times, with each iteration producing a more detailed solution to
the original problem. When the steps cannot be broken down further, the algorithm is complete.
Note
The top-down design approach is also called functional decomposition or stepwise refinement.
Question
Top-down design is a specific approach to a problem.
Which method do you think top-down design encourages?
Options:
1. Starting with the details
2. Starting with the overall problem
3. Considering the overall problem and the details at the same time
Answer
Top-down design encourages the developer to start with the overall problem.
Top-down design automaftically produces modules in an algorithm.
1086

Note
Modules are groups of instructions that perform specific functions.
Let's say that you want to write an algorithm to print invoices and identify these tasks in the first
iteration of top-down design.
The step calculate the total invoice amount can be further refined.
retrieve customer details
retrieve all order details for that customer
calculate the total invoice amount
add 5 percent interest to orders one month overdue
add 10 percent interest two months and older
sum the orders add sales tax
print the invoice
By decomposing the original instruction, modules such as the calculate the total
invoice amount step become evident.
retrieve customer details
retrieve all order details for that customer
calculate the total invoice amount
add 5 percent interest to orders one month overdue
add 10 percent interest two months and older
sum the orders add sales tax
print the invoice
For each customer that is retrieved, the main algorithm calls a module and the invoice amount is
calculated.
3. Pseudocode
Pseudocode is used to bridge the gap between algorithms and programming languages it is
an outline of a computer program, written in a format that can easily be converted into
programming statements.
Question
Pseudocode enables you to write algorithms in a defined and consistent way
Which of the following do you think is true of pseudocode?
Options:
1087

1. It can run as a program in its own right
2. It must adhere to a recognized standards
3. There is no absolute standard for pseudocode
Answer
There is no absolute standard for pseudocode.
There is no absolute standard for pseudocode, but you can follow these guidelines:
use simple English
write each instruction on a separate line
use indentation where appropriate
provide only one entry and one exit point for an algorithm
group instructions into modules
You can make your pseudocode clear and concise by using simple English. The statement
Find the difference between numbers A and B is more clearly expressed as
Difference = A - B.
Having multiple instructions in one line makes your algorithm harder to follow.
BEGIN READ A READ B CALCULATE Difference = A-B PRINT Difference END
By allowing one line per instruction, your code is easier to follow.
BEGIN
READ A
READ B
CALCULATE DIFFERENCE = A-B
PRINT DIFFERENCE
END
If the sequence in which instructions are performed is subject to such control structures as IF
statements, you should use indentation for clarity.
When the execution sequence returns to normal, the indentation should return to its previous
level.
IF B = 10
THEN A = A-B
ENDIF
C = A-B
To avoid having to keep track of code that will not execute, you should ensure that your
algorithm has only one entry and one exit point.
1088

Sometimes, a set of instructions performs the same operation repeatedly at different points in
the algorithm, and instructions can be grouped together into a module with its own name.
Question
Suppose that you are writing a piece of software to address circulars, and you have a piece of code
to print and format an address.
You want to reuse the code to print and format addresses in the algorithm for addressing circulars.
Which of the following do you think you should do?
Which of the following do you think you should do?
Options:
1. Place the code in a separate module and call it as required
2. Modify the code for each instance it is called upon
3. Copy and paste the code each time it is needed
4. Indent the code
Answer
If you want to reuse a piece of code that performs a certain operation, you should place the code in
a separate module and call it as required.
Pseudocode is not a programming language it will not run or execute. Rather it is a design tool
you can use to plan your code.
4. Transforming input
Computer code uses specific language conventions for basic computer operations.
Question
Computers receive input from sources such as a file or modem.
Which of the following statements do you think you would use to initiate input operations?
Options:
1. GET
2. SEND
3. READ
4. FORMAT
1089

Answer
GET and READ are the statements that initiate input operations.
You can use the GET statement to acquire input from the keyboard, whereas the READ
statement acquires input from any other source, such as a file.
Computers can output data to the screen, other devices, or files.
The PUT, OUTPUT, or DISPLAY statements send data to the screen.
And you use the WRITE statement to store data on a computer file.
In statements, a noun usually follows an input or output command.
This noun can be the name of a variable in which you can store values.
You can use the INITIALIZE, SET, STORE, or SAVE statements to assign values.
For example, the command

SET total TO 10

stores the value 10 in the variable total.
Note
INITIALIZE sets a value at the beginning of a program.
You can use a variable to store an input value. The code

GET total

will assign the value typed on the keyboard to the variable total
The code

PRINT total

will output the value stored in total to a printer.
However, you can enclose text in single quotation marks to output specific text. For example,
the code

PRINT 'total'
1090


will output the text 'total' to the printer.
Arithmetic operations are central to computer operations. In code, you can use these symbols to
describe arithmetic operations.
=
+
-
*
/
()
=
= (equal to)

You can use = to assign a value.

For example, the code

total = 4

assigns the value stored in total to 4.
+
+ (plus sign)

You can use + to add values.

For example, the code

total = total + 1

adds one to the value stored in total.
-
- (minus sign)

You can use - for subtraction.

For example, the code

total = total - 1

subtracts one from the value stored in total.
1091

*
* (asterisk)

You can use * for multiplication.

For example, the code

total = total * 2

multiplies the value stored in total by two.
/
/ (forward slash)

You can use / for division.

For example, the code

Total = total / 2

divides the value of total by two.
()
() (parentheses)

You can use () to indicate order of precedence.

The code

Total = total 3 * (2+4)

will set the value of the total to 18. The addition is performed prior to the multiplication.
You have now learnt about arithmetic operations.
Summary
An algorithm is a set of instructions designed to solve a specific problem. Every algorithm must
take input, perform some action on that input, and then generate output.

You can use top-down design to simplify a problem into steps and substeps. This process
reveals a modular structure for your code.

You can use pseudocode to structure an algorithm. Pseudocode is a useful design tool it
clarifies design problems and reveals errors in logic.
1092


Specific language conventions are used for basic computer operations. Algorithms can express
the arithmetic operations that you require a computer to perform.


























1093

Construction an algorithm
Learning objective
After completing this topic, you should be able to describe the GOTO statement, the Structure
Theorem, and how to write an algorithm.
1. The GOTO statement
Before structured programming was developed in the 1960s, programmers used the GOTO
statement to pass control to a part of the program other than the next statement.
Depending on the programming language, code lines were identified by names or numbers.
For example, to transfer control to the code at line 151 in a program, programmers used the
statement GOTO 151.
The problem with the GOTO statement is that it results in a program that jumps backward and
forward, making the logic difficult to follow. This is known as "spaghetti code."
Because of the difficulties in following the logic, programs that use many GOTO statements are
prone to errors and tend to be unreliable.
Let's suppose that you want to write a program that prints address labels.
Some people have street addresses, whereas others have mailboxes. You need to cater for
both possibilities in your algorithm.
The following code is used to print address labels using the GOTO statement.
21: PRINT name
22: IF street IS empty GOTO 25
23: PRINT street
24: GOTO 26
25: PRINT postbox
26: PRINT city
27: PRINT state
28: GOTO 17
The following code is used to print address labels uses the IFTHENELSE statement. This
code is simpler and easier to follow.
1094

IF street IS empty
THEN
PRINT postbox
ELSE
PRINT street
ENDIF
PRINT city
PRINT state
The structured program reads and executes each line of code sequentially.
The logic and outcome of both the GOTO and IFTHENELSE programs is the same, but it is
easier to follow the logic of the structured program's code.
2. Introducing the Structure Theorem
In 1966, mathematicians Bhm and Jacopini published an article outlining what is now known as
the Structure Theorem.
The Structure Theorem shows how any program can be written using three control structures:
sequence
selection
repetition
sequence
A computer program executing in sequence performs each instruction once only. The instructions
are executed in the sequence in which they appear, and the program does not skip or repeat any
of the instructions.
selection
Selection implies that a choice will be made, which depends on the value of a condition specified
by the programmer.
repetition
Repetition repeats a section of code while a certain condition holds true.
One form of selection is IFTHENELSE.
If I = (a condition) THEN
Response.Write(i)
ELSE
1095

EXIT
ENDIF
In most programming languages, an IF statement ends with some form of the corresponding
keyword for example ENDIF.
IFTHENELSE makes a selection from two options.
Question
In this example, selection is made based on the variable "age."
Which statement do you think is executed if age equals 18?

IF age < 18
THEN
OUTPUT 'You cannot vote yet'
ELSE
OUTPUT 'You can vote '
ENDIF
Options:
1. Both output statements
2. Neither output statement
3. The first output statement
4. The second output statement
Answer
The second output statement is executed if age equals 18.
Because the code is written so as to make a choice between the two options, both statements
cannot be executed at once.
Because the code is written so as to make a choice between two options, one of the two statements
must execute.
The first output statement will execute when the value of age is less than 18.
The second output statement will execute when the value of age is 18 or more.
1096

You may want no action to be taken when the condition in the IF statement is false. To do this,
you can use a null ELSE statement.
A null ELSE statement has no code associated with it, so you can leave it out. The following
code is an example of a null ELSE statement.
IF age >=18 THEN
STORE name IN voters_roll
ENDIF
In this case, no code will be executed for those under 18.
Repetition repeats a section of code while a certain condition holds true.
A WHILEDO loop is used to initiate the statement block to be repeated.
The statement block ends with ENDWHILE.
seats_allocated = 0
WHILE seats_allocated < 5 DO
GET booking
PRINT ticket
ADD 1 to seats_allocated
ENDWHILE
Here is an example of repetition that prints tickets for six child seats on a minibus. The program
initializes seats_allocated before it enters the loop. If you omit this statement, the loop
cannot run, as seats_allocated has no value that can be judged to be less than 5.
seats_allocated = 0
WHILE seats_allocated < 5 DO
GET booking
PRINT ticket
ADD 1 TO seats_allocated
ENDWHILE
While seats_allocated is less than five, the program executes the code in the repetition
block, which is the code up to the ENDWHILE statement.
You should note that the control variable seats_allocated changes every time that the
statement block executes.
If the control variable stayed the same during the loop execution, the loop would not end.
1097

When five seats have been allocated, the program moves to ENDWHILE, ending the loop.
seats_allocated = 0
WHILE seats_allocated < 5 DO
GET booking
PRINT ticket
ADD 1 TO seats_allocated
ENDWHILE
3. Defining a problem
You must understand a problem before you can write an algorithm that solves the problem. A
problem is normally presented in the form of a statement or a requirement.
Question
See if you can identify the three defining elements of an algorithm.
Options:
1. Input
2. Output
3. Process
4. Questions
Answer
Input, process, and output are the three defining elements of a programming problem.
Option 1 is correct. For example, an algorithm for performing automatic updates on database
records would take record field data types as input. Instead of passing an unknown number of
parameters to the algorithm, a smarter version would take an array as input and process the array.
You can extend this concept to multi-dimensional arrays.
Option 2 is correct. Typically, an algorithm will return a true or false value indicating success or
failure. It can also return values, allowing it to interact with the calling routines. Using OO (object
oriented) languages, it is particularly useful to be able to return whole objects, where necessary.
Option 3 is correct. Processes vary, depending on the purpose of the algorithm. However, a generic
algorithm involves one or more loop statements and an operation on its arguments. A well-designed
algorithm should perform its own housekeeping such as freeing memory and disk resources and
error handling.
1098

Option 4 is incorrect. Each algorithm should perform a well-defined, basic task. In this way, you
avoid overly complex code and facilitate code reuse. To allow a single algorithm to respond to
diverse questions limits the flexibility of the code by involving too many hard-coding practices.
The process comprises the actions that transform the given input into the desired output. Verbs
such as "find," "calculate," and "sort" are used to identify processes.
Nouns, adjectives, and adverbs in the problem statement normally describe input and output.
Nouns, adjectives, and adverbs in the problem statement normally describe input and output.
When you have identified all the elements of a problem, you list them in a defining table. The
table has three columns Input, Process, and Output.
You can use the table to write an algorithm its processes become statements in the algorithm.
And the input and output elements become arguments for the statements.
Note
A defining table is also known as an input-process-output table.
In programming statements, arguments are comparable to objects in the grammar of human
language sentences.
So in this statement, GET is the verb and booking is the object, or argument.
seats_allocated = 0
WHILE seats_allocated < 6 DO
GET booking
PRINT ticket
ADD 1 TO seats_allocated
ENDWHILE
Question
Suppose that you need to calculate the speed a courier must drive at in order to cover a given
distance within a given time.
See if you can identify the input elements of the problem.
Options:
1. The noun "time"
2. The noun "speed"
3. The noun "distance"
1099

4. The verb "calculate"
Answer
The nouns "distance" and "time" are input elements of the problem.
The noun "time" is an input element of the problem.
The noun "speed" is an output element of the problem.
The noun "distance" is an input element of the problem.
The verb "calculate" is a problem process that calculates the value of the variable "speed."
For every input element in the problem, there will be a statement such as GET distance.
The final output element has to be presented to the user, so your defining table must include a
process to deliver the output, such as DISPLAY speed.
You can now use your table to write your algorithm.
4. Writing an algorithm
Once you have defined the problem, you can write the algorithm. You will probably need to
rework your algorithm several times in order to improve it.
Algorithms have certain characteristics. Every algorithm starts with a name that describes what
it does. It usually starts with a verb and ends with a noun as shown in this example.
All the instructions between the algorithm name and the END statement should be indented for
readability.
Every time a new control structure is introduced, it must be left indented.
At the end of the control structure, the indentation returns to the previous level.
CALCULATE overdraft_interest
WHILE answer="Y" DO
READ name
READ address
PRINT label
DISPLAY "Print another?"
ENDWHILE
1100

Each processing step in the defining table results in one or more pseudocode instructions.
The items in the Input and Output columns become arguments for the instructions.
The END statement concludes an algorithm.
WHILE answer="Y" DO
READ name
READ address
PRINT label
ENDWHILE
Question
Let's suppose that you want to write a program that converts a distance in kilometers to a distance
in miles. There are 0.625 miles in every kilometer..
See if you can match each option to its correct place in the defining table
Options:
1. miles
2. kilometers
Targets:
A. Input column
B. Output column
Answer
Kilometres goes in the input column, and Miles goes in the output column.
You need a process that gets the kilometers from the user.
You need a process that gets the kilometers from the user. The verb "converts" in the problem
statement indicates a process. So you have to calculate the number of miles that is equivalent to
the given number of kilometers.
And you need a process to display the calculated miles. You can use your table to write your
algorithm.
The algorithm first asks for a distance in kilometers from the user.
Then it converts that number into miles.
1101

Finally, it displays the result.
Convert kilometers_to_miles
DISPLAY 'Enter the distance in kilometers.'
GET kilometers
miles = kilometers * 0.625
DISPLAY kilometers 'kilometers = ' miles ''miles.'
END
The program that converts kilometers into miles would typically execute as follows.
Enter the distance in kilometers.
10
10 kilometers = 6.25 miles.
Summary
The GOTO statement can be used to pass control to a part of the program other than the next
statement. It is very difficult to follow the logic of programs that use many GOTO statements.

The Structure Theorem shows how any program can be written using three control structures
only sequence, selection, and repetition. This eliminates the need for GOTO statements in
programs.

A problem is normally presented in the form of a statement or a requirement, which consists of
three elements input, output, and process. Once identified, the problems can be listed in a
defining table.

The defining table can be used to write an algorithm. Algorithms begin with a name and end with
an END statement. Their instructions are indented for readability.









1102

Creating an algorithm
Learning objective
After completing this topic, you should be able to structure an algorithm.
1. Exercise overview
In this exercise, you are required to identify the input, process, and output elements of problem
statements in order to construct an algorithm.
This involves the following tasks:
using a defining table to create a letter-counting algorithm
using a defining table to create a tax-calculating algorithm
2. Task 1: Structuring a letter counting algorithm
Suppose that you want to write an algorithm that asks the user to enter two words and then
displays the number of letters in the first word, the number of letters in the second word, and the
total number of letters in both words.
Question
In order to create your algorithm, you must first use a defining table to identify the input and output
elements and the order in which they should appear in the algorithm.
Rank the following options in their correct position in the Input and Output columns.
Options:
1. word_length1
2. total
3. word_length2
4. word1
5. word2
Targets:
A. Input 1
B. Output 1
C. Input 2
D. Output 2
E. Output 3
1103

Answer
Input 1 is word1,.Output 1 is word_length1, Input 2 is word2, Output 2 is word_length2, and
Output 3 is total.
word_length1 corresponds to the number of letters in the first input , word1. This algorithm is
designed to output a result immediately following each input, and an additional total output at the
end.
After entering two words, the algorithm returns the total number of characters in the combination of
both words. You could extend this algorithm to receive a variable number of words.
word_length2 is the number of letters in the second input , word2. As the algorithm stands at the
moment, the total number of characters is output straight after this result.
word1 is the first input parameter. If the algorithm is well designed it will gracefully shut down if it
encounters a problem, such as an invalid or missing input. A good algorithm does not assume the
availability of required elements.
word2 is the first input parameter. Note that, in this case, the algorithm is symmetric, in that you can
reorder the inputs to get the same total.
Question
Suppose that you want to structure the processes that will change the input elements to the desired
output elements.
Rank the following processes in the Process column of the table in the order in which they should
appear in the algorithm.
Options
Option Description
A ADD word_length1+word_length2=total
B GET word1
GET word2
C PRINT total
D CALCULATE word_length1
CALCULATE word_length2
1104

Answer
Correct ranking
Option Description
B GET word1
GET word2
Once inside an algorithm, the first step is to retrieve the parameters passed to it. This step
depends on the programming language used in this case, you use the GET operation.
D CALCULATE word_length1
CALCULATE word_length2
You calculate the length of each input once that parameter has been successfully retrieved
from the calling routine. A letter-counting routine can be an algorithm in itself. You can
refactorize this routine to further modularize your code.
A ADD word_length1+word_length2=total
The ADD operation takes two integral inputs and adds them together. Note that this operation
can easily be expanded to accept more than two inputs, making the algorithm more dynamic
and flexible.
C PRINT total
Every programming language has an equivalent of a PRINT operation that prints to the
standard output usually the screen. Standard output can be redirected to a printer, a file, or
some other device.
The defining table has been completed and you can now create your algorithm.
3. Task 2: Structuring a tax-calculating algorithm
Suppose that you have to write an algorithm that calculates and prints the tax payable on an
invoice total. You also want to print the final invoice amount, including tax.
Question
You have identified all the input, process, and output elements necessary for your algorithm.
Rank the elements in the position they should appear in the Input, Process, and Output columns of
the table and in the order in which they should appear in the algorithm.
Options
1105

Option Description
A tax / final_amount
B PRINT tax / PRINT final_amount
C GET invoice
D ADD tax+invoice=final_amount
E CALCULATE tax
F invoice
Answer
Correct ranking
Option Description
F invoice
This is the only necessary input to this algorithm. Normally, an invoice reference is in the form
of a unique numeric or character ID which references a database record, based on a primary
key.
C GET invoice
After passing an invoice reference into the algorithm, it looks up the invoice code in a memory
table or database table. The result of this operation is the details of the invoice, such as the
client, the products, and total cost.
E CALCULATE tax
Each invoice generates a different amount of tax, depending on how large the invoice is and its
geographical location.
D ADD tax+invoice=final_amount
The tax that the algorithm calculates against a particular invoice must be added to the invoice
amount. This gives the total billing amount to each client.
B PRINT tax / PRINT final_amount
The penultimate step in this algorithm is the printing of the tax and final amount. Printing results
is merely an informative process usually to aid debugging. Most algorithms return their results
to the calling routines.
A tax / final_amount
The last step that this algorithm performs is to return the results it calculates to the calling
1106

Correct ranking
Option Description
routine. The algorithm doesn't disturb any inputs passed to it in fact, in most cases,
parameters are passed by copy and not by reference.























1107

Variables, constants, and data types
Learning objective
After completing this topic, you should be able to discuss the roles of variables, constants and
data types in a program
1. Variables and constants
Computers use data to perform tasks in a function called data processing. Data processing is
made possible when data is stored in a computer's memory.
Question
Data may be changed or remain the same during data processing.
Which of the following terms do you think describes data that is preset and remains unchanged
during processing?
Options:
1. Variable
2. Constant
3. Operator
4. Procedure
Answer
The term constant describes data that is set before the program is used and will remain the same
while the program is running.
The term variable describes data that may change while the program is running.
Although variables may change while the program is running, they are often given a starting
value by programmers to allow them to be used within an application. This is known as
initializing the variable.
2. Naming variables and constants
During processing, an address is used to store data in a particular location in the computer's
memory.
Memory addresses are identified by hexadecimal numbers, such as 166D. However, in order to
make the address more memorable, it can be given a name.
1108

Note
Whereas the decimal system is a base 10 counting system, the hexadecimal system is a base 16
counting system. The hexadecimal system utilizes numbers from 0 to 9 and letters from A to F.
Question
Programming languages have rules that govern how constants and variables are named.
Which of the following rules do you think apply when naming variables and constants?
Options:
1. Names may not be the same as those reserved as keywords in a programming language
2. Names may not begin with a digit
3. Names may not begin with a letter
4. Certain characters may not be used in variable names
5. Names must have a minimum length of eight bytes, or characters
Answer
Some programming languages do not allow the use of certain characters in constant and variable
names. Names may not begin with digits, and they may not be the same as those reserved as
keywords in a programming language.
Certain languages don't allow the use of specific characters. BASIC, for example, does not allow
the use of characters such as * (asterisk), + (plus sign), and () (parentheses).
And variable or constant names may not begin with digits or certain characters. For example,
the names "2jan" and "12month" would not be allowed because they begin with digits. But the
names "jan2" and "month12" would be acceptable.
Keywords, which are used in programming languages, may not be used as variable or constant
names.
For example, FOR is a keyword in BASIC and var is a keyword in Pascal. Neither of these
words could be used as constant or variable names in their respective languages.
Constant and variable names are allotted a maximum length depending on the language being
used. In Pascal, a variable name may not exceed 32 characters.
Question
To understand the purpose of a particular variable or constant, it is important to give it an
appropriate, meaningful name.
1109

Which of the following naming conventions do you think result in an appropriate, meaningful variable
or constant name?
Options:
1. The name of a variable or constant should be transparent enough to describe the data it
represents
2. The number of characters in each constant should be five or less
3. Each name must be unique within the part of the program in which it is used.
4. Each variable name should begin with the prefix "vari."
Answer
The name of a variable or constant should be transparent enough to describe the data, and each
name must be unique within the section of the program in which it's used.
A variable referring to a company's sales for the month of January could be called "jansales."
The variable name "rt545LL" could be used to refer to the same data, but it is more difficult to
understand and less meaningful.
Variables used in the same part of a program can't have the same name, or one variable may
overwrite the other. This is known as name collision.
3. Data types
These are the four main simple, or primitive, data types. There are other data types that
represent more complex data.

Data types limit which kind of data a variable can hold and determine which kinds of operations
can be performed on it.
Char
Integers
Real
Boolean
Char
The char data type represents single characters, such as "m."

A variable made up of a number of characters is called a string.

The variable employee_name might contain the string "John Smith."
Integers
1110

Integers are among the data types that most computers support. There are different sizes of
integers available, including short integers and long integers. For example, in Java, the short data
type holds an integer up to 8 bits in length and the long data type holds one of up to 64 bits in
length.

Integers are positive and negative whole numbers, for example -2 and 117954.
Real
Real data are numbers with a fractional part, for example 8.65 and -0.03.

They also include numbers that have no fractional part but are expressed as a whole number with
a decimal point, such as 4.0 or -1.0.
Boolean
Boolean values are logical values and can be either true or false.

Booleans indicate true with a value of 1 and they indicate false with a value of 0.

Some programming languages define subsets of the basic types of data.

In Pascal, for example, long, short, and unsigned are variations of the basic integer type.

Some languages use different names for the same type of data. Numbers with a decimal point,
for example, are called "real" in Pascal and "floats" in C.
You have now learnt about data types.
Some programming languages define subsets of the basic types of data.
In Pascal, for example, long, short, and unsigned are variation of the basic integer type.
Some languages use different names for the same type of data. Numbers with a decimal point
for example are called "real" in Pascal and "floats" in C.
Question
Variables that are used in a piece of code need to be declared in a statement at the start of that
code before they can be used in expressions.
Which of the following do you think must be provided in a declaration statement for a variable?
Options:
1. Its scope
2. Its name
3. Its type
1111

4. The number of times it will be used
Answer
A variable's name and type must be included in a declaration statement before it is referenced in
code statements.
Declaration statements determine the variable's name and the type of data it will contain. Each
language uses a different syntax for its declaration statements.
In Pascal, the var keyword is used to indicate the start of variable declarations. Pascal uses the
code

var car: integer;

to show that a variable car is an integer-type variable.
And it uses the code

var car: real;

to show that a variable rate is a real-type variable.
Note
The var keyword does not need to appear next to each variable being declared it should appear
once only at the beginning of the declaration statements.
In the following Pascal example, the variables car and rate are declared at the beginning of
the program.
program
var
car: integer;
rate:real;
begin

End
The C programming language uses int car; to show that the variable car is an integer.
And float rate; is used to show that the variable rate will store floating point numbers.
1112

Note
Java declare variables in a similar way, using the syntax

datatype variablename;
QBASIC doesn't require you to explicitly declare variable types. Instead, you simply initialize a
variable using the required data type. So in QBASIC, car=9 to allocates an integer value to the
variable car.
And the statement rate=-7.32 allocates a real value to the variable rate.
Question
Which data type is used to store individual letters?
Options:
1. Boolean
2. Char
3. Integers
4. Real
Answer
You use the Char data type to store individual letters, like "a" and "Z".
Option 1 is incorrect. Boolean data types are bit fields that store single bits, representing (on, off),
(true, false), and so on. In low-level languages you can conserve memory space by using bit-wise
arrays, whereas in Java, Boolean types take up 2 bytes (16 bits) in memory.
Option 2 is correct. In most modern programming languages, a character value takes up 2 bytes.
This type is able to store any character both printable and non-visual in the standard ASCII
character set. This set represents characters with decimal values in the range 0-255, which include
the digits 0-9 and the English alphabet, both lowercase and uppercase.
Option 3 is incorrect. Integer types are used to store integral values positive and negative whole
numbers. In Java, for example, an integral type (int) takes up 4 bytes on all platforms. As the byte
size is limited to each language, attempting to store too large a value will result in an overflow and
data loss.
Option 4 is incorrect. Real types are numeric values with a floating point segment. For example,
2.5573 is an example of a real value. Variables types for such values have become standardized as
double and float.
1113

Summary
Data that is preset and remains the same during data processing is called a constant, whereas
variables represent data whose value may change while the program is running.

During processing, data is stored in a specific address in the computer's memory. Memory
addresses are represented by hexadecimal numbers, or they may be named to make them
more memorable. Programming languages have rules that govern how variables and constants
can be named.

Data is classed according to four main simple types integers, real numbers, char, and
Booleans. Some languages use different names for the same type of data. Variables that are
used in a program need to be declared at the start of the program before being referenced in
code statements.



















1114

Expressions and statements
Learning objective
After completing this topic, you should be able to describe the functions of expressions and
statements in programming.
1. Introducing expressions and statements
An operator is a symbol that represents a specific action that must be performed on data.
Question
Operators work with operands.
Which of the following do you think is the best definition of an operand?
Options:
1. Anything in a statement that isn't an operator
2. The value that results after an action has been performed
3. The value on which a specific action is being performed
4. The address in the computer's memory where data pertaining to the operator is stored
Answer
The values on which an action is being performed are known as operands. In the example
expression 2 + 6, the values on either side of the + (plus sign) operator are the operands that are
being added.
Each operator is represented by a specific symbol.
Question
The + operator indicates that two values must be added.
See if you can complete the statements to identify which operator is represented by which symbol.
Options:
1. *
2. -
3. /
Targets:
1115

A. The subtraction operator is represented by the _____symbol.
B. The multiplication operator is represented by the _____symbol.
C. The division operator is represented by the _____symbol.
Answer
The - symbol represents the subtraction operator, the * symbol represents the multiplication
operator, and the / symbol represents the division operator.
An expression is a combination of operators and operands that ascertains a value. For example,
in the expression 7 * 2, 7 and 2 are the operands and * is the operator.
This expression gives a value of 14.
A statement is an instruction in a computer language. Computer programs are made up of many
statements.
CLS
Value = 7 * 2
PRINT value
END
As statements are executed, the program performs a particular task.
Assignment operators are used in statements to instruct programs to assign values to data.
When assigning a value to a variable, the variable is always placed on the left-hand side of the
assignment operator.
Total = sales1 + sales2;
Different languages use different assignment operators. BASIC and C, as well as many other
languages, use the = (equal to) symbol as the assignment operator.
An example of an assignment statement in C is

Total = sales1 + sales2;
The following pseudocode demonstrates a typical assignment statement. It adds 2 to the
present value of the variable num and stores the answer in num.
CLS
num = 5
num = num + 2
PRINT num
END
1116

In both languages, the statement

num = num + 2

adds 2 to the present value of the variable num and stores the answer in num.
So if the variable num initially has a value of 5, after this statement executes, it will have a value
of 7.
Pascal uses the : (colon) and = in combination as the assignment operator. The code

num := + 2

is an example of an assignment operator in Pascal.
2. Operator Precedence
Operators are evaluated in a specific order according to operator precedence.
Question
Operator precedence means that certain operators have precedence over others.
See if you can put the operators and parentheses in the order in which they are evaluated according
to operator precedence.
Options
Option Description
A Multiplication and division
B Addition and subtraction
C Parentheses
Answer
Correct ranking
Option Description
C Parentheses
1117

Correct ranking
Option Description
A Multiplication and division
B Addition and subtraction
In the statement

y = 7 + 3 * 2

the multiplication operator is executed before the addition operator, according to operator
precedence.
CLS
y = 7 + 3 * 2
PRINT y
END
In this case, y has a value of 13.
If there is more than one operator in an expression with the same precedence, the operators are
executed from left to right.
For example, in the statement

amount = 4 / 2 * 3

the division operator is executed before the multiplication operator.
CLS
amount = 4 / 2 * 3
PRINT amount
END
The statement assigns a value of 6 to amount.
Question
You can use () (parentheses) in statements.
In code, which of the following do you think () are used for?
1118

Options:
1. As a division operator
2. To group expressions
3. As an addition operator
4. To entirely exclude the rest of the statement from execution
Answer
In code, () are used to group expressions.
You use ( to indicate the start of the grouped expression and ) to indicate the end.
Operators between () are given the highest precedence, and the result is used for further
calculations.
Terms within parentheses are evaluated according to standard operator precedence.
Question
Expressions in () are given highest precedence.
In the expression
t=3 * (1 + 4)
what do you think the value of t is?

CLS
t = 3 * (1 + 4)
PRINT t
END
Options:
1. 7
2. 13
3. 15
4. 18
Answer
The value of the variable t is 15.
In the statement

y = 3 * (1+ 9 / 3)
1119


the expression in () is executed first. It equals "4," so y is assigned the value of 12.
Relational operators compare two values. The mathematical symbols < (smaller than) and >
(greater than) are used as operators in these comparisons.
Question
The statement
IF p > 5 THEN PRINT "true"
compares the value of p with the numeric value 5 using the > operator.
What do you think the statement denotes?

CLS
p = 4

IF P < 5 THEN PRINT "false"
END
Options:
1. If the value of p is greater than 5, then the statement is true
2. If the value of p is smaller than 5, then the statement is true
3. That p is equal to 5
4. That p is less than or equal to 5
Answer
If the value of p is greater than 5, then the statement is true.
The expression y < 5 means that if the value of y is less than 5, then the statement is true.
CLS
y = 6
IF y > 5 THEN PRINT "true"
IF y < 5 THEN PRINT "false"
END
3. Building statements
Certain rules prescribe how to build assignment statements.
1120

Question
Select the rule that you think is applicable to building assignment statements.
Options:
1. Statements may contain only operators
2. Statements are executed from left to right
3. Only one assignment operator per statement is permitted
4. The same variable can't appear on both sides of an assignment operand
Answer
Statements are executed from left to right.
Option 1 is incorrect. Statements can contain as many operators as the programmer wishes to
include, but operands are required for operators to work on.
Option 2 is correct. In the statement red = 829 the variable red is assigned the value 829.
Option 3 is incorrect. Statements such as m = r = 3 are allowed for many programming
languages.
Option 4 is incorrect. The same variable can appear on both sides of an assignment operand. In the
statement a = a + 1, the value of a is incremented by 1.
In complex calculations, statements can be broken down into several steps to aid code legibility.
For example, the statement

total = ( (price * 0.175) + price) * 1.2

may be broken down further to make it easier to read.
total = ( (price * 0.175) + price) * 1.2

tax=price*0.175
cost=tax+price
total=cost*1.2
Summary
An operator represents a specific action that has to be performed on data. Each operator is
represented by a specific symbol. The values on which an operator works on are known as
operands. An expression is a combination of operators and operands that ascertains a value.

1121

Operators are evaluated in a specific order known as operator precedence. Parentheses take
precedence over all other operators and multiplication and division operators take precedence
over addition and subtraction operators. If there is more than one operator in an expression with
the same precedence, the operators are executed from left to right.

Statements are built according to certain rules. Multiple assignment operators are permitted per
statement. Statements are executed from left to right.
























1122

Building expressions
Learning objective
After completing this topic, you should be able to understand the elements that are used in code,
recognize different data types, and construct simple expressions.
1. Exercise overview
In this exercise, you're required to recognize different data types and convert expressions
written in words to expressions written in operators and operands and calculate their answers.
This involves the following tasks:
providing appropriate definitions for code elements and recognizing the syntax of
different languages
evaluating the answer to expressions using operator precedence and converting
expressions written in words to expressions written in operators and operands
identifying different data types
2. Task 1: Processing data
Computer languages use a number of data types and specialized symbols to represent and
manipulate the data they process.
Question
In data processing, there are a number of data types, symbols, and values that are used to write
computer programs.
Complete the sentences to define terms.
Options:
1. Operators
2. Constants
3. Variables
4. Operands
Targets:
A. represent data that remains the same while the program is running
B. represent data that may change while the program is running
C. are symbols that represent specific actions that are performed on data
1123

D. are the values or variables on which a specific action is being performed
Answer
Data that remains the same while the program is running is represented by constants, data that may
change while the program is running is represented by variables, symbols that represent specific
actions that are performed on data are operators, and the values or variables on which a specific
action is being performed are operands.
* and / are examples of the multiplication and division operators, respectively. These symbols are
standard across most programming languages. You can group operators using appropriate
parentheses., This is sometimes necessary in complex expressions because operators obey order
precedence rules.
Constants are values that don't change throughout an application's lifetime. Because you don't want
these values being inadvertently changed, you define them as being constant at the programming
level. For example, the mathematical symbols pi and e have well-defined values, which are
invariant.
Variables are programmable placeholders for holding character, string, numeric, and boolean
values. Typically, you declare, initialize, and process variables, in that order. You can change a
variable's value at any point in a program. However, each new value must be of the initial type. For
example, you will generate an error by attempting to store "abcd" in an integral type.
Operands are the values variable or constant used in a processing instruction. For example, in
the code total = (first + second) * third, first is added to second, the result is
multiplied by third and assigned to the total variable. first, second, and third are all
operands.
Question
Declaration statements state the variable's name and the type of data it will contain. Many
languages use different syntax for declaration statements.
Select the declaration statement written in QBASIC from those listed.
Options:
1. item=9
2. float rate;
3. int car;
4. var car: integer;
1124

Answer
QBASIC declares variables to be integers by allocating integer values to them.
Option 1 is correct. Most programming languages force you to declare a variable's type before
assigning values to it. These are called type-safe languages, which compilers can optimize because
they know the type of each variable. Some languages, however, like QBASIC and Clipper, can
automatically assign a type at runtime, allowing you to reassign types as well as values.
Option 2 is incorrect. In languages like C, C++, and Java, float rate declares a floating point
variable, like 10.2342. In this example, the variable must be initialized in C and C++ to avoid random
memory values and unpredictable results. In Java, rate is automatically assigned 0.0, if it's a
member variable.
Option 3 is incorrect. int is an integral type, representing positive and negative whole numbers, like
2 and 634. QBASIC automatically recognizes variable types from the assignment code you don't
have to declare specific types in QBASIC.
Option 4 is incorrect. Some languages, like Pascal, use this form of declaration syntax. You are
declaring car to be a variable capable of storing whole numbers. Don't forget to initialize variables
to default values before processing them. This helps to prevent memory corruptions, which can be
difficult to detect and debug.
Question
Programming languages articulate variable declarations in different ways.
Which of the following assignment statements would be valid in Java?
Options:
1. var number=123
2. dim number=123
3. int myNumber=123;
Answer
An example of an assignment statement in Java is
int number;
Option 1 is incorrect. var stands for "variable" and is used in languages like Javascript to declare
variables of generic type variables that can hold any data type. This means that variables can be
reassigned at will and you don't have to track their usage when you are finished with them, you
simply forget about them.
1125

Option 2 is incorrect. In Visual Basic and VBScript, you use the dim keyword to declare a variable
that can hold random values. This is useful in processing arrays and other memory structures,
where data types are anonymous. Generic types like dim allow you to take full advantage of
polymorphism.
Option 3 is correct. Java borrows much of its syntax from C++ which, in turn, draws from the C
language. For example, to declare character, string, and floating types in Java, you use char,
String, and float respectively. Note that misusing these keywords will result in compilation
errors.
3. Task 2: Examining operator precedence
Much computer programming depends on operator precedence, which are rules that govern
how the computer reads formulae.
Question
In an expression, certain operators have precedence over others.
Match each expression with the result it will produce.
Options:
1. 7+3*5
2. 7*(3+5)
3. 4*6-4
4. 4*(6-4)
5. 8/4-3+20-4
Targets:
A. = 8
B. = 22
C. = 20
D. = 56
E. = 15
Answer
The correct results are
8 = 4*(6-4)
22 = 7+3*5
20 = 4*6-4
26 = 7*5+3
15 = 8/4-3+20-4
1126

Multiplication (*) takes precedence over addition, unless you override this precedence using
parentheses (). Here, 5 is multiplied by 3 to give 15. Finally, 15 is added to the 7 to give 22.
In this example, parantheses override the normal precedence of multiplication. 5 is added to 3 to
give 8, which is multiplied by the 7 to give a final answer of 56.
6 multiplied by 4 gives 24. Subtracting the 4 gives 20. This shows that operator precedence holds,
whichever positions the operators occur.
In general, operations in parentheses are processed first, from the inside out. This means that the
innermost nested parentheses are calculated first, followed by the outer parentheses. Here, 6 minus
4 gives 2, which is multiplied by the 4 to give 8.
8 is divided by 4 to give 2. (2+20) (4 +3) is then calculated to give a result of 15. Note here,
however, that (8/4)-3+20-4 also gives 15, whereas 8/(4-3+20-4) gives 8/17.
Question
Conditions or calculations can be written in operators and operands.
Convert the expression written in words to an expression written in operators and operands by
completing the expressions.
Options:
1. +
2. -
3. *
4. /
Targets:
A. m_m
B. m_5
C. 12_5
D. 5_7
Answer
The correct answers are
Add variable m to five times m is m + m * 5
and
Divide 12 by 5 and subtract 7 is 12 / 5 - 7
1127

Note here, that both references to m are merely placeholders each variable refers to a separate
value. One m refers to the original value, while the second represents the original value multiplied by
5. These two values must now be added using the + operator.
The specification stipulates that the original value of m is to be multiplied by 5. This is accomplished
using the * operator.
12 is divided by 7 before subtraction occurs. In reality, there is no need to specify this because
operator precedence will ensure it multiplication and division assume higher priority than both
addition and subtraction.
The operation of subtraction occurs last. You can guarantee that this operation is carried out first, by
enclosing it in parentheses. You are recommended to use bracketing, to make your code legible to
others not all programmers are comfortable with operator rules and precedence.
4. Task 3: Identifying data types
The four main simple types of data are integers, real numbers, char, and Boolean.
Question
Integers are a specific subset of positive and negative numbers.
Which of the following are integers?
Options:
1. 1
2. -1.5
3. -1348
4. 5
Answer
Integers are positive and negative whole numbers, for example 1, -1348, and 5.
Option 1 is correct. Integers are positive or negative whole numbers that is, non-decimal numbers.
For very large whole numbers, programming languages support long types. Longs are 4 bytes in
length, whereas int types are 2 bytes.
Option 2 is incorrect. You cannot store decimal numbers in an integral type. You can, however, cast
a decimal number to an integer, in which case you will lose the decimal portion of the number. You
do this in Java, for example, with code like int myInt = (int) 2.34.
1128

Option 3 is correct. -1348 is within the range of integral values, so there is no data loss in storing
this as an integer. You should familiarize yourself with the value limits of each data type, rather than
relying on compilers to warn you they don't always.
Option 4 is correct. Generally, any integral multiple of an integer is, itself, an integer, allowing for the
natural limits of each data type. Thus, trying to store 12 divided by 5 as an integer, will result in
either a compiler warning or a runtime error. To avoid this situation, you can use casting.
Question
Real numbers are a subset of positive and negative numbers.
Select the real numbers from the list.
Options:
1. 0.25
2. 4
3. 4.0
4. -6.378
Answer
Numbers with fractional parts and whole numbers expressed with decimal points are known as real
numbers. Real numbers include 0.25, 4.0, and -6.378.
Option 1 is correct. Real numbers can be positive or negative, and they form a continuous range,
about zero. In particular, every number between -1 and 1 is a real number, including -1.0, 1.0, and
0.0. In this sense, the set of integers is a subset of the set of real numbers.
Option 2 is incorrect. In programming terms as distinct from mathematical terms 4 is treated
differently from 4.0 because 4.0 represents a float or a double data type and 4 is a proper
integer.
Option 3 is correct. When a compiler sees a decimal specified, it knows that the number should be
treated as a real number. Memory space is allocated, in this instance, to allow 4.0 to change to 4.12,
for example. Integers, like 4, cannot be freely manipulated in this fashion.
Option 4 is correct. You can store practically any length decimals as real numbers, for use in
engineering and scientific applications. Precision is a function of the chipset. For example, when
Pentium 3 first came out, there was a floating point bug that affected precision at the sixty-fourth
decimal.
Question
A variable may be made up of a number of characters.
1129

What is a variable made up of a number of characters called?
Options:
1. String
2. Operand
3. Operator
4. Float
Answer
A variable made up of a number of characters is called a string.
Option 1 is correct. In Java, for example, there is a String data type built into the language. The
Java designers considered string types to be important enough to make them a native data type.
You also have string libraries for C++ and other languages. These libraries facilitate string
manipulation. Normally, strings are treated as character arrays.
Option 2 is incorrect. An operand is any value acted upon by an operator such as *, /, +, and -. For
example, in the operation A+B, both A and B are operands of the addition operation. An operand
must comply with rules of the particular operation being processed. For example, a division
operation is only allowed where the denominator operand is nonzero.
Option 3 is incorrect. Apart from the standard arithmetic operations, programming languages allow
for custom operations, such as bitwise manipulation using the OR, XOR, and AND operators. In
C++, for example, you can even redefine operators to suit your objects a feature deliberately
excluded in Java's design.
Option 4 is incorrect. Floating point numbers or decimal numbers are a feature of all modern
programming languages. They are described by the float and double data types. While they store
numbers rather than characters, in Java there are specially designed values to denote positive and
negative infinity NaN and -NaN, respectively.
Question
Booleans are used to test whether an expression is true or false.
See if you can complete the statements to identify which value is indicated by what number.
Options:
1. true
2. false
Targets:
1130

A. Booleans indicate_with a value of 1.
B. Booleans indicate_with a value of 0.
Answer
Booleans indicate true with a value of 1, and they indicate false with a value of 0.
In C and C++, booleans record true and false values. True has the value 1. Boolean conditions are
used to perform code branching, depending on input values. For example, to print out all invoices
with numbers between 100 and 200, you might use the code if (invNo >= 100 && invNO <=
200) print(invNo);. The conditional expression evaluates either to true or false (1 or 0). That
is, a given invoice number is either in the range or it isn't. In Java, you use the keywords true or
false, instead of 1 and 0.
Sometimes, you need to use code to test for negative conditions. That is, you are interested in an
event set that doesn't satisfy a supplied condition. In these cases, you can use the ! operator to test
boolean expressions. For example, to divide by a random variable, you might use the code if
(!(d==0) print(n/d);. This code performs a division only if the denominator is not equal to 0.
Note that true is equal to !false.
















1131

Variables, Constants, and Data Types
Learning Objectives
After completing this topic, you should be able to
recognize how to create a variable
recognize the conventions for naming a variable
identify the types of data stored in variables
1. Creating variables
At the simplest level, a program is a set of instructions that processes inputs and outputs. Input
data can take many forms and can come from various sources. For instance, data can be
captured from keyboard or mouse input.
Graphic
The diagram of a program shows the input of data from a keyboard or mouse, for example that
is then processed. The data can be saved to and retrieved from storage. The processing of the data
produces output in the form of information. This output can be displayed on a screen or printed on
paper.
Input data is stored in a computer's memory and is accessible to a program via its memory
address. However, memory addresses are represented in hexadecimal format and are very
unwieldy for humans to use.
Variables solve this problem by assigning user-friendly names to data. A program then performs
the hard work by keeping track of each variable in memory.
The trade-off for this convenience is reduced processing speed. Every time you want to read a
variable's data from memory, a computer has to look up the memory address to access the
data. However, some programming languages like C++ and Assembler allow you to access
data directly using its memory address.
Programming languages also support the use of constants, which is data that is set and remains
the same while a program runs. One example of a constant could be the mathematical number
pi.
Creating a variable usually involves three steps:
declaring the variable
1132

Naming a variable is known as declaring the variable. All variables have names that you use to
access the data they store. The name of a variable should describe the data it will contain, but
must also adhere to specific naming conventions.
defining the data type, and
A data type defines the kind of data a variable can contain, which can include text, special
characters, or numbers. Most programming languages require that a variable be assigned a
certain data type. This helps ensure that data is stored correctly and prevents incompatible types
of data from being used together.
initializing the variable
The process of assigning data, or a value, to a variable so it can be stored in memory is known as
initializing the variable. A variable can typically contain only one piece of data at a time. If you
assign another value to it, the new value will replace the existing data. One way around this,
however, is to use arrays, which are designed to store a number of variables together under the
same name.
It's best practice to declare variables at the start of code. However, some programming
languages do allow you to declare variables anywhere in code, as long as they're declared
before they're used.
Each variable must be given a unique name to ensure that the correct data is stored and can be
retrieved using that name.
Computer memory used to be relatively expensive, which meant that variables were typically
given very short names to save on space. Simple variable names like X or Y were commonly
used.

This made it difficult to remember which variable names represented which values, and you had
to go back and check your source code to figure out what a particular variable was used for.

Modern variable names, however, can be longer and more descriptive.
Code
Dim markupPercentage As Integer = 10
When naming variables, it's important to adhere to three basic naming conventions:
a variable name shouldn't consist of any keywords that are reserved in the programming language you're
using
a variable name can't begin with a number, and
a variable name can't contain special characters that are disallowed by the programming language
1133

Keywords have particular code meanings in programming languages and so may not be used
as variable or constant names. For example, FOR is a keyword in BASIC and var is a keyword
in PASCAL. Neither of these words could be used as constant or variable names in the
respective languages.
Variable or constant names may not begin with digits or certain characters. For example, the
variable name "2ndName" wouldn't be allowed because it begins with a digit. Instead you could
name this variable "name2."
Certain languages don't allow the use of special characters. BASIC, for example, doesn't allow
the use of characters such as the asterisk (*), plus sign (+), or parentheses (()). Using these
characters would result in errors.
To make variables easier to distinguish, you can name them using strings of words that describe
the data they store.
For example, if your program needed to calculate sales totals using Value Added Tax, you could
combine the words to name a variable "valueAddedTax."
Two casing styles commonly used in programming are
camel case, and
When you string together a name using camel casing, the first letter of the variable name is
written in lowercase. The first letter of each subsequent word is written in uppercase. An example
is valueAddedTax.
Pascal case
Pascal casing is similar to camel casing except that the first letter of each word, including the first
word, is written in uppercase. An example is ValueAddedTax.
Some programming languages like C++ are case sensitive, so it's important to be consistent
with capitalization throughout the program. For example in C++, you can use both
ValueAddedTax and valueAddedTax as variable names. However, C++ will assume that you're
referring to two different variables.
The maximum length of a variable name depends on the programming language being used. In
PASCAL, for example, the maximum length is 32 characters.
Question
Which naming conventions apply to variable names?
Options:
1. They can't consist of keywords
1134

2. They can't begin with a number
3. They can't contain special characters
4. They must be at least eight characters long
5. They have to start with a capital letter
Answer
Option 1: Correct. Variable names can't be keywords, which have particular code meanings in a
programming language and are reserved for performing specific functions.
Option 2: Correct. Variable names can't begin with numbers, although they can contain numbers.
Option 3: Correct. Variable names can't contain special characters that are disallowed by the
programming language you're using.
Option 4: Incorrect. There is no minimum limit on the number of characters in a variable name.
However, a maximum length restriction may be imposed by the programming language.
Option 5: Incorrect. Variable names can start with uppercase or lowercase letters. In languages that
are case-sensitive, you need always to use the same capitalization when naming and referring to a
particular variable.
Correct answer(s):
1. They can't consist of keywords
2. They can't begin with a number
3. They can't contain special characters
2. Data types and values
Variables can contain various types of data, ranging from character strings and numbers to
combinations of strings and numbers.
Data can take the form of
numbers
A variable of the Integer data type can store whole numbers. You can use different sub-types
depending on the size, or length, of the numeric data you need to store. For example, a variable
of the Byte data type is 8 bits long and can store numbers from 0 to 255.

Another sub-type is also called Integer and is usually declared using int. This stores a larger
integer number range than the Byte data type, but less than the Long integer data type, which
can store the largest range of integer numbers.

1135

The Real data type stores floating point numbers, which are numbers that have decimal values.
There are two Real sub-types Single Precision and Double Precision. A Single Precision
variable requires 4 bytes of storage and a Double Precision variable uses 8 bytes.
text, or
The String data type is the main data type you'll use for text and can house a virtually unlimited
number of characters at a time. It can store letters, special characters, and numbers.

It's important to note than even though you can store a number in a String variable, you can't then
use this number in a calculation. You'd have to convert the String variable to the Integer or Real
data type before doing so.

A variable of the Char data type can store only one character at a time.
Boolean values
The Boolean data type includes two values such as 0 and 1, or true and false to represent
logical conditions. When you assign a value to a Boolean variable in programming, you typically
use the term true or false.

Note that if you enclose either value in quotation marks using "true", for example it will be
interpreted as a literal string. If you do this for a Boolean variable, a program will return an error.
The sizes of the numerical data types and the range of numbers they can store depend on the
programming language you use. It's advisable to research this before you start writing a
program.
Some programming languages define subsets of the basic types of data. In PASCAL for
example, the Long, Short, and Unsigned data types are variations of the basic Integer data type.

Also, some languages use different names for the same types of data. For instance, numbers
with a decimal point are of the Real type in PASCAL but are defined as of the Float type in C.
Both the Real and Integer data types can be positive or negative. Values without a minus sign
are assumed to be positive values.
It's important to find the right data type for the data you want to store. This helps ensure that the
data is correctly identified and used. It also enables you to be economical with storage space
and memory.
If you want to store a person's age in a variable, for example, using the Integer sub-type would
be unnecessarily large. In this case, the Byte data type would be more efficient.

Similarly, if you use a variable of the Byte data type to store a phone number, only the first few
digits of the number will be saved and the rest will be discarded. And if you use a variable of the
Integer data type to store a real number, the decimal value of the real number will be discarded.
1136

Question
Which data types can contain only numerical values?
Options:
1. Integer
2. Real
3. Char
4. String
Answer
Option 1: Correct. You can store only whole numbers in variables of the Integer data type.
Option 2: Correct. You can store real and whole numbers in a variable of the Real data type, but a
whole number will have two decimal digits added to its end.
Option 3: Incorrect. You can store only ASCII characters in a variable of the Char data type.
Option 4: Incorrect. You can store text, special characters, and numbers in a variable of the String
data type.
Correct answer(s):
1. Integer
2. Real
Many programming languages perform an operation called type-checking, which validates data
to ensure that the data is compatible with the associated variable's data type.
Type-checking returns an error if a program attempts to store data that doesn't match the
variables data type, like trying to store a text string in a number variable. To prevent type-
checking errors, the programmer writes code to validate input and thus filter out potentially
troublesome data.
For example, if you've declared a variable that stores a person's age, you should write
commands that validate the age number input by the user. You would need to create a function
that checks if the input number is a positive number and below or equal to the maximum age
humans are generally expected to reach. Failure to program these input checks often lead to
type-checking errors.
Variables are initialized when values are assigned to them. It's good practice to assign a value
to a variable when you declare it, even if this is a zero for a numerical variable or "" for a string.
1137

Note
Some programming languages will automatically assign 0 or "" for a string if you don't assign a
value when declaring a variable.
The way that values are assigned to variables differs from one programming language to
another. In C and C++, for example, you specify a data type, then the variable name, and then
the variable's initial value in parenthesis.
Code
int i(0);
In Java and JavaScript, you use var followed by the variable name. You then include a colon
and specify the data type. Finally you assign an initial value using an equals sign.
Code
var i:int = 0;
Note
In C, C++, Java, and JavaScript, the end of any line is indicated by a semi-colon (;).
In Visual Basic, you use Dim followed by the variable name. You follow this with As and the
variables' data type, an equals sign, and then the value you want to assign to the variable.
Code
Dim i As Integer = 0
When you assign a string value to a variable, you enclose the text in quotation marks.
Code
String FirstName("");
Say you're using C++ to write a program and want to store the name John in a string variable
named FirstName. You start by declaring the data type and the variable name, and follow it with
the value, in quotation marks and inside parentheses.
Code
1138

String FirstName("John");
Question
Which are valid variable declarations in C++, JavaScript, or Visual Basic?
Options:
1. Boolean status(true);
2. var status:Boolean = true;
3. Dim status As Boolean = true;
4. Boolean status = "true";
5. var status:Boolean = "true";
Answer
Option 1: Correct. In C++, you declare a variable by specifying its data type, then its name, and
then its value in parentheses.
Option 2: Correct. In JavaScript, you declare a variable by specifying the var keyword, followed by
the name of the variable, a colon, the variable's data type, an equals sign, and finally the value you
want to assign to the variable.
Option 3: Correct. In Visual Basic, you declare a variable with Dim, followed by the name of the
variable, the As operator, the required data type, and an equals sign followed by the initial value of
the variable.
Option 4: Incorrect. The Boolean data type can accept only true or false as its value. When
either of these values is enclosed in quotation marks, it's identified as a string value and can't be
stored in the Boolean data type.
Option 5: Incorrect. If you use quotation marks while assigning a value, you indicate that the value
is a string. However, the Boolean data type doesn't accept strings. It accepts only true or false,
without the quotation marks, as values.
Correct answer(s):
1. Boolean status(true);
2. var status:Boolean = true;
3. Dim status As Boolean = true;
1139

Summary
The data processed by programs is stored in variables or as constants. A constant is declared at
the beginning of a program and is a value that remains unchanged, whereas the value of a
variable can change during normal program execution. To create a variable, you declare it by
naming it, define its data type, and initialize it by assigning it a value. You need to adhere to a
number of naming conventions for variables to ensure correct program execution.

Programming languages use a number of data types and sub-types to identify which data
particular variables can store. It's important to set variables to the correct data types so that
values are stored correctly, and for program efficiency. Many programming languages provide
type-checking, which raises an error if the wrong data type is assigned to a particular variable.
Properly written programs include code to validate input data thus preventing type-checking
errors.



















1140

Expressions and Statements
Learning Objectives
After completing this topic, you should be able to
identify the functions of mathematical and comparison operators
recognize how operators are evaluated
1. Mathematical expressions and operators
Expressions and statements form a large part of developed applications. An expression is a
combination of operators and operands that determines a value. This example expression
shows 22 divided by 7.
Graphic
An example is 22 / 7.
A statement is an instruction in a computer language that performs a task. Assignment
operators are used to instruct the program to assign values to data. In the example, the variable
X equals 3.14.
Graphic
An example is X = 3.14.
You can use an expression with a statement to calculate a value and store it in a variable. When
you do this, the variable name is always placed on the left of the operator. The expression is
written on the right of the operator. In the example X equals 22 divided by 7, X is the variable
and 22 divided by 7 is the expression.
Graphic
An example is X = 22 / 7.
The simplest operator is the equals sign, or =. It's used to assign values. In this example, the
variable variableOne is assigned the value 22. You can assign a numerical or string value, or
the result of a mathematical expression, to a variable.
Graphic
The example is variableOne = 22.
1141

The term operands refers to everything in a statement that isn't an operator. In this example,
variableOne and 7 are operands, whereas = and / are operators.
Graphic
The example is result = variableOne / 7.
Assignment operators in a program function differently from operators in mathematics. In
programming, the compiler returns an error because it will try to assign the value on the right of
the operator to the expression on the left. In this example, X multiplied by 2 equals 10.
Graphic
An example is X * 2 = 10.
To remedy this, the statement is written the other way around with the expression on the right of
the assignment operator. In this case, the example is changed to X equals 5 multiplied by 2.
Graphic
The example is changed to X = 5 * 2.
You can assign a new value to a variable by using it as an operand in the expression and
performing an operation on it. In this example, X equals X multiplied by 2. If X has an initial value
of 10, the new value of X will be 20 when the statement is executed.
Graphic
The example is X = X * 2.
The operators you'll use most often are mathematical operators.
()
Parentheses are used to prioritize expressions within other expressions. The result of an
expression in parentheses is used as an operand in the main expression. Operators and terms
within parentheses are evaluated according to standard operator precedence. In the example p
= (X + 2) / 7, the expression in parentheses, X + 2, is prioritized.
The example shown is p = (X + 2) / 7.
^
The caret symbol is the exponentiation operator. It's used to multiply a number exponentially a
specified number of times. In the example s = p * r ^ 2, r is the base number and 2 is the
1142

exponent.
The example s = p * r ^ 2 is shown.
*
The asterisk is the multiplication operator, used to multiply one number or variable by another. As
in the example, d equals r multiplied by 2.
The example d = r * 2 is shown.
/
The forward slash character is used for division operations using integers or floating point
numbers. The result will be rounded to an integer if p is an integer data type, otherwise, the result
will be a Real number with a quotient. In the example, p equals X divided by 7.
The example is: p = X / 7.
\
The backslash character is used for integer division operations. Integer division returns a whole
number and any decimal value will be discarded, even if the result is stored in a variable of the
Real data type. In the example, q equals the integer value of 22 divided by 7, q has a value of 3
once the statement is executed.
The example q = 22 \ 7 is shown.
+
The plus sign is used for addition operations. In this example the value of X is replaced by the
result of the expression X plus 2. If you have an expression like X = 10 + -2, the result will be
8.
The statement X = X + 2 is shown.
-
The minus sign is used to subtract one number or variable from another. If you use two -
characters, like in Y = 22 -- 7, the operation will be changed to addition and Y will be 29.
The example is Y = 22 - 7.
%
A modulo operation divides one number with another and returns the remainder. In the example Z
equals Y % 2. if Y is 15, Z will have the value of 0.5 when the statement is executed. The
percentage symbol represents a modulo operation in languages such as C#, Java, and Visual
Basic. In other languages, the mod command is often used.
Two examples are shown Z = Y % 2 and Z = Y mod 2.
Programming languages use particular rules of precedence when there's more than one
operator in an expression. Operations will be executed in this order:
1. expressions in parentheses
2. exponentiation
3. multiplication and division
1143

4. integer division
5. modula, and
6. addition and subtraction
Operators that use two different operands to produce a result are called binary operators.
Graphic
The example is:
int a;
int b;
int c;

a = 10;
b = a++;
c = --b;

The three integer declarations are highlighted.
In C++, you can use unary operators, which operate on a single operand. You can use either ++
to increment a value by one, or -- to decrement a value by one. The result of using these
operators in statements depends on which side of the operand you place them on.
Graphic
The highlighted example is a = 10.
Note
C++ was developed from C and gets its name from the ++ operator, which essentially means "one
more."
In the first example, the unary operator is on the right so when this expression is executed, b
equals 10 and a is increased to 11. This is because the value of b is assigned before the unary
operation is performed.

If the unary operator is written on the left of the operand, the unary operation is performed
before the value is assigned. So in the second example, both b and c will be 9 because the
value of b is decreased before it's assigned.
Graphic
1144

The highlighted examples are:
b = a++;
c = --b;
Mathematical operators are used to change numbers but comparison operators are used to
compare values. The result of a comparison is returned as a Boolean value either true or
false.
Graphic
Example of comparison operators include = or == which means equal to, <> or != =which means not
equal to, < which means less than, > which means greater than, <= which means less than or equal
to, and >= which means greater than or equal to.
Comparison expressions are often used to make decisions on which step a program should
perform next.
There are a number of comparison operators.
Graphic
The example is a = 12, b = 10, and c=10.
= or ==
The equal comparison operator is denoted by one or two = signs. You use it to check whether
two values are equal. The single = sign is usually used to assign a value, but in some languages
this is also a comparison operator. In Java, JavaScript, and C++, == is distinguished as the equal
operator. In this example, the expression will be true.
The example is b == c. Both b and c equal 10.
<> or !=
The not equal to operator is represented by the <> or != set of characters, depending on the
programming language. You use it to check if one value is not equal to another. In this example
the expression will be true.
The example is a != c. Variable a = 12 and variable c = 10.
<
The less than operator is represented by the < sign. You use it to check if the operand on the left
of the operator is less than the one on the right. In this example, the expression will be false.
The example is a < b. Variable b = 10 and variable a = 12.
>
The greater than operator is represented by the > sign. You use it to check if the operand on the
left of the operator is larger than the one on the right. In this example, the expression will be
1145

true.
The example is a > c. Variable a = 12 and variable c = 10.
<=
The less than or equal to operator is represented by the <= set of characters. You use it to check
if the operand on the left of the operator is less than or equal to the one on the right. In this
example, the expression will be true.
The example is b <= c. Both b and c equal 10.
>=
The greater than or equal to operator is represented by the >= set of characters. You use it to
check if the operand on the left of the operator is greater than or equal to the one on the right. In
this example, the expression will be true.
The example is a >= b. Variable a = 12 and variable b = 10.
You can also use comparison operators to compare strings. Each character corresponds with a
numerical value in the ASCII character set used by computers. When you compare two
characters, the ASCII or Unicode numerical values of the characters are compared. In the
example, "j" is greater than "J".
Graphic
The example is "j" > "J".
In this example, the ASCII values for the characters are shown. The expression 106 > 74 will
return true.
Graphic
The examples are "j" > "J" and 106 > 74.
When comparing two strings, a program compares each character in one string with the
character in the same position in the other string. If the first characters are the same, it moves
through the strings one character at a time until a true or false result is achieved. The
example 74, 75 > 74, 107 will return false when the expression is executed.
Graphic
The examples are "JK" > "Jk" and 74, 75 > 74, 107.
Programming languages also use Boolean operators to calculate Boolean values. Because the
results of Boolean expressions are either true or false, they are often used with comparison
expressions to return the results of the comparisons.
1146

Most programming languages use four main Boolean operators.
AND
The AND operator compares two Boolean values and returns a single Boolean value. If both
values are true, it returns true, but if one or both is false, it returns false. In this example,
payment = 550, therefore both comparison expressions will return true, so the result of this
Boolean expression will also be true.
The example shown on screen is:
(payment < 650) AND (payment > 450)
OR
The OR operator is the opposite of the AND operator and will return true if any of the compared
values are true. For a false result, both Boolean values have to be false. In this example,
payment = 550, therefore the second comparison expression is true, so the result will also be
true.
The example is (payment < 450) OR (payment >= 500).
XOR
The XOR operator, also known as the exclusive or operator, returns a true value if one but not
both of the operands is true. So if you compare two true or two false values, the result will be
false but if one value is true, it returns true. In this example, payment = 500, therefore
the first expression is false and the second true, so the result will be true.
The example is (payment != 500) XOR (payment == 500).
NOT
The NOT operator changes a Boolean value to its opposite. In this example, payment = 500,
therefore the result will be false because the comparison expression is true.
The example is NOT (payment < 650).
An example in which Boolean operations are used is an automated road toll system where
drivers buy credit before using a road. In this example, a car is allowed through with true
expression results.
Graphic
The example statements are
restricted = false;
registered = true;
credit = false;
VIP = true;
When a driver approaches, the first evaluation determines whether the car is restricted and so
not allowed to enter the toll road. If it's NOT restricted, the program passes to the next
evaluation.
1147

Graphic
The statement is NOT(restricted).
Then if a car is registered AND has available credit, it's allowed to pass. In addition, if credit is
false but the car is marked as VIP, the car will be allowed through as result of the OR
operation.
Graphic
The statement is (registered AND credit) OR VIP.
Along with basic mathematical operators, most programming languages have built-in math
functions for performing more complex calculations. Functions like square root or logarithm are
either incorporated natively or can be added using math libraries.
These functions work on the same principles as other programming functions and take
numerical values as parameters.
Graphic
An example is X = sqrt(360).
Question
Match the mathematical and comparison operators with their descriptions.
Options:
A. ^
B. \
C. /
D. %
E. !=
F. <
Targets:
1. Multiplies a number exponentially
2. Divides a number into another and returns a whole number
3. Divides a number into another and returns a real number with a decimal value if the variable has been
assigned as Real
4. Computes the remainder of a division operation
1148

5. Compares two values and checks if they aren't equal
6. Compares two values and checks if the first is smaller than the second
Answer
You use the caret symbol, or exponentiation operator, to multiply a number exponentially.
You use the backslash for integer division. It returns a whole number and discards decimal values.
You use the forward slash for division. It returns a real number with a decimal value if the variable
has been assigned as Real.
You use either the percentage symbol or mod keyword to divide two numbers and return the
remainder.
You use != or <> for not equal comparison operations. The result is returned as a Boolean value.
You use the less than symbol to check whether one value is smaller than another. The result is
returned as a Boolean value.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
Target 6 = Option F
2. Operator precedence
Operators are evaluated in a specific order according to operator precedence. This means that
certain operators have precedence over others when written in an expression.
Operators between parentheses are given the highest precedence, and the results are used for
further calculations. Terms within parentheses are evaluated according to standard operator
precedence.
Two common mnemonics can help you remember the order of operator precedence:
PEMDAS, and
1149

PEMDAS is an acronym for parenthesis, exponentiation, multiplication, division, addition, and
subtraction.
BEDMAS
BEDMAS is an acronym for brackets, exponentiation, division, multiplication, addition, and
subtraction.
Integer division and modulo are omitted from this list because these are more obscure operators
and not often used in programming.
The words "brackets" and "parentheses" are interchangeable and have the same meaning. The
order in which multiplication and division, or addition and subtraction occur is also irrelevant,
because the results will be the same.
If operators in an expression have equal precedence, calculation occurs from left to right.
Say you want to buy something from a web store based in another country. You want to
calculate the total cost in dollars before buying the item.
Graphic
Two expressions are shown - unitCost equals unitPrice plus shipping, and dollarValue equals
unitCost multiplied by exchangeRate. These are represented as:
unitCost = unitPrice + shipping
dollarValue = unitCost * exchangeRate
You can use two expressions to do this, but combining them into one expression would be more
efficient. If the two expressions are simply combined, however, you won't get an accurate
answer because operator precedence dictates that multiplication will occur before addition.
Graphic
The expression dollarvalue equals unitPrice plus shipping multiplied by exchange rate. This is
represented as dollarValue = unitPrice + shipping * exchangeRate
If you add parentheses to the first expression, the cost of shipping the unit will be added to the
unit price before the exchange rate is multiplied. This will return the correct answer.
Graphic
The expression dollarvalue equals open parenthesis unitPrice plus shipping closing parenthesis
multiplied by exchange rate. This is represented as dollarValue = (unitPrice + shipping) *
exchangeRate
1150

You can construct complex statements as long as you factor in operator precedence.

Say you want to find the exponential result of a base value using a variable exponent. Currently
the value of the exponent is 2.
Graphic
The expression is exp = 2.
When the statement in this example is executed, value will be 100 because the ++ unary
operation will occur only after the exponential operation is performed.
Graphic
The expression is value = 10^exp++.
However, if you include parentheses in the expression, value will be 1000 because the
operation inside the parentheses will be performed before the exponentiation operation.
Graphic
The expression is value = 10^(exp++).
Strings play a major role in computer programming. As with numbers, you can perform addition
and subtraction operations on strings.
Some programming languages also enable you to search a string for a character or set of
characters, and replace or remove them.
More complex operations are usually performed using functions, but some operators will also
work with strings.
Say you want to print a person's name on the screen.
Graphic
Two variable values are shown FirstName = "Emily" and LastName = "Novak".
To do this, you add the two variables to form a new string variable, and print this to screen. It's
important to remember to add a space between the variables, which you do by using a set of
quotation marks surrounding a space.
Graphic
1151

The example statements are person = FirstName + " " + LastName and PrintToScreen person.
Alternatively, you can combine the two statements into one print statement.
Graphic
The example statement is PrintToScreen FirstName + " " + LastName.
You can also add text to an existing string variable using the addition operator.
Graphic
The expression Name equals FirstName plus Novak. This expression is represented as Name =
FirstName + " Novak".
Question
Using standard operator precedence, match each expression with the correct result.
Options:
A. X = 8 - 3 + 7
B. Y = (34 + 7) * 89
C. Z = 7 + 7 * 7
D. V = 882 / 3^2
Targets:
1. 12
2. 3,649
3. 56
4. 98
Answer
In this statement, the - and + operators have equal precedence. So the expression is simply
calculated from left to right.
In this statement, the expression between parentheses takes precedence. So the result is calculated
as 41 multiplied by 89.
In this statement, the multiplication operator takes precedence. So the result is calculated as 7 plus
49, which equals 56.
1152

In this statement, the exponentiation operation takes precedence. So 882 is divided by 9 to give the
result of 98.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Summary
Programs typically contain a large number of expressions and it's vital that they're accurate. A
number of different types of operators are used to form expressions. Of these, mathematical
operators are the most common. A number of mathematical functions are also generally
available. Comparison operators are used to compare two values and return a Boolean value. In
programming, Boolean operators are most often used for decision making.

It's important to know the rules of operator precedence when creating expressions. Two
common mnemonics for remembering these rules are PEMDAS and BEDMAS. In some
languages, you can manipulate strings in ways similar to those you use to manipulate numerical
values.













1153

Building Expressions
Learning Objectives
After completing this topic, you should be able to
recognize how variables, operators, and values are used to construct expressions
recognize how to build expressions
Exercise overview
In this exercise, you're required to demonstrate a basic understanding of variables and
expressions in programming.
This involves the following tasks:
recognizing how to declare variables, and
recognizing how to build expressions
Declaring variables
Question
Which term describes data that is preset and remains unchanged during processing?
Options:
1. Constant
2. Variable
3. Operator
Answer
Option 1: Correct. A constant is a value that is declared in source code and remains unchanged
during processing.
Option 2: Incorrect. A variable is a placeholder for data that is declared in the source code. The
value it stores can change during program execution the variable may receive a value from user
input or as the result of an expression.
Option 3: Incorrect. An operator is a character that represents a mathematical or logical operation
to be performed on data.
Correct answer(s):
1154

1. Constant
Question
Which variable names follow the standard naming conventions?
Options:
1. secondNumber
2. SecondNumber
3. 2ndNumber
4. second()
5. *Numbers
Answer
Option 1: Correct. It's acceptable to write a variable name with an initial word in all lowercase and
subsequent words beginning with an initial uppercase letter. This is known as camel case. The
name in this example also doesn't violate any other conventions for variable names.
Option 2: Correct. It's acceptable to include an initial capital for each word in a variable name. This
is known as Pascal case. The name in this example also doesn't violate any other conventions for
variable names.
Option 3: Incorrect. Variables may not start with a number. You can add the number after the name
if required.
Option 4: Incorrect. Parentheses, or brackets, aren't allowed in variable names.
Option 5: Incorrect. The asterisk is a special character it's used as an operator in programming
languages and so can't be included in the names of variables.
Correct answer(s):
1. secondNumber
2. SecondNumber
Question
Match each data example with its data type.
Options:
A. true
1155

B. 254
C. a
D. 17.2553
Targets:
1. Boolean
2. Byte
3. Char
4. Real
Answer
The Boolean data type can represent true or false values. It stores 1 or 0 to reflect the value.
The Byte data type can store up to eight bits of data and a number in the range from zero to 255.
You can also save the number 254 in a variable of the Integer type, but good programming
conventions dictate that the size of the data type should be as closely matched to the value as
possible.
The Char data type can store a single character at a time. You can also use the String data type for
this value but if the value of this variable will always be only one character, using Char is the better
solution.
The Real data type can store real numbers that have decimal values. Whole numbers can also be
stored, but will be written with a decimal value of .0.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Question
When you name a variable, what are you actually doing?
Options:
1. Declaring the variable
2. Initializing the variable
1156

3. Validating the data type
Answer
Option 1: Correct. When you declare a variable, you give the variable a name and specify its data
type.
Option 2: Incorrect. A variable is initialized when it's given a value. Some programming languages
will assign 0, or "" for strings, if you don't assign a value explicitly.
Option 3: Incorrect. Data type validation is done automatically by a programming language when
data is entered.
Correct answer(s):
1. Declaring the variable
Building expressions
Question
Using standard operator precedence, match each expression with the correct result.
Options:
A. 2 + 3 * 2
B. (2 + 3) * 2
C. 2 + 3 ^ 2
D. (2 + 3) / 2
E. (2 + 3) \ 2
F. 2 + 3 / 2
Targets:
1. 8
2. 10
3. 11
4. 2.5
5. 2
6. 3.5
Answer
1157

In this statement, the multiplication operator takes precedence. So the result is calculated as 2 plus
6.
In this statement, the expression between the parentheses takes precedence. So the result is
calculated as 5 multiplied by 2.
In this statement, the exponentiation operator takes precedence. So the result is calculated as 2
plus 9.
In this statement, the expression between the parentheses takes precedence. So the result is
calculated as 5 divided by 2.
In this statement, the expression between the parentheses takes precedence. The backslash
character is used for integer division operations and returns the integer value of 5 divided by 2,
which equals 2.
In this statement, the division operator takes precedence. So the result is calculated as 2 plus 1.5.
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
Target 6 = Option F
Question
Identify the order in which the components of expressions are evaluated, from first to last.
Options:
A. Expressions in parentheses
B. Exponentiation
C. Multiplication and division
D. Addition and subtraction
Answer
Correct answer(s):
1158

Expressions in parentheses is ranked the first place.
Parentheses take precedence over all other operators, so the expressions they contain will
always be evaluated first.
Exponentiation is ranked the second place.
Operations involving exponentiation are performed after any expressions in parentheses have
been evaluated, but before operations involving multiplication or division.
Multiplication and division is ranked the third place.
Multiplication and division are performed after exponentiation but before addition and
subtraction.
Addition and subtraction is ranked the fourth place.
Addition and subtraction are at the lowest level of precedence and are performed last.
Data types and naming conventions for variables have been detailed and mathematical
operators have been used to build expressions.


















1159

Arrays
Learning Objectives
After completing this topic, you should be able to
recognize how to use arrays in programs
recognize how to create arrays in BASIC, C++, and Revolution
1. Using arrays
All computer programs need to store data and variables are the most common way to do this.
However, variables are limited to storing only one piece of data at a time. For example, if you
want to store an employee's first name, last name, and telephone number, you'd have to create
three variables which isn't very efficient.
Structures and arrays were created as two ways to store several pieces of related data in one
place.
Structures provide a way to group several variables, and can be described as variables that can
contain several other variables.
Arrays offer a better solution. They can be described as "super" variables to which you can add
as many pieces of related data as you want.
For example, if you want a program to store the names of all 20 employees in a company, you
can create one array to store them.
When you create an array, you need to define
a variable name
When you create an array, you have to give it a name. It's best to give arrays descriptive names
so you know what kind of data they store.
the array size, and
The advantage of arrays is that they can each hold many pieces of data. Each piece is stored in
an element of the array. When you create an array, you have to specify how many elements it will
contain. This is known as the size of the array.
the type of data you want to store
All the elements in an array must have the same data type. You specify the data type when you
create the array, although there are commands that let you convert to a different data type later.

If an array is for storing names, for example, you should specify the data type as String. Other
data types you can set are Integer and Boolean. Storing numbers is, however, not limited to the
1160

Integer data type. For example, if you want to store names and telephone numbers in one array,
you can set the data type as String and store the numbers as strings.
It's important to plan before you start creating an array so you can specify its size. You set the
size by specifying the bounds of an array. The lower bound defines the number of the first array
element and the upper bound defines the number of the last array element.

Depending on which program language you're using, the default lower bound can be either zero
or one. It's important to know what the default lower bound is so that you can specify enough
elements for your data.
Programs such as BASIC, Java, and C and any language derived from the C language
always define the lower bound of an array as zero. These are called zero-based arrays. To
specify the number of an element, you have to start counting at zero.
Other programs use one-based arrays. To set the size of a one-based array, you have to start
counting at one.
Some programs, such as Pascal, enable you to define both the lower and upper bounds of an
array. The advantage of this is that the lower bound doesn't have to start at zero or one, but can
start at any number you want.
This is useful when you want to link each element to a meaningful number. For example, if your
company uses employee numbers and you're creating an array to store employee names, you
can set the lower bound to correspond to the first employee number.
Most arrays are one-dimensional and store data in the form of a list. So they are defined only in
terms of their length.
You can, however, create multi-dimensional arrays. These are more flexible and enable you to
store more complex data.

The most common multi-dimensional array is a two-dimensional array, which can be
represented as a grid with either two columns or two rows.
You can create arrays that are two-, four-, or even nine-dimensional. But the more dimensions
arrays have, the more complex they are. With too many dimensions, working with arrays can be
rather confusing.
Question
Identify what you need to specify when creating an array.
Options:
1. A name for the array
1161

2. The size of the array
3. The type of data the array will store
4. How the data will be entered
5. The language used for data in the array
Answer
Option 1: Correct. When you create an array, you need to give it a name preferably a name that
describes the data it will store.
Option 2: Correct. When you create an array, you have to specify how many elements it should
contain.
Option 3: Correct. All the elements in an array must have the same data type, which you need to
specify when you create the array.
Option 4: Incorrect. You don't have to consider how the data will be entered when creating an array.
You need to give an array its name and specify its size and data type.
Option 5: Incorrect. You don't need to specify language settings when creating an array, although
you do need to consider what type of data the array will contain so you can specify the right data
type.
Correct answer(s):
1. A name for the array
2. The size of the array
3. The type of data the array will store
2. BASIC, C++, and Revolution
Although the general method for creating an array is the same no matter which programming
language you use, some of the details vary.
To create arrays in LibertyBASIC, you use the DIM keyword.
Code
DIM
You specify a name for the array, without using spaces or special characters.
Code
1162

DIM EmployeeNames
In LibertyBASIC, an array can accept either strings or numbers. To define the data type as
String, you need to add a dollar sign $ at the end of the array name. If you don't add the
dollar sign, the data type will be defined as Integer by default.
Code
DIM EmployeeNames$
To define the size of the array, you provide the upper bound, which defines the number of the
last array element in brackets.

Arrays in LibertyBASIC are zero-based so you start counting from zero to number the elements.
In the example, the number four indicates that the array has five elements. The first element is
zero, the second is one, and so on.
Code
DIM EmployeeNames$(4)
To create an array in REALbasic, you also use the DIM keyword.
Code
DIM
You specify a name for the array and specify the size of the array by providing the number for
the last element in brackets after the name. Arrays are zero-based in REALbasic.
Code
DIM EmployeeNames(4)
To specify the data type of the array, you use a declaration with the DIM command. After the
name and size, you simply state As and then provide the data type, such as Integer or String.
Code
DIM EmployeeNames(4) As String
To create an array in C++, you start by specifying the data type. You provide the name of the
data type, such as String or Integer.
1163

Code
String
Next you provide the array name.
Code
String EmployeeNames
You then specify the array size. C++ is different from other languages in that you specify the
number of elements in the array rather than the upper bound. Also, in C++ you specify the size
in square brackets instead of in parentheses. In the example, the number five indicates that the
array should contain five elements.
Code
String EmployeeNames[5]
Note
Arrays in C++ are zero-based so the index numbers start from zero.
The way you create arrays in Revolution is different from in the other programming languages.

You don't have to create an array in advance by declaring its name, size, and data type
before you can start adding data. Revolution enables you to add data as you create arrays using
the put command.
Code
put
Another difference is that items in a Revolution array aren't identified by an index number.
Instead Revolution identifies array items by a key, which can be any string or unique number.

In the example, the array named EmployeeNames is created. It stores the name Jonathan
Gold and associates it with the key Sales.
Code
put Jonathan Gold into EmployeeNames["Sales"]
1164

Creating two-dimensional arrays in LibertyBASIC and REALbasic is similar to creating one-
dimensional arrays. You also use the DIM keyword, specifying the array name and data type.
Code
DIM EmployeeNames$()

DIM EmployeeNames() As String
Specifying the size is different. For a two-dimensional array, you use two integers to indicate the
array's size. The first specifies the upper bound of the elements in the horizontal dimension
row of the grid and the second specifies the upper bound of the elements in the vertical
dimension column.

Because LibertyBASIC and REALbasic are zero-based arrays, you start counting from zero.
Code
DIM EmployeeNames$(2,1)

DIM EmployeeNames(2,1) As String
The first example here is in LibertyBASIC, and the second is in REALbasic. Both create a two-
dimensional array named EmployeeNames that's designed to hold six string elements. This
array could be represented as a grid with three rows and two columns.
Code
DIM EmployeeNames$(2,1)

DIM EmployeeNames(2,1) As String
Creating two-dimensional arrays in C++ is similar to creating two-dimensional arrays in
LibertyBASIC and REALbasic. However, you need to supply two values to specify the number of
elements in both dimensions of the grid. Each of these values is specified in its own set of
square brackets.

This example shows the code for creating a two-dimensional array, which has three rows and
two columns when represented as a grid.
Code
String EmployeeNames[3][2]
1165

Using Revolution, you can enter data as you create two-dimensional arrays, just as you can
when creating one-dimensional arrays.
Code
put "Jonathan Gold" into EmployeeNames[0,0]
put "Alison Baker" into NameArray[0,1]
put "Eleanor Davis" into NameArray[1,0]
put "Luke Foster" into NameArray[1,1]
put "Werner Horowitz" into NameArray[2,0]
put "Maggie Chung" into NameArray[2,1]
The difference is that where elements in one-dimensional arrays are identified with a key, you
have to define each element's place on the grid when creating two-dimensional arrays.
Revolution is a zero-based language. This means, for example, that the first element in both the
horizontal and vertical dimensions of the grid will be numbered (0,0). This example shows a
two-dimensional array called EmployeeNames that contains six name elements.
Question
Match the programming languages to corresponding examples of the statements used to create an
array. One of the languages doesn't match to a statement.
Options:
A. LibertyBASIC
B. REALbasic
C. C++
D. Revolution
Targets:
1. DIM ClassArray$(10)
2. string ClassArray[11]
3. put Pilates into ClassArray("P")
Answer
Using LibertyBASIC, you create an array of the String data type by specifying the DIM keyword, an
array name, a dollar sign which identifies the String data type, and the size of the array in
parentheses.
1166

Using C++, you start by specifying the data type and then specify the number of elements in square
brackets.
In Revolution, you can add data as you create arrays, and you identify array items by keys rather
than index numbers.
Correct answer(s):
Target 1 = Option A
Target 2 = Option C
Target 3 = Option D
3. Implementing arrays
You assign values to the elements of an array in the same way that you assign values to
variables.
In ANSI C, you can initialize the contents of an array when you declare the array. ANSI short
for the American National Standards Institute published a standard for use with C to make C
programs more portable.

The declaration in the example is used to initialize an array of vowels.
Code
char vowel [5] = {'a', 'e', 'i', 'o', 'u' };
When you want to initialize the array of vowels in BASIC or Pascal, you have to assign a value
to each element separately.
Code
vowel[1]="a"..vowel[5]="u"
To insert an element into an array that is already filled, you can copy and move all the elements
forward one place to the right of the insert position. So the very last element in the array falls
away.

If you move all the elements back one place, to the left of the insert position, the very first
element in the array falls away.
1167

This may seem easy if you have a small array with only a few elements. But for a large array
with thousands of elements, this could be an extremely cumbersome job, especially if you have
to do it regularly.
Another way to insert an element in an array is to overwrite the current array element with the
new element.

Consider an array of four integers {19,20,21,22} called year. You want to insert 0 between
20 and 21 at position 2, assuming the index numbers in the array start at zero.
The C code inserts 0 at position 2 in the array. The program starts at the end of the array and
copies the element to the left of the current position onto the element at the current position.
This process repeats until the insert position which is 2 is reached. At this point, the array
contains the values {19,20,20,21}.
Code
for (index = 3; index >= 2; index--) {
year [index] = year [index - 1];
}
The last statement in the code assigns the value 0 to the third element in the array. Now the
array contains the integers {19,20,0,21}.
Code
year [2] = 0;
Now you want to delete 20 from the array {19,20,0,21}.
You can do so by overwriting 20 with a null value.
After the code has been executed, the array contains the four values {19, ,0,21}.
Code
year [2] = 0;
To empty an array in BASIC, you can use the command ERASE. So this code replaces all the
integers in the array called "year" with null values.
Code
ERASE year
1168

In C and Pascal, you use a loop to empty an array.
Code
for (index = 0; index <= 4; index++) {
vowel [index] = "";
}
Question
Identify the correct methods for inserting an element into an array that is already filled.
Options:
1. Move all the elements up or down one place
2. Re-create the array with the new element
3. Overwrite a current array element with a new element
4. Have the array determine which item to replace
Answer
Option 1: Correct. If you move the elements up or down one place, the first or last element falls
away to make space for the new element.
Option 2: Incorrect. It's inefficient to re-create an array simply to replace an element. You can either
move the elements up or down, or overwrite the element you want to replace.
Option 3: Correct. You can insert an element in an array by overwriting the current array element
with the new element.
Option 4: Incorrect. An array can't determine which item to replace. You have to overwrite a
specified location in the array with a new value.
Correct answer(s):
1. Move all the elements up or down one place
3. Overwrite a current array element with a new element
Summary
Variables are the most common way for programs to store data but they are limited to storing
only one piece of data at a time. An array can store multiple pieces of related data in one place.
When you create an array, you give it a name and specify its size and data type.

1169

The basic method of creating an array is common to all programming languages, although the
details may differ. Some of the common programming languages are BASIC, C++, and
Revolution.

Once you've created an array, you need to implement it by assigning values to it. You assign
values to the elements of an array in the same way that you assign values to variables.
























1170

Procedures and Functions
Learning Objectives
After completing this topic, you should be able to
recognize called procedures in code examples
recognize the difference between local and global variables
1. Using procedures in programs
Most modern programs are long and complex. So it's hard to organize all the different tasks a
program must perform. To make this process a little easier, it's a good idea to divide a program
into major tasks and subtasks.
Code
Enter_competitors()
WHILE more records
GET current_date
age = current_date - date_of_birth
SET valid_age to true
IF age <18 or age >50 THEN
PRINT "You must be between 18 and 50 to enter"
valid_age = false
ENDIF
IF valid_age = true THEN
GET entrant_name
ADD entrant_name to entrant_list
PRINT receipt
ENDIF
ENDWHILE
END
Top-down design or functional programming involves identifying the tasks and subtasks in a
program. In this process, each program is broken down into modules, which are separate
elements of functionality.
Each of these modules, or procedures, should be used to perform a single, specific task. And all
the modules should work together to achieve the desired program output.
Procedures can be regarded as programs within programs. They are also known as functions or
subroutines. They can be part of a main program file or part of a separate file.
1171

Functions and subroutines normally work in exactly the same way, with a few exceptions. In
some programming languages like Visual Basic functions need to return a value but
subroutines don't.
The programmer decides where it's logical to create procedures in software. However, it's very
important that the overall program structure, as set out in the planning phase of the software
development process, is maintained.
When creating a procedure or function, you begin by deciding what task it should perform. You
also need to decide whether the procedure must return a value to the main program.
Then you can give the procedure or function a meaningful name that reflects the task it
performs. It's considered good form to begin with a verb followed by an object.

For example, a procedure that prints labels could be named "Print_labels." Procedure names
are followed by parentheses, so the full procedure would be Print_labels().
Consider writing a program to calculate the total cost of your grocery bill and to print the average
cost of each item.

You could write all the code in one programming block, as in this example. However, as a
program gets larger, it becomes more difficult to work with.
Code
Process_grocery_bill()
FOR I=1 TO no_of_items
PROMPT FOR item_cost
GET item_cost
total = total + item_cost
END FOR
Average = total/no_of_items
PRINT average
END
A more efficient approach is to create procedures for each of the tasks that has to be performed.
In this case, the first procedure accepts the cost of each item and calculates the total cost of the
bill. The second procedure calculates the average cost of the items you've purchased.
Graphic
The name of the first procedure is Get_amounts() and the name of the second procedure is
Calculate_and_print_average().
Code
1172

Get_amounts()
FOR I=1 TO no_of_items
PROMPT FOR item_cost
GET item_cost
total = total + item_cost
END FOR
END

Calculate_and_print_average()
Average = total/no_of_items
PRINT average
END

The main body of the program now simply includes calls to the two procedures.
Code
Process_grocery_bill()
Get_amounts()
Calculate_and_print_average()
END
The key benefits of creating procedures are that it enables you to
keep a main program small and nimble
If you use procedures to perform the main functions of a program, the main body of the program
will usually consist largely of function calls. It will be small and so run efficiently.
create a modular program
Each procedure is responsible for a specific task. It contains only the statements that allow it to
perform that task.

This makes debugging and maintenance of a program easier because it's easier to isolate a
problem in a single module than in a large block of code.
re-use components, and
Procedures can be reused in other programs or applications. You can store procedures in a
repository and retrieve them as they're needed.
make a program easier to understand
Using procedures makes a program much easier to read and understand, because the program
can then consist mostly of calls to these procedures which should have meaningful names that
describe the tasks they perform.

It's also much easier to locate a procedure for a program than to look for particular lines of code
1173

within all the source code.

Because the code for each procedure is separate from other procedures, it's also easier to
maintain.
When you use procedures in your programming, you should aim to ensure that the different
procedures are as loosely coupled as possible.
Coupling refers to the dependencies among the procedures in a program.

With tight coupling, many procedures are dependent on others to function well. A loose coupling
indicates that each procedure can perform well on its own, without relying heavily on other
procedures.
When procedures are very tightly coupled, a failure in one procedure could cause an entire
program to fail. When procedures are loosely coupled, this is unlikely to occur.
Question
What are some benefits of using procedures in programming?
Options:
1. It lets you create modular programs that are easier to maintain
2. It keeps a main program small and nimble
3. It makes a program easier to understand
4. It enables you to create reusable components
5. It ensures that all code is included in the main body of a program
6. It ensures that values are always returned to a main program
Answer
Option 1: Correct. Procedures break the program up into smaller sections, or modules. Each task in
a program can then be easily isolated and fixed if there are errors.
Option 2: Correct. The main program becomes simpler to maintain because it doesn't contain large
chunks of code. Instead it will consist mainly of calls to procedures.
Option 3: Correct. If you give procedures meaningful names, anyone who looks at the main
program will have a clear picture of what the program does.
Option 4: Correct. You can store procedures you've created for use in other programs.
Option 5: Incorrect. The main goal of using procedures in programming is to create a simpler main
program, which will generally include only calls to procedures rather than large chunks of code.
1174

Option 6: Incorrect. Procedures don't always need to return values to a main program.
Correct answer(s):
1. It lets you create modular programs that are easier to maintain
2. It keeps a main program small and nimble
3. It makes a program easier to understand
4. It enables you to create reusable components
2. Called procedures
A program executes each procedure as it's required.

A procedure can be called multiple times from a single program. It can also be called from
multiple locations in a program, and even from within other procedures.
Code
Enter_competitors()
WHILE more records
Calculate_age(age)
Validate_age(age, valid_age)
IF valid_age = true THEN
Add_entrant()
ENDIF
ENDWHILE
END
The flow of execution, or controlling logic, in a program is called the mainline, or main program
loop.
Code
Enter_competitors()
WHILE more records
Calculate_age(age)
Validate_age(age, valid_age)
IF valid_age = true THEN
Add_entrant()
ENDIF
ENDWHILE
END
To call a procedure, the programmer uses the procedure name as a command. In this example,
the highlighted lines of code will cause the specified procedures to be executed.
1175

Graphic
The first highlighted line is Get_amounts() and the second line is Calculate_and_print_average().
Code
Process_grocery_bill()
Get_amounts()
Calculate_and_print_average()
END Get_amounts()
The logic used depends on the type of programming, which can be either
procedural programming, or
In procedural programming, programs have a mainline procedure that ties other procedures
together and provides master control over them.

Applications are structured in terms of the actions the program must carry out and the procedures
used to implement those actions.
object-oriented programming
In object-oriented programming, or OOP, the mainline is the starting point for a program.
Examples of OOP languages are Java and C++.

OOP applications comprise numerous interacting objects, each with their own data and functions.
The data in an object is encapsulated.

In Java, the main method is always executed first. Similarly, the main function is always executed
first in C++.
Consider writing a program that adds users' names to a list of competition entrants and prints a
receipt for each entrant.

The mainline of the program is Enter_competitors().
Code
Enter_competitors()
WHILE more records
Calculate_age(age)
Validate_age(age, valid_age)
IF valid_age = true THEN
Add_entrant()
ENDIF
1176

ENDWHILE
END
When the program runs, it calls three procedures.
Graphic
The subprocedures listed are Calculate_age ( age ), Validate_age ( age, valid_age ), and
Add_entrant ().
Code
Enter_competitors()
WHILE more records
Calculate_age(age)
Validate_age(age, valid_age)
IF valid_age = true THEN
Add_entrant()
ENDIF
ENDWHILE
END
The Calculate_age() procedure is called first. So control of the program passes to this
procedure. That means that the main program halts at that point and jumps to the procedure to
execute its instructions.
Code
Calculate_age (entrant_name, date_of_birth)
GET current_date
age = current_date - date_of_birth
END
When the Calculate_age() procedure is completed, control is transferred back to the main
program. The next program instruction is then executed, In this case, it's a call to the
Validate_age() procedure.
Code
Validate_age(entrant_name.age)
SET valid_age to true
IF age <18 or age >50 THEN
PRINT "You must be between 18 and 50 to enter"
valid_age = false
1177

ENDIF
END
After this procedure has executed, control returns to the mainline. A condition is tested and, if it
evaluates to true, the Add_entrant() procedure is called.
Code
Enter_competitors()
WHILE more records
Calculate_age(age)
Validate_age(age, valid_age)
IF valid_age = true THEN
Add_entrant()
ENDIF
ENDWHILE
END
The Add_entrant() procedure completes the entry process and prints the receipt for the
competitor.
Code
Add_entrant (entrant_name, date_of_birth)
GET entrant_name
ADD entrant_name to entrant_list
PRINT receipt
END
Question
You're writing a program that checks the availability of theater tickets requested by clients. If the
tickets are available, you want the program to calculate their cost and print the results.

Which are the called procedures in this program?
Code
Process_ticket_request()
SET more_records to yes
DOWHILE more_records
get_details(no_of_tickets, section)
check_availability(no_of_tickets, section,
available)
IF available = true THEN
calculate_cost(no_of_tickets, section,
1178

price)
print_ticket(no_of_tickets, section, price)
ENDIF
ENDDO
Options:
1. get_details
2. check_availability
3. calculate_cost
4. print_ticket
5. Process_ticket_request
6. more_records
Answer
Option 1: Correct. get_details is a called procedure for checking how many tickets a person
requires.
Option 2: Correct. check_availability is a called procedure for checking if tickets are still
available.
Option 3: Correct. calculate_cost is a called procedure for determining the cost of the tickets.
Option 4: Correct. print_ticket is a called procedure for printing the tickets that have been
booked.
Option 5: Incorrect. This is the mainline of the program, rather than a called procedure.
Option 6: Incorrect. more_records is a variable rather than a procedure.
Correct answer(s):
1. get_details
2. check_availability
3. calculate_cost
4. print_ticket
3. Local and global variables
Constants in a program are values that are specified and remain the same for the entire time
that the program is running.
1179

Variables hold values that can change while the program is running. This can be due to user
input or results generated during processing.
Each variable used in a program has a given scope, which controls when and where the
variable can be used.
There are two types of variables:
Code
Process_grocery_bill()
PROMPT FOR store_name
GET store_name
Get_amounts()
END

Get_amounts()
FOR I=1 TO no_of_items
PRINT store_name
PROMPT FOR item_cost
GET item_cost
total = total + item_cost
END FOR
END
global, and
Global variables are available to procedures throughout a program, and so have a global scope.
They can be used more than once, and they can be created at any point in a main program. In
this case, store_name is a global variable.
local
Local variables are used only within a procedure and have local scope only. They aren't visible to
or usable by procedures in the rest of the program.

If you try to access a local variable outside of its specific function, you'll get an error. In this
example, total is a local variable. It can be used only within the Get_amounts()procedure.
A disadvantage of global variables is the potential problem of side effects. Side effects occur
when one procedure alters a global variable or makes other changes to its environment. If the
altered global variable is used by another procedure, the result returned by that procedure will
change. This is undesirable when you want it always to return the same result.
Code
1180

Process_grocery_bill()
PROMPT FOR store_name
GET store_name
Get_amounts()
END

Get_amounts()
FOR I=1 TO no_of_items
PRINT store_name
PROMPT FOR item_cost
GET item_cost
total = total + item_cost
END FOR
END
Side effects can cause confusion because they make it hard to identify which procedures are
changing variables. This can make maintaining and debugging code very difficult.
Code
Process_grocery_bill()
PROMPT FOR store_name
GET store_name
Get_amounts()
END

Get_amounts()
FOR I=1 TO no_of_items
PRINT store_name
PROMPT FOR item_cost
GET item_cost
total = total + item_cost
END FOR
END
One way of dealing with side effects is to use local variables whenever possible in procedures.
Code
Process_grocery_bill()
PROMPT FOR store_name
GET store_name
Get_amounts()
END

Get_amounts()
1181

FOR I=1 TO no_of_items
PRINT store_name
PROMPT FOR item_cost
GET item_cost
total = total + item_cost
END FOR
END
So the advantage of using local variables is that you won't have the problem of incorrect values
being used in different sections of a program.

Consider this example. The loop inside the function is supposed to loop ten times using the
variable i. In this instance, i is a local variable. When the loop executes, it will start at zero and
end when i is equal to 9.
Code
display()
i=0
WHILE (i < 10)
println ("i = ", i)
i=i+1
ENDWHILE
END
Here the code has been modified slightly i is now a global variable, which has a value of 5.
When i is referenced in the procedure, it will have a value of 5 rather than zero.
Code
Program_main()
i=5
display(i)
END

display(i)
WHILE (i < 10)
println ("i = ", i)
i=i+1
ENDWHILE
END
When the loop executes, the value of i will change according to the processing of the loop and
may cause the rest of the program to use a new value for i.
1182

Once data has been processed in a procedure, it may need to be passed to another part of the
program.
A parameter is any variable or constant that is passed between parts of a program. In many
programming languages, including C and Java, parameter names are placed in parentheses
after a procedure name. The set of parameters for a procedure is referred to as a parameter list.

In this example, the Java println method prints a string that is passed to it as a parameter.
Code
println(String x)
It's very important that the parameters in a parameter list match in both a main program that
calls a procedure and in the procedure itself.

The parameters in each case must be of the same type. The number of parameters has to be
the same, and they have to be in the same order based on the order in which they're needed
for processing.
Code
Process_ticket_request()
SET more_records to yes
DOWHILE more_records
get_details(no_of_tickets, section)
check_availability(no_of_tickets, section, available)
In this code sample, the procedure is being called with three parameters, no_of_tickets,
section, and available.
Code
Process_ticket_request()
SET more_records to yes
DOWHILE more_records
get_details(no_of_tickets, section)
check_availability(no_of_tickets, section, available)
The actual procedure uses the same three parameters in the same order.
Code
1183

Check_availability(no_of_tickets, section, available)
IF no_tickets <= section_seats_left THEN
available = true
section_seats_left = section_seats_left -
no_of_tickets
ELSE
available = false
ENDIF
END
Parameters don't process and change data. Instead they provide a way to control procedures.
The procedures themselves access the specified data and modify it according to the instructions
it contains.
Code
Process_ticket_request()
SET more_records to yes
DOWHILE more_records
get_details(no_of_tickets, section)
check_availability(no_of_tickets, section, available)
IF available = true THEN
calculate_cost(no_of_tickets, section, price)
print_ticket(no_of_tickets, section, price)
ENDIF
ENDDO
END
Passing parameters to a procedure ensures that the same procedure can be used many times
with different values. The values of the parameters passed to the procedure can simply be
changed. This is a better method than creating a new procedure each time it's necessary to
process a new value.
Graphic
The parameters that will be passed to the get_details() procedure are no_of_tickets and section.
Code
Process_ticket_request()
SET more_records to yes
DOWHILE more_records
get_details(no_of_tickets, section)
check_availability(no_of_tickets, section, available)
IF available = true THEN
1184

calculate_cost(no_of_tickets, section, price)
print_ticket(no_of_tickets, section, price)
ENDIF
ENDDO
END
Parameters are passed from a calling procedure to a called procedure, and returned from a
called procedure to a calling procedure. In this example, Process_ticket_request() is the
calling procedure and get_details() is the called procedure.
Code
Process_ticket_request()
SET more_records to yes
DOWHILE more_records
get_details(no_of_tickets, section)
check_availability(no_of_tickets, section, available)
IF available = true THEN
calculate_cost(no_of_tickets, section, price)
print_ticket(no_of_tickets, section, price)
ENDIF
ENDDO
END
Question
Match each variable type to its characteristics.

Each type may match to more than one characteristic.
Options:
A. Local
B. Global
Targets:
1. Used within a procedure
2. Not visible to or usable by other procedures
3. Available throughout a program
4. Accessible to a variety of procedures
5. Occur in a number of places in a program
Answer
1185

A local variable is used only within the procedure in which it was created. You need to use global
variables to allow access from any procedure.
A local variable can't be seen or accessed from any procedure except the procedure in which you
create it.
A global variable is created in the main program and can be used at any point.
A global variable can be re-used by different procedures. This makes it unnecessary to create the
variable each time it's needed.
Global variables can be declared at any point in a main program and referenced in the main
program or in any procedure.
Correct answer(s):
Target 1 = Option A
Target 2 = Option A
Target 3 = Option B
Target 4 = Option B
Target 5 = Option B
Summary
Top-down design divides a program into major tasks and subtasks. In this process, each
program is broken down into modules, or separate, workable sections. Modules are further
divided into procedures, each of which addresses a separate task.

In many programming languages, the flow of execution of a program is controlled by a
procedure called the mainline, or main loop. The mainline controls execution by calling
procedures as they're required. Once a called procedure has executed, control passes back to
the mainline.

Variables used in a program have a given scope either local or global. Side effects occur when
a procedure alters a global variable or other parts of its environment. Parameters are variables
or constants passed between parts of a program. Passing parameters to a procedure ensures
that the same procedure can be used many times with different values.



1186

Using Arrays and Procedures
Learning Objectives
After completing this topic, you should be able to
use arrays in programs
use procedures in programs
Exercise overview
In this exercise, you're required to recognize how to use arrays and procedures in programming.
This involves the following tasks:
using arrays in programs, and
using procedures in programs
Using arrays in programs
Question
You're using LibertyBASIC and want to create an array that contains 21 elements. The data you
want to store is test scores, so you have to give the array the Integer data type. You decide to name
the array "TestScores."

Identify the correct array declaration.
Options:
1. DIM TestScores$(20)
2. DIM TestScores(20)
3. DIM TestScores(21)
4. DIM TestScores(20) As Integer
Answer
Option 1: Incorrect. The dollar sign specifies the data type as String. The correct data type is
Integer.
Option 2: Correct. In LibertyBASIC, you create an array by specifying the DIM keyword, the array
name, and the array size in parentheses. To specify the size, you identify the required upper bound
which is 20 in this case because LibertyBASIC uses zero-based arrays.
1187

Option 3: Incorrect. LibertyBASIC is a zero-based array so the index number of the twenty-first
element should be identified as 20.
Option 4: Incorrect. You use a declaration with the DIM keyword to specify the data type of the
array in REALbasic rather than in LibertyBASIC .
Correct answer(s):
2. DIM TestScores(20)
Question
You're using C++ and want to create an array that contains 21 elements. The data you want to store
is the names of test subjects, so the array must be of the String data type. You decide to name the
array "SubjectNames."

Identify the correct array declaration.
Options:
1. String SubjectNames[21]
2. SubjectNames$[20]
3. String SubjectNames[20]
4. String SubjectNames(21)
Answer
Option 1: Correct. To create an array in C++, you specify the data type, then the array name, and
finally the size in square brackets. To indicate the size, you supply the number of elements.
Option 2: Incorrect. In C++, you specify the data type by providing the name of the data type. You
use a dollar sign to specify the String data type in LibertyBASIC. Also, array size in C++ isn't
indicated by the highest index number but by the number of elements.
Option 3: Incorrect. The array size in C++ isn't indicated by the highest index number but by the
number of elements.
Option 4: Incorrect. In C++, the size of the array is indicated in square brackets rather than
parentheses.
Correct answer(s):
1. String SubjectNames[21]
1188

Question
You're using REALbasic and want to create a two-dimensional array that contains eight elements, in
a grid with four rows and two columns. The required data type is String, and you've decided to name
the array "Doctors."

Identify the correct array declaration.
Options:
1. Dim Doctors(1,3) as string
2. Dim Doctors(3,1) as string
3. Dim Doctors(2,4) as string
4. Dim Doctors[1][3] as string
Answer
Option 1: Incorrect. You use the DIM keyword with a declaration at the end to specify the data type.
You specify the array name and provide two numbers for the size. The first is the horizontal upper
bound, for rows, and the second is the vertical upper bound, for columns.
Option 2: Correct. When you specify the size of a two-dimensional array, the first number indicates
the horizontal upper bound for rows and the second number indicates the vertical upper bound,
for columns.
Option 3: Incorrect. REALbasic uses zero-based arrays so you provide index numbers to specify
the array size.
Option 4: Incorrect. You'd provide the size of each dimension separately in square brackets in C++,
rather than in REALbasic.
Correct answer(s):
2. Dim Doctors(3,1) as string
Using procedures in programs
Question
What happens when a program calls a procedure?
Options:
1. Control passes to the called procedure, which executes and then returns control to the calling procedure
1189

2. Control passes to the called procedure, which loops repeatedly until the main program signals that it
should halt
3. Control passes to the called procedure after all the calling procedure's instructions are executed
Answer
Option 1: Correct. When a procedure is called, the calling procedure transfers control to the called
procedure. The called procedure executes and then transfers control back to the calling procedure.
The called procedure may or may not return a value to the calling procedure.
Option 2: Incorrect. When a procedure is called, the calling procedure passes control to the called
procedure, which completes its execution. Then control is passed back to the calling procedure.
Option 3: Incorrect. When a procedure is called, the calling procedure immediately jumps to the
called procedure. Control is passed back to the calling procedure once the called procedure
completes its execution.
Correct answer(s):
1. Control passes to the called procedure, which executes and then returns control to the calling
procedure
Question
This is an example of the main body of a program.
Which are the procedures being called in this example?
Code
Enter_competitors()
WHILE more records
Calculate_age(age)
Validate_age(age, valid_age)
IF Valid_age = true THEN
Add_entrant()
Print_tags()
PRINT "Age is:", Valid_age
ENDIF
ENDWHILE
END
Options:
1. Enter_competitors
2. Validate_age
3. Calculate_age
1190

4. Add_entrant
5. Print_tags
6. Valid_age
Answer
Option 1: Incorrect. Enter_competitors() is the mainline of the program, rather than a called
procedure.
Option 2: Correct. Validate_age() is a called procedure.
Option 3: Correct. Calculate_age() is a called procedure.
Option 4: Correct. Add_entrant() is a called procedure.
Option 5: Correct. Print_tags() is a called procedure.
Option 6: Incorrect. Valid_age is a variable name, rather than a called procedure.
Correct answer(s):
2. Validate_age
3. Calculate_age
4. Add_entrant
5. Print_tags
Question
In the main body of the program, you need to insert a procedure call to the Print_ticket()
procedure.

Which procedure call do you use?
The procedure to be called is:

Print_ticket (no_of_tickets, section , price)
PRINT "This is your ticket to enter the theater"
PRINT no_of_seats, section , price
END
Code
Process_ticket_request()
SET more_records to yes
DOWHILE more_records
1191

Get_details(no_of_tickets, section)
Check_availability(no_of_tickets, section,
available)
IF available = true THEN
Calculate_cost(no_of_tickets, section, price)
INSERT THE MISSING CODE
ENDIF
ENDDO
END

Print_ticket(no_of_tickets, section , price)
PRINT "This is your ticket to enter the theater"
PRINT no_of_seats, section , price
END
Options:
1. Print_ticket(no_of_tickets, section, price)
2. Print_ticket( )
3. Print_ticket(section, price, no_of_tickets)
4. Print_ticket(no_of_tickets, section)
Answer
Option 1: Correct. You need to specify the parameters being used in the correct sequence when
you call a procedure.
Option 2: Incorrect. You need to specify the parameters within the parentheses of the procedure
call.
Option 3: Incorrect. You need to specify the parameters in your procedure call in the same order as
in the procedure itself.
Option 4: Incorrect. You need to specify the same number of parameters in your procedure call as
the procedure is expecting.
Correct answer(s):
1. Print_ticket(no_of_tickets, section, price)
Question
You want to access a value at multiple points in your program. Which program element should you
use?
1192

Options:
1. Local variable
2. Global variable
3. Procedure
Answer
Option 1: Incorrect. A local variable can be accessed only in the procedure in which it's created.
Option 2: Correct. A global variable can be accessed at any point in a program. It's created in the
main body of the program so that all procedures can access it.
Option 3: Incorrect. A procedure is used to perform a specific task. It's not used to pass values.
Correct answer(s):
2. Global variable
You have answered questions about using arrays and procedures in programming.















1193

Software Engineering concepts

Analyzing Requirements Using Models
SkillBriefs
Use Case Modeling
Learn how to analyze user requirements by creating usage models.
Usage Modeling Techniques
Discover the techniques used to create usage models.
Entity Relationship Diagrams
Learn how to create entity relationship diagrams.
Data and Behavior Modeling Techniques
Discover the techniques used to create data and behavior models.
Class Diagrams
Discover how class diagrams are used in data and behavior modeling.
Solution Development Methodologies
Learn about solution development methodologies.
Business Rules
Discover how business rules help business analysts model a solution.
Data Flow Diagrams
Learn how to create data flow diagrams.
Process and Flow Modeling Techniques
Discover the techniques used to create process and flow models.
Activity Diagrams
Learn how to use activity diagrams as a modeling technique.




1194

SkillBrief
Use Case Modeling
Business analysts effectively analyze user requirements for software projects by creating usage models.
Usage models are the analysis techniques of choice because they focus on describing requirements from
the user's perspective; if the user's requirements are not fulfilled, the project cannot succeed.
Popular usage models
Typically, more than one usage model is used to analyze or discover requirements during business
analysis on a project. Three usage models are most often used during business analysis:
User stories are the most informal of the three models. User stories are written by the intended
end users of the system and drive development based on user needs for features, function, and
behavior. User stories are used when there will be a close relationship between end users and
developers.
Use case descriptions are written descriptions of how a user interacts with the solution being
modeled to achieve a goal. They provide a structured approach to requirement analysis. This
structured approach can help ensure the necessary information is gathered about each
requirement.
Use case diagrams are probably the most common and important usage model because they
provide a comprehensive, graphical depiction of the problem domain. Use case diagrams do not
stand alone; they must be supported by either user stories or use case descriptions.
User stories
User stories are written descriptions of functionality requirements. Written by end users, they describe
how and what the system must do to allow users to successfully accomplish their goals. Because user
stories are written by the intended users of the solution they place increased ownership on the end users,
they help achieve agreement on the features that are most important to users, and they help prioritize the
attention features should receive during development.
User story development is a collaborative process that begins with the business analyst working with end
users to identify key features. As each need is identified by the user, a story is written to describe the
need.
A user story has five key elements:
A story card is used to record a user story a user requirement and story cards are
maintained throughout solution development.
The story card includes a brief, high-level description of the requirement. Written by the end
user, it contains only enough information to allow developers to accurately estimate the effort
required to implement the requirement.
1195

The estimate tells what development resources will be needed to code the feature and pass an
acceptance test.
The priority is set by the user and expresses the importance of the requirement described by the
user story relative to all other user stories.
A unique identifier is assigned to each user story so it can be tracked throughout development.
The business analyst will return to the user to gather more detailed user task information when the
development team is ready to implement the user story. There are standards or guidelines for how the
additional information will be gathered.
A big advantage of user stories is that they facilitate just-in-time development. Having developers and end
users working more closely can speed development time and reduces the need for detailed
documentation. However, user stories are not the best technique to use on projects that must conform to
regulatory guidelines or projects that require documentation.
Use case descriptions
The information required to develop use case descriptions is elicited from project stakeholders and the
intended end users of the solution or system.
The process for developing use case descriptions involves these five steps:
1. Before use cases can be created, the business analyst must first identify which user goals to
expand into use cases. Business analysts use an agreed-upon list of stakeholders and a set of
user profiles to determine which stakeholders (actors) will interact directly with the solution to
achieve which goals. These goals can now be expanded into use cases.
2. Pre-conditions conditions that must be true or things that must have already occurred before
the use case can begin must be identified and documented.
3. The business analyst will then define the basic flow of the use case. The basic flow is described
by the user and defines the typical, simplest path to successful completion of the use case.
4. The business analyst must then work with end users to define all possible alternate and
exception flows. Alternate flows define different but also successful scenarios. Exception flows
define circumstances that lead to abandonment of the goal represented by the use case.
5. Post-conditions must be identified and documented. For successfully completed use cases,
the post-conditions will describe conditions that must be true when the use case is complete.
Post-conditions on failure describe the conditions that must be true when a use case completes
unsuccessfully in abandonment of the goal.
Use case descriptions, often referred to simply as use cases, are written descriptions of how a user - a
person or system external to the system being modeled - interacts with the system to achieve a goal.
Use case descriptions combine the "who" (actors), the "what" (behavioral requirements), and the "how"
(events and conditions) with the "why" (use case goals) to clarify scope and provide a high-level
understanding of the problem to be solved or the goal to be accomplished.
1196

While the detail and the format of the documentation used to express use cases will vary depending on
the project, some elements are mandatory for all use case descriptions.
The use case must be given a name that uniquely identifies it within the project and should
describe the goal the use case is meant to satisfy.
In use case modeling, an actor is any person, external computer system, or event that interacts
with the solution through a use case. Actors should also be given unique names that describe the
role they play in interactions with the system.
Pre-conditions are facts that are assumed to be true when the use case begins.
Post-conditions are facts that must be true when the use case is complete.
The flow of events describes the steps the actor and the system take during the execution of the
use case. The use case description breaks the flow into a basic flow and alternate flows. The
basic flow describes the simplest, most efficient path to successfully complete the use case and
achieve the goal it represents. Alternate flows describe logic and error handling. If the actor can
still achieve the goal of the use case, it is defined as an alternate. If the actor cannot achieve the
goal of the use case, the use case is abandoned and is defined as an exception.
Some strengths of the use case description technique are its ability to determine scope and communicate
behavioral goals, and to describe basic and alternative ways a use case can be executed. Each of the
ways a use case can play out is known as a scenario. Use case descriptions are able to combine the
who, what, how and why of use case goals and describe the dynamics of a solution.
Because this technique focuses on requirements from a user's perspective, it is not the best technique to
describe the functional requirements of systems with limited end-user interaction. Also, it is not the best
technique to use to analyze projects that are data intensive.
Use case diagrams
A use case diagram is a graphical depiction of the problem domain, including system boundaries, use
cases, and actors. The use case diagram is used during requirements analysis to show the problem and
gain stakeholder agreement on the scope of the project.
Business analysts can begin the process of use case diagram creation in one of two ways. A business
analyst can work from an agreed upon list of actors and completed use case descriptions and then
employ the use case diagram to show the problem domain or she can begin modeling a use case
diagram as a way to discover actors and use cases.
A use case diagram employs certain key elements to visually depict the use case and show the problem
or goal to be solved or achieved. Three key elements are represented in the use case diagram using
symbols or shapes.
An actor is represented with a stick figure. If the actor is a system or an event, a rectangle may
be used to represent it.
An oval is used to represent a use case.
1197

A rectangle is used to represent a boundary. A boundary is used to define the scope of the
system being modeled. Boundaries may also be used to convey or highlight important information
such as phases of system development or a grouping of related functions. The use of boundaries
is optional.
Actor relationships include associations and generalizations. The associations that exist between actors
and use cases are represented with a solid line and indicate that the actor supplies information to the use
case, receives information as a result of the use case, or initiates the use case. The associations between
actors and use cases are nondirectional; meaning they do not imply a process flow.
A generalization relationship between two actors indicates that the two actors perform similar roles in the
use case. A solid line with a filled arrowhead at one end represents a generalization relationship between
actors in a use case diagram. The filled arrowhead points to the primary actor.
Relationships between two use cases include associations and generalizations. The two associations,
extend and include, are represented by a dashed line with an open arrowhead at one end. In an include
association, the arrow points to the including use case, and in an extend association, it points to the base
use case. The stereotype "include" or "extend" is added to the connecting arrow to identify the
association.
Each association has a different impact on the base use case:
The logic in the extend use case may be required by the base use case to complete a task. An
extend use case may be invoked by the base use case at any time during its execution and can
even execute parallel to the base use case, without impacting the base use cases logic.
The logic in the include use case is required by the base use case to complete a task. Include
associations can exist between multiple use cases that require the same business logic. An
include use case is invoked by another use case at a specific point during the business flow.
The generalization relationship indicates that the two use cases are similar; that one is like the other. The
inheriting use case has similar logic but not exactly the same logic of the base use case. The inheriting
use case contains steps that have to be rewritten to support its ability to achieve the specific user goal.
A line with a filled arrowhead at one end represents a generalization relationship between two use cases
in a use case diagram. The filled arrowhead points to the base use case.
Analyzing use cases
As with the other models, the business analyst will choose the usage modeling technique that best suits
the project being modeled or the use case being analyzed. Regardless of the models used, use case
analysis will generally involve an analysis method that involves these six steps:
1. identify actors
2. identify use cases
3. create use case diagrams
1198

4. describe context
5. describe basic flow
6. describe alternate and exception flows
Most projects benefit from the structure provided by use case descriptions and the effectiveness of a use
case diagram. Because this combination of usage models is often used during business analysis, it is
important to understand how this approach fits within the six-step analysis method.
Step one, identify actors, is done early in the project. This is accomplished through using the information
gathered during interviews with stakeholders or taken from previously developed user profiles. Identifying
actors can help determine project scope and help focus requirements interviews. An actor is any person,
external computer system, or event that interacts with the system through a use case.
Step two, identify use cases, is done with actors. During interviews with each group of actors, as defined
by user profiles, the business analyst must find out about three types of use cases:
Tasks are the goals an actor accomplishes through interaction with the system; each task is a
system use case.
Events are anything to which the system must respond. Each response is a use case.
Automated requests originate from other systems. Each request is a use case.
Step three is to create use case diagrams. The business analyst can begin by adding the actors and the
use cases to the diagram. More information is needed to describe the relationships between the use case
diagram elements. The remaining steps will be driven by the creation of the use case diagram.
In step four, describe context, the business analyst returns to the stakeholders to get more details about
the use cases - the context information. Context includes information about actors, pre-conditions, and
post-conditions. These details are gathered as part of use case description creation and could have been
done during initial interviews. If use case descriptions are being used to support the use case diagram
this step will have already been completed.
Steps five and six may also have been completed during the creation of use case descriptions. Step five,
describe the basic flow, is also done with stakeholders. Here the focus is on the typical success
scenario. The business analyst asks the stakeholder to describe the typical success scenario and
documents it in the use case description.
Step six, describe alternate and exception flows, deals with scenarios other than the basic flow.
Stakeholders are asked to describe possible variations to the basic flow. Alternate flows still lead to
success, but if exception flows lead to the abandonment of the use case goal, the use case ends in
failure. Each flow is documented in the use case description.
Detailed information about each use case and the possible scenarios basic, alternate, and exception
flows is documented in the use case descriptions. Much of the detail about context is not added to the
use case diagram because it would complicate the diagram and reduce its effectiveness as a clear and
accessible communication tool.
1199

The most popular usage models are user stories, use case descriptions, and use case diagrams.
Essentially, user stories define the problem from the user's perspective, use case descriptions describe
the problem, and use case diagrams graphically depict the problem.
Often, these models are combined to provide the business analyst and the project team with an
understanding of the problem domain. For instance, user stories and use case diagrams may be used to
analyze and communicate user requirements on an in-house project or extreme programming
environment, where the project can succeed and will even benefit from the less structured approach
provided by user stories. Alternatively, use case descriptions and use case diagrams may be used
together on projects that demand a structured and more detailed approach to requirements analysis.


Usage Modeling Techniques
Usage models are analysis techniques used to describe how users a person or system external to the
system being modeled interact with the system or solution to fulfill requirements and achieve goals.
Various usage models are likely to be used together to model and analyze requirements for a project.
When deciding which usage models to employ, you will need to focus on which models will work together
to provide the information you need, rather than what type of project they are best suited for use on.
What distinguishes usage models from other requirements analysis models is their focus on the user.
Usage models provide business analysts with valuable information about the solution or system from the
user's perspective.
Usage models are typically used to
describe how users interact with a system or solution to fulfill requirements
describe the system or solution from the user's perspective
describe system or solution features visible to the user
Usage models describe only what is visible to external users during their interaction with the system.
Nothing else within the solution scope is modeled; not system components or processes.
Usage model types
The usage models most commonly used during business analysis are
prototypes
user interface designs
user profiles
1200

user stories
use case descriptions
use case diagrams
Prototypes
A prototype can be developed for products or software to represent how the thing being created will work
or behave when it is complete. A product prototype consists of a physical, tangible model of the product.
A software prototype may be a series of hand, or digitally, drawn user interfaces approximating what the
system will look like or how it will behave when complete. A software prototype may also evolve into a
functioning, coded software component.
When prototyping is used to model user interaction with a system, the intended end users of the solution
use the prototype and then provide feedback on it. This gives the users a chance to provide valuable
feedback, especially if their requirements have not been met.
A business analyst is likely to use a prototype to reduce project risk when working in an unfamiliar
business domain or when end-user needs are difficult to understand. Prototyping is usually performed for
features of the solution that present the highest risk and not for the entire solution. High-risk features are
features that are critically important to the success of the solution; failure to meet them will negatively
impact the project or even lead to project failure. Risk may also be prioritized based on a feature's value
to the end user or by the degree of difficulty in understanding the feature.
Business analysts use prototypes to
gain a visual understanding of how an end user interacts with a system
gain end-user input about whether or not the software solution meets their requirements
capture end-user input on how to improve the software solution
demonstrate technical feasibility
gain stakeholder consensus on hard to understand requirements
Storyboards are often used during the early stages of prototype development. Storyboards provide early
design feedback from intended end users of the user interface. This feedback is incorporated into the
solution design, improving usability and ultimately reducing project risk. Storyboards are an efficient and
effective way to present and gather design input without the expense of developing a software prototype
with working code. Each storyboard must include a screen shot of the feature or screen intended for
development. Storyboarding can be used whenever appropriate, such as during end-user consultation on
usability or features.
User interface designs
User interface designs are written descriptions or models that describe end-user preferences for
interface usability. End users are given the opportunity to express their preferences for system usability
how they want to navigate specific system features, achieve their goals, or complete work tasks. Involving
1201

end users early in the design process helps to make sure the system will meet user requirements
because user preferences are designed into the solution from the beginning.
User interface design is an appropriate technique to use when usage will vary by type of user, when the
system is interface intense, or when the user type or market is unfamiliar to the project team.
Business analysts use user interface designs to
focus on system usage
gain stakeholder agreement on user goals
gain understanding of how the system can be designed to better help users achieve their goals
reveal different usages from different user types
The level of detail and the format of the documentation used to express user interface design will depend
on the specific needs of the stakeholders and the project team. However, all user interfaces must
include user profiles or user type documentation that provide information about the end users that
will interact with the system
include a list of unclear system requirements prioritized for further discussion and clarification
comply with company standards, thereby ensuring that the output of the documentation will be
useful during design and development
User profiles
User profiles are written descriptions of a system's end users. User profiles are used to help ensure that
solutions provide positive and effective user experiences. When reengineering projects, the goal of user
profiles is to improve end-user interactions.
User profiles enable analysts to identify, study, and model both the current and future end users of the
system. During user profile analysis, information is gathered about end users and then they are
categorized into types.
To effectively exploit user profiles, business analysts need to know when they are the appropriate
technique to use and how they are typically used.
User profiles are the appropriate technique to use when the project team, including the business
analyst, is unfamiliar or inexperienced with the problem domain area. User profiles are also a
good choice when there are a variety of user types with different user requirements.
User profiles are typically used to check the analysis provided by other techniques, to document
requirements for end user types, and to identify user workflow and user task improvements.
The level of detail and the format of the documentation used to express user profiles will depend on the
specific needs of the project. However all user profiles must include information on user types, user type
attributes, elicitations, and revised user types.
1202

User stories
User stories are written descriptions of a system's functionality requirements, as described by users.
User stories express what it is that end users need the system to be capable of in order to support them
in achieving their goals. This technique places increased ownership for the discovery of requirements on
the end user.
User stories are used to
identify key features
reach stakeholder agreement on the key features and functions that must be included in the
system and their priority
determine estimates of the time it will take to code each feature
User stories are the appropriate technique to use to document requirements when the system being
developed requires iterative, incremental, extreme programming (XP). User stories can be used to
support use case diagrams, providing information about user expectations for functionality.
The level of detail and the format of the documentation used to express user stories will differ from project
to project; however, all user story documentation must include a story card and a description, and should
include an estimate, priority, and a unique identifier.
Use case descriptions
Use case descriptions (use cases) are written descriptions of how a user - a person or system external
to the system being modeled - interacts with the solution to achieve a goal. The goal represents a system
requirement. Use case descriptions are created through combining the information provided by user
profiles and a list of stakeholder goals.
Use cases are a good choice when the solution requires an understanding of who does what, and the
dynamic behavior of a solution from the user's perspective.
Use cases are used to
gain stakeholder agreement on expected system behavior
communicate the proposed functionality, and therefore the scope, of the system
describe how end users interact with the solution to achieve a goal
identify technical or complex requirements that require prototypes to reduce project risk
perform feasibility analysis
provide detail for other usage models
1203

The detail and the format of the documentation used to express use cases will depend on the project.
However all use cases must have a unique name and include information on actors (users), pre-
conditions, flow of events, and post-conditions.
Use case diagrams
A use case diagram is a graphical depiction of the solution domain, including system boundaries, use
cases, and actors.
Use case diagrams are used when the business analyst wants to show how actors (users) interact with
use cases and the relationships that exist between users and use cases or between use cases. The
information depicted is taken from use case descriptions and user stories. Alternatively, use case
diagrams can be used to discover actors and use cases. Use case diagrams can also depict the solution
boundaries.
During business analysis, use case diagrams are used to
express the requirements documented in use cases or user stories
build an understanding of the problem domain and the components within the scope of the
domain
get agreement on the scope of the project
Usage models show how systems are used by end users. Usage models used during business analysis
include prototypes, user interface designs, user profiles, user stories, use case descriptions, and use
case diagrams. These models are grouped together as usage models because common to them is the
ability to describe solutions from a user's perspective.
Usage Modeling Techniques
Usage models are analysis techniques used to describe how users a person or system external to the
system being modeled interact with the system or solution to fulfill requirements and achieve goals.
Various usage models are likely to be used together to model and analyze requirements for a project.
When deciding which usage models to employ, you will need to focus on which models will work together
to provide the information you need, rather than what type of project they are best suited for use on.
What distinguishes usage models from other requirements analysis models is their focus on the user.
Usage models provide business analysts with valuable information about the solution or system from the
user's perspective.
Usage models are typically used to
describe how users interact with a system or solution to fulfill requirements
describe the system or solution from the user's perspective
1204

describe system or solution features visible to the user
Usage models describe only what is visible to external users during their interaction with the system.
Nothing else within the solution scope is modeled; not system components or processes.
Usage model types
The usage models most commonly used during business analysis are
prototypes
user interface designs
user profiles
user stories
use case descriptions
use case diagrams
Prototypes
A prototype can be developed for products or software to represent how the thing being created will work
or behave when it is complete. A product prototype consists of a physical, tangible model of the product.
A software prototype may be a series of hand, or digitally, drawn user interfaces approximating what the
system will look like or how it will behave when complete. A software prototype may also evolve into a
functioning, coded software component.
When prototyping is used to model user interaction with a system, the intended end users of the solution
use the prototype and then provide feedback on it. This gives the users a chance to provide valuable
feedback, especially if their requirements have not been met.
A business analyst is likely to use a prototype to reduce project risk when working in an unfamiliar
business domain or when end-user needs are difficult to understand. Prototyping is usually performed for
features of the solution that present the highest risk and not for the entire solution. High-risk features are
features that are critically important to the success of the solution; failure to meet them will negatively
impact the project or even lead to project failure. Risk may also be prioritized based on a feature's value
to the end user or by the degree of difficulty in understanding the feature.
Business analysts use prototypes to
gain a visual understanding of how an end user interacts with a system
gain end-user input about whether or not the software solution meets their requirements
capture end-user input on how to improve the software solution
demonstrate technical feasibility
gain stakeholder consensus on hard to understand requirements
1205

Storyboards are often used during the early stages of prototype development. Storyboards provide early
design feedback from intended end users of the user interface. This feedback is incorporated into the
solution design, improving usability and ultimately reducing project risk. Storyboards are an efficient and
effective way to present and gather design input without the expense of developing a software prototype
with working code. Each storyboard must include a screen shot of the feature or screen intended for
development. Storyboarding can be used whenever appropriate, such as during end-user consultation on
usability or features.
User interface designs
User interface designs are written descriptions or models that describe end-user preferences for
interface usability. End users are given the opportunity to express their preferences for system usability
how they want to navigate specific system features, achieve their goals, or complete work tasks. Involving
end users early in the design process helps to make sure the system will meet user requirements
because user preferences are designed into the solution from the beginning.
User interface design is an appropriate technique to use when usage will vary by type of user, when the
system is interface intense, or when the user type or market is unfamiliar to the project team.
Business analysts use user interface designs to
focus on system usage
gain stakeholder agreement on user goals
gain understanding of how the system can be designed to better help users achieve their goals
reveal different usages from different user types
The level of detail and the format of the documentation used to express user interface design will depend
on the specific needs of the stakeholders and the project team. However, all user interfaces must
include user profiles or user type documentation that provide information about the end users that
will interact with the system
include a list of unclear system requirements prioritized for further discussion and clarification
comply with company standards, thereby ensuring that the output of the documentation will be
useful during design and development
User profiles
User profiles are written descriptions of a system's end users. User profiles are used to help ensure that
solutions provide positive and effective user experiences. When reengineering projects, the goal of user
profiles is to improve end-user interactions.
User profiles enable analysts to identify, study, and model both the current and future end users of the
system. During user profile analysis, information is gathered about end users and then they are
categorized into types.
1206

To effectively exploit user profiles, business analysts need to know when they are the appropriate
technique to use and how they are typically used.
User profiles are the appropriate technique to use when the project team, including the business
analyst, is unfamiliar or inexperienced with the problem domain area. User profiles are also a
good choice when there are a variety of user types with different user requirements.
User profiles are typically used to check the analysis provided by other techniques, to document
requirements for end user types, and to identify user workflow and user task improvements.
The level of detail and the format of the documentation used to express user profiles will depend on the
specific needs of the project. However all user profiles must include information on user types, user type
attributes, elicitations, and revised user types.
User stories
User stories are written descriptions of a system's functionality requirements, as described by users.
User stories express what it is that end users need the system to be capable of in order to support them
in achieving their goals. This technique places increased ownership for the discovery of requirements on
the end user.
User stories are used to
identify key features
reach stakeholder agreement on the key features and functions that must be included in the
system and their priority
determine estimates of the time it will take to code each feature
User stories are the appropriate technique to use to document requirements when the system being
developed requires iterative, incremental, extreme programming (XP). User stories can be used to
support use case diagrams, providing information about user expectations for functionality.
The level of detail and the format of the documentation used to express user stories will differ from project
to project; however, all user story documentation must include a story card and a description, and should
include an estimate, priority, and a unique identifier.
Use case descriptions
Use case descriptions (use cases) are written descriptions of how a user - a person or system external
to the system being modeled - interacts with the solution to achieve a goal. The goal represents a system
requirement. Use case descriptions are created through combining the information provided by user
profiles and a list of stakeholder goals.
Use cases are a good choice when the solution requires an understanding of who does what, and the
dynamic behavior of a solution from the user's perspective.
1207

Use cases are used to
gain stakeholder agreement on expected system behavior
communicate the proposed functionality, and therefore the scope, of the system
describe how end users interact with the solution to achieve a goal
identify technical or complex requirements that require prototypes to reduce project risk
perform feasibility analysis
provide detail for other usage models
The detail and the format of the documentation used to express use cases will depend on the project.
However all use cases must have a unique name and include information on actors (users), pre-
conditions, flow of events, and post-conditions.
Use case diagrams
A use case diagram is a graphical depiction of the solution domain, including system boundaries, use
cases, and actors.
Use case diagrams are used when the business analyst wants to show how actors (users) interact with
use cases and the relationships that exist between users and use cases or between use cases. The
information depicted is taken from use case descriptions and user stories. Alternatively, use case
diagrams can be used to discover actors and use cases. Use case diagrams can also depict the solution
boundaries.
During business analysis, use case diagrams are used to
express the requirements documented in use cases or user stories
build an understanding of the problem domain and the components within the scope of the
domain
get agreement on the scope of the project
Usage models show how systems are used by end users. Usage models used during business analysis
include prototypes, user interface designs, user profiles, user stories, use case descriptions, and use
case diagrams. These models are grouped together as usage models because common to them is the
ability to describe solutions from a user's perspective.
Data and Behavior Modeling Techniques
To ensure that you have the best requirements for a system, you need a clear understanding of what
objects, data, and relationships exist in the current or target system. Data and behavior modeling
provides you with a snapshot that covers these three areas, so that you know what direction to take and
what to focus on when implementing a solution.
1208

Data and behavior modeling provides a static model or a single moment in time of the current or
target system or of some aspect of that system. These models describe system objects within the
confines of a project's scope. This description includes information recorded about these objects, their
relationships, and the business rules that govern them. Thus this form of modeling provides a framework
for analyzing requirements for system objects. Data and behavior modeling does not provide an overview
of a system's behavior over time, nor does it reflect how users outside the system scope may interact with
the system.
Data and behavior modeling is useful in situations where you need to understand the data and how it fits
together to create the system. Although this model outlines relationships between these data entities, it
does not focus on how data flows from one entity to another. Additionally, it does not describe all possible
user decisions or actions.
Useful techniques
Most projects need some form of data and behavior modeling to ensure that requirements are clarified
and to ensure that no requirements are omitted. So it is important for business analysts to be familiar with
data and behavior modeling techniques.
Entity relationship diagrams (ERDs) (ERDs) are probably the most widely used technique for data and
behavior modeling. These diagrams allow you to identify entities and their relationships with one another,
providing a structured analysis of business data and data relationships.
ERDs depict data types or entities, the data that needs to be recorded for these entities, and how the
entities are connected in terms of business rules and cardinality. These diagrams are useful because they
are flexible enough to provide both a high-level overview of complex issues and detailed documentation
of the data requirements of a business area. A detailed ERD can be given to relational database
developers as a complete set of data specifications that can be used directly in database development.
The technique, however, is data-centric and so, does not allow you to map business processes. Also,
ERDs that are detailed and complex may be difficult for users to understand.
Class diagrams are the most common object-oriented technique used to model data and behavior.
These diagrams identify data object classes, operations, and the data that should be recorded within
each class. The diagrams also depict a range of relationships between classes.
The diagrams help business analysts to break down complex business systems into a series of simple
business-data components that are easy to understand and communicate.
These diagrams can only be used in object-oriented analysis and design approaches. However, within
this setting, they create clear visualizations of implementations and code as well as simplifying the
process of designing and building system architecture.
Other common techniques associated with data and behavior modeling are
keeping data dictionaries
1209

using metadata definitions
using CRUD matrices
using data transformation and mapping
A data dictionary is a frequently used technique both in requirements elicitation and analysis. Data
dictionaries are collections of terms and their definitions. These entries are used to identify business
objects, processes, and behaviors.
Data dictionaries ensure that stakeholders understand the terminology and use it consistently. They also
help ensure that all stakeholders agree on the format and content of information relevant to the target
system.
With data dictionaries and metadata definitions, you generally use spreadsheets to represent the
definitions. This allows you to structure the data consistently, to standardize how the data is recorded and
stored, and to ensure that the data is traceable.
Data dictionary entries should include
the term name and aliases
the term description
any values or meanings associated with the term
For composite data entries, you also need to include sequences and repetitions associated with the entry.
Metadata definitions model data and behavior by describing the context in which data is used, thereby
ensuring that data is easily understood. Metadata definitions describe the explicit and tacit information
that is required to understand both technical and business data in a target system. They are also used to
ensure that this data is valid. Thus it is a critical tool for understanding data.
These definitions should be recorded within the target system and this system should be structured to
capture and maintain metadata.
A CRUD matrix or a Create, Read, Update, Delete matrix defines user group access rights to data
stored within software solutions. It comprises a matrix-type table that depicts data elements, and how
specific user groups can interact with these elements.
A CRUD matrix is represented in matrix form that organizes access levels for user groups. The matrix
provides stakeholders with a quick reference for validating what data is available to particular groups and
it provides information for development teams that need to develop data security mechanisms.
Each entity in a matrix must be able to be created, read, updated, and deleted by at least one user group.
A CRUD matrix is useful in software development projects but is of little use in business process analysis.
It is important that business analysts ensure that the matrix is consistent with user groups and entities
described in other requirements.
1210

Data transformation and mapping is used to transfer data, business records, and processes from a
legacy system to a target system. It is used in application development projects that intend to use existing
business data records. It encompasses moving data from multiple sources, reformatting and cleansing
data, and loading data into another system.
Data transformation and mapping ensures that issues such as heterogeneous systems, differing data and
definitions, and data quality are addressed. This is a complex process and requires input from business
owners and subject matter experts to avoid complications and delays.
When transforming and mapping data for application development projects, you need to follow a set
process.
1. First you need to include a high-level data model describing the entity relationships.
2. Next you map each entity to its associated business rules and owner. Then you create a plan to
cleanse data ensuring that the data meets the needs of the proposed system and that
unnecessary or invalid data is removed.
3. Finally, you create an environment plan for the migration of the cleansed data from its source, to
a repository for analysis, and then to the production system.
Data behavior and modeling describes system objects within the confines of a project's scope. Common
techniques associated with this strategy include class diagrams, entity relationship diagrams (ERDs), data
dictionaries, metadata definitions, CRUD matrices, and data transformation and mapping.
An ERD is the most common technique used when conducting a structural analysis. A class diagram is
typically used when conducting object-oriented analyses in software development projects. A CRUD
matrix defines user group access rights to data stored within software solutions. Data dictionaries and
metadata definitions should generally be used in all projects. Data transformation and mapping should be
done in software development projects that need to use some of the original data in a new or updated
system.
Class Diagrams
Class diagrams are the most common and comprehensive modeling technique for object-oriented
analysis in data and behavior modeling. Using these diagrams, business analysts can break down
complex business systems into a series of simple components that are easy to understand and
communicate.
Class diagrams help to bridge the gap between business and technical processes and different
stakeholder groups. This modeling technique provides a widely accepted standard for communicating
business requirements to technical personnel.
Class diagrams are similar to entity relationship diagrams (ERDs) in that they map entities known as
classes and their relationships. Class diagrams differ from ERDs in that they map operations and they
expand on the types of relationships that are mapped between classes.
1211

Class diagram components
Class diagrams organize each instance termed objects into categories named classes, so that
transactions and changes for a particular group can be handled consistently.
A class diagram includes the following basic components:
Classes are categories that incorporate objects that are tracked by business and software
processes. They are similar to entities in ERDs.
Each class is associated with a list of attributes that are recorded or tracked for each object in
the class. Each object's attributes can be changed through the operations of a class.
Operations refer to actions or services that objects belonging to a particular class provide
operations describe what a class can do. Attributes are added, deleted, or modified through a
class's operations.
Attributes and operations that are documented for each class apply to all objects in that class. This allows
you to centralize business rules and related data for objects within a class, thereby reducing repetition in
data storage, documentation, and data processes.
When documenting each operation in a class diagram, you include information about three areas of the
operation:
An operation pre-condition is the state that an object must hold, or what must be true, before an
operation can begin.
An operation post-condition is the state that an object must hold, or what must be true, after an
operation is complete.
The business logic for an operation describes the sequence of actions that are associated with
a particular operation.
Classes in a class diagram are represented as labeled rectangles. Directly below the class name,
attributes for the class can be listed.
Operations are depicted directly below attributes within the class rectangle. The operation name is
followed by an opening and a closing parenthesis ( ). In some cases, when attributes do not need to be
represented, operations are depicted directly below the class name.
Class diagram relationships
Class diagrams list classes, their attributes, and their operations. They also depict the relationships
between classes. Determining how each business entity is related to another helps you to identify shared
documentation and shared requirements. It also identifies the shared business rules that an
organization's IT system should support.
The class relationships that can be depicted in a class diagram include the following:
1212

The association relationship is similar to a relationship depicted in an ERD. It explains how one
class is linked or associated with another class via a business or software rule.
A generalization relationship has one generalized class and several specialized classes that fall
under the generalized category.
An aggregation An aggregation relationship depicts a class that forms part of a whole or larger
class. So, aggregation shows components that make up a class.
The multiplicity relationship in class diagrams is similar to that of cardinality in ERDs. Multiplicity
specifies the minimum and maximum number of occurrences allowed within a relationship
between two classes.
Aggregation and generalization relationships help you to distinguish between attributes that apply to one
large category and those that apply to a component category or sub-category only. Identifying these
relationships helps you to reduce requirement repetitions between related classes.
Generalization is represented in a class diagram as an arrow that moves from the specialized class to the
generalized class. Aggregation is represented as a line with a diamond positioned directly below the class
that represents the whole category.
Association relationships are depicted on a class diagram as an annotated line with a directional arrow
that specifies in what direction the association should be read.
Although the multiplicity relationship is similar to the cardinality relationship in an ERD, it is depicted
differently on a class diagram.
A single integer, for example 1, specifies that that number and that number only applies to the
relationship. This relationship is depicted immediately below or above the class using the
appropriate integer.
A multiplicity relationship may involve integers x through y. This relationship is depicted
immediately below or above the class using the appropriate integers separated by an ellipsis.
A multiplicity relationship may involve x or more instances. This relationship is depicted
immediately below or above the class using the appropriate integer, an ellipsis, and an asterisk.
Class diagrams provide an object-oriented approach to breaking down complex business systems into a
series of simple components that are easy to understand and communicate. The diagrams comprise
classes, attributes, and operations.
Classes are represented in terms of their relationships to one another. Potential relationships include
aggregation, association, generalization, and multiplicity.
Solution Development Methodologies
Before business analysts can effectively analyze requirements, they must have an accurate
understanding of the enterprise and the solution development methodology (SDM) intended for the
project.
1213

Business analysts create a business domain model to help them achieve an accurate understanding of
the enterprise before they start analyzing requirements. While the business domain model of each
business is unique, domain models for businesses belonging to the same industry, like the financial
services industry, will be similar because they offer similar products and services.
Business domain model
A business domain model is a conceptual model of an enterprise. Usually, the domain model focuses on
the particular area of the business affected by the project, unless the project has important implications
throughout the entire enterprise.
Business domain models are valuable because they help ensure the solution will meet the business need
by helping business analysts
accurately understand the current state of business within the enterprise
accurately understand the proposed future state of business within the enterprise
verify a common understanding of the proposed solution among stakeholders
When complete, the business domain model provides a complete description of an enterprise's current
and proposed organizational structures, processes, and the information required to conduct business.
The understanding gained by completing the business domain model will help ensure the requirements
are accurate.
Business domain models are highly conceptual and there are no guidelines or conventions for their
creation. When creating the business domain model, be careful to include all the elements of the domain
and show the interactions between them. Here is a simple representation of a business domain model for
an organization.
Solution development methodologies
With a clear understanding of the business domain, the business analyst can determine which techniques
to use to analyze requirements. This decision will, in part, be decided by the solution development
methodology being used.
Solution development methodologies (SDMs) are the methods used to perform business analysis on a
project, and the three broad types of SDMs are
business process analysis
object-oriented analysis
structured analysis
Each SDM relies on process and flow, data and behavior, and usage models to help model the solution.
Each SDM also makes use of various analysis techniques to express requirements. Some analysis
techniques are more closely associated with a particular SDM because they are better at representing the
1214

type of information the SDM needs to express. However, analysis techniques are not exclusive to specific
SDMs.
Business process analysis is the methodology primarily used when the project solution requires
business process reengineering, which is intended to improve business processes and maximize
business results.
During business process analysis both the current and the proposed processes of the enterprise must be
described. Three analysis techniques can provide this capability:
An activity diagram depicts workflow sequence how a set of related activities or actions occur
and the decisions that control the flow.
A flowchart depicts workflow sequence how a set of related activities or actions occur and the
decisions that control the flow.
A workflow model depicts the flow of work in a specific business area. Workflow models help to
document work processes and to find opportunities for process improvement.
Object-oriented analysis is the methodology primarily used when the project solution requires object-
oriented software development. In general, object-oriented methodologies describe how people interact
with a system to achieve work goals.
Object-oriented analysis views a system as a collection of objects that pass messages to one another
and it models data and processes together. Several analysis techniques can provide this understanding:
A use case diagram depicts the problem domain by identifying the solution boundary, the actors
and use cases involved in the solution, and the relationships between these two elements.
An activity diagram depicts workflow sequence how a set of related activities or actions occur,
and the decisions that control the flow.
A class diagram depicts the elements relevant to the solution. Class diagrams also depict the
internal structure of each element and the relationships that exist between elements.
A sequence diagram depicts the logic of use case descriptions. It shows the information that
passes between objects in the system and throughout the execution of the use case.
Structured analysis is the methodology primarily used when the project solution requires the
development of data process analysis and data management capabilities. Structured analysis is process-
centric and pays particular attention to the data that flows into and out of processes. Unlike object-
oriented analysis, processes and data are usually modeled separately.
Structured analysis relies on analysis techniques that can provide an understanding of the processes
involved in the solution. Business analysts use different analysis techniques to understand the processes
involved in a solution:
A flowchart depicts workflow sequence how a set of related activities or actions occur, and the
decisions that control the flow.
1215

A data flow diagram depicts how information flows through a system; how it is inputted,
processed, stored, and outputted from a system.
An entity relationship diagram (ERD) depicts a data structure. ERDs show the entities
elements the business needs information about that are important to the solution, the
information that must be retained by the system about each entity, and the relationships between
the entities.
The decision about which SDM and which analysis techniques to use may be decided prior to the
business analyst's involvement with the project. Because of this, it is beneficial for business analysts to be
familiar with the three solution development methodologies and the various analysis techniques
associated with them.
The SDM used will dictate the analysis techniques that will be used. While a business analyst may prefer
certain techniques, he should be familiar with all the analysis techniques. This will give him greater
flexibility in expressing requirements and will also allow him to understand work completed by colleagues
using other techniques.
In order to effectively analyze requirements, a business analyst must first clearly understand the business
domain and know which solution development methodology (SDM) is being used on the project.
Creating a business domain model provides a current understanding of the enterprise, as well as an
understanding of the proposed future reality of the enterprise. An inaccurate understanding of the
business domain can result in inaccurate requirements.
Three SDMs are used to perform business analysis on a project. Business process analysis focuses on
process improvement, and the analysis techniques closely associated with it are the activity diagram, the
flowchart, and the workflow model. Object-oriented analysis focuses on software development, and the
analysis techniques closely associated with it are the use case, activity, class, and sequence diagrams.
Finally, structured analysis focuses on data process analysis and data management, and the analysis
techniques closely associated with it are the flowchart, the data flow diagram, and the entity relationship
diagram.
Business Rules
As business analysts model a solution, they need to know how the enterprise conducts business.
An enterprise's business activities and acceptable business practices are guided and defined by internal
policies and guidelines as well as any internal or external standards and regulations. Business analysts
learn about the things that might impact proposed solutions by identifying, documenting, and creating, if
necessary, the business rules that govern the business. Business rules are essentially a written
statement that exactly and unambiguously expresses all rules included in policies, guidelines, and
relevant standards.
In the absence of a standard definition for the term business rule, many in the business world have
adopted the definition put forth by the Business Rules Group in 2000.
1216

"A business rule is a statement that defines or constrains some aspect of the business. It is intended to
assert business structure or to control or influence the behavior of the business."
Business rules define what data the data that guides the activities of the business - is acceptable or
expected and govern the interaction between the business and its customers, suppliers, employees, and
systems.
"An employee with less than six months' employment with the company is not entitled to health benefits"
is an example of how a policy translates into a business rule. This rule expresses the acceptable
interaction between an enterprise and its new employees. It will guide human resource, accounting, and
payroll activities.
A single business rule may impact many business activities, processes, information, and systems. This is
why it is important to identify business rules before solutions are developed and requirements are
analyzed. Business rules affect solution capabilities and therefore directly affect requirements. Analyzing
requirements and planning a solution without taking business rules into consideration will likely result in
an ineffective solution.
There is no universally agreed upon business rules classification scheme. Nonetheless, the professionals
who practice business analysis find it useful to classify business rules by type because it can have the
following benefits:
Using a rules classification scheme to classify rules by type can help business analysts efficiently
discover and validate rules by giving them a process to follow.
Using a rules classification scheme to classify rules by type can help business analysts
document and maintain business rule information that will become a resource for future use
throughout the enterprise. This makes it easier to update existing solutions or to identify the
business rules that will impact other projects.
Business rule types
A classification scheme that works well for business professionals consists of the following business rule
types:
terms
facts
mandatory constraints
guidelines
action enablers
computations
inferences
1217

The first two types of rules terms and facts present information and are often referenced in other rules
to give meaning to the other business rule types. They can stand alone in context, but may not be
complete sentences.
A term defines data concepts and details about concepts such as properties and values. Terms generally
take the form of a noun, or a noun phrase, with an agreed-upon definition. Terms define words that have
specific meaning to stakeholders, defining the word and identifying what is known about the thing in
question. A term may be a definition of a concept, such as "stakeholder," or it may be a phrase identifying
a value of a concept, like "end user."
A fact is a statement that defines the relationships among terms. An example of a fact might be
"Preferred customers qualify for discounts."
The next two types of rules, mandatory constraints and guidelines, constrain information by testing data
values and placing constraints on a business event.
Mandatory constraints stop events from happening. Rules expressing mandatory constraints identify an
unconditional circumstance that must be true for the business event to be allowed to complete. People
interacting with the solution have no control over the event.
Guidelines provide warnings about the completion of an event. Guidelines warn about circumstances
that should be true in order for an event to complete in an acceptable way. Unlike mandatory constraints,
people interacting with the solution or system can decide how to proceed.
Action enablers initiate a new action that takes place outside the target system or business event. An
action enabler rule tests conditions with a predetermined truth. If the conditions are true another business
event, message, or activity is initiated.
The final two types of business rules are computations and inferences. Both of these types of rules use
existing information to create new information.
Computations arrive at a data value using an algorithm. Common computations include sum, difference,
product, quotient, count, maximum, minimum, and average. These are based on quantitative data and
are necessary to the business event being completed.
Inferences arrive at a data conclusion by testing conditions. Upon finding the conditions true, inferences
establish the truth of a new fact. Inferences have an if "A" then "B" relationship. If the condition set forth in
"A" is true, then it becomes the true condition of "B."
Business rules are a written expression of data and details that must be followed in order for the business
to operate as intended. With that in mind, it stands to reason that business analysts would be interested
in discovering and validating business rules before requirements analysis is completed. Otherwise, the
solution delivered may not support those business rules and therefore be ineffective.
Business analysts often find it helpful to classify business rules. A classification scheme that works well
for business audiences includes seven types of business rules. Terms and facts define and provide
1218

meaning for the other rule types. Constraint rules mandatory constraints and guidelines test data
values. Action enablers initiate new action. And finally, computations and inferences create new
information.
Data Flow Diagrams
Constructing a data flow diagram (DFD) is an ideal way to understand your current IT system before
attempting to upgrade it. A DFD is a process and flow modeling technique that shows how information
flows through a system how it is inputted, processed, stored, and outputted from a system.
Business analysts use data flow diagrams to help them determine or verify the data requirements of the
processes supported by a system.
Data flow diagrams allow for structured analysis, which means they not only describe the system, but also
describe each of the processes that make up the system. Data flow diagrams are an ideal choice when
the solution involves complex data processes. Business analysts use data flow diagrams to
communicate information about system requirements to stakeholders
describe the data requirements of business processes supported by an IT system
document legacy system requirements
describe automated or business systems
What are the limitations of data flow diagrams? Data flow diagrams do not show how a system or
business area works, only what the system does. This means decisions and user interactions are not
described, making data flow diagrams ineffective on projects aiming to improve processes or create
interactive user-based systems.
Data flow diagrams provide a data-centric understanding of what a system does. They allow the business
analyst to visually depict the
external entities that provide or receive data from a system
processes that transform data within the system
data flows that move data from external entities to processes, between processes and data
stores, and from processes to external entities
data stores that store data within the system
Key elements
These first two key elements of the data flow diagram show where the information comes from and what
the system does with it.
An external entity is a key element of the data flow diagram. An external entity can both send
and receive data from data processes within the system. An external entity is represented in the
diagram by a labeled rectangle. The label identifies the external entity.
1219

A data process transforms or processes data so it can be used by the system. A data process
can transform or process data in many ways including combining it with other data, recording,
converting, or filtering it. The standard symbol used to represent a data process is a labeled
circle, but a rounded rectangle is also an acceptable variation. Labels name or identify the
process by describing the transformation the data process performs. The label-naming
convention is to use a verb-object structure.
If an asterisk is included in the data process's name, it means that the process can be decomposed
further. This means that more data flow diagrams will need to be developed or that they already exist and
should be consulted to ensure a comprehensive understanding of the system.
The other two key elements of the data flow diagram help to describe the flow of data within the system.
A data flow moves data through the system and identifies both the data being moved and where
the data is moving to. Data flows move data between data processes and external entities, and
between data stores and other data processes. A data flow is represented by a single, or forked,
arrow-headed line, indicating where the data is moving. Preferably, the data flow label should be
a noun phrase that describes the data being moved.
A data store is a location where data is stored or held for future use. While stored, the data is
passive; that is, it remains as it was at the time it was stored it is not processed or transformed
in any way. A data store is represented as a label between two parallel lines. The label denotes
the type of data it stores.
Understanding data flow diagrams
DFDs allow a business analyst to define system boundaries, analyze the data flow through the main
processes of a system, and break down the complex processes into their constituent processes. DFD
analysis involves three steps:
1. designing a level 0 DFD
2. designing a level 1 DFD
3. breaking down complex processes
A level 0 DFD, sometimes referred to as a context diagram, defines system boundaries. Each level 0 DFD
depicts the system as a single, usually complex, process.
In addition to defining boundaries, a level 0 DFD is used to analyze the requirements of processes
supported by a system. The level 0 DFD shows the movement of data into and out of the system.
Designing a level 0 DFD
To create the level 0 DFD, you need to know the
process involved
external entities involved
1220

information that flows in and out of the system
The processes involved in a system are the tasks a system performs. Data can flow both in and out of
processes. Processes receive input data from the external entity and transform the data into output data.
The data outputted by a process can flow to an external entity, a data store, or another process.
Once the single, complex process has been identified, the next step in creating a level 0 DFD is to
determine which external entities the process interacts with and how the data moves.
The external entities that interact with a system lie just outside the system and identifying them
defines the system's boundaries or scope. External entities that interact with the system include
people, organizations, and computer systems. External entities are sources or destinations of
data. Information about the external entities is collected from stakeholders.
Data flows represent the information the information that is received from and provided to
external entities that moves between the processes and the external entities. A data flow is
shown as a line with an arrow indicating the direction the data is flowing and is labeled with a
descriptor of the data being moved.
Designing a level 1 DFD
Now that system boundaries have been successfully defined by creating a level 0 DFD, it is time to move
on to the second step - designing a level 1 DFD.
Designing a level 1 DFD allows you to analyze data flow through the main processes of a system. A level
1 DFD shows the main processes within the project's scope and the data that is required and produced
by each process. If you are updating or adding to an existing system, be sure to determine if any
processes are being added or revised.
As you design the level 1 DFD, you will find that not all the data produced by a process is used right away
by another process. When this happens, you must define a data store. A data store is a location where
data is stored for future use. While stored, the data is passive. It remains as it was at the time it was
stored it is not processed or transformed in any way. The level 1 DFD uses the data store element a
label between two parallel lines to represent a data store.
Breaking down complex processes
If any of the processes can be broken down even further, you will need to proceed to the third step: break
down complex processes. This is the only way to make sure you have discovered all the system's data
requirements.
When analyzing a system's data requirements, you must break down complex main processes into lower-
level DFDs. Each process is deconstructed and broken down into as many DFDs as are necessary to
represent the details of complex processes. For example, after the system boundaries are identified by
the level 0 DFD and the main processes are identified on the level 1 DFD, the main processes may be
broken down and identified on a level 2 DFD, a level 3 DFD, and so on, until the process cannot be
broken down any further.
1221

Here are a few rules that will help you check the accuracy and completeness of your DFD:
each process must have at least one data flow going into it and one going out of it
every data store must have at least one data flow going into it and one going out of it
all data flows must either start or end at a process
every data item that appears on a data flow diagram must originate and be used somewhere
within the related DFDs
Every analysis technique has its strengths and weaknesses that determine its appropriateness for use on
various projects. DFDs have several strengths and weaknesses:
they are easy to understand
they constitute a useful analysis, deliverable to developers in a structured programming
environment
they enable stakeholders to easily match requirements to technical specifications
they enable stakeholders to verify entity relationship diagrams (ERDs)
they are not effective as an analysis deliverable on an object-oriented analysis project
The data flow diagram is a process and flow analysis technique that works well on structured analysis
projects. The key elements in a data flow diagram are external entities, data processes, data flows, and
data stores.
Depending on the complexity of the process involved, a business analyst will use at least two DFDs to
analyze the data requirements of the system. A level 0 DFD, also commonly known as a context diagram,
defines the boundaries of the system under review. A level 1 DFD analyzes the flow of information. DFDs
are then used to break down each process into single processes or tasks that can't be broken down any
further.
Data Flow Diagrams
Constructing a data flow diagram (DFD) is an ideal way to understand your current IT system before
attempting to upgrade it. A DFD is a process and flow modeling technique that shows how information
flows through a system how it is inputted, processed, stored, and outputted from a system.
Business analysts use data flow diagrams to help them determine or verify the data requirements of the
processes supported by a system.
Data flow diagrams allow for structured analysis, which means they not only describe the system, but also
describe each of the processes that make up the system. Data flow diagrams are an ideal choice when
the solution involves complex data processes. Business analysts use data flow diagrams to
communicate information about system requirements to stakeholders
describe the data requirements of business processes supported by an IT system
1222

document legacy system requirements
describe automated or business systems
What are the limitations of data flow diagrams? Data flow diagrams do not show how a system or
business area works, only what the system does. This means decisions and user interactions are not
described, making data flow diagrams ineffective on projects aiming to improve processes or create
interactive user-based systems.
Data flow diagrams provide a data-centric understanding of what a system does. They allow the business
analyst to visually depict the
external entities that provide or receive data from a system
processes that transform data within the system
data flows that move data from external entities to processes, between processes and data
stores, and from processes to external entities
data stores that store data within the system
Key elements
These first two key elements of the data flow diagram show where the information comes from and what
the system does with it.
An external entity is a key element of the data flow diagram. An external entity can both send
and receive data from data processes within the system. An external entity is represented in the
diagram by a labeled rectangle. The label identifies the external entity.
A data process transforms or processes data so it can be used by the system. A data process
can transform or process data in many ways including combining it with other data, recording,
converting, or filtering it. The standard symbol used to represent a data process is a labeled
circle, but a rounded rectangle is also an acceptable variation. Labels name or identify the
process by describing the transformation the data process performs. The label-naming
convention is to use a verb-object structure.
If an asterisk is included in the data process's name, it means that the process can be decomposed
further. This means that more data flow diagrams will need to be developed or that they already exist and
should be consulted to ensure a comprehensive understanding of the system.
The other two key elements of the data flow diagram help to describe the flow of data within the system.
A data flow moves data through the system and identifies both the data being moved and where
the data is moving to. Data flows move data between data processes and external entities, and
between data stores and other data processes. A data flow is represented by a single, or forked,
arrow-headed line, indicating where the data is moving. Preferably, the data flow label should be
a noun phrase that describes the data being moved.
1223

A data store is a location where data is stored or held for future use. While stored, the data is
passive; that is, it remains as it was at the time it was stored it is not processed or transformed
in any way. A data store is represented as a label between two parallel lines. The label denotes
the type of data it stores.
Understanding data flow diagrams
DFDs allow a business analyst to define system boundaries, analyze the data flow through the main
processes of a system, and break down the complex processes into their constituent processes. DFD
analysis involves three steps:
1. designing a level 0 DFD
2. designing a level 1 DFD
3. breaking down complex processes
A level 0 DFD, sometimes referred to as a context diagram, defines system boundaries. Each level 0 DFD
depicts the system as a single, usually complex, process.
In addition to defining boundaries, a level 0 DFD is used to analyze the requirements of processes
supported by a system. The level 0 DFD shows the movement of data into and out of the system.
Designing a level 0 DFD
To create the level 0 DFD, you need to know the
process involved
external entities involved
information that flows in and out of the system
The processes involved in a system are the tasks a system performs. Data can flow both in and out of
processes. Processes receive input data from the external entity and transform the data into output data.
The data outputted by a process can flow to an external entity, a data store, or another process.
Once the single, complex process has been identified, the next step in creating a level 0 DFD is to
determine which external entities the process interacts with and how the data moves.
The external entities that interact with a system lie just outside the system and identifying them
defines the system's boundaries or scope. External entities that interact with the system include
people, organizations, and computer systems. External entities are sources or destinations of
data. Information about the external entities is collected from stakeholders.
Data flows represent the information the information that is received from and provided to
external entities that moves between the processes and the external entities. A data flow is
shown as a line with an arrow indicating the direction the data is flowing and is labeled with a
descriptor of the data being moved.
1224

Designing a level 1 DFD
Now that system boundaries have been successfully defined by creating a level 0 DFD, it is time to move
on to the second step - designing a level 1 DFD.
Designing a level 1 DFD allows you to analyze data flow through the main processes of a system. A level
1 DFD shows the main processes within the project's scope and the data that is required and produced
by each process. If you are updating or adding to an existing system, be sure to determine if any
processes are being added or revised.
As you design the level 1 DFD, you will find that not all the data produced by a process is used right away
by another process. When this happens, you must define a data store. A data store is a location where
data is stored for future use. While stored, the data is passive. It remains as it was at the time it was
stored it is not processed or transformed in any way. The level 1 DFD uses the data store element a
label between two parallel lines to represent a data store.
Breaking down complex processes
If any of the processes can be broken down even further, you will need to proceed to the third step: break
down complex processes. This is the only way to make sure you have discovered all the system's data
requirements.
When analyzing a system's data requirements, you must break down complex main processes into lower-
level DFDs. Each process is deconstructed and broken down into as many DFDs as are necessary to
represent the details of complex processes. For example, after the system boundaries are identified by
the level 0 DFD and the main processes are identified on the level 1 DFD, the main processes may be
broken down and identified on a level 2 DFD, a level 3 DFD, and so on, until the process cannot be
broken down any further.
Here are a few rules that will help you check the accuracy and completeness of your DFD:
each process must have at least one data flow going into it and one going out of it
every data store must have at least one data flow going into it and one going out of it
all data flows must either start or end at a process
every data item that appears on a data flow diagram must originate and be used somewhere
within the related DFDs
Every analysis technique has its strengths and weaknesses that determine its appropriateness for use on
various projects. DFDs have several strengths and weaknesses:
they are easy to understand
they constitute a useful analysis, deliverable to developers in a structured programming
environment
they enable stakeholders to easily match requirements to technical specifications
1225

they enable stakeholders to verify entity relationship diagrams (ERDs)
they are not effective as an analysis deliverable on an object-oriented analysis project
The data flow diagram is a process and flow analysis technique that works well on structured analysis
projects. The key elements in a data flow diagram are external entities, data processes, data flows, and
data stores.
Depending on the complexity of the process involved, a business analyst will use at least two DFDs to
analyze the data requirements of the system. A level 0 DFD, also commonly known as a context diagram,
defines the boundaries of the system under review. A level 1 DFD analyzes the flow of information. DFDs
are then used to break down each process into single processes or tasks that can't be broken down any
further.
Activity Diagrams
An activity diagram is a modeling technique that depicts workflow or a sequence of dynamic activities
how a set of related activities or actions occur and the decisions that control the flow. Like the data flow
diagram, the activity diagram is a process and flow modeling technique, but it focuses on the actions and
activities that are completed by the system.
Activity diagrams are often used to describe complex processes and to gain consensus. Because they
describe both the sequence of activities and the decisions that control the flow of the activities, they are
able to describe logic and behavior.
While performing business analysis it is important to use a model that will provide the most useful
information. Activity diagrams are a good choice when
the details of complex processes involving actions or activities need to be communicated
a sequence of activities needs to be understood
it is important to understand the logic of the workflow
it is important to know about the decisions that can affect the order in which activities occur
An activity diagram is likely to be used to analyze and describe or document
complex use case scenarios
business workflows
complex algorithms
responsibility for the completion of activities
Key elements
Activity diagrams use specific components to help describe a sequence of activities or workflow.
1226

The start point indicates the start of the sequence being modeled and is represented by a filled
circle.
An arrow-headed line is used to represent the sequential flow of activities ; the order in which
activities occur.
Each activity in the workflow is represented by a rounded rectangle. Activities are always labeled
to denote the action taken by the system.
A branch is used to depict the splitting of one flow into two or more mutually exclusive alternate
flows that the workflow could follow based on a decision. A diamond is used to represent a
branch in the workflow.
A merge is used to depict the joining of mutually exclusive alternate flows back into one. A
diamond is also used to represent the merge of the workflow. The merge symbol is not always
used. A popular variation is to simply show the independent flows becoming one again. However,
this convention is not compliant with the Unified Modeling Language (UML) 2 standards.
These components are also used in activity diagrams to help describe a sequence of activities or
workflow.
A fork, represented by a bar, indicates where a single flow turns into two or more parallel flows.
A join, also represented by a bar, indicates where parallel flows become one.
Responsibility for completion of the activities in the modeled workflow can be represented by
labeled swimlanes. Swimlanes are lines drawn in the activity diagram to indicate specific areas of
responsibility. Swimlanes can be horizontal or vertical, depending on the layout of the activity
diagram.
The end point indicates the end of the sequence being modeled and is represented by a filled
circle with a border around it. When an end point occurs on an alternate flow, it is referred to as
an exception because the sequence does not complete as it normally would on the basic flow.
Understanding activity diagrams
In addition to knowing the components of an activity diagram, knowing how one is created can help build
an understanding of the activity diagram. To create an activity diagram, you first need to find out some
information from stakeholders:
Knowing where the sequence being modeled begins and ends sets the boundary for
requirements analysis.
To accurately depict a sequential flow, you need to know which activities must happen before
others, so the sequence dependencies must be known.
Any conditional logic that affects the flow of activities must also be accurately depicted in the
activity diagram. Conditional logic describes the decisions that, when made, create an alternate
flow.
On some projects, and in some workflows, it may be important to know who or what business
area or group is responsible for the completion of activities.
1227

The information gathered from stakeholders helps you determine an activity diagram's basic flow, as well
as any alternate flows and exceptions.
The basic flow is the expected and most probable flow a sequence of activities will follow from beginning
to end.
Alternate flows depict how the flow will behave as a result of conditional logic.
Exceptions can occur on basic or alternate flows and signify the premature end to the flow, for instance if
a user's login fails to be verified by the system.
When the required information has been gathered and organized, it needs to be expressed in the activity
diagram. Components are coupled with notation to help make sense of alternate flows and exceptions
within the activity diagram. The basic flow of activities arrows are not generally accompanied by notation
because their flow is expected; however, flow of activities arrows receive notation in a couple of
instances:
When decisions are necessary the branch component is used to start an alternate flow. The
alternate flow exiting the branch component is labeled with notation that expresses the guard, or
condition, that made the alternate flow necessary. This may be as simple as "yes" or "no" or it
may be a complex algorithm.
An exception occurs at a decision point where the condition, or guard, specifies that if the
condition is not met the flow must end.
Rules can help you complete an activity diagram and check that it is done properly. The rules are
only one start point per diagram
as many end points as required
one activity follows another
following a branch, either one activity or another happens next
following a fork, activities are parallel and may happen at the same time or one may start first
A recognized strength of activity diagrams is their ability to visually represent complex flows, decision
points, and parallel flows. The ease with which they are developed and the potential for a wide audience
to understand them.
While their ability to show responsibility for activities can be seen as an advantage, if the sequence being
modeled is complex, it can make the activity diagram difficult to both develop and understand.
The activity diagram is a process and flow analysis technique that works well on business process and
object-oriented analysis projects. The key components used to create an activity diagram are the start
point, flow of activities arrows, activities, branches, merges, forks, joins, and the end points. Activity
diagrams can also use swimlanes to denote responsibility for activities. However, the use of swimlanes is
optional.
1228

Activity diagrams can model complex sequences of activities and workflows and still be understood by a
variety of audiences. They are a good choice when it is important to communicate how a system behaves
and the logic that controls its flow over time.
Refining and Documenting Requirements
SkillBriefs
Functional Requirements
Explore techniques for documenting functional requirements.
Quality of Service Requirements
Discover ten types of quality of service requirements.
Decomposing Requirements
Learn key concepts associated with decomposition techniques.
Constraints and Assumptions
Learn about the influence of constraints and assumptions.
Requirements Attributes
Learn how to identify and determine requirements attributes.
Types of Requirements Documents
Explore the various types of requirements documents.
Validating and Verifying Requirements
Discover how to verify and validate requirements.










1229

Functional Requirements
The set of core behaviors that must be supported by a business system is called functional requirements.
Of the six requirement types, user requirements and functional requirements are similar and often
confused.
Functional requirements describe the required behavior of the solution. Functional requirements are
required for all projects, and must be thoroughly documented and analyzed. The difference between
functional and user requirements is that user requirements describe a specific set of stakeholder needs,
and not all solutions require defined user requirements.
The business analyst needs to be able to analyze different types of requirements. In order to do that,
requirements must first be properly documented. Functional requirements can be presented using four
documentation methods: textual documentation, matrix documentation, diagrams, and models.
Textual documentation
Textual documentation is typically used to state uncomplicated functional requirements that are small in
scope. This method is often used to describe business rules. The advantage of textual documentation is
that it is simple and easy to search.
Requirements should be stated in short paragraphs using simple terms, and each requirement must be
documented separately. It's important to use consistent terminology and to write in the active voice when
describing the requirement.
Three things must be included when documenting functional requirements textually:
a description of the capabilities of the solution
a description of any conditions that must exist for the requirement to operate
a description of any constraints that may prevent the solution from being able to fulfill the
requirement
Matrix documentation
Matrix documentation is used when the business analyst needs to present a set of complex, uniform,
functional requirements. A matrix may be used to document requirements attributes and data dictionaries,
and for prioritizing requirements with respect to project objectives.
The advantage of matrix documentation is that functional requirements are traceable and map to
objectives. A matrix should not be used for requirements that are not uniform.
Matrices are used to indicate how two or more elements relate to each other. The simplest form of matrix
documentation is a single-column table. A more involved table contains related information across rows
and columns.
1230

When constructing a matrix, the business analyst should use one row per requirements specification
paragraph, and identify it by the paragraph number assigned in the requirements document. There should
be one column per identified configuration item.
Diagrams
Diagrams are another way to document functional requirements. Diagrams are used to visualize
relationships between elements of a requirement. They should be simple and the graphical
representations consistent.
The benefit of a diagram over a textual requirement is that a diagram can often be easier to understand,
presenting clear views of the structure and relationships of functional requirements.
Diagrams can be used to show
the relationship between different elements of a solution
events that need to occur in a specific order, including parallel events
the physical location of elements of the solution
Models
Models are used to represent functional requirements that are too complex to be effectively covered by a
single document item. They may take the form of one or more of the other documentation methods.
The benefits of modeling are that models simplify complex systems and concepts, and help eliminate less
relevant information that may be confusing. This is why they are typically used for documenting very
complex project or system requirements.
Models depict requirements from different perspectives. Because of this, they help the business analyst
examine all elements of a problem and devise a solution.
Sometimes a model is unnecessary or undesirable. A business analyst may decide against modeling
when
the problem domain is well known
the solution is simple
few people need to collaborate to plan or implement the
the solution requires minimal maintenance
the scope of future requirements is limited
When documenting functional requirements, it's important to do so in such a way that stakeholders are
able to
1231

uniquely identify every statement of requirement - Each statement of requirement needs a
unique identifier so that it can be referenced and tracked.
classify every statement of requirement in multiple ways - Functional requirements should be
documented with enough information that stakeholders can classify them in different ways, such
as in terms of importance, type, or urgency.
track the status of every statement of requirement solution - The status of each functional
requirement must be traceable in different ways, such as review status, satisfaction status, and
qualification status.
elaborate a requirement in multiple ways - Functional requirements must be defined in multiple
ways, such as in terms of performance information, quantification, test criteria, rationale, and
comments.
view a statement of requirement in the document context - A statement of requirement must
be available to be reviewed in context alongside other relevant statements.
navigate through a requirements document to find requirements according to
classification or context - Functional requirements must be documented in such a way that
stakeholders can find what they need by searching either a requirement classification or by the
context of the requirement.
trace to any individual statement of requirement - Every functional requirement must be
associated with one of the requirements listed in the statement of requirement. These
requirements have unique identifiers in order to be more easily referenced.
Functional requirements describe the required behavior of the solution. They need to be documented and
analyzed for every project. Four different documentation methods can be used: textual documentation,
matrix documentation, diagrams, and models. The business analyst must learn how and when to use
each of these methods appropriately and effectively using best practices.
Functional requirements need to be documented in such a way that they include all relevant information
and so that stakeholders can find the information they need quickly and easily.
Quality of Service Requirements
Just as business solutions must meet particular functional requirements, they must also maintain the
expected quality of service under a variety of conditions. Quality of service requirements describe the
conditions under which the solution must remain effective. Sometimes called non-functional requirements,
quality of service requirements often describe solution constraints.
There are ten types of quality of service requirements:
Environmental requirements are constraints that come from outside the scope of the project, and must
be specified by the business analyst. The three most common types are audit, globalization and
localization, and legal and regulatory.
1232

Audit requirements involve information that isn't strictly needed by the system but that must be
available if requested.
Globalization and localization requirements are things that need to be included for different
countries and cultures.
Legal and regulatory requirements are those imposed by governments and external regulatory
bodies.
Interface requirements deal with how the parts of a computer system interact.
Hardware interface requirements describe how the interface needs to interact with the hardware
components of the system.
Software requirements describe how the interface interacts with other software components.
Operational requirements describe how a system functions, and how it needs to interact with other
operators.
Performance requirements establish the level of efficiency the system needs to be able to reach in a
specific time frame.
Privacy requirements define what information is private and the conditions under which it can be
distributed, internally and externally.
Quality requirements define the expectations of quality for a system. They describe specific, prioritized
characteristics of a system, and must be qualitative and verifiable. There are various types of quality
requirements:
Failure and disaster recovery requirements define the protections that need to be in place to help
prevent full or partial system failure and data loss.
Maintainability requirements explain the way in which future changes to the solution must be
implemented.
Scalability requirements describe how to plan for the growth of the solution over time.
Safety requirements define the requirements involved with potential losses or damages that may be
incurred as a result of using the system. This includes safety measures and precautions that must be
taken, as well as preventative measures.
Security requirements deal with protecting the information used and produced by the system. This
includes requirements for monitoring and restricting access to sensitive information, as well as defining
the risk of the information being accessed illicitly.
Training requirements define the level of knowledge required to interact with the solution, as well as any
changes that may arise and who may be affected.
1233

A glossary is also a quality of service requirement. It describes terms and definitions relevant to the
project.
Quality of service requirements define conditions under which the solution must be able to operate. They
are sometimes called non-functional requirements, and they can be used to define solution constraints.
Quality of service requirements include environmental, interface, operational, performance, privacy,
quality, safety, security, and training requirements, as well as a glossary. These requirements define how
the solution must behave under different circumstances, which can help keep the project on track toward
the expected solution.
Decomposing Requirements
Requirements should be organized in such a way that stakeholders can easily find the information they
need. Requirements decomposition is a way to group requirements into categories. A business analyst
can use decomposition techniques to structure requirements into packages. This helps refine the
problems and solutions initially identified during enterprise analysis.
The business analyst needs to define the solution boundary and structure the solution definition.
Defining the solution boundary involves documenting the ownership of the solution, such as
where other actors interact with the solution, where other systems provide or extract information
from the solution, and where time initiates activities for the solution.
Structuring the solution definition involves describing the solution in manageable terms and
breaking tasks down so they are as independent as possible.
Defining the solution boundary and structuring the solution definition can be done using any or all of three
key decomposition techniques: goal decomposition, feature list decomposition, and functional
decomposition.
Goal decomposition
A goal is a textual business requirement. The purpose of goal decomposition is to focus the solution to
meet high-priority stakeholder needs. Goal decomposition breaks high-level goals into lower-level goals.
These lower-level goals must be measurable, must include objective criteria, and must be achieved by
the solution or by an external source.
Goals need to be measurable in order to be properly met. If a goal is not measurable,
stakeholders' expectations may differ.
In order for stakeholders to determine when the goal has been achieved, the lower-level goals
need to include objective criteria that can be decisively met. Objective criteria are things like
performance targets, costs, and aesthetics.
1234

Each goal must be addressed by the solution. If an actor outside the scope of the solution is
responsible for achieving the goal, the solution must still be able to accommodate success or
failure to achieve the goal.
Feature list decomposition
Features are high-level descriptions of the desired behavior of the solution. They let the business analyst
manage scope and priority at an early stage. They also validate stakeholder views of the solution.
A feature can be textual or it can be graphical. For example, use cases are sometimes presented
graphically. A use case is an examination of an actor's flow through a system. It is used to understand
how a system will be used. For example, a feature in a use case might be that users can print reports
from the system.
Feature list decomposition involves breaking each feature into specific detail. This includes the feature
description and priority - Each feature should have a specific description and priority assigned to
it.
stimulus/response sequences - The interaction between each component of the solution needs to
be explained in order to understand the possible reactions.
functional requirements - The functional requirements of each feature should be included in the
feature list. These are descriptions of the required behavior of the solution.
Functional decomposition
Functional decomposition involves breaking down functions into smaller tasks. This enables detailed
analysis of each task.
When performing functional decomposition, the business analyst must follow these steps in order:
1. Identify the high-level functions of a solution. This allows the business analyst to ensure all of the
key processes will be considered.
2. Break down the high-level functions into lower-level processes. Each high-level function can be
broken down into smaller, more specific functions. The resulting functions are also broken down
until a single identifiable task is reached that cannot be broken down any further.
3. Model the functions and processes. The components of the functions and processes can be
presented in several ways, including a hierarchical diagram, a tree diagram, or by simply
numbering each task. This allows each task to be understood in relation to the others.
Requirements should be organized for easy access. Requirements decomposition is one way to do this.
A business analyst uses techniques such as goal decomposition, feature list decomposition, and
functional decomposition in order to break requirements down into manageable pieces.
1235

Constraints and Assumptions
When you're working on a project, you need as much information as possible about anything that may
influence it. This might include how much money you have to work with, how long before the project
needs to be completed, and who can work on the project. Business analysts identify these influences as
assumptions and constraints. They're usually documented textually since they don't present as well using
a model.
Constraints
Constraints are any restrictions or limitations to the solution. The specific nature of the constraints dictates
the flexibility of the project to meet the solution requirements. This especially applies to things that would
normally be allowable, but for some reason are not valid options for the project.
A business analyst needs to break down constraints into two categories: business constraints and
technical constraints.
Business constraints define operational and organizational limitations on the solution. This includes
restrictions on time, budget, and resources, as well as skills required by project team members and
stakeholders.
When considering business constraints, it's important to analyze them closely and ensure they are
justified. Business constraints may differ in type, but they all have an impact on the solution. Some types
of business constraints are
budget - Any financial restriction on the project is a business constraint. For example, if business
leaders mandate a specific operating budget to which the solution must adhere, the project team
must in turn implement a solution that adheres to this restriction.
time - Time and scheduling are critical to the success of a project. A business constraint might be
when the use of a resource with limited availability is required during the project. In this case, it is
important that the project schedule is prioritized in a way that puts this resource to use only when
it is available.
resources - Resources can be either human resources or infrastructure resources. A business
constraint on the solution could be a construction project obligated to use a specific supplier for
building materials. The necessity for and availability of team members with specific skill sets is
also a business constraint. If the project will require the services of a database performance
expert, this needs to be addressed, since the unavailability of such an individual will impact the
effectiveness of the solution.
policy - Company policies can impose business constraints on a project. For example, a company
may insist that each new software product it develops passes a third-party security certification
before being released.
Technical constraints also describe restrictions or limitations on the solution, but refer specifically to the
technical environment under which the solution will be deployed. These constraints may include items
1236

such as hardware and software requirements, architectural design standards, and required application
software.
Like business constraints, technical constraints also come in a variety of types:
hardware - Hardware constraints put limits on what equipment must be used. For example, a
company developing a portable global positioning system dictates that the new devices must use
the same power adapters and chargers as wired GPS. The solution is technically constrained to
use implementations that use the same adapters and chargers.
software - Technical constraints may be in the form of software restrictions, such as requiring
compatibility with a specific software platform. For example, it may be required that a digital
imaging application be compatible with other digital imaging applications.
architectural - Architectural constraints include restrictions such as resource utilization, number of
files, and data record sizes. For example, a company is developing a software system that is
intended to be deployed on a number of varying physical servers that cannot be upgraded. The
application is technically constrained to work with the current amount of memory and disc space
available on the system with the lowest specifications.
standards - Technical constraints may be in the form of specific standards that the solution must
meet or adhere to. For example, for ease of maintainability, a software engineering group
requires that all projects to which it contributes use a specific coding standard.
Assumptions
Where constraints tend to limit a solution, assumptions open up possibilities. Assumptions are
suppositions about conditions that apply the project. Assuming certain things about the project allows the
project team to move forward in the face of a certain amount of uncertainty.
Assumptions are based on the best knowledge or expectations at the time. Because they are not always
known with certainty, they are a source of some project risk. Therefore, it is important to formally record
assumptions as soon as possible.
Assumptions can be one of two types:
an assumed but unverified condition - Some critical conditions may be assumed when designing
a project solution, even if they are not verified when the requirements are specified.
a verified condition that is assumed will not change - A business analyst may identify an existing
condition that is vital to the successful implementation of the solution. The assumption is that this
condition will not change; if it does, it will have a detrimental effect on the project.
Business analysts identify assumptions and constraints that may influence the implementation of a
project. Constraints put limits on a solution. They may be business constraints, such as restrictions on
budget, time, and resources. Or they may be technical constraints, such as restrictions on hardware and
software usage on the project.
1237

Assumptions make things possible on a project. A business analyst may assume certain conditions, such
as material availability, in order to move a project forward. Or the business analyst may include an
assumption that a critical condition for the project will not change, such as the retention of any key project
team members.
Requirements Attributes
Attributes provide necessary information about project requirements. They make it possible for
requirements to be grouped according to different criteria. Being able to sort requirements in different
ways enables more efficient requirements analysis. Two requirements may seem unrelated at first, but
sorting by common attributes may reveal a relevant connection.
Requirements and their attributes must be presented properly. Using a template is a good way to ensure
accuracy and consistency when documenting requirements attributes. It's also important to use the right
language when documenting requirements. The use of specific imperatives can add weight to the priority
of the requirement, such as
shall and must - By using "shall" or "must" you are indicating that the requirement is mandatory.
should - The use of "should" indicates the requirement is desirable, but not mandatory.
may - Using "may" indicates that the requirement is optional.
will - The use of "will" indicates that the requirement is already expected to be fulfilled external to
the solution.
Requirements may have several different attributes assigned. The ten most common requirements
attributes can be grouped into three categories.
Four of the ten most common requirements attributes identify or describe the requirements:
The unique identifier attribute is a numeric or textual reference that each requirement must
have. It must be unique, and it must never change, even if the requirement is altered or even
removed. Given a unique identifier, a requirement can be tracked through all versions of
requirements documentation. Making it immutable improves document maintainability and
consistency throughout the course of the project.
The author attribute is straightforward it refers to the person who wrote the requirement.
Noting the author of a requirement is important in the event that clarification is needed at a later
project stage. The author attribute can be used to differentiate between the writer and the person
who is ultimately responsible for the requirement. The author may have provided the requirement
and is a good point of contact to get more information about a requirement or the purpose behind
the requirement when performing analysis. But the author may not necessarily be the person
responsible for ensuring the requirement is properly specified or satisfied.
The ownership attribute describes the person or group for whom the requirement is necessary.
It may also refer to the business owner once the project is completed. It is especially useful if a
project has requirements from several different sources. Ownership can be used to clarify a
1238

distinction between the author who writes the requirement and the person or organization
ultimately responsible for specifying the requirement and ensuring it is satisfied.
The source attribute refers to the origin of the requirement. Each requirement must be traceable
to an authorized source, in the event that the requirement changes or more information is needed
during the course of the project. Business objectives or stakeholders are often the source of
project requirements.
Attributes that identify or describe requirements are important in that they allow requirements to be
properly traced and accessed at any time during the course of the project. Dealing with requirements that
cannot be properly identified may result in wasted time and resources if a problem arises during the
course of the project.
Two of the ten most common requirements attributes deal with the significance of the requirement:
The priority attribute describes the order in which requirements must be implemented. Common
priority levels are "low," "medium," and "high." Prioritizing requirements is a balancing act
between schedules, resources, and quality. Some necessary requirements must be completed
before others may begin; this is where priority is especially important. Some requirements will be
non-negotiable, but some may fall into the "nice to have" category. The traditional tradeoffs during
the course of any project are time, cost, and quality. "Nice to have" requirements need to be
evaluated and prioritized in order to deliver an acceptable product in an achievable time frame at
a reasonable cost.
The urgency attribute refers to how quickly the requirement is needed. This is documented
separately from the priority attribute when there is a specific deadline for implementation of the
requirement. Urgency is measured in terms of the date and time the requirement must be
completed.
Attributes that deal with the significance of requirements are useful when deciding how to handle each
requirement. Requirements with specific implementation deadlines can be planned for, and the highest-
priority requirements can be given the attention they need.
The final four of the ten most common requirement attributes indicate the state or condition of the
requirement:
The stability attribute refers to the maturity of the requirement. The amount of change to a
requirement since its origin indicates its stability a requirement with many changes is less stable
than one with only a few. Stability levels are often documented as "low," "medium," and "high." A
version number should also be included to help track the evolution of the requirement. Stability
should be used when requirements are in a state of flux, or when a requirement is subject to rapid
changes. Unstable requirements are a sign that project team members need to perform frequent
checks to ensure the latest modifications to the requirement are implemented and tested.
The complexity attribute refers simply to the difficulty expected in implementing the
requirement. Complexity management is critical it's important to know how much work will be
required to satisfy the requirement. Complexity can be documented on a scale of one to five, with
one being a simple requirement, and five being a complex requirement.
1239

The acceptance criteria attribute describes the conditions that indicate the requirement has
been correctly implemented. It is a set of minimum behaviors to which the solution must adhere in
order to be considered satisfied.
The status attribute indicates the state of the requirement. Requirements may be proposed,
accepted, verified, or implemented.
Some attributes are mandatory for all requirements. Every requirement must have a unique identifier,
status, and acceptance criteria assigned. This information is critical to effective requirements
management.
Knowing how to decide which attributes to assign is important to proper requirements documentation.
When deciding which attributes to assign to a requirement, a business analyst must decide what
information will be the most useful when dealing with the requirement. It isn't practical to assign every
attribute to every requirement. Key attributes that are most often necessary include author, priority, and
source. This is in addition to the mandatory attributes of a unique identifier, acceptance criteria, and
status.
Attributes offer important information about requirements. They allow requirements to be grouped based
on different characteristics, enabling more efficient requirements analysis. When documenting these
requirements attributes, use of imperatives can provide insight into the priority of the requirement. Terms
like "shall" and "must" indicate a mandatory requirement, whereas "should" and "may" represent non-
mandatory requirements, and "will" describes a requirement that is expected to be fulfilled external to the
solution.
More than one attribute may be assigned to a requirement. There are ten requirements attributes
commonly used, which can be grouped into three categories. Attributes that identify or describe the
requirement are unique identifier, author, ownership, and source. Attributes that deal with the significance
of the requirement are priority and urgency. Finally, attributes that indicate the state or condition of the
requirement are stability, acceptance criteria, complexity, and status. Of these ten attributes, three are
mandatory for every requirement unique identifier, status, and acceptance criteria.
Types of Requirements Documents
When starting any project, whether it's charting unknown waters or building a house, you need to know
exactly what is required for success. Requirements documents describe the functional and quality of
service requirements for a project. Requirements documents contain all the information about each
requirement and are used to define project tasks. They are statements of what the project needs to
accomplish.
There are no strict rules to follow when choosing how to write requirements documents. It's up to the
business analyst to evaluate several factors including the methodology adopted by the enterprise, the
objective of the project, and the needs of stakeholders and then make the best choice.
A business analyst has five different formats to choose from when drafting requirements documents:
1240

A vision document can be created through enterprise analysis. It documents the overall scope of the
solution domain, and should be the first requirements document the business analyst puts together.
A business process description is a high-level summary of the problem and the solution. It addresses
issues such as what the problem is and what the customer wants. It includes information about what the
project is about, who will use the solution, and how the solution should behave.
A business requirements document (BRD) is used to describe the business requirements defined
through enterprise analysis. It is intended to be utilized by customers and users. In addition to a basic
cover page, a business requirements document typically contains several components:
A version control table is used to track the history of the documents. It records the date,
description, author, and authorization for each version, which is given a unique identifying
number.
A RACI matrix Responsible, Accountable, Consulted, and Informed is used to describe how
project team members and stakeholders interact with the business requirements document. It
explains who is responsible for creating the document, who is accountable for the accuracy of the
document, who is consulted during the development of the document, and who must be informed
of any changes to the document.
The executive summary is a single page that summarizes the business requirements document.
It should provide a brief overview of the project, including background and objectives, and
summarize the requirements and the proposed solution. The executive summary also describes
the project scope and any constraints that have been identified. The risk analysis, business case,
and the impact of proposed changes should also be included in this document.
Software requirements specifications (SRS), also called system requirements specifications, describe
the required behavior of a software system, and how it is to be implemented. It is used by the
development team responsible for implementing the solution.
Requests for proposal (RFPs) and requests for quotation (RFQs) are used to contract solution
development services from external organizations. Specific objectives need to be stated to ensure the
developers understand exactly what the solution requires.
Each requirements documentation format offers specific information to the project team, the stakeholders,
and the client. Vision documents, request for proposal documents, and request for quotation documents
state the business requirements for the project. The business process description describes the current
business model, as well as user and functional requirements.
The business requirements document and software requirements specification both cover the
requirements model; user, functional, and quality of service requirements; and assumptions and
constraints. Software requirements specifications also cover requirements attributes and include a
traceability matrix.
Requirements documents are used to describe the functional and quality of service requirements for a
project. They can be developed using five different formats: a vision document, a business process
1241

description, a business requirements document, a software requirements specification, and a request for
proposal or quotation.
Validating and Verifying Requirements
Validation and verification of requirements are similar, but different things. Understanding the difference is
important to ensure requirements are handled properly.
Requirements validation helps the business analyst answer the question "Are we producing the right
product?" Requirements verification helps answer "Are we producing the product right?"
Requirements validation
It's important to validate project requirements before work begins. Requirements validation helps ensure
that the requirements have been sufficiently defined to allow the right solution to be developed.
Three techniques that can be used for requirements validation are requirements reviews, prototyping and
model validation, and acceptance testing.
Requirements reviews are a type of peer review. They help identify any requirements that are
ambiguous or incomplete, as well as any requirements that are unverifiable or improperly defined. The
reviews can be performed formally or informally. Informal reviews can be used to introduce the project
and its requirements to others, and to obtain general feedback. There is no set process, and reviews are
not always consistent or thorough.
Formal, structured reviews follow a specific process to help achieve more comprehensive coverage of the
requirements. This type of review results in a report that summarizes the problems with the requirements
and any issues that arise during the review.
One type of formal review is an inspection. People with different perspectives on the project should be
included in the inspection process up to about six people in order to keep the process manageable.
Among them should be the business analyst, the project manager, and key project team members.
During the inspection process, requirements are evaluated to determine their
organization and completeness In order for requirements to be valid, they need to be properly
organized and complete. They should be written consistently, with an appropriate level of detail to
ensure they provide the information needed to design the solution. Ambiguous requirements will
cause problems later in the project, so it's important to validate the requirements before the
project begins.
correctness Requirements need to be correct for them to be valid. They must be unique, and
cannot contradict other requirements. Each requirement must fall within the scope of the project,
and be achievable within known project constraints. They must also be clearly written using
proper syntax.
1242

quality attributes Validation includes making sure the requirements attributes are right.
Performance objectives, and security and safety considerations must be properly specified, and
any other quality attributes need to be specifically documented.
traceability Each requirement must be uniquely identified to ensure it is traceable. If a
requirement is not identified correctly, it may be mishandled or left out of decisions that should
take the requirement into account, potentially causing errors or mistakes for the project.
special issues Requirements validation includes addressing special issues, such as ensuring
that the documented requirements are actually requirements and not solutions in themselves. It
also involves checking whether any time restrictions are identified and properly documented, and
ensuring that internalization issues are sufficiently prepared for.
Part of validating requirements is prototyping and model validation. Test cases are used to
demonstrate expected system behaviors. This helps expose any problems with the requirements early,
before correcting them becomes a complicated and expensive process. Problems could include
incomplete requirements or even missing requirements.
Black box test cases help you understand how a system is expected to behave under specific conditions.
This information can be used to evaluate textual requirements, analysis models, and prototypes.
Acceptance testing is used to evaluate whether the solution or system meets the requirements.
Acceptance tests should be developed early on so that any discrepancies between the acceptance
criteria and the stated project requirements can be identified and remedied.
Anticipated usage scenarios should be the focus of acceptance testing. Use cases help determine the
acceptance criteria that the solution will have to achieve in order to satisfy the testing. They should focus
on the normal expected behavior, and do not need to map every possible scenario.
Requirements verification
Requirements verification is necessary to ensure that the stated requirements for the project will help to
achieve the expected solution.
Criteria for verifying requirements include determining whether the requirement is
complete Requirements must be complete to be verified. This means that each requirement
must be documented, providing all of the information needed to achieve the requirement.
consistent It's important that requirements are consistent they must not contradict or come
into conflict with each other.
correct Requirements must be correct in order to be verified. Each requirement should be
described accurately according to the standards of the person who set the requirement.
unambiguous A requirement cannot be verified unless it is unambiguous. The requirement
should be phrased in such a manner as to leave no room for interpretation, and its meaning
should be absolutely clear to all readers. One way to keep requirements unambiguous is to write
1243

the requirements using simple, concise language and to ensure that any technical terms that may
impact understanding are clearly defined.
feasible Requirements must also be feasible in order to be verified. They should be possible to
achieve within the scope of the technical and operational environment of the project.
traceable A backward traceable requirement has a clear path to its specific origin, whether that
origin is based on a client's statement, a use case scenario, or a business requirement. A forward
traceable requirement has a specific identifier that allows it to be identified through all the parts of
the solution.
measurable and testable Each requirement must also be measurable and testable in order to
be verified. Testing helps ensure that the solution will meet the requirements.
Validating and verifying requirements is essential to ensuring that the project has proper requirements.
Requirements validation helps to determine whether the requirements have been sufficiently defined in
order to develop the expected solution. Three techniques that can be used for requirements validation are
requirements review, prototype and model validation, and acceptance testing.
Requirements verification helps to determine whether the stated requirements will achieve the expected
solution. In order to be verified, requirements must be complete, consistent, correct, unambiguous,
feasible, traceable, and measurable and testable.
















1244

Software testing
The Necessity of Software Testing
Learning Objectives
After completing this topic, you should be able to
recognize different types of software errors
recognize how testing can improve quality in software development
1. Correcting Errors, Defects, and Failures
Software systems form an integral part of our daily lives. Whether in our homes or at our
workplaces, software systems have become indispensable for a comfortable existence.
Therefore, software failure can prove expensive and result in the loss of time, effort, and
reputation.

For critical software, these failures can also cause major financial losses, injury, or result in the
loss of life.
Let's consider a software program used to issue airplane tickets online. Suppose the program
used to create reservations miscalculates airfare because it erroneously inserts an extra zero in
a numeric field used to perform the airfare calculation. In such a situation, if the airfare
calculated was uncompetitively high, potential customers would likely refuse to pay the price and
take their business elsewhere. This could cause a loss of reputation for the airline along with the
lost business.
In another instance, suppose a refrigerator is rolled out with an incorrect automatic defrost
temperature. In this case the refrigerator might overheat resulting in complete failure of the
appliance. This failure may require the company to arrange for a recall or a complete
replacement of the appliance for all new customers. This, in turn, would result in a loss of and a
negative image for the brand.
In more serious cases, faulty software systems may result in injury or loss of life. Consider a
software system that miscalculates the quantity of chlorine needed to disinfect the water in a
reservoir. Suppose a decimal point is wrongly placed so that the amount of required chlorine is
double the permissible amount. This could be fatal for the people using the water.
In another instance, a software error in a medical machine could have serious implications for
any patient using the machine.
This is why it is important to locate and rectify the defects of a software system before it is
released for public use.
1245

To eliminate the defects in faulty software, it is important to understand what causes the defects.
Faulty software is a result of the errors (or mistakes) made while designing and building it.

Most software issues can be divided into three categories. These categories are
error
An error (or mistake) is an action performed by a person or persons that leads to an incorrect
result. This could be an error made by someone using a software system, or an error made by
someone in the process of designing and building the software system.
defect
A defect, also known as a bug or fault, is a flaw in a component or a system that can cause the
component or system to fail to perform its required function such as an incorrect statement or
data definition.
failure
A failure is defined as a deviation of the component or system from its expected delivery, service,
or result.

A defect causes a software system to fail. Failures occur when a software system doesn't perform
as expected by the end user, or executes an action which it shouldn't have. It is important to note
that not all defects result in a failure a failure only occurs when code is executed.
Errors tend to increase due to stringent timelines, inexperience, careless working habits,
complex work situations, or even misinformation.

Failures may also be caused by environmental factors including, but not limited to, climate
change, pollution, and magnetic fields.
Though not all errors translate into failures, errors can lead to a defect, which can, in turn, cause
a failure. You can reduce the likelihood of an error occurring in the future by conducting a root
cause analysis.
Root cause analysis involves trying to track the failure of a system all the way back to its root
cause. Understanding and eliminating the root cause of a failure results in software process
improvement, which should prevent the recurrence of related failures in the future. This should
bring about an overall improvement in the quality of those systems.
Root cause analysis is an important part of quality assurance. Root cause analysis can help to
anticipate defects in a product, and tackle them at an early stage.
Defects can arise in any of the four stages in a product life cycle analysis, design,
development, and implementation.

Based on these stages, here are four scenarios to consider.
1246

Graphic
The table is composed of four rows and four columns. The four columns are named Analysis,
Design, Development, and Implementation. The rows represent requirements one, two, three and
four. All four cells of the first row represent a zero-defect delivery scenario. A box at the end of the
first row says that in such a scenario, all correct attributes of the product are delivered.
In the second row the first two cells represent zero defects while the third and fourth cells represent
defects. A box at the end of the second row says that in such a scenario, defects can be corrected.
In the third row only the first cell represents zero defect while the second, third and fourth cells
represent defects. A box at the end of the third row says that in such a scenario, redesign is
required to correct defects.
In the fourth all the cells represent defects. A box at the end of the fourth row says that in such a
scenario, correction may be impossible.
requirement 1
Requirement 1 is an ideal scenario where you have been able to completely comprehend the
customer needs. The designer of the product has succeeded in understanding customer needs
and designs a product to meet those needs.

The product is built in accordance with the design and as a result, the product works as expected
and houses all attributes required for flawless execution.
requirement 2
In the scenario for requirement 2, all works well until the product is designed. Defects occur while
the product is being built or coded. Such defects are internal and can be detected during testing.
Such flaws can be easily corrected.
requirement 3
In requirement 3, a defect is introduced during product design. Such defects are difficult to
correct. To eliminate such a flaw, it becomes imperative to map customer requirements to the
design. If the mapping is not conducted, such errors will go undetected during the testing phase
and when detected later, they will be difficult to fix as it would require considerable redesigning.
requirement 4
Requirement 4 is the most difficult to address. This is caused when customer needs have not
been comprehended, or have not been communicated effectively. You might design a flawless
product from your understanding of the requirement. The product might also pass all tests but will
be rejected because it does not cater to the customers expectations. Such defects appear only
during the test or live phases and result in considerable financial loss.
Other than understanding the impact of defects at various phases of a product life cycle, it is
also important to understand the effects of fixing defects on cost and time.
Graphic
1247

The connection between time and cost is represented by a graph. The X axis of the graph
represents time while the Y axis represents cost. There are five boxes aligning the X axis
Analysis, Design, Development, Test, and Use.
If you misunderstand a client requirement, and detect the defect during the needs analysis
stage, it becomes very easy to correct. A new requirements document could be issued after a
discussion with the customer. Again, if the same defect is detected during the design phase of
the product, the requirements are mapped to the design and easily corrected with minimal
expenditure.
Graphic
The passage of time is represented by a dotted line appearing from the beginning of the axes and
ending on the block labeled Design. The line is a curved upward line.
But if such a defect is detected after the product is launched, the cost to fix the defect could be
huge, as it demands high level design and code changes. To lower expenses related to testing
and defect fixes, it becomes imperative to eliminate any possible error as soon as it occurs.
Therefore, the cost of fixing a defect is directly proportional to the passage of time.
Graphic
The dotted line increases further and ends on the block labeled 'Use'. The words, 'The cost of
investigating and correcting defects is directly proportional to the increase in time.' appears.
Question
Match the definition to the correct software testing term.
Options:
A. An action by a user that produces a result from the system that is incorrect.
B. A flaw in a component or system
C. A deviation of a component or system from its expected result
Targets:
1. Failure
2. Defect
3. Error
Answer
1248

A failure is defined as a deviation of the component or system from its expected delivery, service or
result.
A defect is a flaw in a component or a system that can cause the component or system to fail to
perform its required function such as an incorrect statement or data definition.
An error is an action by a user that produces a result from the system that is incorrect.
Correct answer(s):
Target 1 = Option C
Target 2 = Option B
Target 3 = Option A
2. Software testing as a solution
Quality is how well a component, system or process is designed, and how well it conforms to the
design.

Testing helps to improve your confidence that a product meets criteria for quality.

You must make sure that the testing has been thorough. Weak tests may provide a false sense
of security because they may not uncover defects. This results in defects being uncovered only
during execution.
Testing is a thorough procedure and tests for both
functional attributes
Testing for functional attributes ensures that the product performs an expected task.
non-functional attributes
Testing for non-functional attributes measures how well or fast a task is performed. Testing non-
functional attributes usually requires a metric, such as time to complete a task.
In addition to testing attributes, part of the testing effort is focused on verification and part on
validation. Verification evaluates a product to determine that it meets the requirements set out
for it. Validation ensures that it meets the needs of users, and that it is fit for the purpose for
which it was built.

It is also important to maintain focus on the variables of time and cost. The best solution is one
that delivers as promised, within the allotted time frame while remaining within budget.
You might design and develop a product that fits a clients specification, but if it significantly
exceeds the clients budget the status of the project as a success could be compromised.
1249


For example, if a customer wants a simple scanning application, designing a complex integrated
scanning, photocopying, collating and mailing system for them will add needless complexity,
cost, and time to what should have been a simple system.

Similarly, if the testing phase for the scanner continues for so long that it results in missing the
targeted release date of the product, it again results in increased cost and customer
dissatisfaction.
It is essential to understand the expectations of customers and then create a testing plan.
We could sum up customer expectation based on five perceptions of quality that include
physical features
When the quality of a product is gauged simply by observing its physical features, the customer
might only want the superficial attributes of the product to be quantified.
usability
When the customer gauges quality by assessing the product's usability, and not just by
quantitative methods, then simply making sure the product can achieve the task is not enough.
The product would not be ready for release until the usability meets their criteria.

This could mean performing a task in a given timeframe, or allowing users to use it with minimal
training.
industry standards
Proper software testing can give a quantitative measure of software quality for both functional and
non-functional requirements.
subjective responses
Customer reactions to quality can often be a gauge to their expectations and willingness to
believe that the product will meet their needs.
The purpose of testing is to eliminate defects and assure a quality product. Complete or
exhaustive testing is defined as a test approach in which the test suite comprises all
combinations of input values and preconditions. Exhaustive testing, though ideal, is neither
practical nor advisable. Which brings us to the question how much testing is enough?
To counter the problem, you should focus your testing efforts on risk and priorities. Exhaustive
testing is impossible in all but a very small number of cases. Take for example a text input field.
Even if we only consider alphanumeric input, there are 62 possible inputs for each character
space available. The number of possible combinations is enormous 14 million combinations
for just 4 character spaces. Clearly exhaustive testing would be impossible.
You can provide customer satisfaction only when you deliver a product that satisfies the
customers needs and is delivered on time and does not exceed the budget.
1250

A test approach should be devised by comparing the test with the risks, which the customer, the
project stakeholders, the project as an entity, and the software is exposed to.

What should be considered is the level of risk technical or business and time and budget
constraints.

A risk assessment will decide the amount of testing that is advisable. This amount will vary
depending on the level of risk involved. Testing should also supply project stakeholders with
requisite information which will help them to make informed decisions about software release for
the next stage in development or roll-out to customers.
Summary
Software systems are an increasingly common part of life, from business applications to
consumer products; yet, most people have experienced software that did not work as expected.
Defective software could lead to a loss of money, time, reputation, and could even cause injury
or death.

A human being can make an error, which results in a defect in the software. When the code is
run this can lead to a failure.

Proper testing of software can help to reduce the risk of problems occurring during operation
and contribute to the quality of software.














1251

What is Software Testing?
Learning Objective
After completing this topic, you should be able to
recognize the different goals in testing
1. Testing as a process
The main objective of testing is to discover defects. Other objectives include preventing defects,
and getting a measure of the quality of software, often to increase confidence. Testing as a
process consists of activities before, during, and after actual testing occurs.
Testing includes a range of activities that form an integral part of every stage of the software life
cycle. You should always try to detect and fix defects during the initial stages of software
development as it is a more economical option. If defects are detected during the analysis phase
while verifying the requirements of the client, it can save a lot of headaches and potential costs
related to finding the defects later in the process.

Testing during the requirement phase involves checking the test basis client requirements and
design specifications against the test design.
Note
A test basis includes all software related documentation which specifies the requirements of a
customer. If a document can be changed only by a formal amendment procedure, then the test
basis is referred to as a frozen test basis.
Various types of testing methods are used during each stage of the software life cycle. You can
classify testing into static and dynamic testing. When you conduct tests by running a software
program it is known as dynamic testing. Dynamic testing, though less cost-effective than static
testing, is a more thorough testing procedure than static testing. Dynamic testing involves
executing the code for an application and generally requires more effort in terms of cost and
time.
Static testing includes reviewing software related documentation and source code. This type of
testing is more economical than dynamic testing and helps deliver an overview of the quality of
the software.

The static testing methods would form a part of the activities such as analyzing customer
requirements and specifications, creating the design for the software, and writing the
instructional manual. Dynamic testing would be required after you have written code for a
functional piece of software.
1252

Planning is key to software testing and includes processes that take place before and after test
execution. Planning may include activities such as creating a test plan and test strategy.
Planning also includes defining entry and exit criteria.
After creating a test plan, preparation is the next step in software testing. Preparation involves
determining test conditions and designing test cases.
Note
A test case is a set of input values, execution preconditions, expected results, and execution post
conditions. A test case is developed with a defined objective or test condition. This is done to
exercise a particular program path or to verify compliance with a specific requirement.
After test execution, you should evaluate the test to check whether it has satisfied all
preconditions stated in the test plan. Also, it is important to check whether enough testing has
been conducted and if it is appropriate to end the testing process.
Different testing viewpoints take different objectives into account. Here are three objectives,
along with some information in general terms about when they might be considered. These
include
finding defects
In development testing, which includes component, integration and system testing, the main
objective may be to cause as many failures as possible in order to identify defects and fix them as
early as possible in the software life cycle.
gaining confidence in product quality and providing information
Later in the software life cycle during acceptance testing, the main objective may be to verify that
the software works as anticipated, and gain confidence that requirements have been met. A
similar objective at this phase may be to provide information about the state of the system to
stakeholders in order to assess the quality of the software (with no intention of fixing
defects). This is done primarily to gauge the risk of releasing the system at a given time.
preventing defects
In maintenance testing, the main objective may be to ensure that no new defects have been
introduced during development of changes.
Other than development and acceptance testing, you also need to conduct maintenance and
operational testing.

Maintenance testing is done on an existing and operational system. It might be required after
modifications to the system, or migration.

The main objective of operational testing is to check for characteristics such as reliability and
availability. Attributes such as reliability and availability surface during the operational use of the
software. Reliability is a set of attributes representing the capability of the software to maintain a
1253

level of performance under stated conditions for a stated period of time. Availability refers to
whether the product is ready for use whenever required.
Testing is an iterative process, and organizations will improve their testing capability and
knowledge with time. This will have a positive knock-on effect for future projects in terms of
quality and assurance.
Question
What stages of a software life cycle would require dynamic testing?
Options:
1. Analyzing customer requirements and specifications
2. Creating the detailed design for the software
3. Building functional software
Answer
Option 1: Incorrect. Analyzing customer requirements would involve static testing as it would only
include studying requirement related documentation.
Option 2: Incorrect. Creating detailed design involves static testing. Here you only check the design
plan against the requirements stated by the customer.
Option 3: Correct. Dynamic testing involves executing the code, and is required to test functional
software after it has been developed.
Correct answer(s):
3. Building functional software
An effective software testing plan should include both testing as well as debugging the software.
Debugging is performed as a result of testing.

Debugging is performed by developers to uncover where a defect in the code exists and correct
it. Debugging can be performed on code or on requirements and specifications. Debugging
might not study the effects of a correction on the other components of a system.
Testing studies various components of a system with the aim to discover defects and report
them; testing doesn't involve fixing the defects. As opposed to debugging, testing also checks
the effects of corrections on the other components of a system.
A detailed debugging exercise is important to make the software worthy enough to complete the
testing phase. It is a waste of time for testers to uncover errors which could have been easily
1254

corrected during debugging.

While debugging ensures partial confidence in a product, testing attempts to rigorously study
every component of a system and reports defects. Testing also repeats tests to check whether
the corrections made by developers are actually effective.
Summary
Testing includes a range of activities that form an integral part of every stage of a software life
cycle. Testing activities may be both dynamic as well as static. Both dynamic and static methods
ensure an effective testing plan.

Testing has a number of objectives, Depending on your point of view, the main objective could
be finding defects, gaining confidence about the level of quality and providing information, or
preventing defects.

Debugging is an important activity. While testing detects failures that are caused by defects,
debugging involves identifying the cause of a defect, repairing the code, and checking that the
defect has been fixed correctly.
















1255

Meeting Software Test Objectives
Learning Objective
After completing this topic, you should be able to
recognize how software testing meets different test objectives
1. The Objectives of Software Testing
The main objective of software testing is to uncover defects and resolve them. Testing can also
be conducted to provide information about the software to its stakeholders and increase
confidence levels by ensuring the quality of the product.

You can perform tests to check certain attributes of the software. For example, you can check
for an attribute like Defect Density by dividing the number of design defects found in down-
stream activities by a measure of product size, such as function points or physical source lines
of code. This type of testing will help you measure product reliability and assess the risk of
releasing the software.
Other than ensuring quality, you should also consider the point of view of end users customers
who purchase the software to use it to complete their daily tasks. These customers wouldn't be
interested in the number of defects in the software unless they are affected by them.

For example, a word processor might have a few lines of erroneous code, but as long as a user
can use it to type documents and format them, the software would qualify as fit for use.
Even if an end user qualifies a product as usable, it does not necessary mean that the product is
free from defects. Thus, in spite of the end user perspective, your attempt should be to free
software of critical defects.

While reviewing defects and failures, you may arrive at the root cause of a defect. A root cause
analysis should uncover the real reason why an error occurs and help you improve testing
processes. The analysis also aids in refining the quality of your test conditions and the general
software development process.

Users might be logging a number of bugs about a feature which is working properly, but is
complex to operate. In such a scenario, you could design a step by step wizard which teaches
an individual to use the function. This wizard could be invoked by starting to use the function in
question. This in turn, improves the design and subsequent development of the product.
Defects tend to gather in single feature or set of features and form a cluster. This might happen
because a certain area of the source code is relatively complicated. These areas are known as
hot spots, and as a tester you should concentrate on hot spots during risk assessment.
1256

Clusters may also be created when a newly introduced correction results in a chain of defects
on various parts of the software. These defects are referred to as knock-on defects.
Early review cycles and static tests always prove to be a more economical option and help you
identify potential defect clusters. So you should begin testing as early as possible in the software
development cycle.
Defect clusters have a tendency to change over time, so if the same set of tests is conducted
repeatedly, they will fail to discover new defects. This can be referred to as the pesticide
paradox.

To eliminate the effects of the pesticide paradox, you should continually review existing tests
and evolve newer ones to check varied parts of a component and uncover new defects.
The pesticide paradox can be illustrated with an animation of a pesticide can. When a test plan
is created for the first time, it is successful in uncovering relevant defects and correcting them.
But as defect clusters tend to change with time, the same set of tests would be redundant for
correcting defects.
Animation
The animation shows a can of pesticide being sprayed over a group of bugs which get killed as a
result, but the spraying continues in the same area and fails to kill the other surrounding bugs.
The pesticide paradox illustrates that an effective testing approach should always integrate new
tests. By creating effective static testing techniques and improving the software development
cycle, you'll encounter fewer defects during a dynamic test.

An improved testing initiative will uncover a greater number of defects.

Initial prevention during the Analysis phase reduces the number of defects that may appear
while operating the software. Later prevention during the Development phase ensures that you
create software with very few defects.
Graphic
The image represents a bar graph which shows the reduction of defects as a result of testing over a
number of software releases. The Y axis represents the number of defects and has a range of 0 to
100. The axis is marked at regular intervals of 0, 20, 40, 60, 80, and 100. The X axis represents the
number of releases and has a range of one to 10. The axis is marked at regular intervals of 1, 2, 3,
4, 5, 6, 7, 8, 9, and 10. The progress of defect prevention is shown by four different groups of bars.
These bar groups can be classified to include the total number of defects, represent the total
number of defects, defects identified during reviews, defects identified during testing, and failures
which occur during live use. All these bar groups are shown as decreasing steadily in size from
release 1 to release 10.
1257

As defect clusters are eliminated, your goal should be to change the focus of your testing efforts.
Apart from uncovering defects, you should also strive to bring about a general improvement in
software design documents and development processes.

This in turn will help you lower the costs associated with the testing initiative.
In an effort to bring about an improvement in software quality, you should also include
debugging as an important activity. Debugging is the process of finding, analyzing, and
removing the causes of failures in software.

Debugging and testing are varied activities:
Debugging
Debugging is conducted by programmers. When a tester discovers a defect in the code, a
programmer locates the defect and its immediate cause. The programmer then corrects the code
and runs it.

The tester verifies whether the defect has been fixed in the manner expected. In certain cases,
the programmer might test their fixes themselves. However, debugging solves only a single
defect in the code, and does not analyze the effect of a fix on other parts of the code.
Testing
As opposed to debugging, testing shows that defects are present.

Testers uncover defects but programmers solve them. Although testing reduces the probability of
undiscovered defects remaining in the software it cannot prove that software is defect free.
Question
You've created a test plan for a software application. How would you ensure that the tests find and
prevent defects if any are present?
Options:
1. Create a detailed debugging plan to precede testing
2. Rely only on testing efforts for uncovering defects
3. Standardize a set of tests for every release of the software
4. Continue to develop and add new tests to the plan
5. Incorporate a healthy mix of static and dynamic tests
Answer
Option 1: Incorrect. Debugging is performed as a result of testing. Debugging is not a testing
activity, but a development activity.
1258

Option 2: Incorrect. It is important to debug software before it actually gets into the testing cycle.
This is because programmers detect quite a few obvious defects in the code and fix them
immediately. Having such defects remaining in the software would only lead to a waste of time and
increase testing related costs.
Option 3: Incorrect. Standardizing tests across releases lowers the chances of finding new defects.
You might have created a group of tests to discover and prevent a particular kind of defect. After
such defects are found and resolved, these tests may become redundant for the rest of the software
and may result in the pesticide paradox.
Option 4: Correct. It is a good idea to constantly develop and evolve the testing plan. What may
have been applicable for a set of defects in Release 1 of the software might not be relevant in
Release 4 where there is a possibility of new defects being introduced into the code as a result of
changes made previously.
Option 5: Correct. A healthy balance of static and dynamic testing should be incorporated in an
effective testing plan. Dynamic testing, though less cost-effective than static testing, is a more
thorough testing procedure than static testing. Whereas, static testing includes reviewing
documentation and source code.
Correct answer(s):
4. Continue to develop and add new tests to the plan
5. Incorporate a healthy mix of static and dynamic tests
Software testing has three clearly defined objectives:
uncovering defects
gaining confidence about the level of quality and providing information
preventing defects
Uncovering defects is the main goal of initial testing. In the early stages of the product
development cycle, you can conduct static tests to review specification documents and the initial
design of the software. For example, if you're developing accounting software, you can map the
initial design to the specifications stated by the customer. This is done to check whether your
team has been able to understand client needs.
After the design has been reviewed, and development begins, you can execute the code to
uncover defects. These tests form part of development testing and include component and
integration testing. The objective is to cause as many failures as possible so that a maximum
number of defects are uncovered and solved.
The objective of testing may not always be to uncover defects but to gain confidence in the
product and provide information about its quality.

1259

Acceptance testing attempts to establish confidence in the system. User acceptance testing
typically verifies that the system is fit for use by users. Operational acceptance testing confirms
that the system is acceptable to system administrators. Contract and regulation acceptance
testing is performed against contractual or regulatory criteria. Alpha and beta testing garners
feedback from potential or existing customers. Alpha testing is typically performed at the
developers site, whereas beta testing is typically done in the field at customers sites.
The last objective of testing is to uncover new defects which may have been introduced into the
software from previous fixes. This testing can be referred to as regression testing. During
regression testing, you can ensure that a change made to fix a defect has not affected any other
part of the software that it should not have affected.
Question
You have completed your first testing cycle for the accounting software. It is important for you to test
whether there have been any unwanted changes in the software as a result of a defect fix. What
kind of testing would satisfy your testing objective?
Options:
1. Development testing
2. Acceptance testing
3. Regression testing
4. Component testing
Answer
Option 1: Incorrect. Development testing occurs after a product has been developed and its main
aim is to create as many failures as possible to uncover and fix defects. Development testing forms
a part of initial testing activities and happens right after the design stage. Regression testing would
help you to check whether any unwanted changes have occurred due to a fix.
Option 2: Incorrect. Acceptance testing checks whether a product is fit for use and whether the end
user will be satisfied with the product. This testing does not eliminate defects but provides
information about the quality of the product and ensures whether the product can be released for
use. You would need to use regression testing to test for any unwanted changes in the software.
Option 3: Correct. Regression testing ensures that no errors have been introduced while changing
software. Software might have been changed to fix a defect and that change might have had an
adverse effect on some other part of the software. Such effects are undesirable and should be
prevented through regression testing.
Option 4: Incorrect. Component and integration testing form a part of development testing.
Development testing forms a part of initial testing activities and happens right after the design stage.
Regression testing would help you to check whether unwanted changes have occurred due to a fix.
1260

Correct answer(s):
3. Regression testing
Summary
Testing has three objectives: finding defects, gaining confidence about the level of quality and
providing information, and preventing defects.

Different viewpoints in testing take different objectives into account. For example, in
development testing the main objective may be to cause as many failures as possible so that
defects in the software are identified and can be fixed. In acceptance testing, the main objective
may be to confirm that the system works as expected. Regression testing checks that no new
defects have been introduced during development of changes.

Debugging and testing are different. Testing can show failures that are caused by defects.
Debugging is the development activity that identifies the cause of a defect, repairs the code, and
checks that the defect has been fixed correctly.

















1261

General Software Testing Principles
Learning Objective
After completing this topic, you should be able to
recognize the fundamental principles in testing
1. General Principles of Software Testing
Software testing is based on certain principles that have evolved over the years. These
principles guide testers and reduce software related problems.
There are seven principles of software testing. Some of these principles are referred to as
general software testing principles, whereas the others are referred to as applied software
testing principles.
General software testing principles provide a standard framework to testers for conducting tests
and discovering defects including
testing shows presence of defects Principle One
exhaustive testing is impossible Principle Two
confusing an absence of errors with product fit is a fallacy Principle Three
The first principle states that running tests on software will discover defects, but that the
absence of defects does not mean that the software is defect free. These tests also decrease
the possibility that the software still contains defects, but testing an application doesn't mean
that you will be able remove all defects from the software.

For example, you might compile a list of tests for testing an online shopping site. You might not
be able to discover any functional defects. When the site goes live, however, and is used by a
large number of users in varying ways, errors and defects may then come to light.
The second principle states that it's impossible to conduct exhaustive testing. Exhaustive testing
can be defined as a test approach in which all possible data inputs and preconditions are used.
Testing every data input and precondition of software is not feasible because it results in an
increase in the cost of testing and also overshoots the time allotted to test the software.

Exhaustive testing is possible only when the application under test (AUT) is based on simple
logic and requires minimal user input. But when the application uses complex logic and requires
a lot of user input, it is impossible to conduct an exhaustive test on the application. So instead of
testing every parameter, it becomes important to base your testing efforts on risks and priorities.
Consider the example of a web page that prompts users to input information for a children's
dance competition. The web page has only a single input field. The field has been designed to
1262

enter the age of a child. The permissible age range for entering the competition is between five
and 12 years, so the only criteria you need to test here is whether the age entered falls in the
range of five to 12. In such a scenario, you would be easily able to conduct exhaustive testing.
But consider the example of web page used to record users delivery addresses and parse them
against a zip code database. These fields would have criteria based on numerous permutations
and combinations. In such an instance, exhaustive testing would be impossible.
The third principle outlines the absence-of-errors fallacy. The fallacy states that although testing
might succeed in locating and correcting all possible defects in the software, the software itself
might not be fit for use by an end user. This might happen as a result of misinterpreting
customer expectations, or as a result of poor usability.
For example, you design a word processor that formats, spell checks, and prints documents.
The software could pass testing and perform all these functions, but if the customer required
language translation and thesaurus functionality then the software does not meet the customers
needs. The absence of errors in testing does not mean that the software is suitable for this
customer.
Question
You have designed an application that calculates wind resistance for concept car 3D models. You
have tested the application and it has passed testing. A salesperson selling the product tells a client
our application has passed our rigorous testing, and so is 100% error free! Which principle of
software testing is your salesperson not familiar with?
Options:
1. Testing shows presence of defects Principle One
2. Exhaustive testing is impossible Principle Two
3. Confusing an absence of errors with product fit is a fallacy Principle Three
Answer
Option 1: Correct. The first principle states that, although testing shows the presence of defects and
can also reduce the probability of discovered defects, it can never be proof that the software is
defect free.
Option 2: Incorrect. While exhaustive testing may have bolstered the salespersons claim, principle
two says that such testing is (in practical terms) impossible.
Option 3: Incorrect. The statement by the salesperson says nothing about product fit.
Correct answer(s):
1263

1. Testing shows presence of defects Principle One
Question
You need to design tests for a very basic authentication system used by an airline ticketing system
that takes a 10 digit number and validates if it is one of three pre-defined values. You realize that
you would need 9,999,999,999 test cases to check every possible combination, and even then it
would exclude cases where the user pressed Enter accidentally, used Backspace, or even had a
long pause between numbers. Which software testing principle would use to design tests for this
software?
Options:
1. Testing shows presence of defects Principle One
2. Exhaustive testing is impossible Principle Two
3. Confusing an absence of errors with product fit is a fallacy Principle Three
Answer
Option 1: Incorrect. The first principle states that running tests on software prove that defects are
present. The test will also decrease the possibility of defects being left over in the software, but
testing cannot prove that the software is defect free.
Option 2: Correct. The second principle states that it is not feasible to conduct exhaustive tests on
software. Exhaustive testing is a test approach that tests all possible permutations of input. The
principle that exhaustive testing is an unfeasible practice is more applicable in this scenario.
Option 3: Incorrect. The third principle is based on the fact that it is a fallacy to assume that,
although no defects are present in the software, it is fit for use. It may happen that a customer
requirement is misunderstood resulting in a faulty product, as a result, the application fails to
perform the task expected by an end user. You would use principle two to design tests for this
software.
Correct answer(s):
2. Exhaustive testing is impossible Principle Two
Question
You have designed tests for a system designed to help workers in two geographically distant offices
collaborate over the Internet. Unfortunately, all traffic for these offices must travel through a
commercial proxy system, and this was not identified by your team during the requirements phase.
When you tested the system, it ended up working perfectly in the test environment, but had no
support for the office proxy server. Which software testing principle did your team overlook while
designing tests?
1264

Options:
1. Testing shows presence of defects Principle One
2. Exhaustive testing is impossible Principle Two
3. Confusing an absence of errors with product fit is a fallacy Principle Three
Answer
Option 1: Incorrect. The first principle states that running tests on software will indicate the
presence of defects if there are any. The test will also decrease the possibility of defects being left
over in the software, but testing is not proof that the software is completely defect free.
Option 2: Incorrect. The second principle states that it is impossible to conduct exhaustive testing.
Exhaustive testing can be defined as a test approach in which all possible data inputs and
preconditions are used. The team overlooked the principle that an absence of errors does not
necessarily mean that the software is fit for use.
Option 3: Correct. The third principle is based on the fact that, although testing may locate and
solve many defects, it may still be unfit for release. A customer requirement may have been
misunderstood resulting in a faulty product design and, as a result, the application fails to perform
the task expected by an end user. The team did not pay attention to the principle that an error free
software is not necessary a usable one.
Correct answer(s):
3. Confusing an absence of errors with product fit is a fallacy Principle Three
Summary
There are three general principles that guide testers while devising software testing plans.

The first principle states that, although testing shows the presence of defects and can also
reduce the probability of discovered defects, it can never be proof that the software is defect
free.

The second principle discusses that exhaustive testing is both impossible and unfeasible in
context to time and cost, and is only possible with instances of an extremely simple logical
structure and limited input.

The third principle outlines the absence-of-errors fallacy. The fallacy states that although testing
might succeed in locating and correcting all possible defects in the software, the software itself
might not be fit for use by an end user. This might happen as a result of misinterpreting
customer expectations.

1265

Applied Software Testing Principles
Learning Objective
After completing this topic, you should be able to
recognize the applied software testing principles
1. Applied Principles of Software Testing
You should always base your software testing efforts on certain established principles. Other
than the three general principles previously discussed, software testing also follows four applied
principles. Applied testing provides a standardized format for creating test plans, and acts as a
guide to effective testing.
The applied principles of software testing concern the importance of early testing, defect
clustering and the pesticide paradox, and state that testing should always be context dependent.
The first principle stresses the importance of early testing. This principle states that testing
should begin as early as possible in the software development life cycle (SDLC).

If defects are detected during the initial stages of the SDLC, they can be corrected with
minimum effort in terms of cost and time. Correcting defects during the initial stages prevents
defects from cascading onto the Development and Implementation stages.

Just before the release of the software, the pressures of a deadline could lead testers to
compromise their testing efforts. Software testing should not just be a part of development but
should be carried out throughout the SDLC. This eliminates the problems associated with trying
to accommodate everything into a single testing effort.
If an error is detected during the Analysis phase through static tests, then there is little chance of
an error being introduced during the Design phase.


On the other hand, if there is no testing conducted during the Analysis phase, errors can only be
discovered during the Implementation phase. During implementation you may realize that there
is a serious design issue with the product which will be costly to fix.
During the Design phase, if a defect in the code goes undetected, it can result in further defects.
Defects can have a tendency to replicate themselves in various parts of the code. A
considerable amount of rework is required to correct such defects.
If a defect is uncovered during Acceptance testing at the Implementation stage, it means going
right back to the Analysis phase to review specification documents. This is important to judge
whether you have understood the customer requirements. It can also involve reworking
specifications and retesting them resulting in increased costs.
1266


Extensive studies are carried out to study the effect of defects on cost at various stages of the
SDLC. Testing objectives differ at every stage of the SDLC. The objective for testing at the
Analysis stage is to review the software requirements document, and at the Development
phase, the objective is to test the code by executing it.

It is impossible to put accurate figures to represent the difference in costs required to correct
defects at different stages of the SDLC. The accompanying graph attempts to present a rough
idea of the same. The graph represents the cost escalation model. It shows that the later an
defect is detected, the more it costs to fix.
Graphic
The graph represents a steady increase in the cost of correcting defects at various stages of the
SDLC. The X axis shows the various testing stages of the SDLC, namely Requirements, Coding,
Program Testing, Acceptance Testing, and Live Use. The Y axis shows the increase in costs from
zero dollars to 500,000 dollars. The increase in cost is shown by a curved line which begins at zero
dollars and ends at 500,000 dollars on the Y axis and at the Live Use stage on the X axis.
The second principle of applied testing is based on the pretext that the defects aren't spread
uniformly in the software. During pre-release of the software, a few software modules will display
the most number of defects and operational failures. This is referred to as defect clustering. This
can be due to
inexperience of the development team
past experiences of the development team
cascading effects of new changes on various parts of the code
volatile code, which is more susceptible to defects
complex logic and structure of a software application
Defect clustering is based on the Pareto principle. The Pareto principle states that about 80% of
defects will be found in approximately 20% of the modules.

You should test components of the software that are more susceptible to defects. However, this
doesn't mean that you should disregard less susceptible areas. You should balance your testing
efforts so that both types of software components are given due attention.
The third applied principle of software testing discusses the Pesticide Paradox. This paradox
states that if you continue using the same set of tests over and over again, the tests will cease
to uncover bugs. This can happen because during the debugging and testing, the software
might have undergone changes. These new changes can no longer be checked using an old
test case, so it becomes important to revise existing tests, and develop newer ones which will be
1267

able to uncover more bugs.

For example, if a change is introduced in the code, new tests need to be developed to check
whether the change has any unwanted effects on other components of the software. This is
referred to as regression testing. The same set of regression tests might not be able to uncover
defects during production because the testing objective might have changed altogether.
The fourth applied principle of software testing states that you need to vary testing efforts
depending on the circumstances. For example, you create a plan for a web site which stores
confidential medical information. This information can only be viewed by doctors, so the test
plan for this web site will be vastly different from a test plan created for a large online bookstore
that sells to the general public.


A different plan would be required for various reasons. The bookstore will need to tie in with
complex logistical systems based around shipping product in a timely fashion. It may also have
many more users than the medical site. The key job of medical site, however, could be viewed
as controlling access to the information it houses.
Question
During development of an e-commerce web site, the specifications of its checkout system were
reviewed. The review revealed a flaw in the logic of the system. As a result, the specification was
rectified before the web site specifications were sent for development. Which principle of software
testing has the development team based their testing efforts on?
Options:
1. Defect clustering Principle Two
2. Pesticide paradox Principle Three
3. Early testing Principle One
4. Testing is context dependent Principle Four
Answer
Option 1: Incorrect. The second principle of applied testing is based on the pretext that the spread
of defects is not uniform. And, during pre-release, a few software modules will display the most
number of defects and operational failures compared to others. In this scenario, the development
team has followed the principle of early testing that states that it is always beneficial, in terms of time
and cost, to begin testing in the initial phases of the SDLC.
Option 2: Incorrect. The third principle of applied testing discusses the Pesticide Paradox. The
principle states that if you continue using the same set of tests over and over again, the tests will
cease to uncover bugs. The development team has based their testing efforts on the principle that
1268

effective testing always begins during the initial phase of the SDLC. This corrects defects during
Analysis and Design and prevents them from appearing during development and implementation.
Option 3: Correct. The first principle of applied testing stresses the importance of early testing. The
principle states that testing should begin as early as possible in the SDLC. Early testing saves
efforts in context to both time and cost.
Option 4: Incorrect. The fourth principle of applied testing states that testing efforts will vary in
different circumstances. For example, testing for a e-commerce site will be very different from
testing for safety-critical software. In this scenario, the development team has followed the principle
of early testing that states that it is always beneficial, in terms of time and cost, to begin testing in
the initial phases of the SDLC.
Correct answer(s):
3. Early testing Principle One
Question
Your organization is developing a content management system. This system uses separate
modules to run most of its core functions. During component testing, you discovered that the user
authentication module has a high number of defects. The same module also faced problems during
integration testing. Which principle of software testing is proved by the above scenario?
Options:
1. Defect clustering Principle Two
2. Early testing Principle One
3. Pesticide paradox Principle Three
4. Testing is context dependent Principle Four
Answer
Option 1: Correct. The first applied principle stresses the fact that defects are not spread uniformly
in the software. Some components of the software display more defects and operational failures
compared to others.
Option 2: Incorrect. The first applied principle is based on the fact that you should start testing from
the initial phases of the SDLC. As the initial phases primarily involve static tests, early testing saves
efforts in context to both time and cost. This scenario illustrates the concept of defect clustering
which indicates that certain software modules are more susceptible to defects than others.
Option 3: Incorrect. The third applied principle discusses the Pesticide Paradox which states that if
you continue using the same set of tests over and over again, the tests will cease to uncover bugs.
This scenario illustrates the concept of defect clustering which indicates that certain software
1269

modules are more susceptible to defects than others. More susceptible modules need to be
resolved earlier than less susceptible modules.
Option 4: Incorrect. The fourth applied principle states that you need to change your testing efforts
based on different circumstances. For example, testing for a gaming site will be very different from
testing for an online store selling music CD's. This scenario illustrates the concept of defect
clustering which indicates that certain software modules are more susceptible to defects than
others.
Correct answer(s):
1. Defect clustering Principle Two
Question
You have a comprehensive set of tests developed for a spreadsheet program developed by your
company and you apply these tests to each successive version of the program that is released. In
the most recent version very few defects were revealed by your tests and you take this to mean that
the software is now very refined. Which principle of software testing might prove your perception
wrong?
Options:
1. Early testing Principle One
2. Defect clustering Principle Two
3. Pesticide paradox Principle Three
4. Testing is context dependent Principle Four
Answer
Option 1: Incorrect. The first principle of applied testing discusses the importance of early testing.
This principle states that testing should begin as early as possible in the SDLC. During the initial
phases of the SDLC, static tests are used to correct defects. Static tests are more economical than
dynamic tests required to resolve errors in the later stages of the SDLC. The pesticide paradox will
prove that your perception of using standardized tests to resolve defects is an incorrect approach to
correct new bugs.
Option 2: Incorrect. The second principle of applied testing is based on the pretext that the spread
of defects is not uniform. And, during pre-release, a few software modules will display the most
number of defects and operational failures compared to others. You should have paid attention to
the pesticide paradox that states that you should always revise your testing efforts to resolve new
defects.
1270

Option 3: Correct. The third principle of applied testing discusses the Pesticide Paradox which
states that if you continue using the same set of tests over and over again, the tests will cease to
uncover bugs.
Option 4: Incorrect. The fourth principle of applied testing states that testing efforts will vary in
different circumstances. For example testing for an e-commerce site will be very different from
testing for safety-critical software. The pesticide paradox will prove that your perception, that using
standardized tests to resolve defects, is an incorrect approach to correct new bugs.
Correct answer(s):
3. Pesticide paradox Principle Three
Question
Your company produces noncritical office software. A new tester has recently joined your team. This
tester had previous experience in testing military systems where failures would be particularly
hazardous. In his first week, the new tester discovers a fair number of defects, but he seems much
slower than your other testers because he insists on fully exercising any code that he is given.
Which principle of software testing might this new employee benefit from learning?
Options:
1. Early testing Principle One
2. Defect clustering Principle Two
3. Testing is context dependent Principle Four
4. Pesticide paradox Principle Three
Answer
Option 1: Incorrect. The first principle of applied testing stresses on the importance of early testing.
This principle states that testing should begin as early as possible in the SDLC. Early testing saves
efforts in context to both time and cost. Testing efforts are always relevant to the context they are
being used in. As this tester is used to testing complicated logic and structure, he would tend to
waste a lot more time for testing simple software.
Option 2: Incorrect. The second principle of applied testing is based on the pretext that the spread
of defects is not uniform. And, during pre-release, a few software modules will display the most
number of defects and operational failures compared to others. This scenario highlights the principle
that states that testing is always context dependent. This tester is suitable for testing complicated
software and would not be suitable to test software that uses simple logic.
Option 3: Correct. The fourth principle of applied testing states that testing efforts will vary in
different circumstances. For example, testing for an e-commerce site will be very different from
1271

testing for safety-critical software, so using this tester in a simple testing environment would be a
waste of time and cost.
Option 4: Incorrect. The third principle of applied testing discusses the Pesticide Paradox which
states that if you continue using the same set of tests over and over again, the tests will cease to
uncover bugs. Testing efforts are always relevant to the context they are being used in. As this
tester is used to testing complicated logic and structure, he would tend to waste a lot more time for
testing simple software.
Correct answer(s):
3. Testing is context dependent Principle Four
Summary
There are four applied principles that guide testers while devising software testing plans.

The first principle stresses that testing activities should start as early as possible in the software
or system development life cycle. Principle two shows that a small number of modules contain
most of the defects discovered during pre-release testing. The third and fourth principles outline
the Pesticide Paradox, and state that testing is context dependent.















1272

The Importance of Software Testing and Mitigating Harm
Learning Objective
After completing this topic, you should be able to
recognize the fundamentals of software testing
Exercise Overview
You need to train the new testing team about how software testing improves quality, how early
testing proves economical, and how testing principles apply to scenarios presented.
You need to train the team on:
how testing can help improve the quality of software
the importance of early testing
how testing efforts differ depending on context
Recognizing how testing improves quality
You're a test manager in an organization. A development team within your organization has
created software that manages railway line switches to control railway tracks and the train
schedule. The scenario involves very real safety concerns. If the software fails, it could result in
hundreds of deaths and millions of dollars of damage.
Question
The success of the software is important as the slightest defect might end up putting the lives of
millions at risk.

What should the testing team focus their testing efforts on?
Options:
1. Functional attributes of the software
2. Functional and non-functional attributes of the software
3. Exhaustive testing
4. Risk assessment and management
Answer
Option 1: Incorrect. Although testing for functional attributes ensures that the product performs an
expected task seamlessly, it is also important to test non-functional attributes to ensure that the task
1273

is completed in the least amount of time and effort. You would need to test for non-functional
attributes too.
Option 2: Correct. Testing for functional attributes ensures that the product performs an expected
task. Testing for non-functional attributes measures how well or fast a task is performed. Testing
non-functional attributes usually requires a metric, such as time to complete a task.
Option 3: Incorrect. Exhaustive testing checks all combinations of input values and preconditions.
Exhaustive testing, although ideal, is neither practical nor advisable. It would be a good idea to
concentrate on risk assessment, and the parameters of validation and verification.
Option 4: Correct. A test approach should be devised by juxtaposing the test with the risks which
the customer, the project stakeholders, the project as an entity, and the software is exposed to.
Correct answer(s):
2. Functional and non-functional attributes of the software
4. Risk assessment and management
Understanding early testing
Early testing and defect removal is usually much less expensive than repairs later in
development. This is especially true in a complex physical system that may need to be taken
offline for testing once it is constructed.
Question
You plan to brief your team on the testing plan they need to create.

At which stage of the SDLC would you recommend testing to begin?
Options:
1. Design
2. Development
3. Analysis
4. Implementation
Answer
Option 1: Incorrect. Testing that begins at the Design stage only tests the design of the software
and does not check software documentation. Although defects detected at the Design stage can be
easily solved, ideally, testing should always begin at the Analysis stage.
1274

Option 2: Incorrect. Testing that begins at the Development stage, might require changes in code.
Although not very difficult to implement, defects of the Design and Analysis stages might pass
unnoticed. Thus, ideally, testing should always begin at the Analysis stage.
Option 3: Correct. Testing should ideally begin at the Analysis stage. If all clarifications are
answered at this stage, there would be a very slim chance of a defect cascading onto the later
stages of the SDLC, thus saving time and money.
Option 4: Incorrect. Defects detected during Implementation are very difficult to correct and involve
a huge amount of investment both in terms of money and time. It could also mean going right back
to the Analysis stage and recreating the product. You should always begin testing during the
Analysis stage.
Correct answer(s):
3. Analysis
Question
Static and dynamic tests are used at various stages of the SDLC. You need to inform the team on
what methods they need to utilize at what stage.

Match each testing type with its relevant action.
Options:
A. Static
B. Dynamic
Targets:
1. Analyzing client requirement documents
2. Reviewing software design documents
3. Reviewing source code of the software
4. Executing the code of the software
Answer
Static methods comprise reviewing software related documentation. Static tests occur at the
Analysis and Design stages of the SDLC. Dynamic testing includes running the code of the
software.
Static methods comprise analyzing software related documentation, like specification documents
and client requirements. Dynamic testing includes running the code of the software.
1275

Static methods comprise reviewing software related documentation and source code. The code is
not executed as is done with dynamic testing. Reviewing code generally happens during the
Development stage of testing.
Dynamic testing happens during Development and Implementation when the testing team executes
the code of the software to check whether the product is performing as expected. Static testing is
generally comprised of reviewing software related documentation and source code.
Correct answer(s):
Target 1 = Option A
Target 2 = Option A
Target 3 = Option A
Target 4 = Option B
Explaining testing principles
You want to inform the team that software testing is based on certain principles.
Question
The spread of defects in software is not uniform and a few software modules will display the most
number of defects.

Which principle of software testing is this?
Options:
1. Defect clustering
2. Pesticide paradox
3. Exhaustive testing is impossible
Answer
Option 1: Correct. Defect clustering is based on the Pareto principle. The Pareto principle states
that about 80% of defects will be found in approximately 20% of the modules.
Option 2: Incorrect. The Pesticide Paradox states that if you continue using the same set of tests
over and over again, the tests will cease to uncover bugs.
Option 3: Incorrect. This principle states that exhaustive testing is rarely achievable in practice.
1276

Correct answer(s):
1. Defect clustering
Question
You have created a test plan for the first release of audio recording software. You use the same
plan to test the software for its second and last releases. The tests reveal very few defects and you
decide that the software can be released without further rounds of testing. After the release, some
bugs come to light.

Awareness of which principle may have reduced the number and severity of these bugs?
Options:
1. Early testing
2. Defect clustering
3. Pesticide paradox
4. Testing is context dependent
Answer
Option 1: Incorrect. This principle states that testing should begin as early as possible in the SDLC.
Early testing saves efforts in context to both time and cost. The principle which outlines the concept
of the pesticide paradox is more applicable in this scenario.
Option 2: Incorrect. Defect clustering states that the spread of defects in software is not uniform
and a few software modules will display the most number of defects. In this case, the relevant
principle is the pesticide paradox.
Option 3: Correct. The Pesticide Paradox states that if you do not develop new tests and attempt to
use a standard set of tests for all release of software, the tests will cease to uncover bugs.
Option 4: Incorrect. Testing effort varies in different circumstances. For example, testing for an
online shopping store site will be very different from testing for safety-critical software. You are
violating the principle that discusses the concept of the pesticide paradox.
Correct answer(s):
3. Pesticide paradox
Question
During the development of an online bookstore, the specifications of the search functionality of the
software were reviewed. During these reviews, a defect in the design logic and functionality of the
1277

software was discovered. This defect was corrected in the specification and the software was sent
for development. If these defects had made it though to a later stage of the software lifecycle, they
could have been more time consuming and costly to remove.

Which principle of software testing did the development team follow?
Options:
1. Early testing
2. Defect clustering
3. Pesticide paradox
4. Testing is context dependent
Answer
Option 1: Correct. This principle states that testing should begin as early as possible in the SDLC.
Early testing saves efforts in context to both time and cost as it involves only static testing
techniques.
Option 2: Incorrect. The spread of defects in software is not uniform. A few software components
will always display more defects and operational failures compared to others. The principle of early
testing in the SDLC is more applicable in this scenario.
Option 3: Incorrect. The Pesticide Paradox stresses that if you continue using the same set of tests
over and over again, the tests will cease to uncover bugs. The test team has followed the principle
of early testing in this scenario.
Option 4: Incorrect. Testing efforts will vary in different circumstances. For example, testing for a
content management system will be very different from testing for an online store that sells medical
equipment. The test team has followed the principle of early testing in this scenario.
Correct answer(s):
1. Early testing







1278

The Fundamental Software Test Process
Learning Objectives
After completing this topic, you should be able to
recognize the test process in a given project
identify the component steps in the test process
1. The software testing process
Once a software application is developed, it is important to test it and verify whether the
software has met the purpose and the objective for which it was developed. The more rigorous
the test process, the better the product quality.

Although testing rigor may vary across software products products with fewer risks may not
require as much testing as a product with higher risks the software testing process remains
the same.
This process includes distinct phases where one phase follows the other and where phases are
interdependent on one another.
Note
Although the process is depicted here as strictly linear, there will be times when you need to go
back to an earlier task, or run tasks in parallel.
There are five fundamental phases in the software testing process.
Graphic
Description of the software testing process flow chart:
The five phases of the software testing process begins with test planning and control as the first
phase. It then moves to the second phase test analysis and design and then the test
implementation and execution phase. This is followed by the evaluating exit criteria and reporting
phase, with the process finally ending with the test closure activities phase.
Description ends.
Test planning and control
In the test planning phase, you establish the need or mission of testing. This helps you focus on
what needs to be tested, the scope of testing, and what defines the exit or completion of the test.
These details are outlined in the test plan a deliverable of this phase.

The test plan also specifies the schedule of activities, resources required for the testing process,
1279

and the test environment. Additionally, it also lists any risks that might affect test execution and
documents contingency plans.

Test control compares actual progress against the test plan. Reports are the deliverable of test
control which include deviations from the plan. Test control involves taking action to meet project
objectives, and is an ongoing activity during the project.
Test analysis and design
In the test analysis and design phase, test objectives determined during planning are converted
into plausible test conditions and test cases. During this phase, you review the test basis
(including requirements, architecture, design and interfaces), and evaluate the testability of the
test basis and test objects. You also identify and prioritize test conditions based on the analysis of
test items, the specification, behaviour and structure.

In this phase, you also design test cases and prioritize them, identify the test data necessary to
support the test conditions and test cases, and design the test environment set-up and identify
the tools and infrastructure which will be required.
Test Implementation and execution
The test implementation and execution phase is where test procedures, or scripts, are specified,
the test environment set up, and tests are run. Test implementation includes developing and
prioritizing test cases and procedures, creating test data and creating test suites from the test
procedures to ensure efficient test execution. You should also verify that the test environment is
set up properly.

Test execution is the phase where you execute tests manually or by using execution tools in
the sequence planned. You also log the outcome of test execution, record what software and
version is under test, and what test tools and testware are being used. You also compare actual
results with expected results and report any discrepancies as incidents. These incidents will be
analysed in order to establish their cause was it a defect in the software, a defect in the test
data, or maybe a mistake in the test execution? Finally, test activities are repeated for any
discrepancy. In the case of confirmation testing, you would re-execute a test that previously failed
to confirm a fix. In the case of regression testing, you might execute a corrected test in order to
ensure that a defect has not been introduced into an unchanged area of software.
Evaluating exit criteria and reporting
In the exit criteria evaluation and reporting phase, you analyze the test execution results against
the objectives defined in the analysis and design phase.

You determine if the exit criteria conditions determined for test completion are met. You then
analyze if more tests are required, or if the exit criteria set should be changed. You also prepare a
test summary report for the stakeholders.
Test closure activities
Test closure activities the final stage of the testing process require you to consolidate and
document data from the completed phases of testing.
1280


This phase involves checking deliverables and ensuring that all test incidents are closed. During
this phase, testware scripts, test environment, and other test infrastructure are archived for
future reference before the product is handed over to maintenance testers for regression testing.
The five-step software testing process ensures that the developed software meets the stated
objectives and mitigates any risks of failures that may occur due to the defects in the software.
Although this process follows a sequence of activities, it is not rigid. Some steps in the process
are iterative and can be conducted in parallel for rigorous and extensive testing.

For example, suppose you completed the planning phase for a software application and have
begun designing test activities for it. A change in the market requirements for the software is
reported, which in turn modifies stakeholder requirements and project objectives. In this case,
you need to revisit the planning stage after the design phase. Similarly, you also iterate the
analysis phase, after test implementation and exit criteria evaluation, if there are changes in the
test plan.
Graphic
In this depiction of the software testing process, the test planning and control phase iterates after
the test analysis and design phase, the test analysis and design phase iterates after the test
implementation and execution and evaluating exit criteria and reporting phases.
Question
Sequence the phases constituting the fundamental software testing process from start to finish.
Options:
A. Analyze test goals and prepare a test plan
B. Analyze test conditions and architecture and then create test cases
C. Implement test suites and report test incidents
D. Evaluate the exit criteria and prepare test summary
E. Archive testware and evaluate test results
Answer
Correct answer(s):
Analyze test goals and prepare a test plan is ranked as the first step of the software testing
process.
In the software testing process, the first phase is to analyze the test goals, objectives, and the
risks, and plan how testing will proceed. This phase is called test planning and control.
1281

Analyze test conditions and architecture and then create test cases is ranked as the second
step of the software testing process.
The second phase of the software testing process is where testing objectives are converted
into test conditions and cases.
Implement test suites and report test incidents is ranked as the third step of the software
testing process.
Implementing test suites and executing them is the third phase. Implementation activities
include creating test scripts. Execution is where you run tests and record incidents.
Evaluate the exit criteria and prepare test summary is ranked as the fourth step of the
software testing process.
The fourth stage of the software testing process is to evaluate the exit or test completion
criteria defined during planning. You validate these criteria against the actual test results
documenting them in a test summary report.
Archive testware and evaluate test results is ranked as the fifth and final step of the software
testing process.
Test closure is the final phase and involves analyzing test results for future projects and
archiving testware for maintenance testers.
Suppose you're a test manager in an organization developing an online auction web site for
automobiles. You want to test the developed software to evaluate its effectiveness, and to check
if it meets the stated expectations.
Applying the fundamental software test process, you begin with the planning phase. In this
phase, you ensure that you understand the goals and objectives of the stakeholders your
company, the clients, and the end-users.

The objective of the auction web site is to provide an online portal that allows users to log in and
place bids on automobiles, with the web site allowing the highest bidder to proceed with the
transaction. Because the transaction is financial, user privacy and security is paramount.

These objectives help you identify what elements are critical to the web site and let you decide
areas that need to be tested. In this example, the testing focus will be ensuring that only
authorized users with valid logins can perform a transaction, checking if users can place bids,
ensuring that the web site allows only the highest bidder to access the transaction page, and
determining that a secure connection is provided for complete anonymity during transactions.
You can then continually monitor these objectives throughout the testing process.
During the planning phase, you also determine the kinds of tests to run and the people who will
be involved. You also create a schedule and then define the exit criteria based on the areas to
be tested.

For your auction web page, you will set 80% statement coverage throughout the web auction
system and 100% branch coverage for areas of code relating to financial transactions as the exit
criteria against which test results are validated. Testing is deemed complete only if the exit
criteria are met.
1282

With a test plan with exit criteria and schedules in place, you proceed to the analysis and design
phase, where you
review the test basis and identify test conditions
Your first task in the analysis phase is to review the test basis and identify test conditions. While
reviewing the test basis, you analyze risks, requirements, and specifications. Based on these, you
identify test conditions for your software.

In the auction web page example, you want users to be able to view automobile models and
place bids without being impacted by large volumes of site traffic. These become your test
conditions, where you can check if the web page functions as expected during hours of peak
network traffic.
design tests and evaluate testability
Based on the test conditions, you design the tests and evaluate the testability of the component
the auction web page, in this example.

If a requirement for the auction web page is that the web page should respond quickly, you must
define 'quickly' and set parameters for how quick you want the page to respond five or ten
seconds, for example. Accordingly, your test environment will include resources that allow this
test to occur.
Once tests are designed and a strategy put in place, you develop and execute test cases.

To do this, you create test procedures instructions for test cases. These procedures focus on
checking elements you defined as critical earlier. These elements could include, for example,
whether you can log into the site, whether an automobile name entered in the search string
displays appropriate images, and whether you're able to place a bid on the car. These details
are mentioned in the test cases.
After creating test procedures and cases, you create test suites, which are logical collections of
test procedures. For your auction web page, the collection of test cases that check whether
users are able to log in becomes one test suite.

In addition, you also ensure that the test environment is set up, and use it to run possible trial
tests to measure the efficiency of the environment.
In the test execution phase, you execute the test suites and document test outcome logs. While
documenting, you record the versions of the software under test, your test tools, and testware.
You also compare actual results to expected results and, where there are discrepancies, record
incidents.

Suppose currency is not displaying correctly in your web page during testing. As a result,
transactions become tedious for a user, who is unable to view the amount accurately. This
instance is reported as an incident during the execution phase.
1283

In this phase, incidents or discrepancies reported should be fixed, and test activities should be
repeated for each discrepancy to confirm that the fixes function correctly and haven't altered the
program in other ways. This procedure may be repeated until test results display expected
outcomes.
After running the test suites, you need to determine whether the exit criteria set during the
planning phase are met. This is the exit criteria evaluation and reporting phase where you check
logs of the test outcome against the exit criteria to determine if they are met. Wherever a
criterion is not met, depending on how critical it is, you may revise it before re-running the tests.

For example, in the auction web page, you can revise the criteria for the 80% statement
coverage to 75% and run tests again. But you would not revise the 100% financial coverage,
because it is directly connected to ensuring a secure finance system. In this case, you devise
further tests to check 100% financial coverage.
Note
Testing is considered complete when exit criteria are met.
Once exit criteria are met, you can create a test summary report. This report informs the
stakeholders about the extent of testing undertaken and its outcomes.
In the final stage of the testing process test closure you deliver the tested software and
document whether incident reports are resolved or deferred. Categorizing incidents is important,
because deferred incidents might become requests for a future version of the software. For
example, in your auction web page, deep bookmarking might not be available for individual cars
in the version, because it is not critical for successful implementation of the application. This
feature, however, is user friendly and could be made available in the next version.
In this phase, you also archive the scripts and details of the test environment so that it is readily
available for use at a later stage. As a sign-off, you hand over the tested software to the
maintenance team in charge of deploying and maintaining the web auction page. Lastly, you
document any lessons learned during testing, in an overall project evaluation report, so that
these lessons can be applied to future projects.
Question
As a test engineer, you want to test the software for managing payroll services in your organization.
The focus of this payroll portal is to maintain employee privacy and security of transactions. Rank
the tasks in the order you would execute them in the software testing process.
Options:
A. Identify unauthorized user access as a security risk
B. Specify as a test condition that only users with authorized user names and passwords can log on
1284

C. Create a test procedure for the ability to log into the payroll portal
D. Check the exit criteria defined for security of transactions against the test outcome
E. Archive testware and prepare a project evaluation report
Answer
Correct answer(s):
Identify unauthorized user access as a security risk is ranked as the first step in testing the
software for managing the payroll service.
Understanding the goals of your project and identifying the risks belong to the planning phase
of the testing process. This also helps you determine the tests required to meet the test
objective.
Specify as a test condition that only users with authorized user names and passwords can
log on is ranked as the second step in testing the software for managing the payroll service.
Setting up test conditions is done in the analysis and design phase. You also proceed to
design the test cases, and identify test data required to support those cases.
Create a test procedure for the ability to log into the payroll portal is ranked as the third step
in testing the software for managing the payroll service.
You create test procedures and execute test suites during the implementation and execution
phase of the process. In this phase, you also repeat the test activities designed for fixed
defects, to validate these fixes.
Check the exit criteria defined for security of transactions against the test outcome is ranked
as the fourth step in testing the software for managing the payroll service.
Evaluating the exit criteria is the fourth phase of the testing process. You compare the actual
results against the estimated results during this phase. You do this using the logs of the test
execution.
Archive testware and prepare a project evaluation report is ranked as the final step in testing
the software for managing the payroll service.
During the test closure phase, you archive the testware for future test components and hand it
over to the test maintenance team. In addition, you prepare a test summary report.
Summary
Software testing is an extensive process that includes a number of phases and tasks. This
process includes five fundamental phases test planning and control, analysis and test design,
test execution and implementation, exit criteria evaluation, and test closure activities.

Each of these phases includes specific tasks. Planning requires you to define the test
objectives. Control compares actual progress with the test plan on an ongoing basis, and takes
action where necessary. Analysis and design is where testing objectives are converted into test
conditions and cases. Implementation includes designing test scripts, and execution is where
the test scripts are executed. Evaluating exit criteria and reporting is where test execution is
1285

assessed against the objectives. Test closure activities include creating a test summary report
and archiving testware.



























1286

Exit Criteria and Test Closure Activities
Learning Objective
After completing this topic, you should be able to
identify the two final steps of the test process in a given scenario
1. Exit criteria and test closure
The objective of testing is to ensure that a quality product that meets the purpose for which it is
created is released. Based on this objective, test plans are created and exit criteria are defined,
which further impacts how tests are designed and executed. Only when these exit criteria are
met is testing considered to be complete.

Evaluating exit criteria is an important task or phase in the test process. Exit criteria are a set of
business-driven conditions that determine the customer-ship or deployment decision for a
software application.
Exit criteria are defined during the planning phase of the test process. These criteria act as a set
of checkpoints that provide focus on what you need to track during testing and also what you
should validate your test outcome against.
For example, you plan to test a web application that helps you book airline tickets. You define
exit criteria based on the critical factors of the application that need to be fully tested. A critical
element of this application is to test its functionality for example, selecting a flight and being
able to enter the number of tickets to book in that flight.

So you set an exit criterion that checks 70% of the application functionality with a certain rigor
no critical defects reported for a particular function, for example. This criterion helps determine
what needs to be evaluated after testing. The testing is considered complete only if this criterion
is met.
Meaningful exit criteria that are measurable and achievable help
ensure test efficiency and effectiveness
prioritize and execute testing activities
evaluate current activities in the testing process and decide steps for further action
suggest corrective measures for incomplete and faulty efforts
identify plausible risks for your test project
1287

Evaluating exit criteria lets you check whether the conditions to complete the testing process are
met. Evaluation requires you to analyze the test results of a completed test suite against the
objectives and the criteria set during the planning phase.
In exit criteria evaluation, you analyze different types of criteria all of which are part of the exit
criteria such as the
coverage criteria
Coverage criteria help you decide test cases that must be included during the exit criteria
evaluation process.

For example, when testing an application that helps you book air tickets; your coverage criteria
could be to test the functionality of the application, which enables the user to select the required
airline tickets and the mode of payment. You will not cover features that process credit card
numbers in this test suite.
acceptance criteria
The acceptance criteria enable you to check whether the software under testing has passed or
failed in the overall process.

For this test suite example, the acceptance criteria could be to pass the application only when it
allows you to select the required flight service and the date of travel. The exit criteria for this
process could specify that testing is complete only when you have completed every step of the
ticket-booking process and prepared the test report.
If you're checking a spreadsheet application, you might set a number of exit criteria statements
to check if testing is complete. The following serve as an example and should not be taken as
complete, accurate or exhaustive:
final draft of the product documentation, including the Contents and Help files, are reviewed, tested in QA,
and approved by the core team
help files are launched with the print option when the required menu option is selected
menu options available on the UI of the spreadsheet are enabled and highlighted when rolled over
spreadsheet runs on all supported hardware and software configurations, as mentioned in the
documentation files
defects of all priorities are fixed and closed during regression testing
navigation across different instances of the spreadsheet is enabled
In addition to analyzing the exit criteria, the exit criteria evaluation phase includes a number of
tasks and activities of which three are particularly important.
1288

Check test logs
When you begin exit criteria evaluation for your test suite, you collect and check the test logs
acquired from the test implementation and execution phase. You check these logs against the
exit criteria set for your test suite during the planning phase. You then identify evidence for every
test executed and the defects that are logged. Defects are analyzed to distinguish between those
that are resolved and those yet to be confirmed or fixed.
Estimate additional test requirements
Depending on the test log analysis, you can estimate if additional tests are required in a test suite
for a more thorough checking. You may decide this based on the number and the criticality of
defects logged. At times, you may even revise exit criteria.

Additional tests are required when the designed tests do not meet the required test coverage.
You change the exit criteria only when the business or technical risks of the software under
testing changes. However, these decisions require the approval of stakeholders.
Prepare test summary report
After analyzing the test logs and assessing if more tests are required, you prepare a summary
report for the stakeholders of the project. This document communicates the test outcome to your
stakeholders, which enables them to make critical decisions about the software under testing.
This document summarizes testing activities and an evaluation of the test results against the exit
criteria.
After you evaluate the exit criteria for your testing process, you proceed to the final phase of the
testing life-cycle test closure. This phase ensures the completion of all test activities and the
sign-off of the end product. Once you reach this phase, you're ready to deliver the software to
your client.
Note
In tests executed for research purposes, you close testing as soon as you've gathered the required
information, because complete testing could exceed the scope of your requirements.
Test closure activities include
checking deliverables
Test closure is initiated by checking planned deliverables against the actual deliverables meant
for the client. This helps check if incident reports are either resolved or deferred according to the
planned deliverables. Planned deliverables specify if an identified incident is to be fixed in the
current version of the software. For example, in the spreadsheet application, an exit criterion is
compatibility with third-party products. If the spreadsheet is incompatible with a specific third-party
product, then you check your planned deliverable to see if this compatibility is required. If not, you
1289

can defer fixing this issue, documenting it so that it's addressed in the future versions of the
application.
archiving testware
After checking deliverables, you collate and archive testware test scripts, test environment
components, and any tools used in the test infrastructure. You archive testware so that the same
components can be reused during maintenance testing, making the process time- and cost-
effective. Archiving also helps you compare test results between the different versions of the
software.
Suppose an earlier version of the spreadsheet application had been tested by you and the test
logs of that test are available from the test library. You can compare these with the current test
logs to check if any errors are repeated. You can then archive your test logs for future use.
submitting testware to maintenance team
Submitting testware to the maintenance team is an important activity of test closure. The
maintenance team independent of the test team supports the software and is responsible for
defect resolution after the application goes live. Archived testware in the test library helps
maintenance testers reuse the same test scripts and environment.
evaluating the overall test process
Finally, you evaluate the overall process that was executed to test the software. This helps
identify and assess lessons learned from the test process, letting you improve future test
processes.
Question
As a development tester, you've recently completed multiple test suites for a word processing
application to check if 85% of statement coverage is tested. You also checked to ensure that user-
defined words could be added to the dictionary.

Having implemented the test suites and generated the test logs, what activities would you perform
as the final steps of the test process?
Options:
1. Check if the functionality of the word processor is tested up to the required degree of test coverage as
planned
2. Create exit criteria to check that 85% statements are covered and words to the existing dictionary can be
added without errors
3. Validate test logs against the exit criteria and identify if further tests are required
Answer
Option 1: Correct. You check the actual deliverable against the planned deliverable during test
closure phase before delivering the tested software to the client. At this stage, you ensure that all
incident reports and defects are resolved.
1290

Option 2: Incorrect. You create the exit criteria that you require for testing, during the initial planning
phase. You would check these criteria against the test outcome, analyze whether they are met, and
if met, exit testing.
Option 3: Correct. Once test logs are generated, it is important to validate them to evaluate exit
criteria. At this stage, if you determine that exit criteria are not met, you can identify further tests to
cover the exit criteria.
Correct answer(s):
1. Check if the functionality of the word processor is tested up to the required degree of test
coverage as planned
3. Validate test logs against the exit criteria and identify if further tests are required
Summary
In the software testing process, the last two phases evaluating exit criteria and reporting and
test closure help you assess whether testing is complete and document the test results and
the scripts for future use.

Evaluating exit criteria and reporting requires you to check the test logs acquired from test
execution and then compare them against the exit criteria set during test planning. In addition,
you also analyze if any further tests are required and prepare the test summary report.

During test closure, you check the actual deliverables against the planned deliverables, before
you deliver the software to the client. You then archive testware in the test library, which is used
by the maintenance testers. Finally, you analyze and suggest improvements to the overall test
process documenting them in the project evaluation report.










1291

The Psychology of Software Testing
Learning Objectives
After completing this topic, you should be able to
identify levels of independence in testing
recognize the role of communication in the psychology of software testing
1. Levels of independence in testing
Among the many factors that affect software testing, psychological factors are important,
because they influence the success of the testing activity. How an individual identifies and
reports defects, how evidence is gathered and shared, and how results are communicated and
interpreted, are all factors determined by the psychological make up of individuals involved.


The psychological make up of a developer differs from that of a tester, and consequently
influences the process of testing.
Testing requires an objective mindset. This objectivity exists only if the person testing the
product is not personally attached to the product.

For example, when a developer creates an application, he constructively resolves the issues in
the design to ensure that the end product meets the required standards. But while testing the
product, the developer may miss defects because he may approach the product given the
effort he put in and the personal involvement in developing the product as one without defects.
But a tester, who is not involved in software development, stays detached from the product
being tested. This helps him or her objectively assess the product and find defects because he
or she consciously looks for them during testing.
Testing activities should be assigned to someone who was not part of the software development
process. This ensures separation of responsibilities between a tester and a developer, called
independence.
Independence in software testing introduces objectivity and adds value. It defines the success of
the software testing process by preventing author-induced biases from creeping in and allowing
valid defects to be reported.
You can implement different levels of testing independence at different stages of the
development life cycle depending on the nature of the testing and reviewing activities in that
stage.
1292

There are four basic levels of independence graded from high to low in software testing. The
grade of independence depends on the degree of responsibilities shared between the members
of the testing and the development teams.
Software developer
When the developer who created the software tests his own software, the level of testing
independence obtained is minimal. There is no actual separation of duties, because the tester
and the developer are the same person. This first level of independence is the lowest in the order
of independence and can be employed for cursory reviews or when the project is considered low
risk.

For example, when you program a word-processing application, you can do a self-review of the
product for any design-based defects easily identifiable by you. But this level of independence
would not suffice for in-depth analysis of the software for example, to check functionality defects
or third-party application support.
Peer reviewer
The second level of testing independence is when a peer within the team reviews the product or
application. This person brings a fresh perspective to the testing and tends to be more objective
than the product author. Typically, peers are members from the same development team, who
may be in charge of developing a different application or different portions of the same
application.
Internal tester
For a higher level of testing independence with improved objectivity, you can employ an internal
tester from a different functional group or a testing team. For example, you can ask a qualified
tester from the QA team in your organization to review your software.

This is the preferred and most common level of testing independence employed by most
organizations. It is cost effective, because you employ someone within your organization to
independently evaluate your software.
Third-party reviewer
The highest and the fourth level of testing independence is achieved when a third-party reviewer
usually a certified tester from a different organization tests your software. Although expensive,
this level provides optimum results in a test scenario, providing maximum separation of
responsibilities between the development and testing teams.

Suppose your team develops a calendar application. To ensure complete objectivity, you can
hand over the product to a third-party test team. This team approaches the product as flawed,
unlike teams within the organization which may not bring this level of objectivity. As a result,
they're able to find defects that teams within the organization may overlook.
1293

Although objectivity is critical during software testing, sometimes developers test their products
due to resource and time constraints. In these cases, the developer must adopt the mindset of a
tester to look consciously for defects for testing to be effective.

The primary advantages of self-review include early defect detection and prevention and cost
effectiveness.
However, higher levels of independence in testing produce more effective results, even though
they may impact the schedule and project costs.
Question
As a Project Manager for a payroll application, you want to employ different levels of testing
independence for different testing activities.

Rank the levels of testing independence from the lowest to the highest.
Options:
A. Ask Pete, who designed and worked on the payroll application, to review his module and report
defects detected.
B. Acquire the help of Sandra, who is working on a related application, to test the payroll module created
by Pete
C. Hand over one module of the payroll application to the testing team in your organization that tests all
completed software products of your organization
D. Hire certified testers from outside your organization to run tests on the payroll application
Answer
Correct answer(s):
Ask Pete, who designed and worked on the payroll application, to review his module and
report defects detected. is ranked as the first level of independence in the software testing
process.
The first level of testing independence is applied when the developer who created the software
is employed to test the product. This level can be applied for cursory reviews.
Acquire the help of Sandra, who is working on a related application, to test the payroll
module created by Pete is ranked as the second level of independence in the software
testing process.
When a peer within the team is involved in testing a software product, then second-level
independence is applied. This level of testing independence is higher than the level of self-
reviews.
Hand over one module of the payroll application to the testing team in your organization that
tests all completed software products of your organization is ranked as the third level of
independence in the software testing process.
1294

The third level of independence is applied when a member of a different functional group, such
as the QA team in your organization, is involved in the testing process.
Hire certified testers from outside your organization to run tests on the payroll application is
ranked as the final level of independence in the software testing process.
The highest level of independence is applied when a tester from a different organization or
company is employed to test the software product developed in your organization.
2. The role of communication in testing
Although processes and procedures are critical to the success of software testing, an
overlooked but equally important component affecting testing is communication.

Because software testing includes the participation of multiple teams internal testers,
development team, stakeholders, and external testers these teams must communicate with
each other as seamlessly as possible. Otherwise, misunderstanding and misinterpretation can
undermine the test objective.
Suppose your organization requires test activities at every stage of the process. The test results
at every stage should be communicated to the entire team, because the tester may change for
every round of testing.

For example, a developer tests the software design model during the design phase and an
integrator checks for integration defects later in the development stage. Results of these tests
need to be communicated to the next level of testers and the final testing team so that they are
aware of what occurred in the past and how it was resolved. It also helps them to look for similar
defects while testing.
Not only is communicating initial test activities to the testing team important, but how the testing
team communicates its test results to the development team is equally critical. A tester's mindset
is to look for defects in a product, and when they find them; their role in the process is justified.
This can affect the tone used when they log defects.

A harsh tone can make a developer defensive. The developer may feel that the defect log
pinpoints faults, which in turn reflects on the developer's skills and competency. This may lead
him to disregard defects reported. The validity of the defect is lost and the purpose of testing is
defeated. Effective inter-team communication can help avoid these issues.
For communication among team members during the test process to be effective, it is important
to communicate
defects and incidents neutrally
Chances of test results being taken positively by the development team would increase if you
communicate the defects and incidents in an objective manner. This means that the defects
should be recorded without attributing the cause to the person who worked on it or undermining
his effort. You should provide objective information on the defects so that the developer
1295

understands that you're not finding fault with him. For example, if the developer of the software
has made a recurring error, simply explain the defect and discuss your observations of the
incident. You can also record anything that you felt worked particularly well in the software.
how the end user benefits
For successful software development and testing, it helps to keep in mind the requirements and
the benefits to the end user. Communicating how the defects you observe can impact end-user
experience, provides objectivity to the test process. You should also emphasize how the defect
prevents the product from meeting its stated objective. For example, you are evaluating a GUI-
based web application that requires high network bandwidth usage. As a tester, you can highlight
this to the development team and explain to them how this may hinder the end user experience.
the need for collaboration
The test process benefits from team effort, with the test and development teams collaborating
effectively. In addition to achieving end-user satisfaction, working in a collaborating team helps
you detect and fix defects, with multiple perspectives. Collaboration requires you to share your
observations and suggestions with your team and receive feedback. For example, you've
identified a new defect in a piece of software, but you are unsure of the scope of the defect.
Instead of logging with the information you have, you could collaborate with the developer to get
more information. As well as improving the information logged, this could help the developer feel
more involved and invested in the testing process.
As a tester, you should remember and understand the objectives and the stakeholder
requirements defined for the testing process. The project and the test process are driven by
these factors, and test plans are based on them. Understanding these factors helps you adopt
the right perspective while testing.

For example, if testers understand the objectives, they can set test parameters and the exit
criteria, and rate the performance of the product according to these details. Otherwise, testing
can be flawed, with noncritical defects possibly emphasized over others. In such cases, the
developer may reject the defects logged against the software, hindering the overall test process.

Testers must be able to identify what is critical and what is not while reporting defects. This
ensures that the development team does not spend time and money in closing defects that are
not critical to delivery.
Involvement in software testing enables individuals to learn confidential and privileged
information. A code of ethics is necessary, among other reasons to ensure that the information
is not put to inappropriate use.

Recognizing the ACM and IEEE code of ethics for engineers, the ISTQB states the following
code of ethics:
public
Certified software testers shall act consistently with the public interest.
1296

client and employer
Certified software testers shall act in a manner that is in the best interests of their client and
employer, consistent with the public interest.
product
Certified software testers shall ensure that the deliverables they provide (on the products and
systems they test) meet the highest professional standards possible.
judgment
Certified software testers shall maintain integrity and independence in their professional
judgment.
management
Certified software test managers and leaders shall subscribe to and promote an ethical approach
to the management of software testing.
profession
Certified software testers shall advance the integrity and reputation of the profession consistent
with the public interest.
colleagues
Certified software testers shall be fair to and supportive of their colleagues, and promote
cooperation with software developers.
self
Certified software testers shall participate in lifelong learning regarding the practice of their
profession and shall promote an ethical approach to the practice of the profession.
Question
You implemented a test suite and found some incidents and defects. Now you want the programmer
who developed the application to fix them. How would you communicate your findings to the
programmer?
Options:
1. Record incidents in a neutral and factual manner
2. Record your surprise on how such defects were allowed to creep in
3. Discuss how closing the defect helps the end product
4. Direct that all incidents must be closed without any delay
Answer
Option 1: Correct. As a tester, you need to create neutral and factual incident reports that clearly
and constructively discuss the defects, without insulting or blaming the developer.
1297

Option 2: Incorrect. When you log errors against a programmer, your reports should be written in an
objective tone devoid of personal remarks. Expressing surprise in incident reports detracts from
objective testing.
Option 3: Correct. As a tester, you need to explain to the developer how your observations would
help improve the end product. This helps the developer recognize the testing process as an effort to
improve the product.
Option 4: Incorrect. Once you report the defects against the programmer and explain your
suggestions, the programmer takes over. Insisting on a particular schedule is not a tester's domain.
Correct answer(s):
1. Record incidents in a neutral and factual manner
3. Discuss how closing the defect helps the end product
Summary
The process of software testing is influenced by psychological factors that determine the
success of the testing activity. These factors help you understand the differences between the
mindsets of a developer and a tester. Generally, objective testing testing carried out by
someone other than the developer is preferred because it supports the separation of
responsibilities across the various teams involved in testing. This separation of responsibilities is
called independence.

There are four basic levels of independence, based on the degree of separated responsibilities.
These levels include tests executed by the programmer himself, a peer programmer, a tester
from the same organization, or a test team from another organization.

Communication across teams also affects test results. Test results should be communicated in
an impersonal, nonjudgmental manner so that they are taken as constructive critiques.









1298

Contrasting Software Testers and Developers
Learning Objective
After completing this topic, you should be able to
recognize the different mindsets of a tester and developer in a test situation
1. The mindset of testers and developers
The success of software testing is dependent on effective communication across different teams
that participate in this activity, including testers and developers.
As a software tester, you need to interact with the programmers or developers, who build the
software applications and services being tested. This interaction drives the entire process,
helping achieve the project goals and objectives. Project objectives drive the test plans, and to
understand these objectives thoroughly, developers and testers need to interact with one
another seamlessly.
The interaction between the testers and the developers are influenced by numerous factors
psychological differences, roles and responsibilities in the testing process, and more.

The roles and responsibilities of testers and developers impact their differing attitudes toward
testing.
For example, the basic responsibility of a developer is to code and to create a software
application based on customer requirements. Even if the developer performs a self-review
during development to locate and fix bugs, she is likely to undertake testing from the perspective
that the product is defect free. A tester, on the other hand, is not expected to create or code
software, and may not factor in the effort the developer puts in. She may only focus on testing
the software on the assumption that it does not meet customer requirements and so consciously
looks for defects in the application.
There are basic differences in the mindset of testers and that of developers.
Tester
A tester tests the product for defects, keeping in mind the complete picture of the development
life cycle and how different systems in the application are interconnected. Consequently, he or
she is most likely to locate defects in the product. Because the tester didn't create the product, he
or she is more objective and more likely to find defects.
Developer
A developer is usually an expert in a specific technical domain. Developers understand how a
specific development model works and what functionality provides a better user experience of the
product.

1299

However, because they delve deeply in their domains, they may lose perspective of the complete
picture. They may discount some defects reported if they feel that the tester isn't competent
enough to understand the development model or the technology used. Being personally involved
in the development may make them less likely to accept defects reported objectively.
Testers should display competence by thoroughly understanding the objectives and
requirements of the application. In doing so, they should get the developer's perspective so they
know what is critical and valid. This understanding is reflected in the test cases and in the nature
of defects reported. This competence helps convince the developer to fix the defects.

In addition, testers should demonstrate maturity and integrity in communicating defects. They
must avoid personal and judgmental communication. At the same time, they must maintain
integrity and resist pressure from any stakeholder to allow the product to pass without thorough
testing.
The mindset of testers is to look at products being tested as flawed, and they approach testing
as an activity that uncovers these flaws. So they design test suites to detect defects instead of
designing test cases that only check if something works. This results in more defects being
uncovered.
In the same test situation, a developer is likely to fit the defects reported within the established
development models, and in cases where they don't fit, disregard them. The developer aims to
create a working solution, not to look for intermittent bugs that arise in some other element of
the application.
The differing mindsets of the testers and developers can lead to misunderstandings and
communication gaps when the two interact. There are ways that testers and developers can
bridge this gap:
understand and appreciate each other's roles and responsibilities in the testing process
communicate and coordinate with one another throughout the development and testing life-cycle
initiate conversations with the programmers, as testers, and not wait for them to start inquiring about
defect reports
share plans, drafts, schedule, design documents, and prototypes to stay updated of the process
provide fair feedback to the developers, appreciating their good work and reporting defects objectively
A tester should be able to discriminate between the critical factors that need immediate attention
and those that are minor. This helps him log faults that are valid and require immediate
attention. He should also maintain logs and incident and test summary reports as evidence for
test defects. This helps him substantiate defects when questioned by the developer.

Although reporting defects is a key responsibility, the tester must also communicate the fault
appropriately to the developer so that it can be fixed. The tester should avoid offending the
1300

developer and present the defect report in a manner that makes the developer understand that
the aim is to improve the end product.
Question
What mindset should a potential tester adopt while analyzing a test case?
Options:
1. Understand the need to observe, identify, and record evidence of the defects
2. Recognize and fit defects found within the development models used
3. Be open to appreciate good work in the application in addition to reporting defects
Answer
Option 1: Correct. A potential tester should always back the defects identified with evidence, such
as test logs and test summary reports. Doing so provides a clear perspective of the defects and the
conditions they occur in, and allows developers to validate and fix the defect.
Option 2: Incorrect. Developers work based on established development models and usually try to
fit defects within these models when they're reported. Testers only need to understand the basics of
these models so that defects can be communicated effectively.
Option 3: Correct. A good tester always provides fair feedback, which includes positive and
constructive feedback, using an incident report.
Correct answer(s):
1. Understand the need to observe, identify, and record evidence of the defects
3. Be open to appreciate good work in the application in addition to reporting defects
Summary
The success of software testing is dependent on the effective interaction between testers and
developers.

To improve this interaction, you should first understand the differences in the mindsets of a
developer and a tester. These mindsets are dependent on their roles and responsibilities.
Testers possess an overview of the entire development life cycle, and the developers are
experts in a specific technical domain. Developers code and create software, and testers review
these software products and identify the defects within.

The responsibility of a tester does not end with reporting the defects. He should communicate
the defects politely to the developers and offer suggestions to fix the defects. He should provide
1301

fair and objective feedback. This helps bring testers and developers together and creates a
unified team.



























1302

Organizing Testers and the Software Test Process
Learning Objectives
After completing this topic, you should be able to
organize a test team
organize test activities
Exercise overview
In this exercise, you're required to set up a test team and organize activities that constitute the
software testing life cycle.
This involves the following tasks:
setting up a test team
organizing test activities
Setting up a test team
You are a test manager in an organization. A development team within your organization has
created a payroll administration web site for the company, which will help payroll executives
manage the payroll account of all employees. The site also helps employees view their salary
credits, view and print pay slips, and claim monthly reimbursements.

As a test manager, you want to test and evaluate the functionality of the payroll intranet. To
begin, you want to set up a core team of potential testers.
Question
You want the team you set up for testing the payroll application to have a degree of independence
and objectivity. Due to budgetary limitations, you cannot opt for the highest level of independence.

Who would you assign as testers considering the level of independence required?
Options:
1. The developer who worked on the application
2. A peer of the developer from within the team
3. A testing team from within the organization
4. Testers from a certified testing organization
Answer
1303

Option 1: Incorrect. This is the lowest level of testing independence and should be applied for
cursory reviews of the product, not for achieving higher degrees of testing independence.
Option 2: Correct. The second level of testing independence is achieved when peer reviews are
implemented in testing a software product. This level is higher than self-reviews and provides a
fresh perspective lacking in self-reviews. In the absence of a testing team, this is an option to
consider.
Option 3: Correct. For a higher level of testing independence, you can employ an internal tester
from a different functional group or a testing team to test the product. This is the preferred level of
testing independence in most organizations.
Option 4: Incorrect. Although certified testers from organizations that specialize in testing provide
the highest level of independence, it is expensive. With budgetary limitations, this isn't a feasible
option.
Correct answer(s):
2. A peer of the developer from within the team
3. A testing team from within the organization
Question
You decide to use testers from a different functional group to test the product to get the level of
independence required. You want to ensure that the testers on your team display the right mindset.

Identify the mindset that a potential tester should adopt while analyzing a test case.
Options:
1. Upgrade their skills to gain expertise over the specific domain in the development model being tested
2. Provide evidence in support of defects observed at all times
3. Discriminate between critical defects that require immediate attention and those that are minor
4. Thoroughly understand the objectives and requirements of the application under test
Answer
Option 1: Incorrect. Obtaining the working knowledge of a specific domain in the development
model is the responsibility of a developer, who is considered a specialist in that domain. A tester
needs only an overall idea of the entire test case.
Option 2: Correct. A potential tester should always back the defects identified with evidence, such
as test logs and test summary reports. This helps developers validate and quickly fix the defect.
1304

Option 3: Correct. Testers should be able to differentiate between the two to help save both time
and cost of the overall testing process.
Option 4: Correct. Understanding the objectives and the requirements of the application helps
testers to design and implement test suites that help them detect defects.
Correct answer(s):
2. Provide evidence in support of defects observed at all times
3. Discriminate between critical defects that require immediate attention and those that are minor
4. Thoroughly understand the objectives and requirements of the application under test
Question
You also want the test team to focus on communication. Suppose a test engineer in the team finds a
simple but valid defect in the login functionality of the payroll application. This defect is to be
communicated to the senior programmer who designed and developed the program. How would you
want the test engineer to communicate this defect to the programmer?
Options:
1. Create a strongly worded incident report escalating how such a basic but major defect could occur
2. Explain the defect with observations and defect history in a factual incident report
3. Communicate the defect in a neutral tone with remarks on how fixing it helps the end user
4. Inform the programmer that the defect is assigned to someone else with experience
Answer
Option 1: Incorrect. A good tester creates neutral and factual incident reports, and contributes as a
team rather than blame anyone for defects found. A strongly worded incident report can cause the
programmer to feel that he or she is being judged.
Option 2: Correct. The incident reports that a tester creates should be neutral and objective. For
this, the defects should be recorded without attributing the cause to the person who worked on it or
undermining the effort of that person.
Option 3: Correct. Testers should always communicate their opinions subjective and objective
in a neutral manner. This emphasizes to the developer that the tester's only interest is to ensure that
the product meets the stated objective and meets end-user expectations. This tone also makes it
easier for developers to accept the feedback positively.
Option 4: Incorrect. A potential tester should never assume that a defect cannot be fixed by the
programmer who worked on it. The programmer has the domain knowledge and is skilled enough to
fix a major defect in design.
1305

Correct answer(s):
2. Explain the defect with observations and defect history in a factual incident report
3. Communicate the defect in a neutral tone with remarks on how fixing it helps the end user
Organizing test activities
Now that you've set up a core testing team, you want to identify the order of test activities that
need to be performed to carry out the test process.
Question
You want the focus of the test team to be client privacy and security for the payroll application.
Sequence the tasks in the order your team will perform them during the software testing process for
this payroll site.
Options:
A. Identify exit criteria based on client privacy and security objectives and create test plans
B. Specify as a test condition that only authorized employees with valid user IDs can enter the site
C. Create a test suite for the payroll administration site with test procedures that check if individual logins of
employees could be circumvented
D. Check the logs of the actual test outcome to check if the exit criteria on employee privacy is met
Answer
Correct answer(s):
Identify exit criteria based on client privacy and security objectives and create test plans is
ranked as the first step in testing the software for managing the payroll administration site.
Understanding the goals of the project and identifying the objectives and risks belong to the
planning phase of the testing process. During this phase, the testers can also determine the
kinds of tests to run.
Specify as a test condition that only authorized employees with valid user IDs can enter the
site is ranked as the second step in testing the software for managing the payroll
administration site.
During the test analysis phase, the test documents such as requirements and design
specifications are analysed.
Create a test suite for the payroll administration site with test procedures that check if
individual logins of employees could be circumvented is ranked as the third step in testing
the software for managing the payroll administration site.
During the test implementation and execution phase, the testers on your team will convert the
test conditions that were determined during test design into test cases and test suites. For the
payroll site, these test suites would focus on the security features of the site.
1306

Check the logs of the actual test outcome to check if the exit criteria on employee privacy is
met is ranked as the fourth step in testing the software for managing the payroll
administration site.
Checking the logs of the actual test outcome against the exit criteria is carried out during the
exit criteria evaluation phase. During this phase, your testers would analyze if the exit criteria
for the privacy of the site is adequate, or if more tests are required.
Question
After test suites are executed and test results evaluated, you now want your team to close the test
process. What test activities should the team perform to close the test process?
Options:
1. Archive testware for maintenance testers
2. Analyze lessons learned for future test projects
3. Recommend additional tests to resolve open defects in the payroll processing site
4. Check the test logs against the exit criteria set for the payroll application
Answer
Option 1: Correct. Testers archive testware so that maintenance testers can reuse the same
components during maintenance testing and regression testing because it is time- and cost-
effective.
Option 2: Correct. In the project evaluation report, testers identify and assess the lessons learned
from this test process, which would help them improve the test process as well as the development
life cycle in the future.
Option 3: Incorrect. A tester determines whether additional tests are required during the exit criteria
evaluation phase, not in the test closure phase.
Option 4: Incorrect. Checking the test logs against the exit criteria set for the payroll application
occurs during the exit criteria evaluation phase. This test activity is not part of the test closure
phase.
Correct answer(s):
1. Archive testware for maintenance testers
2. Analyze lessons learned for future test projects



1307

Software Development Models
Learning Objectives
After completing this topic, you should be able to
recognize how software testing relates to the development life cycle
identify software test levels
1. Software testing and development models
Depending on the requirements of a software-development project, you use a specific
development strategy. For example, if you want to quickly design and develop software, you use
a fast-track approach. However, if your main aim is to develop a high quality product, you spend
extra time on the design and development process.

Your development strategy depends on the availability of time and resources, the allocated
budget, and the scope of the project.
Each development strategy is known as a
Software development model. Each model defines the order in which you should perform
project-related activities. These activities include identifying the client's requirements, creating a
product design, developing the required product, and testing the product for defects. Testing is
an important part of each model.
Software development models are of two types:
sequential
iterative
In a sequential development model, the project-related activities are distinct from each other.
Only after you complete one activity can you initiate the next.

The simplest sequential development model is the waterfall model. The waterfall model
comprises six activities.
Graphic
Description of the waterfall model flow chart:
When using the waterfall model, you first identify client requirements. Second, you identify system
requirements. Third, you create an overall design, and fourth, you create a detailed design. Then
you develop the product, and finally, you test the product.
Description ends.
1308

Identify client requirements
To develop a satisfactory product, the development team starts by identifying the client's
requirements. During this activity, the team determines the client's expectations of the product.
Then the team records these requirements in a requirement specification document.
Identify system requirements
After identifying the client's requirements, the team identifies system requirements or the
requirements that the product should satisfy. This activity helps them identify the features and
functions the software product needs to possess to meet the client's needs. The output of this
activity is the functional specification document.
Create an overall design
Based on the identified requirements, the team creates an overall design of the software product.
This overall design outlines the external features of the product. This design also describes the
internal components of the product, such as modules and classes, and their interrelationships.
The team saves the overall design in the technical specification document.
Create a detailed design
While creating a detailed design, the team defines the functions of each of the identified
components and decides on the method to create the components. To store the detailed design,
it creates the program specification document.
Develop the product
Using the detailed design as a blueprint, the team writes code for each component of the product
and, finally, integrates the components to create the product.
Test the product
After developing the product, you test it to ensure that it meets the client and product
requirements as well as the requirements of all types of end users.
The main drawback of the waterfall model is that it incorporates testing toward the end of the
development life cycle. Because the code for the product is too complex at this stage, fixing
bugs or defects in the product can be time consuming. Also, while fixing the bugs, you can
introduce new bugs in the product.
To overcome the drawbacks of the waterfall model, you can divide the development of the
product into various stages and perform a testing activity at the end of each stage. This division
of development and testing activities can help you identify bugs in their nascent stage, when you
can easily fix them.
The V-model is a sequential model that improves upon the waterfall model. In the V-model, the
development team first identifies client and system requirements and creates an overall and
detailed design. You and other members of the testing team review the documents generated at
the end of these processes. You simultaneously plan for the testing activity.

As the product is progressively developed, you and the other testers test it. However, you divide
the testing into four test levels.
1309

Graphic
Description of the V-model flow chart:
In the V-model, you first identify client requirements and plan for acceptance testing. Next, you
identify system requirements and plan for system testing. The third step in the V-model is to create
an overall design and plan for integrating testing. And the fourth step is to create a detailed design
and plan for component testing. After the fifth step, you move on to developing the product. Finally,
you progressively conduct component testing, integration testing, system testing, and acceptance
testing.
Description ends.
Component testing
During component testing, you test each component of your product for defects. Also, you fix any
defects immediately.

You use the detailed design of the product as the basis for creating a component-testing plan.
Integration testing
Integration testing is used to test the interrelationships between the components of the product.
During integration testing, you determine whether the components interact correctly with each
other and with computer hardware and other software.

To create an integration-testing plan, you refer to the overall design of the product.
System testing
Before you begin system testing, developers integrate all the components and build a functional
software product. It exhibits the desired features and functions and performs without any
evidence that there are defects present.

You create a system-testing plan based on the system requirements.
Acceptance testing
Acceptance testing is conducted by the representatives of the client. The representatives may
either test the product at your site or test it after you've delivered it to them. Their main objective
during acceptance testing is to determine whether the product meets all their requirements.

You create an acceptance-testing plan after the client's requirements have been identified.
In the V-model, you test the product at each stage of development. You release the outcome of
each stage to the next stage only when all identified defects have been fixed.

However, the V-model also has a drawback. In this model, you verify a product against client
requirements only toward the end of the development process. Fixing bugs and adding missing
features and functions to the product at this stage can be difficult, expensive, and time
consuming.
1310

The iterative development model eliminates the drawback of the V-model. In the iterative model,
developers build a product using a series of iterative steps. Each step consists of four tasks
Identify requirements, Create a design, Create code, and Test code. You, as the tester, are part
of the development process. Because you are able to test the product while it is being
developed, you can identify bugs easily and accurately.
Graphic
Description of the iterative model flow chart:
In the flow chart, four rectangular boxes represent the four tasks Identify requirements, Create a
design, Create code, and Test code. Connected to the test code box is a decision box labeled "Have
all requirements been met?". If the answer to this question is "Yes", you end the development
process. Otherwise, you move back to the first task and repeat the entire process.
Description ends.
In the iterative model, representatives of your client can participate in the testing process at the
end of each step. The representatives can also suggest changes to the product during
development.
If you use the iterative model, you
don't prepare formal documents, such as the requirement specification document, before you begin
development
don't have to identify all client and system requirements or design the entire product before you start
creating code
have a set schedule and cost for the project and for each iterative step
repeat each iterative step until you develop a final product that meets all client and system requirements
The iterative model also has its drawbacks. These drawbacks can adversely affect the testing
process.

Two significant drawbacks of the iterative model are
absence of formal documentation
In the absence of formal documentation, you can't verify requirements accurately. So you write a
functional test for each iterative step and ask the developers to create code that can pass the
functional test.
increased testing time and cost
Compared to the other models, the iterative model can increase testing time and cost. For
example, during an iterative step, developers can inadvertently modify a previously approved
feature. To prevent such modifications and deletions, you have to spend more effort on testing.
This can be a drawback for small-scale projects.
1311

Question
Match each software development model to its diagram.
Options:
A. V-model
B. Iterative model
C. Waterfall model
Targets:
1. Model 1
2. Model 2
3. Model 3
Answer
In the iterative model, you perform a series of iterative steps until all your project requirements are
met.
The waterfall model is a sequential software development model. In this model, you build and then
test a software product.
The V-model is a customized version of the waterfall model. In this model, you combine the testing
process with the software-development process. This ensures that you test each component,
feature, and function of your product as it is built.
Correct answer(s):
Target 1 = Option B
Target 2 = Option C
Target 3 = Option A
The V-model and the iterative model are not stringent and you can modify them to suit your
requirements. For example, you can use the four test levels component testing, integration
testing, system testing, and acceptance testing during each iterative step of the iterative
model.
You can also customize the order in which you perform the four test levels, regardless of the
development model you use. For example, if you're testing a web portal that contains a third-
party application, you perform acceptance testing on the third-party application first. Then you
carry out system testing for the web portal.
1312

Question
Match each test level to the correct scenario.
Options:
A. Component testing
B. Integration testing
C. System testing
D. Acceptance testing
Targets:
1. You are testing the interaction between the component of your software product and an operating
system
2. You are testing whether a software product meets users' needs
3. You are testing an assembly that you want to add to your web page
4. You are testing whether a tax-calculator application performs calculations correctly
Answer
Integration testing helps you determine whether the components of your software product interact
correctly with computer hardware and other software. It also helps you test the interrelationships
between the components.
During acceptance testing, you check whether or not your software product meets all actionable
client requirements.
During component testing, you check each component of your software product for defects.
At the system testing level, you check a complete product and ensure that it meets all client and
system requirements.
Correct answer(s):
Target 1 = Option B
Target 2 = Option D
Target 3 = Option A
Target 4 = Option C
1313

Summary
The development model of any software-development project depends on its requirements.
Sequential and iterative models are two types of development models. Testing is an integral part
of both these models.

The waterfall model is the simplest sequential development model. In this model, you test a
complete product. So you should use the waterfall model only if you've identified the client and
system requirements accurately and don't expect to find extensive defects in the product.

The V-model is an improved version of the waterfall model. In this model, you divide the testing
activity into four test levels: component testing, integration testing, system testing, and
acceptance testing. You use these test levels as you progressively build the product. This
makes the testing and fixing processes easy.

When using the iterative development model, you develop your software product in parts, using
a series of iterative steps. Testing is a part of each step, and you can involve client
representatives in the testing process. This makes it easier to identify bugs.

















1314

Component and Integration Testing
Learning Objectives
After completing this topic, you should be able to
recognize how component testing works
recognize how integration testing works
1. Component testing
In advanced software development models such as the V-model, testing is an elaborate activity
and is performed at four levels. Dividing the testing activity into these levels helps you efficiently
manage and control the activity. These test levels also make it easier for you to identify bugs
and fix them.
Component and integration testing help you locate code-related defects and determine whether
the various code segments interact with each other as intended.

You perform component and integration testing during the early stages of software
development. So you can correct identified defects with minimal rework and reduce, or even
prevent, defects in the integrated software.
Component testing helps you identify errors in each component, such as an object, program, or
module, of a software application. After the code for a component is written, it can be tested by
the original developer, or passed for testing to another developer. The involvement of another
developer brings objectivity and independence to the component-testing process.
During component testing, you don't maintain a formal record of defects. So to avoid oversights
later, you or the designated tester should fix all errors as soon as you detect them.
A common approach to component testing is the test-first approach, which is an iterative
process. According to this approach, you create test cases before you start developing and
testing code. To create the test cases, you use the specifications documents and the blueprint
for the software application.

The test-first approach involves repeating three steps until the code passes the tests:
create test cases
develop code
run tests
While you're testing the code of a component, you may also need to check whether the code
correctly responds to or calls other components. However, sometimes, you may not have
1315

immediate access to these other components.

The unavailability of the other components in a component-testing scenario is similar to the
testing of parts at a car-manufacturing plant. For example, when you begin testing the motor of a
particular car model, the braking system or the ignition mechanism might not be ready. Here the
braking system is a called component and the ignition mechanism is a component that calls the
motor.
To test the functions of the motor in the absence of a braking system and ignition mechanism,
you might first create a temporary, no-frills braking system and ignition. Then you could connect
both to the motor. Similarly, to check whether a software component can respond to or call other
components, you create two temporary components:
stubs
Stubs simulate called components. While testing a software component in isolation, you use a
stub in place of each called component. For example, if an component calls an object that is not
yet ready, you can use a stub in place of the object.
drivers
During component testing, you may also have to create simulated components or test tools
known as drivers. A driver acts as a substitute for a component that calls the component you're
testing. For example you can use a driver in place of the button that calls the authentication
system you're testing.
At the component-testing level, apart from checking the functions of a software component, you
also verify whether it meets nonfunctional requirements. For example, you check whether a
component can manage memory and storage space efficiently.
Note
A nonfunctional requirement is one that isnt related to functionality, but to an attribute such as
usability, efficiency, reliability, maintainability or portability.
During component testing, you also test the robustness of a component. For example, you
check how well the component responds to invalid inputs. You also check whether the
components require additional testing and perform the tests, if required.
Question
The training department at Easy Nomad Travel, a worldwide travel agency, has developed various
training courses over the years. To manage these courses, the agency hires your company to
develop a modular course management system. As a testing manager, you're responsible for testing
the system. Identify the steps which are necessary to ensure successful component testing.
Options:
1316

1. Assign a developer to test each module created by another developer
2. Maintain a formal record of defects
3. Ensure all called components are available
4. Create test cases before you develop and test code
Answer
Option 1: Correct. To bring objectivity and independence to the component-testing process, you
can ask a developer to test a code segment or module created by another developer.
Option 2: Incorrect. It is not necessary to maintain a formal record of defects during component
testing. You fix all defects as soon as you detect them.
Option 3: Incorrect. During component testing, you may not have access to all called components.
So to check whether the code you're testing correctly calls other components, you substitute the
called components with stubs.
Option 4: Correct. A commonly used approach to component testing is the test-first approach. In
this approach, you create test cases before you start developing and testing code.
Correct answer(s):
1. Assign a developer to test each module created by another developer
4. Create test cases before you develop and test code
2. Integration testing
After successful component testing, you move on to integration testing. At this test level, you
determine whether software components interact with each other as intended.

During integration testing, you also verify whether the software components interact correctly
and efficiently with computer hardware and other software, such as an operating system. This
level of testing is also known as component integration testing and is typically conducted by
either developers or integrators.
You can also conduct an integration test after the system-testing process. At this stage, you
refer to integration testing as system integration testing. This type of testing helps you accurately
analyze the interactions between a complete software product and other software systems.
During component and system integration testing, you can test the nonfunctional characteristics
of the integrated components and systems. For example, after integration, two components may
use a single system resource at the same time. This can negatively affect the performance of
the components. You can check for such performance degradation during component
integration testing.
1317

Before you plan for and perform integration testing, you should choose an integration strategy.
This strategy helps you decide the order in which you integrate the components of a software
application. The order depends on the number and types of bugs you expect the application to
have.

Based on the integration strategy you choose, you can adopt one of two methods to conduct
integration testing:
big-bang integration testing
You perform big-bang (or non-incremental, as it is formally known) integration testing on a fully
integrated system. You should use this method of testing only if you plan to integrate the software
components first and then test the resulting system. Bang-bang integration testing proves
successful if the components have few and uncomplicated bugs.
Description of the big-bang integration testing animation:
The animation depicts the pieces of a jigsaw puzzle being assembled to complete the image of a
car.
Description ends.
incremental integration testing
Incremental integration testing is opposite to the big-bang method. In this type of testing, you
gradually build and test the system on a component-by-component basis. For example, you test
the interactions between any two components before you integrate and test additional
components.
Description of the incremental integration testing animation:
The animation depicts the pieces of a jigsaw puzzle being assembled one-by-one to complete the
image of a car.
Description ends.
Both integration testing methods have their advantages and disadvantages.

Big-bang integration testing ensures that you don't require stubs and drivers to simulate missing
components. Yet this method is time consuming because it involves testing an entire system.
While conducting such tests, you may be unable to identify the cause of defects quickly.

Additionally, big-bang integration testing allows you to detect defects only late in the
development process. Fixing defects at this late stage can considerably increase the defects
and expenses of the project, leading to budget overruns.
The advantage of incremental integration testing is that you start testing on a small scale. For
example, you first test the interaction between two or three components. This increases your
chance of isolating defects.

However, when you conduct tests using incremental integration testing, you need to use stubs
and drivers to substitute for missing components. Creating the stubs and drivers can be time
consuming, increasing the cost and effort involved in the test process.
1318

In most cases, incremental integration testing is preferable to big-bang integration testing
because the advantages of incremental integration testing outweigh the disadvantages.
You can divide incremental integration testing into two types:
top-down integration testing
Top-down integration testing involves testing the external features of a software application first
and then gradually integrating and testing the internal components. For example, you start by
testing the interactions of the graphical user interface (GUI), which isn't called by any other
component. If the components the GUI calls aren't ready, you use stubs to simulate them. When
you receive the missing components, you perform integration testing on them.

The advantage of top-down integration testing is that you don't need to create drivers. Also, this
type of testing helps you easily identify and fix defects in the design of your software application.
However, additional effort is required to create stubs.
bottom-up integration testing
In bottom-up integration testing, you first test the component at the lowest level in the software
application. This would be the component that doesnt call any other components. You can use
drivers to simulate the components that call this component. Similarly, you progressively build the
application and test the higher-level components.

This method helps you test the interactions between software components more effectively than
the top-down method.
Question
Having integrated the components of the Easy Nomad Travel course management system, you
want to perform big-bang integration testing. Before you do so, what should you know about this
testing method?
Options:
1. Is performed in an incremental manner
2. Involves the use of stubs and drivers to simulate missing components
3. Allows you to detect defects at a late stage of software development
4. Tests the interactions between components and computer hardware
Answer
Option 1: Incorrect. Big-bang integration testing involves testing an entire system. You perform this
type of test only after you've integrated all the software components.
1319

Option 2: Incorrect. You perform big-bang integration testing on a fully integrated system. Because
you don't have missing components, you don't require stubs and drivers.
Option 3: Correct. You can conduct big-bang integration testing only after you've integrated all the
components of your software application. This prevents you from detecting defects until all the
components are ready.
Option 4: Correct. Big-bang integration testing verifies the interactions between software
components and other systems such as the operating system, computer hardware, and other
software applications.
Correct answer(s):
3. Allows you to detect defects at a late stage of software development
4. Tests the interactions between components and computer hardware
Summary
To accurately identify bugs in your software applications, you can test them at four levels. The
first two test levels are component testing and integration testing.

During component testing, you test the code of each component of a software application and
immediately fix the bugs you discover.

Integration testing helps you verify the interactions between the components of a software
application. You can carry out integration testing in two ways big bang and incremental. Using
big-bang integration testing, you test a fully integrated system. Conversely, incremental
integration testing involves progressively integrating components and testing their interactions.
You can perform integration testing using either a top-down or a bottom-up approach.










1320

System and Acceptance Testing
Learning Objectives
After completing this topic, you should be able to
recognize how system testing works
recognize how acceptance testing works
1. System testing
After you have successfully tested the features and functions of each component of a software
application, you can test the application as a single entity. This level of testing is called system
testing.
During system testing, you ensure that the application meets the requirements you'd identified
during the initial phases of the software-development process.
You also test whether the application can withstand potential risks, such as hacker and virus
attacks. Additionally, during this level of testing you determine whether the application can
optimally utilize system resources. Checking whether the application can interact with the
operating systems it supports is also a part of the system-testing process.
System testing is typically conducted by a dedicated testing team. This team will assess the
application on the basis of its external features and not the underlying code. To ensure that the
implementation details are not known to the testers, they should not have worked on the
development of the code.
The objective of system testing is to verify that the system meets specified requirements. You
test the application in the simulated environment to do this, checking for any defects as you
progress.

You can categorize requirements into
functional requirements
Functional requirements refer to the features and functions of the application. For example, an
order-processing system needs to display order details to users. So the ability of the system to
retrieve the order details from a database is a functional requirement.

You can also consider the security mechanism of an application and the ability of the application
to interact with other systems as functional requirements.
nonfunctional requirements
Nonfunctional requirements are those that are not related to specific functionality, but to attributes
such as usability, efficiency, reliability, maintainability or portability. For example, you consider an
1321

application efficient if it retrieves information within a few seconds. So the ability of an order-
processing system to retrieve customer details within a few seconds may be a nonfunctional
requirement. Although somewhat generic, nonfunctional requirements do need to be identified as
part of requirements gathering.
While testing functional requirements, you start with a specifications-based black box approach.
Black box testing is so called because it takes no interest in the internal structure of the system
or component.
White box, or glass box, is used to describe testing that is concerned with the internal workings
of a system. As well see, structural testing is one such testing type.
Note
To influence the experience of developers, testers, and users and to determine what should be
tested, black box and white box testing may be used in conjunction with experienced-based
techniques.
While performing nonfunctional tests, you verify quality attribute requirements. For example, you
check whether an application performs as efficiently and reliably as intended. You might
determine if the system is as easy to learn and use as you require, and test for issues relating to
future maintenance. You may be testing for how easy it is to install or adapt the system into
other environments.
The attributes, and their sub-attributes, tested for during nonfunctional requirements testing, are
Reliability, comprising robustness, fault-tolerance, recoverability and compliance
Efficiency, comprising speed, resource utilization, and compatibility
Usability, comprising comprehensibility, learnability, operability, appeal, and compliance
Maintainability, comprising analyzability, stability, changeability, testability and compliance
Portability, comprising adaptability, compatibility, installability, replaceability, and compliance
Question
During system testing, you verify whether an application meets two categories of requirements:
functional and nonfunctional. Match each type of requirement to the appropriate category.
Options:
A. A graphics-sharing web site allows users to edit their graphics online
B. An accounting application must be capable of being expanded in the future
1322

C. A bank's website runs in all types of web browsers
D. The web site of an airline company must be able to process payments made via a range of credit cards
E. An order-processing system provides buttons and menus that are easily accessible
F. A web form displays transaction details only to authorized users
Targets:
1. Functional requirement
2. Nonfunctional requirement
Answer
Functional requirements are application specific. These requirements refer to the features and
functions your client wants in an application. An example of a functional requirement is the ability of
a photo-sharing web site to allow users to edit photos. Similarly, the ability of a web site to correctly
process credit-card payments and the ability of a web form to display transaction details only to
authorized users are functional requirements. Not all web sites and web forms need to satisfy these
requirements.
Nonfunctional requirements are those that are not related to specific functionality, but to attributes
such as usability, efficiency, reliability, maintainability or portability. For example, a systems
readiness to have new features and functionality added at some future date is a maintainability
attribute.
Correct answer(s):
Target 1 = Option A, Option D, Option F
Target 2 = Option B, Option C, Option E
Question
Which of the following tests form part of system testing?
Options:
1. Testing an application that can support a minimum number of concurrent users
2. Testing an application that works properly on a specific Operating System
3. Testing a component that interacts with other components correctly
4. Testing a module of an application before code is available
Answer
Option 1: Correct. System testing tests the whole system as it might be used in a production
environment.
1323

Option 2: Correct. System testing tests that the system interacts as intended with its environment.
Option 3: Incorrect. This kind of testing would form part of integration testing.
Option 4: Incorrect. This kind of testing would form part of component testing.
Correct answer(s):
1. Testing an application that can support a minimum number of concurrent users
2. Testing an application that works properly on a specific Operating System
2. Acceptance testing
After successful system testing, you hand over the application to the client. Representatives of
the client, such as prospective users of the application or designated testers, then conduct
acceptance testing. Instead of checking the application for defects, the testers verify whether the
application meets all their requirements, both functional and nonfunctional.
Some clients may also send their representatives to your company to conduct acceptance
testing on a product. This type of acceptance testing is known as Factory acceptance testing.
After a successful factory acceptance test, the representatives take the product to their site and
perform another acceptance test there. At this stage, you call the test Site acceptance testing.
Note
Overlapping of system and acceptance testing is common during factory acceptance testing. If an
application contains multiple independent subsystems, you don't need to wait for system testing on
all the subsystems to be complete. You can perform acceptance testing on any subsystem that has
passed a system test.
For successful acceptance testing, you simulate the environment in which the application will
run.

During acceptance testing, you determine whether an application
meets all the specified requirements
is ready to be deployed
adversely affects existing applications and business operations
If an application fails an acceptance test, then unless the customer chooses to accept the
defect, it needs to be fixed by developers. For example, if you discover that a new order-
processing system causes problems when coexisting with an existing line of business system,
then a fix will need to be sought.
1324

You can categorize acceptance testing into various types:
user acceptance testing
The prospective users of an application conduct user acceptance testing. During this testing
process, they check whether the application allows them to perform business tasks. For example,
they check whether an accounting application allows them to generate and print reports.
operational acceptance testing
Operational acceptance testing is conducted by system administrators. These administrators try
to assess whether the application can withstand malicious attacks, can recover from failures, and
can be maintained easily and efficiently. For example, a system administrator may check if a
customer-survey form can use back up data to recover from failures.
contract acceptance testing
If you sign a contract with the client about the type of application you'll create, the client conducts
contract acceptance testing. During this testing process, the client ensures that the application
meets the acceptance criteria specified in the contract. For example, if a contract mentions that a
web site must allow users to customize each web page, the client verifies this.
regulation acceptance testing
To ensure that an application complies with standard government, legal, and safety regulations,
the client conducts regulation acceptance testing.

Suppose a company is developing software for US government use. There may be a requirement
that the software complies with Section 508 Amendment to the Rehabilitation Act of 1973.
Compliance means that the software is accessible to people with disabilities, and that access and
use are comparable to access and use by a people with no disabilities. The government
department receiving the software would test for section 508 compliance against these criteria.
Two other types of acceptance testing are alpha and beta testing. You perform alpha and beta
testing on software applications your organization produces for mass use, for example,
commercial off-the-shelf (COTS) applications.
During the alpha testing process, your team and a group of prospective customers check an
application to ensure that it meets all specified requirements. You perform alpha testing at your
site.
After successful alpha testing, you send the application to another set of prospective customers
for beta testing to help simulate a real-world environment. These customers check whether the
application meets their needs and report problems to you. Based on their reports, you fix the
application and then release it to the market.
Note
Alpha testing that takes place at the developers site is sometimes referred to as factory acceptance
testing, while beta testing in the customers site corresponds to site acceptance testing.
1325

Question
The development team at your company has created a transaction-processing system for the call
center at Easy Nomad Travel. After conducting a successful system test, you send the system to the
client for acceptance testing. The client decides to conduct operational acceptance testing on the
system. Identify the characteristics of this type of testing.
Options:
1. Is conducted by system administrators
2. Is conducted by prospective users
3. Assesses the ability of a system to resist hackers
4. Verifies whether a system meets safety regulations
5. Checks whether a system meets client acceptance criteria
Answer
Option 1: Correct. During operational acceptance testing, system administrators try to assess the
robustness of a system. They also check whether they can maintain the system easily and
efficiently.
Option 2: Incorrect. The prospective users of a system conduct user acceptance testing. During the
testing process, they check whether the system can help them perform required tasks.
Option 3: Correct. During operational acceptance testing, the administrators try to assess whether a
system can withstand malicious attacks and recover from failures. They also check whether their
security guidelines and user-management criteria can be applied to the users of the system.
Option 4: Incorrect. Regulation acceptance testing verifies whether a system complies with
standard safety, government, or legal regulations.
Option 5: Incorrect. To check whether a system meets acceptance criteria, representatives of the
client conduct contract acceptance testing. The acceptance criteria are part of a contract, which the
client and representatives of your organization jointly sign.
Correct answer(s):
1. Is conducted by system administrators
3. Assesses the ability of a system to resist hackers
Acceptance testing is often the last test level. However, you can also perform acceptance
testing at other stages of the software-development process:
during component testing
1326

During component testing, you can conduct acceptance testing on a component to verify it
performs as expected.
during installation or integration
You subject a COTS application to acceptance testing while youre installing it or while youre
integrating it with another application.
before system testing
If you add a new feature to an existing application, you first perform acceptance testing on the
feature. Then you conduct system testing on the entire application.
Question
You've handed over the course management system to representatives of Easy Nomad Travel. The
representatives want to run an acceptance test on the system. What should they do?
Options:
1. Ask a group of prospective users to perform the test
2. Ask the developers at your company to perform the test
3. Check each component of the system for defects
4. Check whether the system is ready to be deployed
Answer
Option 1: Correct. A group of prospective users conducts acceptance testing on a system and
checks whether the system meets their requirements.
Option 2: Incorrect. The developers who created the application should not be involved in
acceptance testing although the customer might commission acceptance testing on their behalf by
professional testers from the same company.
Option 3: Incorrect. The client representatives don't perform acceptance testing primarily to look for
defects in a system. They perform acceptance testing to verify whether the system can be deployed
and meets their key requirements, both functional and nonfunctional.
Option 4: Correct. During acceptance testing, representatives of the client check whether a system
is in a satisfactory state and is ready to be deployed. In doing this, they check whether the system
can adversely affect existing applications and business operations.
Correct answer(s):
1. Ask a group of prospective users to perform the test
4. Check whether the system is ready to be deployed
1327

Summary
Before you deliver a fully integrated application to your client, you perform system testing on the
application. This is the first time you test the application as a whole. System testing helps you
determine whether the application meets the requirements you'd agreed upon with your client.

Once the application has completed system testing successfully, acceptance testing is carried
out for, or on behalf of, the client. The client representatives may carry out the tests in two
stages: first at your site (alpha testing) and then at the clients (beta testing).






















1328

Testing to Reveal Defects
Learning Objective
After completing this topic, you should be able to
evaluate software defects and test levels
Exercise Overview
In this exercise, you're required to evaluate software defects and test levels. First, you need to
evaluate given defects and determine which test levels can help detect them. Second, you need
to evaluate given test levels and determine which defects the test levels can reveal.
This involves the following tasks:
recommending test levels
evaluating test levels
Recommending test levels
Your company is developing an online-banking web site for Poseidon Bank. Two significant
features of the web site are an innovative user interface and an authentication system.

The user interface should allow users to log on and effortlessly navigate through the web site.
The purpose of the authorization system is to verify the user credentials and allow authenticated
users to view their account details.

You and your team members have been assigned the task of testing the web site.
Question
During which level of testing would representatives of a client typically note a system failure, for
example difficulty in reinstating a web site after it has been hacked?
Options:
1. Component testing
2. Integration testing
3. System testing
4. Acceptance testing
Answer
1329

Option 1: Incorrect. During component testing, you check the features and functions of each
component of an application separately. The representatives of your client are rarely involved in the
component testing process.
Option 2: Incorrect. Integration testing helps to verify the interactions between the components of
an application. Even if client representatives participate in integration testing, this type of defect is
unlikely to be exposed.
Option 3: Incorrect. Before you deliver an application to your client, you assess the features and
functions of the entire application using system testing. Typically, the representatives of the client
don't participate in system testing.
Option 4: Correct. Acceptance testing is conducted by the representatives of your client. During this
testing process, client representatives verify whether an application meets all their requirements and
is easy to maintain.
Correct answer(s):
4. Acceptance testing
Question
You want to check whether the authentication component of the web site erroneously grants access
to users who provide invalid input. Which testing level helps you achieve this objective?
Options:
1. Component testing
2. Integration testing
3. System testing
4. Acceptance testing
Answer
Option 1: Correct. The authentication system is one of the components of the Poseidon Bank web
site. To verify whether this component can distinguish between valid and invalid input, you conduct
component testing.
Option 2: Incorrect. During integration testing, you don't check the internal workings of a
component. Instead, you check whether the component interacts with other components and
systems as intended.
Option 3: Incorrect. You don't test individual components during system testing. In this type of
testing, you conduct a system test to check an application as a whole and ensure that the
application meets client requirements.
1330

Option 4: Incorrect. Acceptance testing is performed by the representatives of a client. Rather than
look for defects in an application, these representatives verify whether the application meets all their
functional and nonfunctional requirements.
Correct answer(s):
1. Component testing
Question
Users of the web site should be able to locate links and navigation controls easily. Which test level
helps you verify this requirement?
Options:
1. Component testing
2. Integration testing
3. System testing
4. Acceptance testing
Answer
Option 1: Incorrect. Ease of use and effortless navigation are external features of an application.
Component testing can't help you test these features. It only helps you test the code for individual
components of the application.
Option 2: Incorrect. Integration testing helps you verify the interactions between individual
components of an application.
Option 3: Correct. Ease of use is one of the nonfunctional requirements of an application. You
verify this requirement during system testing.
Option 4: Incorrect. Acceptance testing helps verify whether an application can be deployed by the
client. This level of testing is conducted directly by, or on behalf of, the client.
Correct answer(s):
3. System testing
Evaluating test levels
Your company develops gaming software for a wide range of customers and sells the software
through its worldwide retail outlets.

1331

As a testing manger, you supervise the testing of the software. You're currently supervising the
testing of a product aimed for children in the age group 7 through 10. The product will allow
users to change display preferences and color schemes. Also, the product will provide four
levels of complexity during each gaming session.
Question
You ask developers to perform component testing on each component they develop. What type of
defect can they discover during component testing?
Options:
1. The processor of the product cannot resolve user input
2. A logic defect in the user-level management system
3. The product is incompatible with Microsoft Windows Vista
4. The target audience users find the graphical user interface confusing
Answer
Option 1: Incorrect. The processor receives user input from another component, the user interface.
You can verify whether it can interact correctly with the user interface during integration testing.
Option 2: Correct. You use component testing to detect defects in a particular component, such as
the component that manages user levels.
Option 3: Incorrect. You verify the compatibility of a product with an operating system during
system testing. You can make such verifications by simulating the environment in which the product
will run.
Option 4: Incorrect. The discovery that the target market users find the graphical user interface
confusing will typically arise at the acceptance testing level, in particular, during beta testing.
Correct answer(s):
2. A logic defect in the user-level management system
Question
You are conducting system testing, and have simulated the environment in which the intended users
will run the product. Which types of defects are most likely to be exposed during system testing?
Options:
1. Too few of the intended users are able to reach level four of the game
2. The output of the user interface is corrupted after it's transferred for processing
1332

3. Sessions become slow for users at the third and fourth levels of a gaming session
4. The product is not compatible with computers that have less than 256 MB of memory
Answer
Option 1: Incorrect. The ability of the user population to master the product as expected is tested
during acceptance testing, not system testing.
Option 2: Incorrect. The user-interface is one of the components of the product, and its output is
corrupted while it is interacting with another component. You test the interactions between
components during integration testing.
Option 3: Correct. A nonfunctional requirement of any software product is that it responds to users
within a reasonable period. You can verify such requirements only after you integrate the product
and conduct performance testing.
Option 4: Correct. To verify the compatibility of a product with a given system, you need to run it on
that system. You simulate the environment in which a product will actually run during system testing.
So you can use this type of testing to verify the compatibility of the product.
Correct answer(s):
3. Sessions become slow for users at the third and fourth levels of a gaming session
4. The product is not compatible with computers that have less than 256 MB of memory













1333

Functional and Non-functional Software Testing
Learning Objectives
After completing this topic, you should be able to
recognize how functional software testing works
recognize how non-functional software testing works
1. Functional software testing
Testing happens at all phases of the product development life cycle. At every stage of
development, testing reveals defects that need to be fixed to assure quality. When testing a
software product at various levels, merely testing the functionality of each component or system
is not always sufficient.
You define test objectives for the various levels of development. To meet the overall test
objectives, you focus your testing on specific objectives at each level. To meet these specific
objectives, you use different test types.

These test types are typically a set of test activities, focused on a specific test objective, used to
test different components and systems. Different tests enable you to meet each specific
objective in different test phases, whether youre testing a function or testing modifications made
to the software.
There are different test types:
functional testing tests the functionality of a selected component
non-functional testing tests the behavioral, or the quantified characteristics, of the systems and software
structural testing tests the structural aspects of the component or system
changed-based testing including regression and confirmation testing that involve the re-run of tests to
ensure that the software is working correctly following changes
Functional testing is the process of testing a software product to determine its specified behavior
or functionality. As a functionality tester, you focus on the software's capability to provide
functions that fulfill stated and implied needs under specified conditions. In other words, you test
the function that the component or system needs to perform.
For example, consider software that allows people to book tickets online. To test the
functionality of this software, you would have to test whether the software accepts information
requests from travelers, checks for ticket availability and reports back, accepts applications and
returns tickets, and finally records the transactions in a database.
1334

Based on the International Organization for Standardization (ISO) quality standard 9216 that
regulates testing, functional testing is performed for various quality characteristics, such as
suitability
Testing suitability involves testing the capability of the software product to provide an appropriate
set of functions for specified tasks and user objectives. Suitability testing determines if the
product performs as expected for its intended use. For example, a spreadsheet should provide
you with an appropriate set of functions to perform financial, logical, mathematical, and
trigonometrical calculations.
interoperability
Testing interoperability involves evaluating the capability of the system to interact with other
specified components or systems.
accuracy
Testing accuracy involves ensuring that faulty products do not leave the production line and
cause errors during beta testing.

For example, if a word count feature in a word processing application does not function properly,
accuracy testing would detect this defect before a beta user discovers it.
Based on the standard, functional testing is also performed for various quality characteristics,
such as
security
Testing security involves investigating the functions relating to prevention of unauthorized access
to software and data, either intentionally or unintentionally. It also involves detection of malicious
outside threats, such as viruses.

For example, if readers can leave comments on your corporate blog, you will have to ensure that
user input validation is performed in the comments area. There is the possibility of a malevolent
user typing in malicious code, which gets executed automatically. Security testing would be able
to capture this loophole in the code.
compliance
When you test compliance, you determine whether the system adheres to certain specified
criteria, such as standards, conventions, regulations, or laws.

For example, suppose that your organization's information security policy requires that employee
system CD drives be disabled at all times. Code that is run every morning during system boot to
verify that the drive is disabled would be checked during compliance testing.
To perform functional testing, you derive your test conditions and cases from the requirements
specification, functional specification, or from use cases. You design a model, such as a state
transition model, a process model, or a plain language specification, as part of the test design.
1335

In all cases, the functional tests performed across all test levels would look at specific functions
in a system, including undocumented or implicit functions.
Because only the program specification is considered not the design or implementation of the
program this type of testing is also called specifications-based or black box testing.
Note
Black box testing can be either functional testing or non-functional testing and is performed without
reference to the internal structure of the product.
Two approaches to functional testing are:
requirements-based testing
Requirements-based testing designs tests based on a functional requirements specification for
the system. To decide the items to test, you can use the table of contents of the requirements
specification and prioritize the requirements based on the risk criteria. This ensures that the most
important tests are included in the testing effort.

For example, your company is revamping its HTML-based corporate web site. Your job is to test if
the ASP.NET-based web applications display properly in a web browser that supports HTML. You
refer to the requirements specification to create the test cases.
business-process-based testing
Use cases provide a basis for test cases from a business perspective because they often use
business processes as a starting point. Business-process-based testing uses knowledge of the
business processes to describe the scenarios involved in the day-to-day business use of
systems.

For example, your company's travel reimbursement system may have a policy that determines
reimbursements for employees traveling on business.
Question
Match each characteristic against its function.
Options:
A. Accuracy
B. Suitability
C. Interoperability
D. Security
Targets:
1336

1. Tests if the product performs according to specifications
2. Tests if the product is shielded from threats, such as viruses and other malicious software.
3. Tests to ensure that the faulty products are not passed to users
4. Tests if the product interacts correctly with other components or systems
Answer
Suitability testing verifies that the product performs according to specifications and as expected for
its intended use.
Security testing investigates the functions relating to detection of threats, such as viruses, from
malicious outsiders.
Accuracy testing ensures that faulty products do not leave the production line and cause errors
during beta testing.
Tests if the product correctly interacts with other components and systems as specified.
Correct answer(s):
Target 1 = Option B
Target 2 = Option D
Target 3 = Option A
Target 4 = Option C
Question
You are the tester for a web-based banking application where financial data is requested from the
user and stored in a confidential database. How would you perform functional testing for this
application?
Options:
1. Verify that unauthorized access to data is prevented
2. Test the quantified characteristics of the systems and software
3. Ensure that any shortfalls in the required level of precision of the applications results and effects are
detected
4. Conduct tests that verify the impact of a modified operational system on the existing environment
Answer
1337

Option 1: Correct. Because customer financial information is confidential, you perform security
testing to ensure its safety.
Option 2: Incorrect. You test the quantified characteristics of the systems and software in non-
functional testing.
Option 3: Correct. You perform accuracy testing on the application to ensure that an application
that does not meet required levels of precision is not released, particularly because it deals with
sensitive financial data.
Option 4: Incorrect. You test modifications and verify the impact of these modifications on the
existing environment in maintenance testing.
Correct answer(s):
1. Verify that unauthorized access to data is prevented
3. Ensure that any shortfalls in the required level of precision of the applications results and effects
are detected
2. Non-functional software testing
As well as testing the functional aspects of a software system, you must also test the non-
functional aspects of the system. Suppose you are testing the operation of a mathematics
package. You finish testing the functional aspects, such as fomulae and functions, and then
move on to how well the package performs. Here, you would test how the system manages
performance, load, stress, portability, and so on. This type of testing, where you measure how
well or fast a system works, is called non-functional testing.
In non-functional testing, which can be performed at all test levels, the behavioral characteristics
of systems and software are tested and quantified on a varying scale.
For example, you are testing a gaming application that will be hosted online and played by
gamers simultaneously across the world. During functional testing, you determine what the
application does, test its suitability for the web, verify compliance with online gaming standards,
and so on. In contrast, when doing non-functional testing, you will test how the application
performs, the load that it can handle, the speed with which it performs, and other aspects.
Non-functional testing comprises various types of testing:
1. performance testing tests the degree to which a system fulfills its specified functions within
given processing time and throughput rate constraints
2. load testing measures the behavior of a system with increasing load
3. stress testing evaluates a system at and beyond the boundaries of its specified requirements
1338

4. usability testing tests how easily a user can perform a specific task
5. maintainability testing tests how easily a product can be modified in the future
6. reliability testing tests how reliably a product performs over a given period of time
7. portability testing tests how easily a system can be transferred from one platform to another
According to ISO 9216 there are five characteristics covered by non-functional testing. These
are further divided into sub-characteristics.

The first two characteristics are
reliability
A software product is reliable when it performs its required functions under stated conditions.
Reliability testing tests if the product meets the standards of reliability. Reliability testing can be
defined further into maturity, fault-tolerance, recoverability, and compliance. For example, a
server could be tested for robustness by increasing the number of users that access the server
until it crashes.
usability
A software product is said to be usable if the user easily understands and likes the interface, likes
the product itself, and finds it easy to operate. Usability testing tests the extent to which the
software product meets these requirements under the specified conditions. Usability testing is
divided into understandability, learnability, operability, attractiveness and compliance. For
example, a graphical user interface could be tested to determine ease of use and navigation.
The other three characteristics are
efficiency
Efficiency is the capability of the software product to provide appropriate performance, relative to
the amount of resources used under stated conditions. Efficiency testing checks if the software is
efficient. Efficiency testing is divided into performance, resource utilization, and compliance. For
example, a web page could be tested to check if it loads quickly or not.
maintainability
The ease with which a product can be modified to correct defects, meet new requirements, make
future maintenance easier, or be adapted to a changed environment is called
maintainability. Maintainability testing is divided into analyzability, changeability, stability,
testability, and compliance.
portability
When a software product can be transferred easily from one hardware or software environment to
another, it is said to be portable. Portability testing is the process of testing to determine the
portability of a software product. Portability testing is divided into adaptability, installability, co-
1339

existence, replaceability, and compliance. For example, checking the software code to verify if the
application has been created to be platform independent or not.
Question
Match the testing types with their explanations.
Options:
A. Reliability testing
B. Usability testing
C. Efficiency testing
D. Maintainability testing
E. Portability testing
Targets:
1. Test the ease with which a product can be modified to meet requirements
2. Test how easily a user understands an application's interface
3. Test how easily a software product can be transferred across platforms
4. Test the product's ability to perform required functions under stated conditions for a specified period of
time
5. Test capability of the software to perform as specified
Answer
Maintainability testing tests the ease with which product modification can be undertaken to correct
defects, meet new requirements, or adapt to changes.
Usability testing tests how comfortable a user is with an interface and how easy he finds it to
operate when used under specified conditions.
Portability testing is the process of testing to determine the portability of a software product.
Reliability testing is the process of testing if the product meets the standards of reliability.
Efficiency testing checks the capability of the software product to provide appropriate performance,
relative to the amount of resources used under stated conditions.
Correct answer(s):
Target 1 = Option D
Target 2 = Option B
1340

Target 3 = Option E
Target 4 = Option A
Target 5 = Option C
Summary
Test types are activities that help you in testing systems of components to check if they meet
specific test objectives. There are a number of test types.

Functional testing checks if the software product under test meets all its functional
specifications. It also checks if the software product has the characteristics of suitability,
interoperability, security, accuracy, and compliance.

Non-functional testing checks certain quality characteristics of the software product. This
includes checking for performance, reliability, portability, usability, and maintainability.

















1341

Structural and Changed-based Software Testing
Learning Objectives
After completing this topic, you should be able to
recognize how structural software testing works
recognize how change-based software testing works
1. Structural software testing
Every time a system or a component is developed, you test it to verify that the system not only
works as specified but also as efficiently as required. To aid you in this testing, you are provided
with test objectives and test types.

The test objectives will define the test types which are used, such as functional testing or black-
box testing, non-functional testing, structural testing, and regression testing. Each test type has
specific types of test objectives pertinent to that type of test.
You carry out functional testing to check that the application does what the functional
specification requires. Since functional testing is not directly concerned with the inner workings
of the software, and only on what it actually does, it is sometimes referred to as black-box
testing.
Structural testing on the other hand is concerned with the internal architecture and workings of
the software, and for that reason is often referred to as white-box, or glass-box, testing.
Structural tests can be carried out at all test levels. However, they are mostly performed at the
lower test levels such as at the component and the component integration level.

At the component level, the tests are based on the structural aspects of the system such as
code in a program. And at the component integration level, the tests may be based on the
architecture of the system, such as a calling hierarchy.
Structural tests measure the amount of testing done by checking the coverage of a set of
structural elements or coverage items.
In structural testing, in addition to testing the coverage of a set of structural elements or
coverage items, the internal system design is considered and the tests are based on the logic of
the application's code. But in functional testing, the tests are based on the requirements and the
functionality.
For instance, when testing a data object, functional testing tests the working of the data object.
And structural testing verifies if the data object has the specified data fields with correct data
types.

1342

So, in structural testing, you are required to have knowledge of the internal working of software
and the code. Regardless of the specifications, you are required to test each command in the
code.
To ensure that you are testing your program adequately, you need to execute all the elements
such as statements, branches, conditions, and decisions in the code one by one.
The coverage achieved in structural testing is expressed as a percentage of the items being
covered. There are a variety of tools and methods available to support code coverage
measurement at component and integration testing levels. These tools measure the percentage
of executable elements.
If the coverage is not 100%, then more tests may be designed to test those items that were
missed, and thereby, increase the coverage.
You use various structure-based techniques to implement structural testing. These techniques
are also called white-box techniques. They are based on an analysis of the structure of a
component or a system.

Two examples of code-related structural testing techniques for code coverage at the component
level include statement testing and decision testing.
White-box techniques can also be used at various levels, such as
component
At the component level, the structure is that of the code itself, such as in the statements or
decisions.
integration
The structure at the integration level could be a call tree where modules call other modules.
system
At the system level, the structure may be a menu structure, a business process or a web page
structure.
Question
Which of these are accurate statements when applied to structural testing?
Options:
1. Is also referred to as white-box testing
2. Is also referred to as black-box testing
3. Is used to measure the coverage of functional requirements that have been satisfied
4. Is used to measure the percentage of code elements that have been executed.
1343

Answer
Option 1: Correct. Because structural testing is concerned with the internal structure of a
component or system, it is also known as white-box, or glass-box, testing.
Option 2: Incorrect. Black box testing is so called because it is not concerned with the inner
workings of a component or system, unlike structural testing.
Option 3: Incorrect. Functional testing, not structural testing, is primarily used to test whether
functional requirements have been met.
Option 4: Correct. Structural testing incorporates code coverage measurement to determine the
percentage of executable elements that are activated during testing.
Correct answer(s):
1. Is also referred to as white-box testing
4. Is used to measure the percentage of code elements that have been executed.
Question
You are testing an application. Which of these steps will you do while performing structural testing
on the application?
Options:
1. Measure the amount of code used in a system
2. Test all the elements in the code
3. Use structure-based techniques to test components
4. Complement functional tests by measuring the number of tests performed
5. Check how much of the item being tested is covered by the test
Answer
Option 1: Incorrect. While performing structural testing, you measure the amount of a system or
component that is covered by the test.
Option 2: Correct. In structural testing, you execute all the elements in the code such as the
statements, branches, conditions and decisions in the code.
Option 3: Correct. At component level testing, you use structure-based techniques such as
statement testing and decision testing.
1344

Option 4: Incorrect. You would complement functional tests by measuring the extent of the item that
has been tested, not the number of tests performed.
Option 5: Correct. To measure the thoroughness of the tests performed earlier, your structural tests
check the coverage achieved by those tests.
Correct answer(s):
2. Test all the elements in the code
3. Use structure-based techniques to test components
5. Check how much of the item being tested is covered by the test
2. Changed-based software testing
Testing is carried out at every stage of the product development to discover the defects, if any,
and fix them. This ensures that the product is defect free and works as specified.

Every time you find a defect and fix or debug it, you need to retest the debugged component by
re-executing the test cases that failed the last time. The product is considered free of known
defects only when it passes the retest.

This type of retesting is called confirmation testing.
Confirmation testing by itself does not guarantee a quality product. Even after confirmation
testing, because of fixing a bug, or any other modification such as the addition of a new feature,
a debugged or new version of the software can lose its original functionality or a part of it. When
this happens, the new version is said to have regressed with respect to former versions, and is
defective again.
A systems or component that has had changes carried out needs to be tested again to ensure
that none of its functionality was modified unintentionally. A set of tests are designed to
demonstrate that despite the changes that were made, the system works as expected. These
tests are called regression tests and the testing is called regression testing.
Like confirmation testing, regression testing involves executing test cases that were executed
before. However, confirmation testing is performed on the items that failed the tests the last time
they were executed, to confirm that the developers have fixed the defects. And regression
testing is performed to ensure that previously working parts of the system have not had faults
introduced as a result of these fixes.
There are three types of regression:
local regression a change or a bug fix in the existing software creates a new bug
exposed regression a change or a bug fix in the existing software reveals an existing bug
1345

remote regression any change or a bug fix in one area triggers an error in another area of the system
While performing regression testing, most organizations use a regression test suite, which is a
set of test cases used for regression testing at each level. And where the postcondition of one
test is used as a precondition for the next one. Also because the same test cases are used
every time, the test cases can be used for test automation. The test cases perform an overall
testing of each of the most important functions in a system. They are executed every time
software is updated or the environment is changed.
It is important to maintain the test suite so it stays updated with the latest software version. So
every time new functionality is added to software, new regression tests should also be added
and the older and irrelevant tests removed.

In a situation where the regression test suite becomes very large, and the tests need to be
executed, a subset of the test cases can be chosen. This is because it is difficult to execute all
the tests manually or simultaneously. In such cases, or in cases when the test cases have not
captured a defect in a long time, repetitive tests can be combined or, if needed, even eliminated,
but with care.
Note
Unlike the other types of testing, regression testing can be carried out only at the very end, after the
last code that was changed is tested and quality passed.
It is also important not to omit regression testing because the risk involved is huge. Consider a
case where you have added a new feature to an existing product.

While functional tests help you verify the functionality of the features, non-functional tests test
the behavioral characteristics of software, which are quantifiable on a varying scale. And
structural tests measure the amount of the developed component that has been exercised by
testing.

After running the new code through all these tests, you find it passes the tests and is free of
known defects. You release your product to the market confidently. And then suddenly find out
that faults have surfaced in parts of the system that were previously working OK.
There are a number of strategies available to capture defects in the regressed software to avoid
such situations. The main strategies are
repeating all the tests
If you have sufficient time and resources to cover critical risks, repeat all your tests after the last
change to the code. You should be able to find all the important regression bugs. However, if you
are repeating these tests for large, complex systems, you can use automation.
repeating some of the tests
1346

It is not always possible to repeat all the tests. Executing all the test cases for a large and
complex software product may require too much time and too many resources to be practical
every time the product is updated. Even if you consider automation, you may find that full
automation is impossible or impractical. In such cases, you can repeat some tests only.
Other strategies are
using cross-functional tests
You use cross-functional tests to capture accidental regressions. Otherwise, because you are not
going to be running all the tests again, you are likely to miss regressions that may occur in
unanticipated areas.
releasing the product in various phases
You can also choose to release your updates on the product in phases. You will need to phase
your release so that you have more time to ensure that your product is thoroughly tested.
having other users testing the product (Beta testing)
When you send your product for a Beta test, it will be your users who will be testing your product
for you before the commercial release.

If you find yourself bogged down with schedule pressure, instead of releasing poorly tested
emergency patches, it will be a good idea to release smaller but well tested patches to only those
users who need them. You can then roll the final and completed patches into maintenance
releases instead. Doing this will ensure that the regression risk increase for your users is only
short term.
If you are using the strategy of repeating tests, you will need to decide which of the tests to
repeat. To decide which tests to repeat, you can use techniques, such as
traceability
You use the traceability technique when you want to check whether any requirement, design
element, or quality risk is affected by the software modification. You would have a set of tests
related to the behavioral descriptions of the system. You trace back to these tests and re-execute
them.
change analysis
When you want to analyze how changes in one part could trigger off changes in other portions of
the system, you use the change analysis technique. So you look at the structural descriptions to
find the answers. To be able to do this, you need to have an indepth understanding of the code
and the system's design.
quality risk analysis
If you want to decide what to retest based on business risks, you should use the quality analysis
technique. Even though defects are unlikely here, you will have knowledge of the areas that are
1347

prone to high business risk. Using traceability and change analysis techniques will only help you
select tests based on technical risks.
Question
Match the four test types with their definitions.
Options:
A. Functional testing
B. Non-functional testing
C. Structural testing
D. Regression testing
Targets:
1. Is based on an analysis of the internal structure of a component or system
2. Tests the working of a component or system and how it interoperates with other specific systems
3. Confirms that the system works as expected even after changes
4. Tests the behavioral aspects of the system
Answer
Structural tests measure the amount of a component or system that has been exercised by testing
against the total amount possible, which is known by reference to the internal structure.
When you perform functional testing, you focus on the testing of a function that the component or
system needs to perform.
When you perform regression testing, you create a set of tests that demonstrate that the system
works as expected despite the modifications made.
When you perform non-functional testing, you test the characteristics of systems and software that
can be quantified on a varying scale.
Correct answer(s):
Target 1 = Option C
Target 2 = Option A
Target 3 = Option D
Target 4 = Option B
1348

Question
You are testing courses for an online education provider who has converted all Director-based
courses to Flash. You do not have the time to repeat all the tests. How would you perform your
regression tests?
Options:
1. Repeat all the tests nevertheless
2. Repeat some tests only
3. Automate all the tests
4. Use techniques such as traceability, change analysis, or quality risk analysis
Answer
Option 1: Incorrect. Repeating all the tests is not only impractical, it is impossible considering that
you do not have the time to repeat all of them.
Option 2: Correct. Even if the best thing would be to run all the tests again, when you do not have
the time for doing it, you repeat only some of the tests.
Option 3: Incorrect. Automating the tests is not possible without a test suite.
Option 4: Correct. When you've decided to repeat some tests only, you can use different
techniques to decide which tests to repeat.
Correct answer(s):
2. Repeat some tests only
4. Use techniques such as traceability, change analysis, or quality risk analysis
Summary
Structural tests are based on an analysis of the internal structure of a component or system, and
measure the amount of structural elements or coverage items that have been exercised by
testing.

The structural aspects could be the code in an application or the logic behind a decision. While
these tests can be carried out at all levels, they are mostly performed at the component and
integration levels.

Change-based testing is concerned with testing that is carried out on foot of changes made to a
component or system. Confirmation testing is performed on items that failed the tests the last
time they were executed, to confirm that the developers have fixed the defects. And regression
1349

testing is performed to ensure that previously working parts of the system have not had faults
introduced as a result of these fixes.



























1350

Maintenance Software Testing
Learning Objective
After completing this topic, you should be able to
recognize how maintenance software testing works
1. Maintenance software testing
To ensure a product is free of known, unacceptable defects, and meets user requirements, you
need to perform testing at every stage in the product development life cycle. You have to carry
out functional and non-functional testing in the initial stages of the development and then follow
it up with structural, confirmation, and regression testing in the later stages.
After the product is deployed and in use for a number of years, it may require maintenance work
to be carried out on its components. This work may be to correct defects, to improve
performance, or to adapt the product to a modified environment. To confirm that the modified
product is once again free of known defects, you need to retest the modified components. This
is termed maintenance.
And this type of retesting when you test a system, which is in operation in a live environment, is
called maintenance testing. Maintenance testing not only tests the changes to the operational
system, but also the impact of this modified system on the existing environment.
The main reasons for using maintenance testing include
modifications
Modifications refer to any enhancements and emergency corrections made to an operational
system. They also include environment changes such as operating system or database upgrades
and patches for rectifying any vulnerabilities. Maintenance testing for modifications involves
verifying that these changes do not adversely affect the system.

For example, your organization has upgraded its database and installed a patch to a newly
discovered operating system vulnerability. You have to ensure that the data is not lost and that
these changes do not affect any other functionality in the system.
migrations
Migrations refer to a transfer of a system from one platform to another. Maintenance testing for
migrations involve operational testing of the new environment and the modified software. This
operational testing is conducted to evaluate the working of the migrated system or component in
its new operational environment, which typically consists of software installed at the users site.

For example, your organization is migrating to a new environment. After migration, the modified
1351

software may not work as required. You have to ensure that the new environment and all
software specially modified for it, work fine.
retirement of the system
Maintenance testing for the retirement of a system refers to testing of data migration. Or, if data is
to be retained for long periods, archiving is considered.

For example, your organization is retiring a server and replacing it with another one. All the data
stored in the old server has been transferred to the new server. Some of the tables were merged
in the process. You have to check that all the data was transferred accurately and into the
specified rows and columns of the new tables.
Of the main reasons for maintenance testing, modifications are the ones most frequently
occurring in organizations, and therefore very important. From the view point of testing,
modifications can be classified into
Planned modifications
Planned modifications account for around 90% of the maintenance work. They are structured
modifications and are decided well in advance.

Planned modifications include three types of modifications. Perfective modifications refer to
changes such as including additional features or enhancing performance of the system. Adaptive
modifications refer to changes such as the product being retired or migrated to a new platform or
new environment, new software, or new legislation. Corrective planned modifications refer to
changes such as deferred defects being finally corrected.
Unplanned modifications
Unplanned modifications occur when defects arise suddenly and the consequent malfunctions
require an immediate solution. For example, a server being patched when a security vulnerability
is discovered.

By carrying out a risk analysis on the operation system, you can be prepared to minimize the
impact of most unplanned modifications by, for example, having those tests that will most likely
be required already designed and ready.
During maintenance testing, two fundamental tests are carried out to ensure the quality of the
product:
confirmation tests to verify that changed software is functioning correctly after the changes have been
carried out
regression tests to check that unchanged software is continuing to work as expected following changes
being carried out on different parts of the system
Ideally, maintenance testing should test all the changes made to the system and the working of
the entire system itself. However, this may not always be cost effective or even possible. So to
1352

reduce the amount of regression testing, you should always first determine the parts of the
system that could be affected because of the maintenance work. Analyzing this impact of the
changes on the system is called impact analysis.
Maintenance testing often makes use of original test specifications with some updates applied.
An impact analysis helps in assessing the amount of updating required to the original test
specifications.

However, it may be difficult to conduct an impact analysis for a system which has already been
released. This is especially the case when a product's specifications are out of date, or
unavailable, and/or the original development team has moved on to other projects, or is no
longer with the company.
Impact analysis enables you to focus your regression test activities where they are most
needed. The process involves:
performing a risk analysis
The function of a risk analysis is to establish which of the areas of a software product constitute
the greatest risk to the operational services. When you do not have the time to repeat all the
tests, you perform a risk analysis to help you determine which areas to focus on during
regression testing.

For example, you perform a risk analysis on a software system that malfunctions to help you
decide where to focus first and what to do next and where.
checking for the product's original test specifications
If you have the test specifications from the original development process, you can reuse them for
the regression tests. You do this by adapting them for changes to the system. For instance, you
may just change the expected results for the original tests. This helps in reducing the overall
regression testing time.

This also helps you decide if you need to build additional tests for specific areas, which is often
the case for enhancement or extension projects or for updates for automated test sets that
support regression testing.
There are some specific differences between maintenance and regular testing for new products.
The differences are due to factors, such as
test types
Maintenance testing can include all test types that a new product undergoes, although often only
a subset of test types is required. For example, usability testing is unlikely to be required if
changes affecting the user experience have not been made. In most cases however, regressions
and confirmation tests form part of maintenance testing. Maintenance testing is also different from
maintainability testing, which is a test to determine how easily a system can be maintained. It also
1353

tests how quickly a system can be modified to meet new requirements, adapt to a changed
environment, or correct existing defects, and make future maintenance easier.
test triggers
While testing for new products is carried out as part of a project, maintenance testing is carried
out as an activity in a regular organization, only when there are modifications to the system, or
migration, or retirement activities.

This makes maintenance testing more prone to challenges such as resource availability,
flexibility, and competition from other activities when compared with regular new product testing.
issues faced
When systems are maintained for a while, a number of defects come to light. Specifications are
needed, but unlike in the testing for a new product, they are often unavailable.

Also whenever there is an extension or addition, specifications have to be created. For this you
can use documentation similar to the original product specifications. But this poses a problem too
as you may end up having many test cases executing the same scenario. And because no
traceability exists, if an incident is found, it is difficult to trace it back to the actual defect.
From a test management perspective, a somewhat different path is followed for maintenance
testing as against new product testing.

Suppose you are the test manager carrying out the fundamental test activities for a new product.
Upon the receipt of an application for a product test, you produce a test plan using the
application as a basis. Next, you receive test specifications and create test cases, which you
execute upon receiving the test object. Finally, upon completion of the testing, you preserve the
testware.
Suppose you are carrying out the fundamental test activities for a maintenance product instead.
You will follow the same process followed for a new product, except for when it comes to the
test specifications. This is because unlike in regular product testing, test specifications may not
be available. Especially in the case of enhancements or extensions.

So, if test specifications are not available, and if it is impossible to compile them again, you use
an alternative test basis such as a test oracle. The test oracle contains information that is used
to determine expected results to compare with the actual results of the tested product. The
oracle may be anything from the current system in use to a tester's knowledge, as long as it is
not code.

Finally, upon receipt of the test object, you execute the new and modified tests and perform the
regression tests, and then preserve the testware.
Question
Match the definitions of the terms used in maintenance testing to the corresponding term.
1354

Options:
A. Maintainability testing
B. Test oracle
C. Impact analysis
D. Operational environment
E. Maintenance testing
Targets:
1. Assessment of the how a component and its test and development documentation are affected by the
implementation of a specified change
2. Tests the changes to an operational system or impact of a changed environment to an operational
system
3. Helps determine the expected results for a software
4. Determines ease of maintenance of the system
5. Comprises hardware and software products installed at users' site
Answer
Impact analysis is the assessment of change to the layers of development and test documentation,
and to a component, in order to implement a given change to specified requirements.
Maintenance testing tests a system that has been modified but is in operation in a live environment.
It also tests the impact on a system of a change made to its operating environment.
A test oracle provides a source determining the expected results for a software being tested for
comparison with the actual results later.
Maintainability testing determines how quickly a system can be modified to meet new requirements,
adapt to a changed environment, or correct existing defects, and make future maintenance easier.
The software in the operational environment can include database management systems, operating
systems, or such other applications.
Correct answer(s):
Target 1 = Option C
Target 2 = Option E
Target 3 = Option B
Target 4 = Option A
Target 5 = Option D
1355

Summary
Maintenance testing is carried out to test the functioning of an operational system that has been
modified. It also tests the impact of a changed environment on a system. The reasons for
maintenance testing include maintenance fixes, modifications, or migrations.

Maintenance testing involves all test levels and can also involve any test type. Two of the more
common test types that occur during maintenance testing are confirmation and regression tests.
Confirmation tests verify the results of the fixed defect. And regression tests retest the entire
system again in case the fixes have affected any existing functionality.

To reduce time spent on regression testing, an impact analysis is carried out. The impact
analysis determines areas that specifically require regression testing after the maintenance
work.



















1356

Models of Software Testing and Development
Learning Objective
After completing this topic, you should be able to
evaluate test types
Exercise Overview
In this exercise, you are required to evaluate test types.
This involves the following task:
evaluating functional, non-functional, structural, change-based, and maintenance test types

You are a tester in a software development company. You are currently involved in two projects.
In the first project, you are testing a software order/cash management system. In the second
project, you are involved in testing an online audio tool.
Note
You are currently involved in two projects. In the first project, you are testing a software order/cash
management system.
Evaluating test types
You are testing a sales order management system for a fast food restaurant. You want to
evaluate which test types would be most effective at each stage of the product's life cycle.
Question
The product is at the initial phase of the development life cycle. And the code for the order/cash
management system has different elements such as the part that allows for ordering, the part that
calculates the prices/taxes, and the part that transmits the order to the cooks.

Each element of the code is developed separately and then sent for testing. The elements will all be
integrated at a later date. Which test types would be most effective at this stage of the product's life
cycle?
Options:
1. Functional testing
1357

2. Confirmation testing
3. Structural testing
4. Regression testing
Answer
Option 1: Correct. During the first phase of the product's development life cycle, you check if the
product meets the functional specifications.
Option 2: Incorrect. Confirmation testing is conducted on elements that have previously failed a
test, and have been submitted for a re-test.
Option 3: Correct. During the first phase, each developed component is subjected to an analysis of
the component's internal structure and its implemented behavior. And to do this, you perform
structural testing.
Option 4: Incorrect. Regression testing is performed at the end of the product's development life
cycle.
Correct answer(s):
1. Functional testing
3. Structural testing
Question
The elements of code are all now integrated and the complete product is now sent for testing. What
test type would be most effective at this stage of the product's life cycle?
Options:
1. Confirmation testing
2. Non-functional testing
3. Regression testing
4. Functional Testing
Answer
Option 1: Incorrect. Confirmation testing is carried out after the defects found in an earlier round of
testing are fixed. Confirmation testing is like a verification round of testing.
Option 2: Correct. As part of system testing you should test that the system has achieved an
acceptable level of quality.
1358

Option 3: Incorrect. Regression testing is performed after confirmation testing when the defects that
were found are fixed.
Option 4: Correct. Functional testing is conducted to ensure that the integrated system performs
according to specification.
Correct answer(s):
2. Non-functional testing
4. Functional Testing
Question
A number of defects were discovered during the non-functional testing. All these defects were
rectified. The product was also passed through a round of confirmation testing. However, there is a
slight possibility that the defect fixes altered the overall functionality of the software. What test type
would be most effective at this stage of the product's life cycle?
Options:
1. Functional testing
2. Maintenance testing
3. Regression testing
Answer
Option 1: Incorrect. Functional testing is performed in the initial stages of the product development
when you want to check the functionality of any product and verify how it interoperates with other
systems.
Option 2: Incorrect. Maintenance testing is performed only after the product is completed and
deployed to the customer.
Option 3: Correct. Regression testing is performed when as part of a process, you find or suspect
that because of the addition of a new feature, or fixing a bug, a new version of the software may
have lost some functionality that was previously present.
Correct answer(s):
3. Regression testing
Question
1359

After regression testing was performed, and the product cleared for delivery, the system was
released to the client. A couple of years later, an online ordering/delivery system was added. What
test type would be most effective at this stage of the product's life cycle?
Options:
1. Non-functional testing
2. Structural testing
3. Maintenance testing
Answer
Option 1: Incorrect. Although some non-functional testing may be involved, maintenance testing is
called for at this stage of the products life-cycle.
Option 2: Incorrect. Structural testing is performed during the various stages of the product's
development life cycle and not after the product deployment.
Option 3: Correct. Maintenance testing is performed when you want to check a system operating in
a live environment after post-delivery changes are made to it.
Correct answer(s):
4. Maintenance testing











1360

ENGLISH




| Print | Back | Close |



Business Grammar: Punctuation
SkillBriefs

End Punctuation Marks
-Explore the rules for using end punctuation.
Using the Comma Correctly
-Explore the correct use of commas.
Using Connectors and Separators
-Learn how to use semicolons, colons, and dashes correctly.
Using Other Punctuation Marks
-Explore apostrophes, parentheses, and quotation marks.









1361

SkillBrief
End Punctuation Marks
All sentences need to be ended with either a period, a question mark, or an exclamation point. These
punctuation marks indicate the end of a sentence, separate thoughts, and keep ideas moving cohesively
toward a conclusion. They help the reader move in the same direction toward that conclusion.
The period
The period also referred to as the full stop is one of the most commonly used punctuation marks in
the English language. Periods are used
to close declarative, imperative sentences, and indirect questions
in single-word abbreviations
after a number in a list or outline
in Internet addresses, and
to indicate an ellipsis, which is the omission of a word, phrase, line, paragraph, or more from a
quoted passage
The question mark
Questions come up every day in business. It's when you have to communicate questions in writing that
problems can arise. Question marks
are always used after direct questions
are not used after indirect questions, which report what someone has asked but not in the form of
the original question
are occasionally used to indicate surprise or skepticism
are not used when a request is politely disguised as a question, and
are never combined with other question marks, exclamation points, periods, or commas.
You can also use question marks in the following types of sentences:
statements Question marks can turn statements into questions. For example, the statement
"He finished the report yesterday" may be turned into a question that indicates surprise or doubt
"He finished the report yesterday?"
elliptical questions Elliptical questions are questions that refer back to other questions or
statements. Elliptical questions are incomplete in that they can't stand on their own but rely on
other parts of the statement for their meaning.
questions within a sentence Question marks are most commonly used at the end of
sentences, but they can also be used within a sentence. A question might end with a question
1362

mark, but the sentence as a whole ends with a period. For example, "The question, how can we
finish on schedule? was on everyone's mind."
questions in a series Each question in a series should be followed by a question mark.
questions in quotes You place a question mark inside quotes only when it's part of the quoted
matter. But the question mark follows quotes when the entire sentence is a question.
question marks within parentheses You can use question marks within parentheses to
indicate doubt about the correctness of a number, date, or other fact. But you should avoid using
a question mark within parentheses to express sarcasm or irony.
The exclamation point
An exclamation point marks an emphatic comment or indicates excitement. You can use it in two ways:
to show emphasis or strong feelings An exclamation point tells the reader that you are
emphasizing a statement or that you have strong feelings about what you are saying as in the
example "We need to succeed!" Interjections, or exclamations which are words, phrases, or
clauses that denote strong feeling often end in exclamation points. For example, "Wow! That
meeting was long."
with questions that functions as exclamations An exclamation point is also a valid ending
for a rhetorical question, or a question that is essentially an exclamation for example "How
could you do that!" Rhetorical questions don't require answers; they emphasize a point. For
example, "Can you believe that was the final result!"
A caveat is that you should use exclamation points sparingly. Otherwise, they won't be effective. If you
succeed in building the excitement into your sentences, you won't need an exclamation point to tell the
reader how to read them.
End punctuation marks indicate the end of sentences, and they separate thoughts. They also keep your
ideas moving cohesively toward a conclusion by helping the reader move mentally in the same direction
toward that conclusion. End punctuation marks are the period, question mark, and exclamation point. The
period's primary purpose is to end a sentence. Question marks are always used after direct questions,
and exclamation points suggest excitement or add emphasis to a sentence.








1363

Using the Comma Correctly
Commas are used more often than any other punctuation mark, so it's really worth your effort to learn
how to use them correctly. The placement of commas can change the entire meaning of a sentence.
Commas make your writing easier to understand and serve several major functions:
They make your writing easier to understand because they create boundaries between ideas,
which makes them more clear.
They indicate pauses or changes in mental direction, which makes it easier for readers to follow.
They demonstrate your professionalism by showing that you care about the details in your writing,
as well as the reader's comprehension.
Correct usage
Commas separate parts of a sentence in three ways:
commas separate the main elements of a sentence

o Most introductory clauses are separated from main clauses by commas. An introductory clause may be
a subordinate clause, a verbal phrase, or a prepositional phrase. A single word or a very short
introductory phrase doesn't usually require a comma, except to avoid misreading.
o Transitional expressions such as currently or in fact used at the start of a sentence are followed by
commas. And expressions such as fortunately and in other words, which provide comments,
explanations, or other supplementary information, are followed by commas as well.
o You also use a comma to separate main clauses connected by a coordinating conjunction.
they set off nonessential elements within a sentence

o These elements also referred to as nonrestrictive elements are not essential to the meaning of the
sentence. They also don't limit a word to a particular individual or group.
o However, restrictive or essential elements in a sentence aren't set off with commas. They limit the word
they refer to and cannot be omitted without leaving the meaning too general.
o Clauses and phrases that act as adjectives and adverbs may be either nonrestrictive or restrictive. But
only nonrestrictive ones are set off with commas. An appositive renames a noun just before it. Many of
these are nonrestrictive
they separate elements in a series

o You place commas between all items in a series that is, between three or more items of equal
importance. The basic rule is that commas separate each word or phrase listed consecutively in a
series.
1364

o You also use commas to separate two or more adjectives that equally describe or modify the same
word. If you have two or more adjectives before a noun and you could without affecting the meaning
connect those adjectives with and, you normally separate them by commas.
Incorrect usage
The comma is often used incorrectly or not used when it should be. Four rules may help keep you from
misusing commas:
don't separate a subject and its verb Never use a comma to separate the subject of a
sentence from the verb. This applies even when the verb and predicate come first.
don't separate a verb and it object or complement The object of a verb is the target of the
action indicated by the verb. For example, in the sentence "I hit the ball," ball is the object of the
verb hit. You shouldn't put a comma after the verb and before this object.
don't separate pairs joined by a coordinating conjunction When linking elements with a
coordinating conjunction, you don't use a comma except when the elements are main clauses. So
you shouldn't have a comma after wrote in the sentence "She wrote and took photographs for the
local paper." This sentence includes an example of a compound predicate or two verbs that
share the same subject.
don't use a comma after a conjunction Coordinating and subordinating conjunctions are not
followed by commas. For example, you don't put a comma after but in the sentence "She was
early, but she had to prepare the room for the meeting." And you wouldn't put a comma after
although in the sentence "Although the price has gone down, it's still not worth the money."
The main purpose of the comma is to separate thoughts in a sentence. The comma serves three other
common functions or uses in a sentence to separate the main elements of a sentence, to set off
nonessential elements within a sentence, and to separate elements in a series.

Using Connectors and Separators
You can use various punctuation marks to connect and separate elements within sentences. These
punctuation marks have similar functions, and it can sometimes be difficult to figure out which is most
appropriate to use.
Semicolons
Semicolons can join complementary main clauses that are not linked by a coordinating conjunction. They
can also connect ones that are related by a conjunctive or linking adverb or other transitional expression.
Semicolons are used to join main clauses in two situations:
they're not joined by a conjunction Semicolons join balanced sentences or clauses.
they're related by a conjunctive adverb Semicolons should be also used with two main clauses
that are linked by a conjunctive adverb, such as furthermore, in fact, or however, as well as by
1365

other transitional expressions, including words like currently, finally, or as a result. They can also
replace these words. The position of the semicolon between main clauses doesn't change.
However, the conjunctive adverb or transitional expression can be placed in different places
within the clause.
Sometimes you can use a semicolon to separate main clauses that are joined by a conjunction. This is
the case if the clauses are complicated or contain internal punctuation, such as commas. Similarly, you
can use semicolons to separate items in a series if they're long or contain commas.
You shouldn't use a semicolon to separate subordinate clauses or phrases from main clauses. Doing so
will create a disjointed sentence. And you also shouldn't use a semicolon to introduce a series or an
explanation. Colons are used for this purpose.
Colons
You can use colons in several types of sentences:
an explanation for example, We made many mistakes: the underlying reason for all of them
was that we didn't think about the customer.
a series for example, The following issues are on the agenda for the meeting today: appraisals,
sick leave, and deadlines.
a quotation for example, The report starts out positively: "We can increase sales by 10% this
year."
a greeting for example, Dear Mr. Smith:
When a colon is used within a sentence, the first word following the colon is lowercased, except when it's
a proper noun. When a colon introduces two or more sentences, however, the first word following the
colon is capitalized. It's also capitalized if the colon introduces a quote, a speech in dialogue, or an
extract.
And you should use a colon only at the end of a main clause. For example, don't use it after a verb or a
preposition.
Dashes
A dash is used mainly to indicate sudden changes in tone or thought. It's also used to set off some
sentence elements. More specifically, dashes can set off the following:
digressions Dashes can mark a point in a sentence where someone deviates from the original
point. They may indicate an abrupt change in thought or content.
afterthoughts Dashes can also provide additional information.
concluding explanations A clause following a dash can provide a concluding explanation of
what's stated in the previous clause. Note that a dash sets off a concluding explanation more
informally and more abruptly than a colon does.
1366

nonessential elements Dashes are used to add additional descriptive phrases or clauses to a
sentence. They may be used in place of commas or parentheses to set off nonessential elements
in a sentence.
Dashes are especially useful when the descriptive content has internal punctuation. You should use a
pair of dashes when the content element interrupts a main clause. It's not a good idea to use too many
dashes in your writing it can lessen their effect and create a jumpy quality in your writing.
A dash isn't typically used with other punctuation marks. Sometimes a question mark or an exclamation
point may precede a dash but never a comma, a colon, or a semicolon, and rarely a period. In addition,
you usually include spaces before and after a dash. However, some prefer not to add a space on either
side. Either way is acceptable.
Commas, semicolons, colons, and dashes are punctuation marks that connect and separate words,
phrases, clauses, and sentences. They have similar yet different functions that can depend on the
meaning you want to convey and the type of sentence you write. Knowing when and when not to use
these punctuation marks will help you clarify what you want to communicate.
Using Other Punctuation Marks
You may consider the apostrophe, parentheses, brackets, and quotation marks to be unimportant
compared to the punctuation marks used most frequently, such as periods and commas. However, these
four marks have important functions.
The apostrophe
The apostrophe is used to mark the possessives of nouns and some pronouns in several instances:
noun doesn't end in an s If a noun is singular and does not end in s, the possessive is formed
by adding an apostrophe and an s. This also includes irregular plural nouns for example
media's and indefinite pronouns anyone's files.
noun does end in an s If a singular noun ends in s or the s sound, you form the possessive
based on how the word is pronounced. If you naturally say two s sounds, then use the
apostrophe s, as in James's. If you pronounce the word with only one s sound, just use the
apostrophe on its own, as in employees'.
pronounced ssyllable is added If a noun ends in s, and a pronounced syllable is added when
the noun is changed to the possessive form, then add an apostrophe s. For example, "The
witness's statement."
Letters and numbers can be replaced with apostrophes to create contractions or short forms of dates.
The apostrophe is inserted where the letters or numbers are left out. Contractions shorten words or
phrases to conserve space or to create a less formal tone in a document. And remember, because
contractions aren't abbreviations, they aren't followed by a period.
The following are all contractible elements:
1367

words By established convention, letters can be left out to shorten words international
becomes int'l, for example. These types of contractions are used in informal writing and may be
more common in formats that have very limited space such as in addresses. The dictionary lists
many common contractions, along with alternative spellings and, where appropriate, plurals.
phrases In conversational language, letters can also be left out to shorten certain phrases. For
example, you are becomes you're and I have becomes I've.
dates An apostrophe is also used to replace numbers in a date. For example, the '60s instead
of the 1960s. Remember that you don't use an apostrophe between the last number and the s.
plurals You can also use the apostrophe to form the plural with lowercase letters and
abbreviations with two or more interior periods or with both capital and lowercase letters as in
Ph.D.'s and x's and y's. Remember that you never use an apostrophe with an s to make a plural
noun from a singular noun.
Parentheses and brackets
Although very similar, parentheses and brackets have different purposes:
Parentheses are used to provide clarification of certain words that may appear to be vague or
unclear. Or you use them to provide additional explanations, facts, and examples that may be
helpful or interesting but aren't crucial to the meaning.
You can use parentheses for afterthoughts.
You use parentheses to add personal comments to your sentences.
Parentheses typically enclose material that is less closely related to the rest of the sentence than that set
off by dashes or commas. So the content within parentheses is emphasized less than if it were set off by
commas or dashes. And remember not to put a comma, semicolon, or period before a parenthetical
expression.
You use brackets in the following instances:
use of the word [sic] The word sic is Latin for in this manner. It's used in brackets to indicate
that an error in the quotation appeared in the original and was not made by you.
add clarifying material If you need to clarify the words of the writer you quote, you place your
additions in a pair of brackets.
indicate comments The term emphasis added is used within brackets after a quote to indicate
that you have emphasized a word or phrase within the original quote.
Finally, if you need to explain or comment on something within parentheses, then you use brackets.
Quotation marks
Generally, the double quotation mark is used to enclose a direct quotation, whether made by a person or
taken from a piece of literature.
1368

Double quotes are sometimes used to indicate a word is used in a special sense as in "intelligent"
robots. Writers sometimes put quotation marks around a word they're using with irony. This practice is
discouraged in business writing.
Quotation marks are also used around titles that are part of a published work. For example, the titles of
book chapters, short stories, magazine articles, essays, poems, songs, lectures, and conference themes
take quotation marks.
Single quotation marks are used inside a statement that's already enclosed by double quotation marks.
Specific rules apply when using other punctuation marks with quotation marks:
periods and commas Periods and commas always go inside the closing quotation mark.
semicolons and colons Semicolons and colons always go outside the closing quotation
marks.
question marks and exclamation points You should place question marks and exclamation
points inside quotation marks only if they belong to the quotation. When a question mark or
exclamation point applies only to the larger sentence, not to the quotation, place it outside the
quotation marks.
The minor punctuation marks that often confuse people are the apostrophe, parentheses and brackets,
and quotation marks. The apostrophe is used to mark the possessives of nouns and some pronouns.
Parentheses can be used to clarify, indicate afterthoughts, and add personal comments. Brackets are
used within quoted material. You use quotation marks to enclose a direct quotation.













1369

Business Grammar: Sentence Construction
SkillBriefs
Sentence Parts, Phrases, and Clauses
Explore the various parts of a sentence.
The Rules of Subject-Verb Agreement
Explore how to ensure the subject agrees with its verb.
Rules of Agreement for Pronouns and Antecedents
Discover agreement rules for gender, person, and number.
Sentence Fragments, Comma Splices, and Modifiers
Discover the most commonly made mistakes in sentences.
Sentence Parts, Phrases, and Clauses
All too often, badly structured sentences stand in the way of clear communication. Each sentence should
have a logical structure with a clearly defined subject, verb, and object. This ensures the reader can
easily identify who's responsible for an action you describe, what the action is, and who or what is the
recipient of this action.
A sentence is made up of two main parts:
a subject - The simple subject of a sentence is typically a noun or pronoun identifying the person
or thing responsible for the action described by the verb. The complete subject includes this noun
or pronoun, plus all the words that describe or modify it.
a predicate - The simple predicate of a sentence is the verb the word identifying the action
taken by the subject. The complete predicate includes the verb and any other words that describe
or modify it. The predicate provides information about the subject.
In some cases, a sentence doesn't identify a subject explicitly.
It's important to identify the subject and verb in a sentence so you can make sure they agree in number.
In most sentences, the subject comes before the verb. However, some sentences have an inverted
subject/verb order, in which the verb comes before the subject. Sometimes this can make it tricky to
identify the subject and predicate.
Inverted subject/verb order may be used in different types of constructions:
it's typically used in questions, and
it may be used with here or there at the start of a sentence
1370

Direct and indirect objects
A verb may be followed by an object. More specifically, a transitive verb is followed by an object. This
type of verb requires an object to complete its meaning. An object is a noun or pronoun that identifies who
or what is affected by the action of the verb.
Intransitive verbs, on the other hand, don't take objects.
Two types of objects can be used with transitive verbs:
Direct objects identify who or what receives the action of the verb.
Indirect objects identify to or for whom the action of the verb is performed.
A direct object answers the question what or whom about the verb. The answer will indicate what the
direct object of the sentence is, if one exists.
You can identify an indirect object by asking of the verb to whom? to what? for whom? or for what?
Indirect objects are usually placed right before the direct object. They can also be complex in other
words, made up of the simple indirect object and all the words describing it.
Sentences using intransitive verbs don't take any object.
Subject and object complements
A linking verb connects the subject to an equivalent word in the sentence. The most common linking
verbs are forms of the verb to be is, was, and are.
The word or phrase that follows a linking verb is known as a subject complement, because it provides
additional information about the subject. An object complement is similar to a subject complement, except
that it provides additional information about the direct object in a sentence.
Phrases and clauses
Well-crafted phrases and clauses help ideas and thoughts flow naturally from one to another. A phrase is
a group of related words that lacks either a subject or a verb, or both. It acts as a single part of speech.
There are three types of phrases:
A prepositional phrase begins with a preposition such as at, over, in, or along. The preposition
is followed by its object, usually a noun or pronoun, and its object's modifiers.
An appositive phrase provides additional information about a noun in a sentence. It follows
immediately after a noun or noun phrase in order to define or further identify it. Gerund phrases
and infinitive phrases can act as appositives.
1371

A verbal phrase includes a verbal, which is a verb form that does not serve as a verb in the
sentence, and any objects or modifiers.
There are three types of verbal phrases:
Participial phrases include either a past or a present participle and any objects or modifiers.
They always function as adjectives.
A gerund is a verb ending in ing that functions as a noun. So gerund phrases include the gerund
and any objects or modifiers. A gerund phrase can act like a participial phrase the difference is
that the gerund phrase functions as a noun and the participial phrase as an adjective.
Placing to in front of a verb creates an infinitive, which can function like a noun, adjective, or
adverb in a sentence.
Clauses are different from phrases in that clauses have a subject and a verb, whereas phrases lack either
a subject or a verb, or both. Clauses can be either independent or dependent.
An independent clause is also known as a main clause. It can stand alone as a full sentence.
And you can join independent clauses using coordinating conjunctions, such as and or but.
A dependent clause is also called a subordinate clause. It doesn't form a complete sentence but
depends on a main clause. Subordinating conjunctions, like because, although, and after, or
relative pronouns, such as who, which, or that, usually introduce dependent clauses.
Proper sentence construction is an integral part of any communication. Your business documents and
communications should contain sentences and text that are presented logically and clearly. To do this,
you should be aware of the different parts that make up sentences. Being able to identify and knowing
how to correctly use sentence subjects and predicates, direct and indirect objects, phrases and clauses,
and subject and object complements can improve the quality of your writing. This in turn will ensure that
your messages are conveyed as clearly as possible.
The Rules of Subject-Verb Agreement
You probably know that a basic principle for any sentence is that the subject and verb agree in certain
areas:
number In any sentence, the correct form of a verb depends on whether the subject is singular
or plural. And nouns that form irregular plurals such as child/children require a plural verb.
person A verb's person indicates whether the action or state is that of the person speaking in
other words, the first person, I or we ; the person spoken to that is, the second person, you ; or
the person or thing spoken of the third person, he, she, it, or they.
Remember, the verb to be is irregular. The present tense third person singular he, she, it takes the
verb is and the third person plural takes are. In the past tense, the singular verb is was and the plural is
were.
1372

So if a subject noun is plural, it will end in s, but the verb won't. On the other hand, if the subject noun is
singular, it will not end in s, but the verb will. The only exceptions are nouns that form irregular plurals,
such as woman/women these still require a plural verb.
Mistakes in subject-verb agreement can sometimes occur in longer sentences, when a subject and verb
are separated by other words. In these cases, it's important you identify the subject and verb correctly.
For example, in the sentence "The requirements stated in the catalog is unclear," the subject is
requirements not the catalog. This is a plural subject, so the plural verb are is required.
Determining subject-verb agreement can be tricky when the subjects of sentences fall in any of different
categories.
titles of books, names of companies, or other entities These are plural in form. When the
subject is the title of a book or the name of a company or entity, the verb should be singular even
if the title or the name is plural.
subjects joined by and If a compound subject connects two or more people, places, or things
using the word and, the verb must be plural. This is true whether one or all subjects are singular.
An exception is when the parts of a subject form a single idea or refer to a single person or thing.
Then they take a singular verb as in "Corned beef and cabbage is a favorite dish among Irish
Americans." In addition, when a compound subject is preceded by each or every, the verb is
usually singular. But a compound subject followed by each takes a plural verb.
parts of a subject linked by oror nor In instances where parts of a subject are joined by or or
nor, the verb in the sentence should agree with the subject closest to it. And when one part of the
subject is singular and the other plural, it's best to place the plural part closer to the verb.
collective nouns, some of which end in s Collective nouns identify groups of people,
animals, or things. Usually they are treated as single entities, so they agree with singular verbs.
However, if the focus is on members of a group acting separately as individuals, a collective noun
can sometimes take a plural verb. And sometimes collective nouns end in s and look like plurals.
measurements or figures ending in s Although measurements may identify multiple units,
they are considered singular and therefore take singular verbs.
indefinite pronouns An indefinite pronoun is one that doesn't refer to a specific person or
thing. When an indefinite pronoun is the subject of a verb, it's usually singular. However,
sometimes it can have a plural sense. And there are some indefinite pronouns that can take
either a singular or a plural verb for instance, all, any, most, some, and none depending on
the context. For example, if none is followed by a singular noun, you should treat it as a singular.
Then there are some that take only a plural verb, such as both, few, many, and several. Inverted
sentences occur when the verb comes before the subject. This is most common in questions and
in constructions beginning with there, here, or it and a form of the verb to be. It can also occur
with a compound subject. Moreover, in sentences starting with there, you may use is before a
compound subject when the first element in the subject is singular.
In any sentence, the subject and verb must agree in both number and person. Specific rules apply when
the subject is a book title or company name, a compound subject, or a collective noun. Rules also apply
when the subject is linked by "or" or "nor," is a measurement, or is an indefinite pronoun. Ensuring
subject-verb agreement can be tricky when sentences are inverted.
1373

Rules of Agreement for Pronouns and Antecedents
Pronouns can substitute for expressed nouns or pronouns, especially to avoid needless repetition. A
pronoun typically refers to an antecedent, which is an earlier noun, pronoun, phrase, or clause in the
same sentence. To ensure clarity in your sentences, you should make pronouns and their antecedents
agree in gender, person, and number.
Agreeing in gender
Depending on the antecedent, a pronoun can be any of the following:
masculine When referring to a noun that identifies a male, you use a masculine pronoun, such
as he, his, or him.
feminine When referring to a noun that identifies a female, you use a feminine pronoun, such
as she, her, or hers.
gender-neutral When referring to something that cannot be classed as male or female, you
typically use the gender-neutral pronoun it. Using the pronoun it doesn't always mean the noun
has no gender sometimes, the gender is unknown or unimportant. Common-gender is a term
sometimes applied to animate beings, the gender of which is indeterminable.
Traditionally, a generic he was used in cases where the gender was indeterminable or where you were
using an indefinite pronoun that included both masculine and feminine genders. In almost all instances,
the generic he is no longer acceptable.
You can avoid using the generic he in one of three ways:
include both masculine and feminine pronouns It's appropriate to specify both masculine
and feminine pronouns when an antecedent can refer to both genders. However, doing this often
can make sentences tedious. It's a good idea to limit your use of he or she to once in a sentence.
use a plural antecedent and pronoun Often you can convert a sentence into the plural form
without changing its intended meaning. You can then use a plural pronoun like their or they,
which isn't gender-specific.
avoid using a pronoun You can often rewrite a sentence so no pronouns are necessary. This
eliminates the problem of having to choose between gender-specific pronouns.
Agreeing in person
Pronouns and antecedents must also agree in person. Remember, the first person refers to the person
speaking I ; the second person to the person being spoken to you ; and the third person to the person
or thing spoken of he, she, or it. You decide which pronoun to use based on which person the
antecedent refers to and whether it's in plural or singular form.
1374

To make pronouns agree in person, avoid switching from one person to another in the same sentence.
You should keep the use of the personal pronouns consistent. For example, you shouldn't switch from the
third person to the second person.
When multiple antecedents differ in person and are connected by and, or, or nor, the pronoun must take
the person of only one of the antecedents. The first person is preferred to the second, and the second
person to the third. And if the pronoun refers to just one of the connected nouns or pronouns, it takes the
person of that noun.
Agreeing in number
Where the antecedent is singular, the pronoun must also be singular. Likewise, if the antecedent is plural,
the pronoun must be plural too.
It all seems relatively straightforward, but there are some cases where pronoun-antecedent agreement
can be less clear for example, with antecedents that are joined by and, those joined by or or nor, an
indefinite pronoun as antecedent, and collective noun antecedents.
Where antecedents are joined by and, you usually use a plural pronoun. However, an exception is when
the compound antecedent refers to a single entity. Another exception occurs when the compound
antecedent follows each or every. In this case, you use a singular pronoun, even if the antecedent refers
to a plural entity.
When parts of an antecedent are linked by or or nor, you use the pronoun that agrees with the closest
antecedent. And when two or more antecedents of different numbers are joined by or or nor, the
pronoun's number agrees with that of the closest antecedent. If you can, you should recast the sentence
so the plural antecedent comes last. This avoids an awkward construction.
Confusion may arise when antecedent nouns are singular, of different genders, or of indeterminable
gender. Agreement with the nearest antecedent may be misleading. You should recast the sentence in
order to eliminate the need for personal pronouns.
For indefinite pronouns as antecedents, you use a singular or plural pronoun depending on which
indefinite pronoun is used:
singular When each or anyone is the antecedent, the pronoun referring to it should be singular.
plural When both, few, many, or several are used as antecedents to other pronouns, you
always use a plural pronoun.
Some indefinite pronouns namely, all, any, more, most, and some may be singular or plural
depending on the word they refer to.
Collective noun antecedents like team, crowd, or family take singular pronouns when they're acting as
a unit. However, when the members of the group act separately, the pronoun is plural.
1375

Pronouns can substitute for expressed nouns or pronouns, especially to avoid needless repetition. A
pronoun typically refers to an antecedent, which is an earlier noun, pronoun, phrase, or clause in the
same sentence. To ensure clarity in your sentences, you should make pronouns and their antecedents
agree in gender, person, and number.

Sentence Fragments, Comma Splices, and Modifiers
Sentence fragments
A sentence fragment is an incomplete sentence that is formatted like a whole sentence with an initial
capital letter and end punctuation. You can identify sentence fragments because they're usually
incomplete for one of three reasons:
they lack a verb
they lack a subject, or
they contain subordinate clauses not attached to complete sentences
You should generally avoid sentence fragments. However, it's acceptable to use them in some cases:
as exclamations,
in questions and answers
as commands, or
as transitional phrases
When you identify a sentence fragment, you can revise it by turning it into a complete sentence or
combining it with the appropriate main clause. You could also revise a fragment by joining it to a previous
sentence or by attaching a subordinate clause to the main clause to form a complete sentence.
Comma splices and run-on sentences
Comma splices and run-on sentences can be serious mistakes because they usually force the reader to
reread to get the correct meaning.
A comma splice occurs when two or more independent clauses are joined by a comma. If you can read
the text on each side of the comma as a full sentence, a comma splice is present.
You can correct a comma splice using one of several methods:
join the independent clauses with a comma followed by a coordinating conjunction
join the independent clauses with a semicolon
make one clause subordinate, especially if one idea is more important than the other, or
1376

split the independent clauses into separate sentences, each ending with a period
Comma splices also occur when main clauses are separated by a comma that's followed by a linking
adverb. Examples of linking adverbs are however, consequently, and finally. And comma splices also
occur when main clauses are separated by transitional phrases, such as even so and in fact. Transitional
phrases, along with linking adverbs, describe how two clauses relate in meaning.
Run-on sentences are also called fused sentences. They occur when two or more independent clauses
are placed together, without any punctuation or coordinating conjunction to join them.
Like comma splices, run-on sentences can also be corrected by revising the punctuation or wording. To
correct run-on sentences, you can use one of these approaches:
add a comma and coordinating conjunction
add a semicolon
add a subordinating conjunction, or
make the clauses into separate sentences
Misplaced and dangling modifiers
Knowing where to place modifying words, phrases, or clauses is important because readers rely on the
arrangement of words to tell them how those words are related. If modifiers are not connected to the
words they modify, they can be awkward, confusing, and even sometimes funny.
There are two common errors made with modifying words:
a dangling modifier, which is a modifier that doesn't logically describe anything in a sentence,
and
a misplaced modifier, which is a word or phrase that's placed too far from the noun or pronoun
it's meant to modify with the result that it modifies a different noun or pronoun instead
It's especially common for writers to misplace limiting modifiers, like just, exactly, only, and simply. To
avoid ambiguity, you must always place a limiting modifier immediately before the word or phrase you
want it to modify.
Several types of phrases and clauses may be used incorrectly in sentences, resulting in dangling
modifiers. They can occur at the beginning or end of sentences. These include the following:
infinitive phrases These phrases should be followed by a noun or pronoun identifying who
determines the causes. Remember, dangling modifiers are particularly likely when the verb in the
main clause is in the passive voice.
prepositional phrases These phrases should be followed by a noun or pronoun identifying
who studied the report.
1377

elliptical clauses An example of a sentence in which an elliptical clause is a dangling modifier
is "When inspired, our research shows that writers are likely to beat their deadlines." The elliptical
clause "when inspired" is meant to refer to writers, but instead it refers to "our research." The
revised sentence is "When writers are inspired, our research shows that they are likely to beat
their deadlines."
To correct a sentence that contains a dangling modifier, you can change the main clause so it clearly
identifies the subject you mean to modify. Alternatively, you can rewrite a dangling modifier as a complete
clause with its own subject and verb.
You should avoid using sentence fragments, which are incomplete sentences. It's also important to use
the correct punctuation or conjunctions to join independent clauses in sentences. Failing to do this results
in one of two types of errors comma splices or run-on sentences. In addition, using modifying phrases
or clauses incorrectly can result in either misplaced or dangling modifiers. In either case, it's important to
revise sentences to make it clear what the phrases or clauses are meant to modify.



















1378

Business Grammar: Common Usage Errors
SkillBriefs
Recognizing Commonly Confused Word Pairs
Explore the difference between commonly confused word pairs.
Using Prepositions Idiomatically
Understand the idiomatic use of prepositions.
Recognizing Commonly Misused Verbs and Other Words
Discover the correct use of certain verbs.
Recognizing Commonly Confused Word Pairs
English can be a confusing language. When you're not sure of a word's meaning or the difference
between two words you should look it up in a dictionary.
Commonly confused words can be divided into two categories:
words that sound the same or similar When you hear someone use a word that sounds
identical to another word, you know which word the speaker refers to because you contextualize
it.
words with similar or related meanings People often confuse words that sound different yet
have similar or related meanings. But in a technical or economic report, for instance, those
differences in meaning can have negative implications if you don't use them properly.
Similar sounding words
The pronouns you, it, who, and they have forms that can be easily confused:
you You are is contracted to you're, and the possessive form is your or yours.
it It is and sometimes it has is contracted to it's. The possessive form is its.
who Who is or who has is contracted to who's and the possessive is whose.
they They are is contracted to they're. The possessive form is their.
English has many word pairs that often create problems for writers and readers alike. Some examples of
words that commonly get mixed up include the following:
accept and except Accept means to receive something favorably. Except is most commonly
used to mean other than or with the exclusion of.
elude and allude Elude means to escape notice, perception, or often memory. Allude means to
hint at or refer to something indirectly.
1379

imminent and eminent Imminent is an adjective that means about to happen, or expected. It's
often used in the sense of something hanging threateningly over one's head. Eminent means
well-known and having a reputation as an expert. Eminent applies to a person.
cite and site Cite is a verb that means to make reference to something, usually to a source of
information. Site is a noun meaning place or location.
complement and compliment A complement is something that completes or makes perfect. It
can also be used as a verb, meaning to complete or supplement something. A compliment is an
admiring remark or a sign of respect, honor, or praise, often directed at a person.
principal and principle The adjective principal means most important or influential. As a noun,
you use it to refer to the person who has primary responsibility for an institution. But the noun
principle is a basic law or doctrine. Principle may refer to a rule or code of conduct, or to someone
who is an ardent supporter of a principle.
capitol and capital Capitol refers to the official place or building where government work is
done. Capital means chief in importance or influence and refers to the most important town or city
in an area.
stationery and stationary Stationery refers to office supplies such as pens, pencils, paper,
and paperclips. Stationary is an adjective describing an object that isn't moving. A way to
remember the difference between the two is to associate the er in stationery with the er in paper.
a while and awhile The two-word version a while is a noun phrase that follows the preposition
for or in. The one-word version awhile functions as an adverb.
Similar meaning pairs
Some words are confusing because they have similar or related meanings.
Ambivalent almost always applies to feelings or thoughts. It means having mixed feelings or
contradictory ideas about something. If you feel ambivalent, you may be uncertain about which
idea or approach to follow.
Ambiguous means having more than one meaning, open to different interpretations, or even
doubtful or indistinct.
It can help to remember that moods, characters, relationships, attitudes, and behavior or anything
deemed to contain contradictions can be described as ambivalent. The word ambivalence is usually
used in the context of a person whereas ambiguous applies most often to words and language.
Anxious and eager are often confused:
Anxious means worried, tense, or suffering from anxiety.
Eager means marked by enthusiastic or impatient desire or interest.
Continuous and continual are very similar in meaning both describe duration:
Continuous refers to something uninterrupted or constant.
1380

Continual refers to something intermittent or often repeated.
In other words, continuous indicates duration without interruption. And continual denotes duration that
continues over a long period of time, but with intervals of interruption.
Comprise and compose is a particularly troublesome word pair:
To comprise means to be made up of or to include
To compose means to make up, to constitute, or to form the substance of something.
The words fewer and less are often confused:
You reserve fewer for countable things.
And you use less for noncount nouns or amounts.
A guideline to help you remember this is to use fewer with plural nouns and less with singular nouns.
The difference between disinterested and uninterested can be obscure:
Disinterested means impartial and unbiased
Uninterested means unconcerned or bored.
It's usually appropriate to use myself when you have used I earlier in the same sentence. You are
emphasizing your own role in the. A very common error is to use myself in place of the objective pronoun
me or the subjective pronoun I, perhaps because it seems more formal.
Many words either sound similar or have related meanings. For instance, it's easy to mix up certain
contracted pronouns with their possessive forms. Examples of similar sounding words that are sometimes
confused are accept and except, elude and allude, imminent and eminent, and cite and site. Words with
related meaning can also trip you up. A few examples include ambiguous and ambivalent, anxious and
eager, continuous and continual, and comprise and compose.
Using Prepositions Idiomatically
When you compare things, do you compare them to each other or with each other? And would you say
that something is different than, different from, or different to something else?
The word that changes in each of these cases than, from, and to is a preposition, which is a word or
phrase that links an object a noun or a noun equivalent to another word in a sentence to indicate the
relationship between them.
More than one preposition can be used after a verb. And the choice of one over another is often idiomatic
in other words, it's been established through use rather than because of a rule.
1381

But one general guideline for choosing a preposition is to use with when referring to people and another
preposition for situations or things. Remember, though, this applies in some cases but not in all:
you argue with a person, but over or about a situation or thing, and for or against a position
you agree with a person, but agree to or on terms; also, you agree about something, meaning
you concur, and
you differ with a person, but differ from is applied to a thing or quality, and you differ about, over,
or on an issue
But in the case of the word occupied, the guideline about with doesn't apply. For example, the seat is
occupied by a person, but you are occupied with a task or thing.
As you can tell from the examples given so far, idiomatic combinations of verbs, nouns, or adjectives with
prepositions can be confusing because their meanings can change depending on context and because
they have so many idiomatic uses. For example, you can make a comment about another person, but you
can also comment to a person and comment on a situation or thing. And you can charge for a purchase
and charge with a crime.
You use compare to primarily when highlighting similarities between things or when considering how alike
they are. But you use compare with when focusing on the differences between things. You also use
compare with when you want to discern both the similarities and differences between things.
When things are different, are they different from, different than, or different to each other? Generally,
different from is the correct expression. Different from means the same as it differs from. In general,
different from is preferable to different than. However, sometimes differently than is appropriate.
On the other hand, when things are the same, are they identical with or identical to one another? Identical
with is preferred by some, but identical to is also acceptable usage.
When do you use between and when should you use among? Between indicates one-to-one relationships
and is usually used to compare two things. Among denotes undefined or collective relationships and is
used where the emphasis is on distribution rather than individual relationships. However, you can use
between for more than two objects if multiple one-to-one relationships are understood from the context.
It's even appropriate when one thing is mentioned, but repetition is implied.
The expression center around is a common one, but you should avoid it, using instead center on or upon.
Or you could use the phrase revolve around. And when you approve of something, you show favor
toward it. Approve alone indicates official sanction.
More than one preposition can be used after a verb. And the choice of one over another is often idiomatic
in other words, it's been established through use rather than because of a rule. For example, when you
compare things, you compare similar things to each other, and things that are unlike with each other.
1382

Recognizing Commonly Misused Verbs and Other Words
Learning to use words correctly is important for several reasons:
your word usage influences your readers' perceptions of you and in the business world, good
perceptions and reputations are vitally important
careful word usage helps readers pay attention and value your message more, rather than ignore
and disregard the message, and
correct word usage makes your writing easy to read and understand
Commonly misused verbs
Some verbs tend to be misused more often than others:
affect and effect The verb affect means to influence or have an effect on. Affect is usually used
as a verb. You should note that in psychological terminology, affect is another word for a mental
state or feeling. As a verb, effect means to make happen or produce. In business and generally,
effect is usually used as a noun, meaning outcome or result.
appraise and apprise Appraise means to assess or to put a value on something. You can
appraise the amount of something. Apprise means to inform or to tell. You apprise someone of
something.
lie and lay As a verb, the main meaning of lie is to rest, recline, or stay in a horizontal position.
Lie also means to have direction or extend. You should check your dictionary for the variety of
ways that lie can be used. Lay is a transitive verb, which requires a direct object. It usually means
to put or set down.
imply and infer To imply means to suggest something indirectly. Infer is a verb that means to
draw a conclusion from facts or reasoning.
deduce and deduct To deduce means to reason from general principles to specific
conclusions. It is similar in meaning to infer, which is listed as a synonym for deduce. The verb
deduct means remove, reduce, or subtract. It's usually used in mathematics.
precede and proceed Precede relates to sequence. It means to come or go before in time.
Proceed means continue doing or move along.
When to use can and when to use may also causes confusion.
May suggests permission or possibility.
Can traditionally applies to physical or mental ability and means to be able to. In less formal
English, can also expresses a request for permission, but this usage is not recommended in
formal writing.
To irritate means to annoy or to bother. Traditionally, aggravate means to worsen or intensify. A customer
who complains excessively might aggravate your bad mood or your headache, but he doesn't aggravate
1383

or intensify you in the strict sense of the word. The bottom line is that if you mean to bother, use the
word annoy or irritate, rather than aggravate.
Other misused terms
The old meaning of the word hopefully is in a hopeful manner, but its newer use as I hope and it is hoped
seems to have gained some acceptance. Still, many careful writers avoid the new meaning.
These two terms are also commonly misused:
Literally means exactly as described. But people often misuse literally to emphasize something.
The word shouldn't be used in a figurative sense.
In lieu of means in place of or instead of. It doesn't mean in light of.
Irregardless is a word that is simply incorrect. The correct term to use is regardless, meaning without
regard to, without consideration, or without taking into account.
The word unique means one of a kind. Something can't be very unique or a little unique it either is or it
isn't. This is an absolute term that is not gradable.
Due to and because of are often confused. Due to is interchangeable with caused by or attributable to.
When used as an adverb, due to is usually considered inferior to because of or owing to, which mean by
reason of or on account of. It may help to remember that nouns are usually due to something, whereas
verbs happen because of something.
The two-word expression all together does not have the same meaning as its one-word version
altogether. Altogether means entirely, in all or in total amount, or considering everything. But if you say
"The employees assembled all together in the boardroom," it means that the employees are together in
the boardroom.
Using words correctly is important in business communication. Doing so helps to improve your readers'
perceptions of you, ensures readers will pay attention to your message, and makes your writing easy to
read and understand. Commonly confused verb pairs include affect and effect, appraise and apprise, and
lay and lie. Other terms that writers often misuse include in lieu of, literally, unique, and all together.







1384


Business Grammar: Parts of Speech
SkillBriefs
Recognizing the Eight Parts of Speech
Learn about the eight parts of speech.
Using Verbs Correctly
Discover how to use verbs correctly.
Using Adverbs and Adjectives
Recognize how to use adverbs and adjectives correctly.
Using Nouns Correctly
Learn how to use the different types of nouns.
Recognizing the Eight Parts of Speech
To understand the basics of good grammar, you need to be familiar with the eight parts of speech. The
parts of speech tell you how words function in a sentence, rather than what words are or mean. Words
can also be altered to function as different parts of speech.
Nouns
Nouns are words that name things. They can be categorized into five groups:
Common nouns name a generic type of person, place, or thing. Common nouns can be further
divided up into count, abstract, or collective nouns.
Proper nouns name unique people, places, or things, rather than identifying them based on the
categories to which they belong. They always start with a capital letter.
Count nouns express enumerable things. They occur in both singular and plural forms.
Collective nouns or mass nouns refer to things that are normally countable, either because
they are abstract or because they denote an indeterminate number of people or things.
Abstract nouns name things you can't see, hear, smell, taste, or touch. They describe feelings,
ideas, or concepts.
Pronouns
Pronouns replace nouns. Using them can make sentences less cumbersome. Pronouns have different
forms or cases, depending on how they function in a sentence:
1385

Subjective pronouns replace nouns that act as the subjects in sentences. In other words, they
replace nouns describing who or what performs the action described by a verb.
Objective pronouns act as the objects in sentences. They replace nouns identifying who or what
is the recipient of the action expressed by a verb.
Possessive pronouns indicate ownership, or possession. The possessive pronouns my, our,
your, his, her, its, and their can be used as adjectives to qualify nouns as in "my report." Each
possessive pronoun also has a corresponding independent form that can stand alone, without a
noun. With the independent form, the thing possessed may be either an antecedent or something
understood. The independent form can also be the subject or object of a verb.
Some personal pronouns are compounds that use the suffix self or selves. These pronouns are used for
two main purposes for emphasis, as in "I will do it myself," or to refer to the subject of the verb, as in
"They support themselves." When they are used for emphasis, they are called intensive pronouns. When
used to refer to a subject, they are called reflexive pronouns.
A reflexive pronoun looks the same as an intensive pronoun but has a different function. It reflects the
action that the verb describes by renaming the subject, whereas an intensive pronoun adds emphasis
and gives force to a sentence. And intensive pronouns take the subjective case, whereas reflexive ones
don't.
Verbs
Verbs are commonly described as "action" words. That's because verbs typically describe the
performance or occurrence of actions, as in runs or writes. But verbs can also indicate a state of being or
condition. Helping or auxiliary verbs combine with some verb forms. They may indicate tense or
obligation, or provide other additional meaning. These combinations of helping verbs with other verb
forms are known as verb phrases. Commonly used helping verbs are versions of the verb to be. These
include am and is in the present tense, was and were in the past tense, and will in the future tense.
Adverbs
Adverbs describe, qualify, limit, or modify verbs, adjectives, and sometimes other adverbs. You can
classify adverbs into three types. Adverbs of time tell you when something occurs. Adverbs of manner
describe how something is done. And adverbs of place tell you where something occurs. Adverbs
commonly end in the letters ly. Adverbs often modify verbs, but they can also modify adjectives, which are
words that describe nouns. Adverbs can also modify other adverbs.
Adjectives
Adjectives describe nouns or pronouns. They answer questions such as Which one? What kind? or How
much?
Conjunctions
Conjunctions join words, phrases, or sentences. There are two types of conjunctions:
1386

Coordinating conjunctions join words or groups of words that are of equal importance that is,
independent elements.
Subordinating conjunction introduces a clause that is dependent on the main clause of a
sentence.
You may remember being taught at school that you should never start a sentence with a conjunction like
And, But, or So. However, it's now generally considered acceptable to do this if a previous sentence
makes it clear what the conjunction is referring to. It's also appropriate to start a sentence with a
conjunction like Because or Since if the sentence begins with an introductory clause that modifies another
clause that follows.
Interjections
Interjections are words, phrases, or clauses that denote strong feeling or emotion. They're often followed
by exclamation marks. Avoid using interjections in formal business writing unless you're quoting someone
directly.
Prepositions
A preposition is a word or phrase that links an object to another word in a sentence to show the
relationship between them. A preposition's object is usually a noun or pronoun.
Different prepositions indicate different types of relationships:
Prepositions such as on, above, and below identify spatial relationships they specify where
something is in relation to something else
prepositions like before, after, at, and until indicate time relationships, and
prepositions such as by, to, and with identify logical relationships
Being able to identify the eight parts of speech and use them correctly will help ensure your business
writing is clear, professional, and effective.
Using Verbs Correctly
Voice
The verb is the most complicated part of speech. A verb changes form to express different information,
including voice, mood, and tense.
The voice of a verb reveals the relationship between the subject and the action itself in a sentence:
In the active voice, the subject comes before the verb.
In the passive voice, the subject comes after the verb or may even be left out of a sentence.
1387

In business writing, using verbs in the active voice can help you make a stronger impression. In the
passive voice, helping verbs like "am" must be added to support a main verb. These can add to the length
of sentences, and convey less energy and interest than action verbs.
Mood
The mood of a verb indicates the way in which the verb expresses an action or state of being. There are
three types of moods:
You use the indicative mood to state something as a fact, describe something give factual
details, or to ask questions.
You use the imperative mood to issue commands or make requests. Sentences in the
imperative mood usually have an understood "you" as the subject.
You use the subjunctive mood when referring to a possible act or state.
Verb tenses
The tense of a verb reveals the time at which an act, state, or condition occurs or occurred. The three
main divisions of time are present, past, and future. To form verb tenses correctly, you need to know the
principal parts of verbs:
The plain form of a verb is the form you find in the dictionary.
The infinitive is the part of the verb that in its plain form may be preceded by to.
You form the present participle by adding ing to the plain form of the verb. A present participle is
used with a to be verb to show that an action is in progress.
The past participle is usually the same as the past tense form it takes an ed or d after its plain
form.
Regular verbs have basic forms that don't change when you form different tenses. Irregular verbs,
however, change form in different tenses. There are so many variations of irregular verbs that if you are
unsure about how to form a tense, you should check a good dictionary. The verb to be has more irregular
forms than any other verb.
The three major categories of verb tenses break down further into simple, perfect, and progressive
tenses:
The simple present tense indicates an action that is currently taking place, a recurring action, or
something that is always true. To form this tense for regular verbs, you use the plain form of a
verb except when the subject is he or she, in which case you add an s.
The past tense describes an act, state, or condition that occurred or existed at some point in the
past. Regular verbs form their past tense by adding ed to the verb.
The future tense indicates an expected act, state, or condition. This tense is formed by placing
will before the plain form of the verb.
1388

The present perfect tense indicates that an act, state, or condition began in the past and may still
be occurring. This tense uses the helping verb have or has along with the past participle of a
verb.
The past perfect tense indicates that an act, state, or condition was completed before another
specified past time or past action.
The future perfect tense describes an act, state, or condition expected to be completed before
some other future act or time. This tense is formed by using will have with a past participle.
The progressive tenses indicate actions that are still in progress. You form all these tenses using
a form of the verb to be with the present participle. So the present progressive tense indicates
continuing or progressive action. To form this tense, you use the present tense forms of to be
am, is, or are with the present participle.
The past progressive tense identifies an action that occurred for a certain amount of time in the
past. To form this tense, you use was or were with the present participle. Last, the future
progressive tense indicates an action that will be in progress at a certain time in the future. To
form this tense, you use will be with the present participle.
It can be more difficult to form tenses correctly with irregular verbs. Common usage errors occur when
using irregular verbs such as do, hang, and drink :
In perfect tenses, the past participle of do which is done must be used.
The verb to hang takes different past tense and past participle forms depending on the intended
meaning.
The past tense of drink is drank and the past participle is has drunk.
An auxiliary or modal verb is a very irregular verb used with other verbs. Using different modal verbs
can change the meaning of a sentence. One modal verb that doesn't vary in its form in either the present
or past indicative is ought. Moreover, it has no infinitive form or present or past participle.
The verb is the most complicated part of speech because it changes form to express information,
including voice, mood, and tense. The voice of a sentence is either active or passive. In business writing,
active verbs make stronger impressions and are more concise. Statements and questions are in
indicative mood, and commands are in imperative mood. The subjunctive mood expresses hypotheses or
wishes. Verb tenses reveal whether actions or states happened in the past, present, or future. To form
verb tenses, you should know the plain forms of verbs, their infinitives, and their present and past
participles. Verb tenses are divided into simple, perfect, and progressive tenses, each of which is formed
differently. An auxiliary or modal verb is used with other verbs to indicate time or add other meaning.
Using Adverbs and Adjectives
Adverbs and adjectives give life to your writing, helping you to describe things more accurately and draw
your readers in. When used correctly, they can make your sentences stronger and clearer. However,
using too many adjectives and adverbs can clutter your sentences and make them harder to understand.
1389

It's important to be concise, especially in business writing. So you need to use adjectives and adverbs
only when they add real meaning.
Like including too many adjectives or adverbs, using them incorrectly can puzzle your readers and
undermine your credibility as a writer. So it's important you know how to use them, as well as when to use
them, in your writing.
A characteristic of adjectives and adverbs is that you can use them in different forms to specify degrees
of comparison. The three degrees of comparison are positive, comparative, and superlative:
In the positive degree, an adjective or adverb describes the quality, quantity, or manner of one
person or thing. In the sentence "Alice wrote a long letter," the word long is an adjective in the
positive degree. In the sentence "Alice arrived early," the word early is an adverb in the positive
degree.
In the comparative degree, an adjective or adverb compares the quality, quantity, or manner of
two people or things. An adjective in the comparative degree is longer in the sentence, "Alice
wrote a longer letter than Betty." An adverb in the comparative degree is earlier in the sentence
"Alice arrived earlier than Betty."
In the superlative degree, an adjective or adverb compares three or more people or things. It
indicates that what's being described has a quality to a greater extent than anything it is being
compared to.
The way you form the comparative and superlative degrees of an adjective or adverb depends on
whether you have a one-syllable, two-syllable, or three-or-more-syllable word:
one-syllable word You usually add er to make the adjective comparative or est to make it
superlative. The same applies to most one-syllable adverbs that do not end in the letters ly.
Exceptions apply for some irregular one-syllable words, such as good and bad. These become
better and worse rather than gooder and badder. You can use a good dictionary to find the
correct forms of comparison for irregular adverbs and adjectives.
two-syllable word Some adjectives and adverbs with two syllables take the er and est suffixes,
but most take more or most. And a participle used as an adjective - for example, boring requires
more or most before it. Sometimes, the way a word sounds will help you determine whether to
use the suffix or the words more or most. For example, tranquilest does not sound natural,
therefore most tranquil is probably the better form in this case. Consult a good dictionary to check
if you are uncertain about which form to use. And remember, some adverbs and adjectives are
irregular, so no rules guide their forms in the comparative and superlative forms.
three-syllable word You usually form the comparative with more or less, and the superlative
with most or least.
Remember, when using the comparative and superlative forms, you should use either the er / est endings
or the words more and most but not both. And some adverbs and adjectives, by their definitions, are
absolute and can't be compared.
1390

Troublesome adjective-adverb pairs
Some adjective-adverb pairs can cause confusion. They account for many of the common usage errors
with adverbs and adjectives, in writing and speech.
The adjective real is often used incorrectly in place of the adverb really as in "John was real upset."
This is incorrect because real in this context is modifying upset, which is an adjective so the adverb
really should be used.
A simple way to check if you're using really and real correctly is to replace them with the word very. If the
meaning of the sentence stays the same, you should be using the adverb really. But if not, use real.
Confusion between the words bad and badly often arises when they are used with a linking verb. Whether
these verbs are linking depends on their meaning in sentences. When the word after a verb modifies the
subject, the verb is linking and the word should be an adjective, as in "The economy was bad in the first
quarter." But when the word modifies the verb, it should be an adverb as in "The plants grow badly in
this rocky soil." If you were to write "The plants grow bad in this rocky soil," it would mean something
different that the plants somehow become bad.
Similar confusion can occur between the adjective good and the adverb well.
Good describes nouns or pronouns and means commendable, worthy, virtuous, or valid.
The word well is most commonly used as an adverb, meaning to do something in a satisfactory
way, skillfully, or in a kind way as in "he treated her well."
The way adverbs and adjectives are formed differs depending on the intended degree of comparison. The
three degrees of comparison are positive, comparative, and superlative. You usually form the different
degrees based on the number of syllables in a word, although some adverbs and adjectives are irregular.
It's important to avoid confusing certain adjective-adverb pairs, such as real and really, bad and badly,
and good and well. Remembering which part of speech these words function as will help guide you in
their correct use.
Using Nouns Correctly
Nouns are an essential component of most sentences. Without them, there's little we could communicate.
So it's no wonder these are the first group of words young children learn.
Being able to identify different types of nouns can help you improve in three areas:
capitalization becomes easier when you know how to spot proper nouns
subject-verb agreement in a sentence depends on whether a noun is countable or noncountable,
and
being able to spot abstract nouns and replacing them with concrete nouns can often help you
write more clearly and vividly
1391

Whereas a common noun is the generic name of one thing in a class or group, a proper noun is the name
of a person or the official name of a place or thing. So office or person is a common noun, but Simon is a
proper noun. Proper nouns also include brand names, as in Scotch tape and Kleenex tissues.
All proper nouns start with an initial capital letter. A common noun may become a proper noun. Moreover,
sometimes a proper noun may be used figuratively and informally.
When the correct form of a verb matches with the subject in a sentence, it's called subject-verb
agreement. You'll be better able to apply the rules for subject-verb agreement if you can identify these
types of nouns:
count nouns, which name things that can be counted like customers, chairs, or invoices, and
noncount nouns, which name things that can't be or aren't usually counted like advice, water,
furniture, and wealth
Count nouns can be singular or plural, like brick or bricks and photo or photos. They then take the
appropriate singular or plural verb forms.
Noncount nouns are also called collective or mass nouns. When it is the subject of a sentence, a
noncount noun usually takes a singular verb. However, if you express a quantity of units before a
noncountable noun, it becomes countable and the verb must agree with the units. So tea on its own is a
noncountable noun, but cups of tea are countable and take a verb in the plural form. Moreover, in a
collective sense, a noncount noun may take either a singular or a plural verb form. A singular verb
emphasizes the group; a plural verb emphasizes the individual members. Some collective never take the
plural form. You must always use them with singular verbs.
It's important to use definite and indefinite articles correctly with different types of nouns in particular
count and noncount nouns. An article comes before a noun or noun phrase. The article the indicates that
the noun identifies something definite, whereas the article a or an indicates that the noun is indefinite.
You use the indefinite article a or an before a singular count noun when you mention it for the first time.
Plural count nouns are never preceded by a or an. Also, noncount nouns don't take an indefinite article,
except when you're referring to different types of something that's not countable. Noncount nouns that
represent a collection or a mass may be preceded by a phrase that indicates quantity, such as a lot of, a
little, or some.
The definite article points to a definite object that is so well understood that it does not need description. A
singular or a plural count noun may take the definite article. Noncount nouns may also take the definite
article. You use the before a singular count noun in three situations:
you have mentioned it before
you identify it immediately before or after you state it, or
it's unique or the only one in existence
1392

You don't ever use the indefinite articles a or an before a proper noun. In general, you don't use the
either, but there are exceptions - for example, with plural proper nouns and with the names of
organizations.
Business writing should always use words that have clear, concrete, and specific meanings so that the
writing is easy to understand. Abstract nouns denote feelings, thoughts, concepts, or ideas. You may find
them useful sometimes, mainly in the broad statements that set the course for your writing, but their
meanings can be interpreted differently by different people. Concrete nouns name people, places, or
things you can experience through at least one of your five senses. They can be clearly visualized and
are less likely to cause confusion. Using them, along with more specific adjectives, can help you write
more clearly.
It's important to use nouns correctly in sentences. Being able to identify the different noun types can help
you apply correct grammar and punctuation in your business writing. Proper nouns always start with an
initial capital. Specific rules determine whether you must use singular or plural verb forms with count and
noncount nouns. Also, particularly in business writing, replacing abstract nouns with more concrete ones
can make your writing clearer and more vivid.


















1393

Rules for Constructing Prefixes and Suffixes
Learn about the construction of prefixes and suffixes.
Rules for Forming Plurals
Understand how to correctly form plurals.
Rules for Forming Possessives
Learn the rules for forming possessives.
Basic Spelling Rules
Discover how to become a better speller.
Rules for Constructing Prefixes and Suffixes
Prefixes are a standard set of syllables that are added to the beginning of root words to change their
meaning. Suffixes are a standard set of syllables that are added to the ends of words to alter their
meaning as well as their function.
You can break prefixes down into four categories, depending on their meanings. Prefixes can be used to
indicate
quantity
negation
time, or
direction or position
Suffixes can help you recognize which parts of speech certain words are. For instance, the addition of a
suffix to a root word could change it from a verb to a noun. Another suffix could change the word to an
adjective, whereas another might make it an adverb. The three categories of suffixes are as follows:
noun suffixes are those that change the root word to a noun
adjective suffixes change root words into adjectives, and
verb suffixes are added to root words to change them to verbs
So suffixes can be added to form nouns, adjectives, and verbs. And to form adverbs, you usually add the
suffix ly.
General rules
Using prefixes and suffixes correctly requires not only that you know what they mean, but also which
guidelines to follow when attaching them to root words.
1394

In general, hyphens shouldn't be used when adding a prefix or a suffix to a word. There are some
exceptions to the rule. Normally, the prefix mid doesn't require a hyphen, as in midday. However, when
it's followed by a number, a hyphen must used. You should also use a hyphen when mid is followed by a
proper noun such as mid-January or mid-Atlantic. When adding less or like to the end of a word, a
hyphen has to be used if the addition results in three l's occurring in succession.
The prefix re, meaning again, doesn't usually need to be followed by a hyphen. However, you should use
a hyphen with it to distinguish the meaning of words with the same spelling. For example, you release a
statement to the press, but you re-lease an apartment to a tenant.
Another rule is to add hyphens to ensure clarity:
compound words When adding a prefix to a hyphenated or a spaced compound word, it is
necessary to use a hyphen.
"self" words A hyphen is added when self is used as a prefix. However, a hyphen is not
required when self is the base word and it's followed by a suffix, as is the case with the word
selfish.
common elements If you're using two or more prefixes with a common element, you use a
suspending hyphen after each prefix to show its relationship to the common element. For
example, "We completed pre-, mid-, and post -training assessments."
capital letters When you place a prefix in front of a word that begins with a capital letter, you
have to use a hyphen. This would include words like mid-June and trans-American.
You should also add a hyphen when a prefix ends in a or i and the root word begins with the same letter.
But typically, when the prefix ends with e or o and the root word begins with the same letter, you don't use
a hyphen. There are some exceptions, however, including co-owner, co-opt, and de-emphasize. When in
doubt, consult your dictionary.
The trend in spelling has been away from the use of hyphens. Although it's a trend not a rule it may
sometimes help, when deciding whether to use a hyphen, to remember that the trend exists. And if
ambiguity or confusion results from not including a hyphen, then you should add it.
When adding a prefix to a word, the spelling of the root word is not altered in any way. However, when
adding suffixes to words, the spelling of the root word may change. Because of this, there are certain
rules for adding suffixes to root words.
One of these rules relates to the silent e that appears in such words as become, like, and give. This e has
to be dropped from the root word when the suffix being added begins with a vowel. Exceptions to this rule
are the words changeable and noticeable. In these instances, the silent e is maintained because it follows
a soft g or c.
In some cases, you'll keep the silent e when adding a suffix. The silent e is kept if the suffix begins with a
consonant. An exception to this rule is the word argument, which is formed when the silent e is dropped
from the verb argue before the suffix is added.
1395

Another rule for adding suffixes is that you change the y in a root word to i if the letter before the y is a
consonant. You keep the y in the root word if the suffix begins with an i, as is the case when you add the
suffix ing to the word cry to form crying. You also retain the y in a root word in certain one-syllable words
and if the letter before the y is a vowel.
Sometimes it's necessary to keep the y when a suffix is added to certain one-syllable words. If you add a
suffix to the root word dry, you keep the y to form the word dryness, for example. The y is retained if the
letter before the y is a vowel, as is the case with the root word annoy when you add a suffix to form the
word annoyance. The only exceptions to the rule about vowels before the y include for example the one-
syllable words day and say, in which case the y is changed to an i.
The basic component of any word is its root. You can modify the meaning of the word by adding a prefix
before the root or a suffix after it. Prefixes can alter the meaning of the root word by indicating quantity,
negation, time, and direction or position. Suffixes change the part of speech of the word. They can do this
in three ways by changing the root word to a noun, to an adjective, or to a verb. There are several
general rules you need to follow when adding prefixes and suffixes to root words.
Rules for Forming Plurals
Forming plurals can be tricky. But luckily, you can use several rules to guide you:
the basic rule The basic rule when it comes to forming plurals is to add the letter s to the
singular form of the noun. This is the simplest and most straightforward rule. For example, the
singular committee becomes the plural committees, league becomes leagues, menu becomes
menus, and quota becomes quotas.
rules relating to nouns ending in s, x, ch, sh, and z When singular nouns end in s, x, ch, sh,
or z, you add es to form plurals. Examples include the words businesses, faxes, sketches, and
wishes. The only exception to this rule is the noun quiz. To make this plural, zes is added,
forming the plural quizzes.
rules relating to nouns ending in y When a noun ends in a y that's preceded by a consonant,
you form the plural by changing the y to an i and adding es. For example, liability becomes
liabilities, copy becomes copies, and policy becomes policies. However, when a noun ending in a
y is preceded by a vowel, the letter s is added to form the plural, as in the words attorneys, boys,
and delays.
rules relating to nouns ending in f, fe, and ff You form the plurals of nouns that end in f, fe,
or ff by adding s, as in tariffs, beliefs, and safes. The exceptions related to this rule refer to words
such as leaves, halves, selves, and wives. These plurals are formed by changing the f or fe to ve
and then adding s.
rules relating to singular nouns ending in o You create the plural forms of singular nouns
that end in o in two ways. First, if the o is preceded by a vowel, you add an s to form words such
as stereos and ratios. But if the o is preceded by a consonant, you usually add es. For instance,
hero and tomato become heroes and tomatoes.
Some special rules apply to three categories of nouns:
1396

proper nouns, which name individual people or things and should begin with a capital letter
The main rule for forming plurals of proper nouns is that the original spelling must not be altered.
All that's added to the singular noun is an s. For example, "Mr. and Mrs. McCarthy " become the
McCarthys, not the McCarthies.
foreign nouns, which have been adopted from other languages, such as Greek and Latin, into
the English language Foreign nouns use different rules to form plurals. Words ending in o in the
singular sometimes change to i in the plural. For instance, concerto becomes concerti. And
singular foreign nouns that end in on or um receive an a to form the plural. So, criterion becomes
criteria.
irregular nouns, which include nouns surviving from Old English Some nouns, especially those
derived from Old English, are irregular because their plurals are formed by changing letters within
the word or adding letters other than the usual s or e s. You're likely to be familiar with most of
these words, but in cases where you are uncertain, you should refer to your dictionary.
Another area to consider is the plurals of hyphenated and open compound nouns. For hyphenated forms,
you usually add an s to the element that is being pluralized for example, fathers-in-law. In open
compounds, the same applies for example, accounts payable, rules of thumb, and notaries public.
So, as a general rule, you attach the plural form of a compound word to the base element the one that
changes in number or the principal noun regardless where the element falls in the term. If there is no
clear principal noun, then the plural applies to the entire compound as in hand-me-downs or author critics.
The only nouns that don't form plurals are noncount nouns. You don't add s to these types of nouns.
Examples include bread, equipment, respect, and information.
A common error in writing is to form plurals by adding an apostrophe s to the singular form of a noun.
Remember that you use apostrophe s for possessive nouns, such as John's portfolio. It's not meant for
creating plural nouns. However, you may find that certain handbooks teach the use of an apostrophe in
the plural forms of numbers and letters. So, for example, in the sentence "She scored 10's in all quizzes,"
the score 10's contains an apostrophe, but it doesn't have to. This method of forming plurals is not
formally agreed upon.
You can follow several rules for creating plurals from singular nouns. The basic rule is to add s to the
singular form of the noun. When singular nouns end in s, x, ch, sh, or z, you add e s to form plurals.
Nouns ending in a y that are preceded by a consonant are formed by changing the y to an i and adding
es. The plurals of nouns that end in f, fe, or ff are formed by adding s.
Rules for Forming Possessives
The possessive case indicates not only simple ownership but also other relations. It can denote source or
origin as well as description or classification possessive case also replaces an of phrase for example,
one month's salary is the same as the salary of one month.
You use an apostrophe to indicate the possessive case. Two general rules apply for most nouns:
1397

For singular nouns, you add apostrophe s to form the possessive. The same rule applies to
irregular plural nouns. You also apply the rule to indefinite pronouns like someone, anyone, no
one, and everyone. Finally, you apply this to nouns usually creative names that end in
punctuation marks. For instance, the possessive form of Yahoo!, the Internet search engine, is
Yahoo!'s.
For plural nouns, you can add the apostrophe without the s. For instance, you add only an
apostrophe to the plural managers in the sentence "The managers' evaluations have been
positive."
The general rules for possessives cover most proper nouns in both singular and plural form, as well as
numbers and letters.
A rule of thumb for forming possessives is that you don't change the spelling of the noun itself you
always add something to it to form a possessive.
Some nouns that end in s can take an extra syllable when they become possessive. So to match the
pronunciation, you add apostrophe s instead of just the apostrophe. For example, you'd write "The
witness's statement is strong." Here, witness's is pronounced witnesses. You can also leave out the s, as
in "The witness' statement is strong," and pronounce the possessive. Consistency is the key, but the s
after the apostrophe as in witness's is preferred because it represents the more common
pronunciation.
Personal pronouns are often wrongly given apostrophes when they're made possessive. They don't
actually take an apostrophe their spelling changes completely. It is the most common pronoun to be
given the apostrophe incorrectly. The word its is the possessive form of it. The possessive its is often
confused with it's, where the apostrophe is used to form the contraction for it is.
Mastering the guidelines for using the apostrophe in different possessive structures will improve your
business writing in several areas:
With separate ownership when two or more nouns possess something separately you use the
possessive form with each noun. For example, Sarah's and Etienne's projects refers to Sarah's
project and also Etienne's project. With joint ownership, you use the possessive of only the last
noun. So if Sarah and Etienne are working on a joint project, you make only the second name
possessive, as in Sarah and Etienne's project.
You can also use the possessive form to modify a gerund a verb ending in ing that is used as
a noun. There are several ways to use this construction, and it often creates confusing or
awkward sentences. But if you decide to use it out of personal preference, there's a good rule of
thumb to help you avoid errors. The rule-of-thumb is to use this construction only in one particular
instance when the word before the gerund can be replaced with a possessive pronoun. This
could be a personal pronoun such as I, you, or they, or any proper noun or name. While this rule
has several exceptions, it should help you avoid most errors.
In compound nouns and noun phrases, you make the final word possessive for example, a
team member's reaction. However, when a compound noun is plural, as in the bank accounts'
balances, it's often best to use an of phrase instead so it becomes the balances of the bank
1398

accounts. With more complex compound nouns, it's even more important to use the of phrase.
Rather than writing editors-in-chief's responsibilities, you'd write the responsibilities of the editors-
in-chief.
A fuzzy area in possessives is how to tell a possessive noun from an attributive noun in other words,
when it describes a following noun. For instance, in consumer advocate, consumer is used attributively to
modify advocate. But take writers' conference, where writers is used possessively. Here you could leave
out the apostrophe and write it attributively, but this isn't ideal. Generally, it's safer to retain the
apostrophe. You omit the apostrophe and use the attributive only in proper names and where there's
clearly no possessive meaning.
Using the apostrophe to show possession involves several rules. The first is to add an apostrophe s for
singular nouns to form the possessive. Second, you add just an apostrophe for plural nouns and nouns
ending in s. Personal pronouns don't take apostrophes in the possessive case. When two or more nouns
possess something separately, you use the possessive form with each noun. But when joint ownership
exists, you use the possessive with the last noun only. You can use the possessive form to modify a
gerund, but only when you can replace the word before the gerund with a possessive pronoun. In
compound nouns and noun phrases, you only use the possessive case with the final word.
Basic Spelling Rules
Computer spell checkers are good at picking up actual spelling errors. But they're limited; they can't pick
up the very common error of confusing words with similar spellings.
You might already be familiar with some of the rules for spelling, such as those that apply when you add
suffixes to words that end in a silent e and in y, as well as rules for forming plurals. For example, for
words that end in y, you change the y to i when you need to add es or ed. So comply becomes complies
and complied.
You may find spelling difficult because many words contain silent letters, other than e, for example:
silent b, as in debt, subtle, and doubt
silent c, as in obsolescence, acquaintance, and indict
silent g, as in foreign, freight, sign, height, strength, and through
silent k, as in knight, knock, and know
silent i, as in liaison, praise, and achieve
silent n, as in hymn, column, and condemn
silent p, as in psychology and pneumonia
silent t, as in mortgage, listen, and often
Some people find that mnemonics or memory aids are useful in remembering how to spell words that
contain silent letters. You can also use pronunciation aids to help you remember the spellings of words.
1399

A useful memory aid is the phrase i before e, except after c. When a word has an i and an e together after
any letter other than c, you spell the word with ie. Examples of this rule are achieve, yield, and retrieve. If
it follows a c, you normally use ei, as in perceive, deceive, and receipt.
There are several exceptions to the ie rule. When the word sounds like a as in weigh, the e comes first.
Other examples are neighbor, reign, and feint. And exceptions when you have an ie after the c are
science, ancient, and financier.
A rule that applies when you add a suffix to a word is that you double the final consonant. There are two
particular instances when you do this:
single syllable words that end with vowel and consonant When a one-syllable word ends in
one vowel followed by a consonant, and the suffix begins with a vowel, you double the final
consonant. So scan plus the suffix ing becomes scanning you double the n.
multisyllable words with accented final syllable Whether you double the final consonant
sometimes depends on how the word is pronounced. If there's more than one syllable and the
last syllable is accented and the suffix begins with a vowel you double the final consonant.
For instance, occur becomes occurred when you add ed and occurrence when you add ence.
You don't double this final consonant if it's a y, k, or x. So buy becomes buying, and the past tense of fix
is fixed. Many other exceptions trip people up when a suffix is added. For instance, the plural of bus is
buses.
Becoming a better speller
You can become a better speller by following some tips. Remember that you just have to memorize some
words. Many words have odd spellings or don't adhere to the rules. Examples include coolly, woolly,
embarrass, harass, calendar, and itinerary. Words like yacht, buoy, and quay can be tricky too because
their spelling differs from the way they're pronounced.
Remembering two basic rules, one for adding prefixes and the other for adding suffixes, will go a long
way in helping you to spell better. The rule for prefixes applies in every instance, whereas the rule for
suffixes applies to one tricky suffix ending:
When you add a prefix, you don't drop letters from the original word. So equal becomes unequal.
When you add the suffix ful to a word, you always end with only one l. So hope becomes hopeful.
Another useful way to help your spelling is to improve the way you say words. For example, to help you
remember that separate has two a's, pronounce it as "sep-a-rate." Other words that you pronounce as
they're spelled are asterisk, boundary, and Arctic.
You can become a better speller by doing certain things:
keep a list of difficult-to-spell words and review it often
use a dictionary whenever you're not sure
1400

use memory aids for example, visualize a word that you struggle with
try to learn a new word, even if it's just one a day
play word games and do crossword puzzles
Several basic spelling rules can help you become a better speller. Some apply to words ending in silent e
and words ending in y. The rule i before e except after c helps you know whether to use ie or ei in a word.
Other rules apply to adding suffixes to words that end in consonants and memorizing exceptions and
words that contain other silent letters. You can help yourself learn to spell better by recognizing that some
words must be memorized, knowing rules for adding a prefix and suffix, and improving your
pronunciation. Knowing your weaknesses, using a dictionary, and reviewing difficult words will also help.
Business Grammar: The Mechanics of Writing
SkillBriefs
The Correct Use of Abbreviations
Explore the rules that govern abbreviations.
The Correct Methods of Capitalization
Discover the rules that govern capitalization.
Writing Numbers
Discover the rules that govern how you write numbers.
The Correct Use of Abbreviations
Abbreviations are shortened forms of words or phrases. They're sometimes used in business documents
to save time and space. But overuse and inconsistent use can make a document hard to follow. Two
simple rules govern the use of abbreviations: "If in doubt, write it out" and "Be consistent."
Titles and names
When using such social titles, you always use the abbreviation. Professional and academic designations
follow an individual's full name and comma. Similarly, you use the full name with name suffixes like Jr.
and Sr.
A civil or military title is spelled out if used with just a surname. They are abbreviated if used with full
names. You spell out the titles Reverend (Rev.) and Honorable (Hon.) if they are preceded by the. But
they are abbreviated when the doesn't precede the title. The title is usually omitted when just the surname
is used.
It's generally accepted that you do not use a title and a designation before and after a name. Names that
include the title esquire (Esq.) never take any other title, either before or after the name. Titles such as
Rev., Mr., and Dr. should always precede a name. In some cases, designations can be used without a
proper name, particularly if they signify or substitute for a person.
1401

It's not general practice to abbreviate given names, unless you are following a personal preference. And
when Saint is part of a personal name, the individual's preference should be followed when deciding to
use the abbreviation or not. The title Ms. is commonly used in three instances: if a woman prefers it to
Miss or Mrs., if a woman's marital status is unknown, or if the marital status is irrelevant.
In all but the most formal documents, you should abbreviate the names of well-known businesses and
organizations, including labor unions, societies, associations, and government agencies. You may
abbreviate parts of a company's name, such as Company, Corporation, and Incorporated.
Location and time
The names of countries are always spelled out in running text. The names of U.S. states are always
spelled out when standing alone and preferably with the exception of D.C. when following the name of
a city.
Although it's becoming more common to abbreviate the United States to U.S. when used as a noun, it's
more acceptable to use the abbreviation only as a modifier.
You should avoid abbreviating city names and prefixes of geographic names. Exceptions are sometimes
made for names beginning with Saint when it's permissible to abbreviate the location prefix.
The location name in an address on an envelope or a list may be abbreviated. However, these
abbreviations are confusing when you use them in the main body of a business document and should
always be spelled out.
You're probably familiar with the abbreviations a.m. which stands for ante meridiem or before noon
and p.m. post meridiem or after noon. And it's often appropriate to abbreviate time zones such as
Atlantic Standard Time (AST) or Greenwich Mean Time (GMT).
You can also abbreviate units of time. The days of the week and names of months can also be shortened.
However, you should avoid abbreviating days and months unless you need to save space, in a sales
chart for example.
Units of measure
Abbreviated measurements typically appear on charts and tables. Abbreviations for units of measure are
the same in the singular and the plural. Remember to include a space between the number and the
abbreviation. You typically don't use periods in abbreviations of units of measure.
The one exception to this rule is the abbreviation for inches, which takes a period.
When a measurement is used as a modifier, you include a hyphen between the amount and the
abbreviated unit of measurement. If the unit of measure is spelled out, a hyphen shouldn't be used.
1402

When to include periods
For abbreviations that consist entirely of capital letters, you don't include periods. Abbreviations that
appear in lowercase letters usually include periods. Units of measure are exceptions to this rule.
If an abbreviation consists of the first part of a word, then a period is generally included after the
abbreviation. If an abbreviation ending in a period falls at the end of a sentence, then it is unnecessary to
include a second period after the abbreviation.
When to use capital letters
Usage is the determining factor in whether abbreviations other than those standing for proper names
use capital letters. But some guides point out that noun forms are typically uppercase as in the case of
CEO, for example, whereas adverbial forms are lowercase, such as the abbreviation for revolutions per
minute.
When to use i.e. or e.g.
The abbreviation i.e. stands for the Latin term id est and means that is or in other words. You use it when
you want to specify or clarify something.
You typically use e.g. which stands for the Latin term exempli gratia, for example in expressions
similar to including
When to use a or an
In general, the indefinite article a typically precedes words beginning with consonants, whereas an
precedes vowels.
With abbreviations, this varies depending on pronunciation whether the starting sound of the
abbreviation sounds like a consonant or a vowel. Acronyms are read as words and except when used
as adjectives aren't usually preceded by a, an, or the.
Abbreviations are sometimes used in business communications when they represent a shortened form of
a word or phrase. In some cases, the letters forming the abbreviation are pronounced as a word. These
abbreviations are known as acronyms. Most abbreviations fall into four general categories: titles and
names, locations, time, and units of measure. Rules or guidelines can help you use abbreviations
correctly. Keep in mind these two general rules: "If in doubt, write it out" and "Be consistent."
The Correct Methods of Capitalization
In contemporary usage and business writing, you use uppercase letters mostly to highlight parts of written
text and to emphasize important words. The first rule of capitalizing is to always start a sentence with an
uppercase letter. This takes precedence over every other capitalization rule. You also capitalize the first
word of any expression, including a fragment used as a complete thought.
1403

You should also capitalize a sentence that's used as dialog within another sentence. In addition, you
capitalize the first word of a question within a sentence.
Headings, lists, and colons
There are two ways of capitalizing headings:
Title case, where you capitalize all or most of the words, is most often used for titles of books,
chapters, and documents.
Sentence case, where you apply the standard rules for capitalizing sentences, is often used for
headings of sections within documents.
You can choose which case you prefer, as long as you are consistent.
When using title case, you always capitalize the first and last word of a title. Another generally accepted
rule is to capitalize most other words, including all nouns, pronouns, verbs, adjectives, adverbs, and
certain conjunctions. Another rule of title case is that prepositions and the articles a, an, and the are
usually lowercase, unless they're the first word of a title.
There are two exceptions when you do capitalize prepositions:
when they're stressed, and
when they're used as adverbs or adjectives
You don't capitalize words that are coordinating conjunctions. And you don't capitalize to in infinitive verb
forms.
For sentence case, you capitalize only the first word in a title, the first word in a subtitle, and any proper
name. Several general rules apply for capitalizing the first word in vertical lists, depending on the format:
numbered Each list item begins with an uppercase letter.
unnumbered List items begin with a lowercase letter when each item continues or completes a
sentence. However, if a full sentence followed by a colon introduces the list and the list items are
full sentences, each list item begins with an uppercase letter and ends with the appropriate
punctuation.
bulleted Each list item starts with a lowercase letter. Bullets are visual markers to highlight the
start of new items so capitalization here is the same as in unnumbered lists.
You use a colon to introduce an element or a series of elements illustrating or amplifying what has come
before the colon. You capitalize the first word after a colon when the colon introduces two or more
sentences, or when it introduces a speech within dialog or an extract. But when a colon is used to
introduce extra information within the sentence, you don't capitalize the first word after the colon unless
it's a proper name.
1404

Names and titles
When you capitalize people's names, every part of the name takes a capital letter. You also capitalize all
initials or abbreviations of names. And when you use the name of an organization in your business
documents, follow the organization's use of capitalization in its name.
In general, most titles whether civil, military, religious, or professional are capitalized when they come
immediately before a personal name. However, titles are usually lowercase when they come after a name
or are used in place of a name.
In business, senior employees are sometimes given official titles, such as president, director, or chairman.
When an official title precedes a name, you capitalize it.
If you're using a person's name after the title as an appositive a word or phrase that renames or
identifies the noun you don't capitalize the title. Likewise, when the title comes after a name or replaces
it completely, you don't capitalize it. You never capitalize the article in formal titles.
Some companies capitalize official titles when they're used without the person's name in internal
documents. In general, they should not be capitalized if they follow or replace a person's name.
Official titles can be used with a last name alone. Titles referring to occupations are almost never
capitalized. This applies wherever the title is used: before, in place of, or after a name. Occupational titles
can't be used with a last name alone.
You sometimes capitalize common nouns that substitute for proper nouns. This is usually the case in
policy statements and legal contracts when you need to refer to longer proper nouns. Substitute terms
should be defined early in the document.
Places, events, and other entities
Continents, countries, cities, oceans, and other places that appear on maps are always capitalized. And
words derived from place names proper adjectives are also capitalized.
When referring to U.S. states, you capitalize the word state only when it follows the name of the state.
If you use a capitalized geographical term that is made up of more than one word as an adjective, you
don't hyphenate it. However, if a proper noun is used as a hyphenated adjective, you capitalize only the
adjective derived from the proper noun.
Topographical names and sections of a country are also capitalized. You capitalize the names of
buildings and monuments. Names for important contemporary and historical events are generally
capitalized.
You also capitalize some
1405

formal organizations, including companies and groups like non-profit organizations, movements,
and athletic groups
internal departments of companies
government entities, and
products, trademarks, brands, and creative names
You always capitalize
days and months
acts, treaties, and official documents, and
the words Internet and Net
You don't capitalize compass points and terms derived from them if they simply indicate direction or
location. You also don't capitalize the seasons.
You capitalize the start of sentences and dialog and questions within sentences. Various rules apply to
capitalizing numbered, unnumbered, or bulleted list items. How you choose to capitalize headings,
outlines, and titles depends mostly on the case you're using either title case or sentence case. All
proper nouns are capitalized. Abbreviations of proper nouns are also capitalized, as are names derived
from proper nouns.
Writing Numbers
Knowing the rules for writing numbers has several advantages:
you'll write documents containing numbers that are easy to read and understand
you'll avoid using misleading or confusing numbers in your documents, and
you'll effectively convey the importance of the numbers
In documents like technical and economic reports, research papers, and performance assessments, the
significant numbers must catch the reader's eye. But in nontechnical documents, or high-level reports and
correspondence, values can often be expressed in words.
Basic rules
A simple rule you can follow when it comes to numbers is to spell out numbers one to ten and use
numerals for all others. However, whether you follow this rule or not can depend on a number of factors:
Is the number an approximation or a precise quantity? You always spell out imprecise or
indefinite. But when you're sure of the exact value of a number.
Is the number large or small? In general, you write long numbers in numerals because, in some
cases, they take many words to write out. They're also easier to read as numerals. In addition,
1406

you can use a combination of numerals and words to express very large numbers, especially
when they are fractional for example, 2.4 million. And like any large round number, sums of
money are expressed by a mixture of numerals and words.
What context does it appear in? You almost always use numerals for very important numbers,
such as exact amounts of money and scientific values. This helps to avoid errors and makes the
numbers stand out on the page.
What if a sentence contains more than one number one that should be written in numerals and
the other in words? In this case, you use the most convenient form usually numerals for
both. An exception to all the rules is that you always spell out a number that begins a sentence.
Special rules
When it comes to writing out times, you should keep in mind a couple of guidelines.
Use numerals when you want to emphasize exact times.
With the abbreviations a.m. and p.m., you typically use numbers. However, if the time is followed
by o'clock, you spell out the time in words.
Numerals should never be used to express noon or midnight.
If you're using the 24-hour clock, don't include periods between the numerals representing hours
and minutes. You write "The unit will make camp at 2100 and will be on the move again at 0500."
When you write dates, remember that years are expressed in numerals, except at the start of a
sentence.
For specific dates, you use cardinal numbers, even though these may be pronounced as ordinals,
as in "The meeting is on December 18."
In the United States, you typically write the date in the sequence "month day, year" with the month in
words. The day and year are in numerals, separated by a comma. So you write "We started on June 12,
1996." But when you exclude the day, the month and year go together without a comma, as in "We
started in June 1996."
You can write time periods, such as decades, in numerals, as in the 1990s. And you can refer to a
decade less formally by writing just the decade, preceded by an apostrophe, as in the '80s and '90s. Or
you can write out the decade the nineties. A point to remember is that time periods are plural, so you
don't use an apostrophe before the final s. In the case of particular centuries, you can spell them out and
use lowercase letters. It's also acceptable to use numerals.
When it comes to money, numerals are better because they tend to be clearer and quickly understood.
You can use numerals for all amounts of money small or large.
When working with fractions, you spell out simple fractions, use numerals for mixed-number fractions, and
use numerals for decimal numbers. So you write out the fraction three-quarters but use numerals to
express six and one-half yards if the fraction doesn't appear at the start of a sentence. And you use
numerals for decimal numbers such as 2.3 or 0.75.
1407

When deciding whether or not to use a hyphen in spelled-out fractions, these guidelines may help:
when to use the hyphen The basic rule is that when you spell out an independent fraction,
which is considered a single quantity, you hyphenate it for example "One-third of the employees
attended." You also hyphenate fractions that are extremely small, such as "She won by three-
hundredths of a second."
when not to use the hyphen When individual parts of a quantity are in question, you don't use
the hyphen. For example, "The chart is divided into four quarters."
While you write out most independent fractions, there is one exception to keep in mind. If the fraction is
part of an adjective it describes a measurement, for example you express it in numerals to make it
easier to understand. Rules also apply when you are using numbers with abbreviations, such as m for
meter and km for kilometer, and with symbols like the percent sign and the degree sign. The basic rule is
that you always use numerals if the number is followed by a symbol or abbreviation.
The advantages of knowing how to write numbers are that the numbers in your documents will be easier
to read and understand, will not be misleading or confusing, and will get their meaning across effectively.
In technical reports, important numbers are usually written in numerals. In business writing, they're
sometimes written in words; it depends on the context, how large the numbers are, and whether they are
precise or approximations. One rule you might follow is to write out numbers of ten or less in words, and
those above ten in numerals. Guidelines can help you use numbers with dates and times, as fractions
and decimals, and with symbols.














1408

Interpersonal Communication: Communicating with Confidence
SkillBriefs
The Essential Elements of Confident Communication
Learn about the benefits of communicating confidently.
The Use and Impact of Confident Communication Behaviors
Learn about confident communication behaviors.
Trust, Credibility, Rapport, and Confidence
Discover how to communicate confidently.
The Essential Elements of Confident Communication
Benefits of confidence
Being confident gives you the ability to speak freely, without fearing what others may think of you. It
enables you to be assertive, and it reduces anxiety in others. When you are confident, you listen better,
because your perception of what others are saying is not distorted by fears and anxiety.
When speakers lack confidence, listening to them can provoke negative feelings and impressions. You
may also find that you react to a person who lacks confidence rather than to the message this person is
conveying.
During interactions with speakers who lack confidence, it's harder to focus on the information being
communicated and the interactions themselves are less satisfying. You may be less inclined to give
speakers what they want, and they are less likely to help you or your organization to succeed.
There are several advantages to communicating confidently:
more focused on what's being communicated When you are confident, you can focus on the
message itself and on understanding its meaning accurately, without distortions caused by
insecurities. Your focus on what is communicated is also more likely to be mirrored by your
listeners, because they won't be distracted by insecure communication behaviors on your part. If
you're not worrying about how you come across, your listeners are less likely to focus on you and
will listen to what you have to say.
more satisfying When you're speaking with confidence, both you and your listeners will be
more relaxed and attentive. There is more harmonious communication, building a sense of
cooperation toward a shared goal. Ultimately, goodwill is generated, and you and your listeners
feel more satisfied.
more likely to get what you want When you are confident, people are more inclined to
respond to you positively. Your confidence enables others to feel comfortable too. This means
that they pay attention to what you are saying, so your message is clearer and has more
influence over your listeners. This results in more favorable responses to your suggestions.
1409

contributes to the success of your organization Being confident results in fewer
misunderstandings when communicating with colleagues, customers, and other parties. This
preempts many problems and can significantly increase the efficiency and effectiveness of your
organization. Additionally, being confident can give you more influence over customers or
suppliers, who'll sense a cooperative attitude. They are then more likely to want to continue doing
business with your organization.
Elements of confident communication
There are many situational and personal factors that affect the level of confidence you have when
communicating. These vary from situation to situation and person to person. Among the main factors that
affect confidence in most communication environments are how listeners feel about the speaker, the
communication history of the speaker, and the speaker's behavior during the communication including
how the speaker carries him or herself.
Experts in communication have identified the following key elements as enabling confident
communication:
trust This can be defined as the feeling you have that another person has good intentions and
shares information openly and honestly. For you to trust another person, he or she has to be
open to feedback and be able to admit to shortcomings. If you are open to feedback from others,
for example, it enables trust because people feel safer when their views are taken into account.
And when you know yourself to be trusted, you feel more confident.
credibility This can be defined as being convincing or believable to others. Listeners decide
whether a speaker is credible based on assessments of the speaker's motives, knowledge, and
truthfulness. If you consistently keep your promises and honor your commitments, for instance,
others find you credible. They can be sure that you keep your word. When others believe in what
you say, you develop more confidence. Additionally, if you are accurate in what you say, this
adds to your credibility.
confident behavior This consists of the actions and mannerisms associated with confident
communication. Open and relaxed body language, good posture, appropriate eye contact, and
clear speaking are all examples of confident behavior. Others feel more comfortable around you
when you behave confidently, and behaving in this way actually fosters a genuine feeling of
confidence on your part.
Trust and credibility are closely related concepts, but they are not identical. Trust resides with the
recipient, whereas credibility belongs to the speaker in other words, I trust you because you are credible
to me. Credibility is more rational, objective, and fact-based. Trust is more inherent and subjective. For
example, you may trust the bookkeeper in your organization for subjective reasons. However, her
credibility will be based on her training and work experience, and her history of honest and accurate
communication.
To create confident communication, you need all three elements in place. If one is missing, your
confidence will be eroded and information will not be effectively communicated. If you lack the trust of
your listeners or credibility among them, you cannot communicate with them effectively just by behaving
1410

or trying to behave confidently. Additionally, it's not possible to achieve credibility in an environment of
mistrust, or vice versa.
Lack of confidence when communicating is a stressful problem, which can make it difficult for you to
interact effectively with others. Although lack of confidence can manifest itself in a variety of ways, it is
usually caused by a feeling of fear. Anyone can become confident with practice once they understand
how confidence is built. The key to building confidence is to earn the trust of others, establish your
credibility, and carry yourself in a confident way. If you achieve these three goals, you can become a
confident communicator.
The Use and Impact of Confident Communication Behaviors
Preparing for confident communication
Speaking with confidence takes preparation and practice. When preparing to communicate, you need to
keep a few key points in mind:
develop your personal image Being comfortable in your clothing and dressing appropriately
for the occasion help you to feel more confident.
know what you want to say This helps you to feel prepared and competent. So you need to
prepare your message ahead of time if you think you might have trouble conveying it. Consider
where your message may be unclear, because people don't always ask questions. Ensure the
message is simple and specific, and includes arguments or examples to support your main
points. Knowing what your audience wants and what their interests are can help you to speak to
those interests while conveying your message.
address fears and self-talk You may find that you are worrying when speaking, telling yourself
that you will make mistakes or be rejected by your listeners. This type of self-talk erodes your
confidence and increases stress. Another useful strategy is to imagine the worst possible
outcome, and prepare yourself for it. If you are prepared, you are even more likely to succeed.
Confident vocalization
Your voice and how you use it are important aspects of confident interpersonal communication. The
critical areas to focus on are as follows:
inflection Your voice's inflection is how it rises and falls as you speak. Without inflection, you
will speak in a monotone, which is boring for listeners to follow. When your inflection or pitch goes
down at the end of a sentence, it shows certainty and is authoritative. When your inflection goes
up at the end of a sentence, it indicates a question or uncertainty.
volume A confident voice is audible but not overpowering. If you shout, your audience will back
away from your message. If you speak very quietly, people will struggle to hear you and may
become frustrated or disinterested. Speaking audibly engenders confidence in the speaker as
well as conveying confidence to the listener. People are more likely to overrule what you say if
they struggle to hear it, which can create a cycle of weakening confidence. If you know that your
voice is too quiet, practice speaking more loudly and opening your mouth to accentuate each
word.
1411

tone When speaking, you need to ensure that your tone matches what you want to say. If
people think that you are joking when you are serious, you are not getting your message across.
Typically, people find a lower tone more authoritative than a higher-pitched tone.
speed The speed at which you talk affects your confidence and the confidence your audience
has in you. Confident speech is typically fluent and slow enough for people to follow with ease,
and free of lengthy pauses. Speaking rapidly often indicates nervousness and makes it difficult for
a listener to follow your message. This is especially problematic when speaking in groups,
because people in group situations are less likely to ask you to slow down. If you hesitate or
pause frequently when you speak, your listeners will sense your uncertainty and may become
bored waiting for your message to arrive. If you prepare well, you will hesitate less.
Confident body language
How you use your voice can affect your projection of confidence when communicating. So can how you
use your body. Confident communication relies on a few key items:
posture How you carry yourself tells your listeners something about you and about how you
feel about your listeners. Standing tall with your hands loosely by your sides shows that you are
alert and relaxed. If you are sitting, you should sit upright with your arms by your sides, resting
either on the arm rests, the seat, or on your thighs. A posture that is alert and relaxed helps you
to become more alert and relaxed, and conveys confidence in yourself and interest in your
audience.
eye contact A steady gaze mixed with brief periods of looking away can be used to convey
respect and interest in a person, and will enhance your message.
gestures and facial expressions These are important ways of conveying information. If they
don't match your words, you'll give mixed messages and appear inauthentic or unconvincing.
Smiling and using open, relaxed, spontaneous gestures convey a relaxed warmth and build
confidence.
If your posture is rigid and tense, you communicate insecurity or anxiety. If you slouch, you convey a lack
of interest in your audience. Avoiding eye contact can cause you to miss important responses from your
listeners, distances you from them, and conveys a lack of self-confidence. But excessive eye contact is
considered rude. Worrying or criticizing yourself reduces your confidence and your ability to
communicate. When you notice negative thoughts, replace them with positive and encouraging thoughts.
Encouraging thoughts support you in your task and give you the confidence you need to succeed.
It's helpful to pay attention to how your body feels. If your heartbeat is high, your stomach is queasy, or
you feel tension in your muscles, you are probably feeling anxious. By focusing on your breathing and
consciously relaxing your muscles, you can calm yourself.
When preparing to communicate, you need to ensure that your appearance projects the image that you
want it to. You should be clear about what you want to say, why you want to say it, and who your
audience is. You should also prevent negative self-talk and ease your anxiety by ensuring you're
prepared for the worst possible outcome, so you know you'll be able to handle this. To use your voice
confidently, take note of how you use inflections, tone, volume, and speed. Confident body language
includes alert and relaxed posture, and good eye contact. You should use spontaneous and open
1412

gestures to add meaning to your message, and ensure your facial expressions match the content of your
message.
Trust, Credibility, Rapport, and Confidence
Trust
Without trust as a cornerstone, communicating is difficult. With trust, confident communication is much
easier. If you can build trust in interpersonal communication, each person is able to express themselves
more confidently. All communicating parties must trust one another for interpersonal communication to
really work. This means you need to try to trust others to enable them to trust you too. This trust is not
instantaneous. It develops step by step, over time. Trust takes work; it needs to be practiced and earned
before a low-trust environment can turn into a high-trust environment.
People in low-trust environments are suspicious of others' motives. When interpreting why others behave
they way they do, people tend to assume the worst. This generally leads to more misunderstandings, low
morale, and poor relationships. In higher-trust work environments, people tend to assume that others'
motivations are positive. This leads to a greater willingness to try to understand one another, improved
morale, and more satisfying relationships.
It's clearly more beneficial and more comfortable to live and work in a high-trust environment. So building
communication trust is important. To build this trust over time, you need to apply the following behavior:
communicate productively Communicating productively means communicating with the aim
of some positive or constructive outcome. Gossiping about someone's poor performance to a
colleague doesn't meet these criteria. However, directly approaching a person and letting him
know what he's doing right and how he might improve is productive. By giving constructive
feedback or criticism, you help someone improve. When speaking with respect, you demonstrate
that you value your relationship with the other party and further develop trust.
freely share information Freely sharing information means sharing all relevant information
with people who need to know it. It's primarily about being forthcoming with information that
others need. It doesn't include breaking confidentiality. When you share information, people feel
trusted and trustworthy. When you withhold information, people notice. This can result in anxiety,
misunderstandings, wild speculation, and a drop in trust and productivity.
be candid and truthful When you are truthful, you don't exaggerate, omit, or spin the truth.
This truthfulness provides the basis for trust. By being candid and truthful, you show your respect
for those you are communicating with and demonstrate that you trust them with the information.
accept constructive criticism Learning from your mistakes is one of the quickest ways to
grow and improve. By accepting constructive criticism, you show that you believe the person
providing the feedback is interested in your well-being. If people know that you can accept
constructive criticism gracefully, they won't be afraid of being truthful with you. Admitting it when
you're wrong ensures you don't waste energy on covering up mistakes. Without an environment
supportive of learning from mistakes, innovation is lost.
respect other parties' needs and interests Being a trustworthy communicator involves
respecting others, finding ways to speak to the other person's needs and interests, and honoring
1413

confidentiality. Breaches in confidentiality may cost you your job or a relationship. When
information is sensitive or confidential, it's helpful to say you aren't able to share all the
information. In this way, people feel informed, and that they can trust you with confidential
information themselves. Respect for others and yourself fosters trust and also helps you become
more confident and less self-critical.
Credibility
Communicating in a way that builds trust increases your credibility as a communicator and your rapport
with others. Credibility depends to a great extent on trust. And trust is dependent on credibility. If you
have credibility, what you say is believable and people trust it. If people don't trust you, they won't believe
you and you will lose credibility.
Trust-building behaviors create credibility over time, but this credibility is fragile and can be undermined or
destroyed by just a few actions or words. First, admitting it when you're wrong enhances your sincerity in
others' eyes and so builds your credibility. Not admitting your mistakes undermines both credibility and
trust. Second, a reputation for exaggeration undermines people's belief in your honesty and candor.
These behaviors can ruin your credibility.
In addition to trust, a number of other factors can help to build your credibility:
background There's a direct connection between credibility and your background, previous
positions, successes, or accumulated expertise. Your background shapes people's perceptions of
you.
behaviors Extrinsic behaviors can project competence and increase your credibility. This
aspect of building credibility comes from your knowledge of the subject matter, use of confident
body language, and the tone of voice that you use to deliver your message.
To build credibility, your behavior should foster trust and project confidence. These factors constantly
interact to either increase or decrease your own and your audience's confidence in you. Increasing your
credibility increases your confidence when communicating because you know others will have faith in
what you are communicating.
Rapport and confidence
The more your audience trusts you and believes in your credibility, the more you will feel confident when
communicating. Increasing your trust and credibility strengthens your rapport with people. Through
strengthening rapport in your relationships, you are better able to communicate confidently and influence
others. By building trust, credibility, and rapport, you also help others to communicate confidently with
you. So everyone in the relationship benefits.
The basic building block for confident communication is trust. You foster trust through specific behaviors
such as being candid, admitting your errors, respecting others, and disclosing information freely. These
trust-building behaviors contribute to your credibility as a communicator. Other factors that bolster
credibility are your background, knowledge, and how you project competence when you communicate. By
improving trust and credibility, you generate rapport between yourself and your audience. This process is
1414

ongoing, interdependent, and fragile, so you need to be consistent. As rapport grows, you will gain
confidence in yourself. Your audience will also gain confidence in you and will be more confident when
talking to you.


























1415

Business Writing: How to Write Clearly and Concisely
SkillBriefs
Techniques for Writing Clearly
Explore the techniques you use to write clear sentences.
Applying the Techniques of Concise Writing
Discover the techniques you use to write concisely.
Organizing Content to Increase Understanding
Understand the most effective ways to organize content.
Techniques for Writing Clearly
Often the importance of writing clearly in business is overlooked. But poor writing can mean you fail to get
your message across, waste readers' time as they struggle to interpret what you mean, and make a bad
impression overall.
Clear writing needs to be read only once to be understood. It uses simple, straightforward words. In
addition, it presents relevant examples those that relate to readers' experiences.
Specific guidelines can help you ensure your writing is clear.
Using short, familiar words
Business writing needs to be direct. So you should use short, familiar words that are easy to understand.
Whenever there's a choice, use words with fewer syllables. As well as being easier to read, these make
more of an impact.
As well as using shorter words, you should choose familiar words those that most readers are likely to
know. Using too many uncommon words can make your writing harder to follow. It can also come across
as stuffy, pretentious, or even silly.
So as you write, it's a good idea to replace long words with shorter, simpler equivalents. Remember that
using a formal or respectful tone doesn't have to involve being wordy.
Similarly, you should replace uncommon words with more familiar equivalents.
Another aspect of keeping your words short and familiar is avoiding industry-specific jargon, or
"corporatese." Within organizations, it can be common for employees to develop acronyms and words
that are specific to their work environments. It's best to avoid these in your writing because they might not
be understood by people outside your organization, or by new staff.
There are times when you need to use technical terms or jargon. In these instances, ensure that you
initially define the terms or provide equivalents.
1416

You should also limit the use of cliches in your writing. These are stock phrases that have little impact
because they're overused. In modern business writing, they often add to the length but not the meaning of
a message.
As well as avoiding cliches, you should avoid euphemisms. These are indirect terms that disguise or
"soften" your intended meaning. In some cases, a euphemism is appropriate because it shows sensitivity
to the reader's feelings.
Being concrete and specific
Concrete nouns refer to or name particular things, ideas, or actions.
They vary in how specific they are. For example, you can move from identifying a broad category of
entities to being highly specific.
Typically, concrete words answer questions like who, what, where, when, why, or how. In other words,
they provide concrete information.
More abstract nouns name entities that aren't easy to visualize or sense. They often refer to qualities and
ideas for example, management, culture, or freedom. Although you may sometimes use them, they can
be vague and have less impact. Often replacing more abstract words with concrete ones can make your
writing clearer and easier to follow.
Using appropriate connotations
In addition to their literal meanings, words can have connotations or implied meanings. These often
have emotional associations.
Words with similar meanings like "aggressive" and "assertive" can have different connotations. It's
important to choose your words carefully based on what you want to convey. If you're not sure whether a
word has a particular connotation, you can refer to an unabridged dictionary or word usage guide.
Revising noun clusters
Noun clusters are groups of nouns that aren't separated by functional words, such as articles and
prepositions.
The aim of clear writing is not simply to convey your message in as few words as possible. Sentences
also become clearer when you add functional words.
Using adjectives and adverbs sparingly
Strong nouns and verbs are the framework of well-written sentences. And although modifiers like adverbs
and adjectives can help create more accurate and complete images in the mind of your readers, you
should use them sparingly.
1417

This is because using too many modifiers can detract from the importance of a message and make it
harder to follow. When you take out the unnecessary modifiers in the sample text, its meaning becomes
clearer.
Generally, you should use adjectives and adverbs only when they're really necessary to clarify the
meaning of your text.
Using transitional words and phrases
Another way to make your writing clear is to include appropriate transitional words or phrases. These
make it clear how the ideas in your writing are linked. For example, words like "but" and "however" tell
your reader that you're moving from one idea to a contrasting one. Words like "therefore" indicate you're
moving from an explanation into a conclusion. Transitional words can come at the beginning, middle, or
end of a sentence.
And transitional words can be used to indicate several types of connections:
the addition of one idea to another, showing the reader that you are adding more information to
what you have already stated
a concession about an initial idea, or showing compromise or allowance within text
a logical relationship, in which one idea leads to another or relates logically to another
place or direction
any similarity or difference between elements within text
time or sequence, connecting ideas and text by means of succession, progression, or time
Sometimes sentences don't make sense or are unclear because they need a transitional word or phrase.
Using transitions effectively can help make your writing more clear.
In a business context, it's especially important to write clearly. Techniques to help you do this include
using simple, familiar words, being concrete and specific, and choosing words with appropriate
connotations. In addition, you should avoid long noun clusters, use adverbs and adjectives sparingly, and
include appropriate transitional words and phrases.
Applying the Techniques of Concise Writing
A common complaint from business people about the text they have to read at work is that it's too wordy.
Using more words than you have to can bury the core purpose of a message. And it forces readers to
work harder to identify what you mean, which wastes time.
In all business writing, it's vital to be concise. Concise writing is clear, focused, and uncluttered. It
conveys ideas in as few words as possible, without watering them down.
You can use four simple techniques for writing more concisely.
1418

Write short sentences
Readers lose attention when text contains long sentences. This makes it more likely they'll miss vital
information or have to read the same text more than once.
So, ideally, you should aim to include a maximum of 15 to 17 words per sentence.
Where possible, write some longer sentences as well as short ones to add more variety and rhythm to
your writing. Remember, text can become rigid and boring if all sentences are the same length.
The easiest way to keep sentences short and to the point is to ensure you include only one idea in each
sentence.
Avoid unnecessary words
Avoiding unnecessary words can help you write concisely. Some words can pad or clutter sentences
without adding to their meaning. Removing them makes messages clearer and more direct.
So how do you identify which words can be cut out of the sentences you write? You can delete these
types of words because they don't add any meaning:
long prepositional phrases
unnecessary repetition, where more than one word or phrase means the same thing
unnecessary sentence starters, which lead into the message
unnecessary phrases that can be replaced by single words
long-winded conjunctions
unnecessary modifiers, such as adjectives and adverbs that don't add meaning
The trick to avoiding unnecessary words is to identify what it is you wish to communicate to your readers.
This will enable you to cut out any words that don't assist in conveying your message.
Once the unnecessary words are identified and removed, the message becomes more direct and
concise.
It's also important to eliminate any unnecessary repetition in your text. Including more than one word or
phrase that means the same thing just leads to cluttered writing.
Use precise verbs
Choosing precise verbs is another way to make your writing more concise. A verb is a word or group of
words indicating the action or state of being of the subject in a sentence.
Verbs tell the reader that something exists, acts in a certain way, or has certain features.
1419

As a writer, you can use fewer words to greater effect when you replace long strings of words containing
vague verbs with more precise verbs. This adds force and impact to your writing.
Forms of the verb "to be" such as am, are, is, was, were, being, and been are the most commonly
used vague verbs. Often you can replace them with more precise action verbs to create more concise
sentences.
Other verbs, especially those that don't indicate action such as "do," "exist," and "perform" are often
used vaguely. If you add more words to clarify the meaning of these vague verbs, the combination may
make your document long and lifeless.
Again, it's better to substitute precise verbs for vague ones and their additional terms. In this way, you can
be more concise without having to sacrifice the clarity of your message.
It's also possible for verbs that signify an action to be far from precise. For instance, the verb "look" is an
action verb, but it's still vague. You may need to add other words to clarify the particular meaning of "look"
when used in a sentence. Alternatively, to be more concise, you can replace "look" with a more precise
verb, such as "glance," "observe," or "peer."
Precise verbs should also be used to replace vague verbs linked with nouns. Nouns are words that
designate a person, place, thing, state, or quality. In most sentences, you can replace verb-noun
combinations with one precise verb without losing any vital information.
Use the active voice
In the active voice, a basic sentence includes three main parts in a specific order:
first a subject, which identifies who or what performs an action
then a verb that identifies the action
finally an object, which is the entity acted upon
In the passive voice, this order is reversed.
In business writing, it's almost always best to use the active voice. This is because readers instinctively
expect a subject to come before a verb. Reversing this relationship by using the passive voice can slow
down a reader's understanding.
Overall, the active voice is more concise, direct, and forceful.
Although it's best to write in the active voice, there are times when the passive voice is appropriate. For
example, it might be important to be subtle about who was responsible for an action or you may not know
it. Sometimes using the odd passive sentence can help vary your writing style but using this voice
shouldn't become the norm.
To help identify sentences written in the passive voice, you can ask yourself three questions:
1420

Who or what is the actor? In other words, what is the subject?
What is the action or verb?
What has been acted upon? This is the object of the sentence.
Concise writing is succinct and direct. It includes only the words required to convey a message effectively.
Techniques for writing concisely include using short sentences, avoiding unnecessary words, using
precise verbs wherever possible, and writing in the active voice rather than in the passive voice.
Organizing Content to Increase Understanding
As a business writer, organizing your content is an essential part of the writing process. It involves
combining sentences into coherent paragraphs, each of which has a clear purpose.
The two key benefits of organizing your content well are as follows:
it's easier to follow Your sentences may be clear and concise, but if they're not logically
connected, or your main point is buried in a third paragraph, they may frustrate and confuse your
readers. Organizing content so each element of a document leads clearly and logically into the
next helps "lead" the reader through a document.
it's easier to understand Organizing content well involves arranging it so that your purpose in
writing is immediately clear. Further content should then support or expand on the main idea
you're presenting. Doing this makes it far more likely readers will understand what you need to
communicate. In turn, this makes it more likely they'll respond in the way you hope.
There's no one best way to organize a business document. Ultimately, this will depend on who you're
writing for and on what your purpose is.
Methods of organizing content
Four techniques can help you organize the content of your writing well.
Include an introduction
Your introduction should grab your readers' attention. Most readers are busy and need to be persuaded
that it's worth their time to read your message. Include a hook that encourages the reader to continue
reading such as a general statement, a question, or an interesting fact. Your introduction should also
include a brief statement of your key message and an explanation of the purpose of your document.
A poor introduction fails to engage your reader with the rest of your text and does not get the message
across to your audience effectively. A weak introduction can even confuse a reader and create some
doubt as to what they're reading about.
1421

A good introduction serves to set the context for the reader from the outset so that they're clear about
what the text is dealing with.
Ensure the body of the document supports the main idea
The body of a document is where you present the most information. It's important to remember that all
this information should support or expand on the main idea outlined in your introduction.
The body may include background details, supporting facts and statistics, anecdotes, or any other
information readers need to understand the main idea of the text.
The most important information should come first so it gets the reader's attention.
If the body of a document must contain anything more than a few sentences, you should divide the text
into paragraphs. This will make it easier to read.
However, it's common for writers to start new paragraphs as soon as it appears as if there's a big enough
chunk of text on the page. This is a mistake. Instead, paragraphs should group ideas logically. Using
them should be a conscious part of how you get your message across.
A good paragraph starts with a topic sentence. This provides the reader with a core point. Further
sentences in the paragraph then expand on this point.
As well as grouping sentences into logical paragraphs, you should consider how best to order your
paragraphs. These are like the building blocks for a message. It's important they flow in a logical order to
build an overall structure that will make sense to readers.
These are some of the ways you can choose to organize content in the body of a document:
in chronological order, if you're outlining a sequence of events or steps in a process
divided according to advantages and disadvantages, if you're presenting an argument
according to level of importance for example if you need to outline recommended actions
in categories, if you need to present, contrast, or compare different information types
Provide a clear conclusion to close the document
After the body of a document, it's important to add a clear conclusion. This provides closure.
It should also draw the reader back out from details in the body to the core purpose of your message. It
may restate the message, discuss its implications, or request action.
Use design and layout features to improve clarity
Several aspects of a document's layout and design can affect readers' comprehension of text:
1422

white space White space helps readers "breathe" as they navigate text. It makes text less
dense and easier to digest. One good way to include white space is to ensure there's a large
enough margin generally of at least 25 millimeters between your text and the edges of the
page.
graphics Appropriate graphics add visual interest and convey information, sometimes much
more clearly than text alone. However, adding unnecessary graphics can detract from your
message.
short lines Short lines of text that don't all end at the same point are easier to read than long
sentences of uniform length.
bullets Bulleted lists are useful for presenting logically related points clearly and concisely. Use
them for when they assist in the logical flow of information.
headings Headings contribute significantly to the structure of text. They make it clear how text
has been grouped and help break it into sections that are easy for a reader to identify. Once
you've grouped points logically, you'll be able to identify where headings are required.
Ensuring the content in business documents you write is well organized will make your writing easier to
follow and understand.
Techniques for doing this include using an introduction to grab the reader's attention and outline your
main message, following this with body text that supports the main message, and ending with a suitable
conclusion. In addition, you should consider how the layout and design of a document can make it easier
for readers to understand.














1423

The Components of the Communication Process
The Flow of Business Communication
How to Prepare for a Communication
How to Properly Send Messages
How to Properly Receive Messages
Five Barriers to Effective Communication
Understanding Verbal and Non-verbal Communication
Using Formal Business Communication
Using Informal Business Communication
The Components of the Communication Process

The successful administrative support professional should not only have highly developed
organizational skills, but also should possess effective communications skills. Why do you
need to be a good communicator to be an effective administrative support professional?
Because an administrative support professional assists everyone in the running of an office,
and to do this job properly, you must be able to communicate well.
In a single day, it would not be extraordinary for an administrative support professional to
respond to a business letter, send a company-wide e-mail, greet prospective clients, transcribe
an oral memo, or send a voice mail message. Effective communications skills can help you
accomplish all these tasks properly and professionally.
To send clear messages, and to ensure the messages you send are correctly received, you first
have to understand how the communication process works, especially within a business
context. The communication process involves a series of actions that bring about a result
and that result is information exchange.
This process is composed of five major components: the sender, the receiver, the message, the
response, and mental filters. Keep in mind that these five components are active in every
communication, but they are not necessarily all active at the same time. The five components
of the communication process are described below.
1. The Sender
Two components of the communication process are linkedthe sender and the receiver. The
sender transmits the message to the receiver. If you have a sender and no receiver, or a
receiver and no sender, the communication process would be incomplete.
Senders are the source of messages, which they send to receivers. They use different media,
1424

such as speaking face-to-face or on the telephone, letters, e-mail, or video to transmit or give
information to receivers.
2. The Receiver
The receiver gets informationthe messagefrom a source such as letters, literature,
photographs, or people.
3. The Message
In the communication process, a message includes all the information sent. A message has
quantitative elementsthe actual words or images used in a message. A message can also
include qualitative elementsthe information that comes along with the words, which
communicates feelings and emotions through techniques such as intonation or body language.
4. The Response
The response is a confirmation that the message has been received and can include a desire for
clarification or a paraphrase of the message to demonstrate understanding. Depending on the
method of communication, the response may be delayed or there may be no response at all.
There can be a response only if there is a message, although not every message requires a
response.
5. Mental filters
Mental filters are created by experiences, upbringing, and culture. Consider how certain scents
evoke vivid memories and certain words elicit certain emotions in people. Messages pass
through these filters as they are sent and received. These filters affect how we perceive
messages and responses.
Mental filters encode messages as they are sent and decode messages as they are received.
They affect how you transmit messagesword choice, medium, and emotional contentand
affect how you understand a message that has been sent to you. Keep this in mind when
sending or receiving messages, since you need to account for how each person's mental filters
affect the information sent and received.
Remember, effective business communication is fundamental to your success as an
administrative support professional. By understanding the five components of the
communication process, you'll be on your way to communicating more effectively.


The Flow of Business Communication

It is important for an administrative support professional to know how communication travels.
This flow of business communication is constantly moving, and you need to know where it is
going.
Why is it important for administrative support professionals to understand the flow of business
communication? It is administrative support professionals who often send and receive internal
1425

and external messages, or set up communication exchanges between two different
participants. They need to know who to contact in order to perform these duties. Consider how
administrative support professionals in the following roles are involved in the flow of business
communication.
Information officers. Administrative support professionals often act as an information
nexus. They screen communication. Information flows through them; they direct the
flow and distribute the information to those who require it.
Office managers. Administrative support professionals may perform the duties of an
office manager. In many large organizations, they manage an office and are
responsible for many of the practical details of disseminating information internally
and externally.
Administrators. Bosses expect their assistants to look after detailsif bosses had to
provide detailed instructions for what they wanted done, they would just do it
themselves. An administrative support professional needs to be aware of the possible
participants in any business interaction.
In one day, you could talk to your boss, a colleague, a supplier, and a client. Talking with
these four people can be divided into two broad areasexternally and internally. The flow of
business communication externally and internally is examined below.
Externally
External business communication flows from within an organization to destinations outside of
that organization, and from outside to inside an organization. The external flow of business
communication travels in various directions outside of the company.
Administrative support professionals may have contact with many different external sources.
Participants in that communication include clients, suppliers, and partners. These three
external communication destinations are all external stakeholders in an organization.
Internally
Internal business communication flows to and from destinations within an organization. It is
important to know these internal destinations to ensure a message is received by the
appropriate person. The internal flow can be divided into four directionsdownward, upward,
lateral, and diagonal.
Downward communication takes place when someone communicates to a person who
works in a position below them. Downward communication only travels one way.
Upward communication also travels one way. It takes place when someone
communicates to a superior within the corporate structure.
Lateral communication is the most common. It takes place when one person
communicates with another person at the same responsibility level in the company.
Lateral communication travels both ways.
When someone from one department communicates with someone in a different
position in another department, or vice versa, it is called diagonal communication. It
1426

travels both ways.
Remember, the flow of business communication is constantly moving. As an administrative
support professional, you need to know in which directions business communication travels
both inside and outside of your organization, so you can communicate more effectively.




How to Prepare for a Communication

Clear communication is important to everyone. As an administrative support professional, you
need to be able to clearly and effectively communicate with people on all levels both inside
and outside your company. To ensure you communicate clearly, you first need to prepare for
communication before you can send and receive messages effectively.
Just as you stretch before you exercise, you should prepare before you send a message. Listed
below are three steps you can follow to prepare for a communication.
1. Know the purpose for the communication.
The first thing you should consider in the process of preparing to communicate is the reason
the message will be sent. In other words, you should know the purpose for the
communication. To understand the purpose, you should identify the target, or receiver, of the
message you will send. Then you can tailor your message to the specific needs and mental
filter of your target.
2. Prepare the information.
Once you have established the purpose of the communication, your next step is to prepare the
information. To prepare the information, you first have to gather it. Compile all the necessary
concepts, numbers, and visuals for the message. Then you may have to process the
information you have gathered. You may have to give it a sense of order, make it presentable
and user-friendly, and turn it into a logically flowing and understandable document.
3. Choose the medium.
In the final step of preparing to send a message, you must choose a medium for the message.
The word medium is defined as an agency by which information is conveyed or transferred.
There are many different media you can use: phone, e-mail, fax, letter, and your own voice.
When making decisions on media, consider different aspects of the information you will send,
such as style, priority, size, and the receiver.
Remember, it's important to prepare for communication in any business. By following the
three steps outlined above, you can ensure that you are prepared to communicate, so that your
message is clear and effective and achieves the results you seek.
1427

How to Properly Send Messages

As an administrative support professional, you probably communicate with others in any
number of waysby telephone, fax, e-mail, or face-to-face. No matter what form of
communication you use, your success will depend on your ability to communicate your
message clearly with people both inside and outside your organization. To do that, you first
have to prepare for communication, and then understand how to send a message properly.
To successfully send messages, you have to ensure that they are correctly received and
comprehended. For example, a message in a bottle is only successful when it is received and
the castaway is rescued. To ensure you send messages properly, you can follow a two-step
process, which is discussed below.
1. Transmit the information.
The first step in the process of sending messages is to transmit the information. The
information is made of all the concepts, ideas, and facts that need to be communicated through
the transmission. In order to have a clear message you need to make sure you transmit the
correct and complete information.
2. Verify the message is understood.
To verify a message, you need to make sure that the information you sent was received and
understood. Both sender and receiver are responsible for this action. The sender can request
verification, and the receiver should then respond in some way. Verification methods include
the following.
Paraphrase. A paraphrase is a restatement of a transmission using different words. A
paraphrase shows reception and comprehension of a message.
Clarification. Clarification involves asking questions concerning certain details of a
transmission while repeating certain parts. It shows that a message is received, but the
receiver requires more information in order to fully comprehend the message.
Confirmation. Confirmation establishes that a message has reached its destination. It
shows reception. Confirmation can be combined with paraphrase or clarification to
help show that the message is understood.
Remember, to properly send a message, you first should transmit the information, and then
verify that the message is understood. By following these two simple steps, you can
communicate more effectively and successfully, which will help make you a better
administrative support professional.





1428

How to Properly Receive Messages

As an administrative support professional, you can follow several steps to ensure you
communicate clearly with others. The first step is to prepare for your communication, and the
second step is to send the message. The third element of effective communicationreceiving
the messageis equally important.
You probably receive various office messages throughout your day. It's important to listen to
these messages. Successful administrative support professionals use effective listening skills
to help them receive messages. In addition, effective listening skills can help prevent
communication barriers.
Listening is a matter of focusing your attention on receiving a message. To listen to messages
effectively, you can follow the four tips listed below.
1. Be prepared.
An effective listener is a prepared listener. Prepare to receive a message in any interaction.
Preparation helps you focus on receiving a message and avoid distractions. To be properly
prepared, you should have a method to record the information, make sure you're in a
comfortable position, and ensure you are familiar with the points to be discussed.
2. Listen actively.
Effective listeners are active listeners. Successful listening is not passive because the receiver
has responsibilities. Administrative support professionals should employ active listening
techniques when they receive messages. These techniques help them to take on the role of an
alert participant in the communication process. Specifically, an active listener focuses,
interacts with the speaker, and takes notes.
3. Avoid anticipating what will be said.
An effective listener avoids anticipating what will be said in a communication interaction.
Simply listen to a message as it is sent. When you anticipate what a speaker will say, you turn
your focus inward. You no longer focus on the message. Resist the urge to try and figure out
the end of the message before it arrives. Concentrate on the speaker and what is being said.
4. Debrief the message.
Debriefing a message is a great skill for effective listening. A message debrief will ensure that
the receiver has the correct information and will act on it, and helps counteract any
miscommunication due to individual mental filters.
Debriefing may be a form of self-evaluation, it may be a group discussion, or it may involve
only the sender and receiver of a message. There are three main steps of debriefing a message.
Recycling involves considering the message sent to you. Turn it over in your head and
make sure you understand the content. Then provide the sender with feedback on the
content of the message.
Clarify the content of the message with the sender, if necessary. Always review your
1429

own thoughts and notes. Make sure you understand your responsibilities concerning
messages sent, ensuring all details are correct.
Perform any actions required by the content of the communication. Take responsibility
and ownership of the message that was sent to you.
As an administrative support professional, you need to be able to successfully receive
messages. And to receive messages correctly, you will need to develop good listening skills.
Remember, properly receiving messages is an important step in effective communication

Five Barriers to Effective Communication

As an administrative support professional, you have to be able to communicate clearly with
individuals both inside and outside your organization. Clear communication involves a
number of elements. You first have to prepare for communication, and then effectively send
your message and receive other messages. In addition, you have to be able to identify and
remove barriers to communication.
Though there are many possible barriers to effective business communication, five of the most
common are discussed below. By working to remove these barriers, you can communicate
more clearly and effectively.
1. Different perspectives
One barrier to communication is that people view situations differently, and process and
communicate information from different perspectives. You may speak the same language, but
you see things entirely differently.
Perspective is defined as appearance of something relative to a viewer. Having differing
perspectives can be a barrier to effective communication between two people, but is more
likely to occur when communication is taking place within a group. The larger the number of
involved individuals, the more differing perspectives there will be. To overcome this barrier,
consider whole situations and encourage the participants to see the benefits of others' points of
view.
2. Bias
Biases, which can be a barrier to communication in any office, are preconceived judgments or
opinions. Bias is not necessarily wrong. Everyone has preferences or "favorites." However, a
barrier to communication can arise when people with different biases communicate.
Bias is not necessarily about people, but may include certain words, music, pictures, or
presentation styles. Some people have stronger or more comparatively marked biases than
others. These biases act as barriers in a few waysfor example, one prejudges a situation and
is not able to openly communicate. The stronger the bias, the stronger the mental filter, and
the more difficult for that person to receive the message.
Biases can create situations in which people only see what they wish to see. It is important to
recognize when bias is the reason for communication problems. Everyone has biases
1430

overcoming them is a matter of communicating beyond them. To resolve the problem, those
involved need to consider the other person's values.
3. Different organizational structures
Generally, organizational structures can be either strict or loose. Strict, or formal,
organizational structures are characterized by regulated actions, strict rules, and a strong
command structure. In a company with a loose organizational structure, any employee has the
freedom to communicate with all management levels, and interactions are less structured.
Communication barriers in strict organizations can result from an inability to communicate
outside a command chain, and feelings of intimidation. In a loose structure, communication
may not arrive at its appropriate destination, or it may be unclear. Communication barriers
also can arise when people from conflicting organizational backgrounds interact. To resolve
this problem, ensure that all employees understand how to communicate appropriately within
the company, and provide training for new employees when necessary.
4. Word choice
Word choice can be a barrier to effective communication. This barrier often creates confused
or unclear messages. There are two specific types of problems caused by word choices. One
involves semantic differences. This is when the words you use may mean one thing to you but
something different to others. The other involves business jargon, which is the inside language
of an organization. It can include the use of acronyms and codes.
You need to ensure that the words you say and the meanings you associate with them are clear
to the others involved in your communication interactions. Be sure to choose your words
carefully, avoid the use of jargon, and always check for understanding when you communicate
a message.
5. Difficulty reading the written word
There are many people around the world who have some level of reading difficulty. The
difficulty may be the result of dyslexia, illiteracy, or visual impairment. In these cases, the
administrative support professional should consider different ways of communicating, make a
special effort to communicate clearly, and refrain from making judgments.
Remember, as an administrative support professional, you'll encounter various types of
barriers as you strive to communicate clearly with others. Be on the lookout for these barriers,
and use the strategies described above to overcome them. Only by recognizing and removing
these barriers to communication can you ensure that all your messages are clearly received
and understood.




Understanding Verbal and Non-verbal Communication
1431


To communicate clearly and effectively with others both inside and outside your organization,
you can use several types of business communication. Understanding the different types of
communication will help you to fully and successfully communicate your ideas, and maintain
an open dialogue with those involved. The first two types of communication you will use
frequently during your business day are verbal and non-verbal communication.
In a face-to-face interaction, approximately 7 percent of a message's meaning is transmitted
verbally, and as much as 93 percent is transmitted non-verbally. However, in situations where
the non-verbal element is reduced or completely removed from an interaction, the importance
of the verbal element of a message can increase up to 93 percent.
Verbal communication consists of two components: written and oral. A written message is
just thatanything written. An oral message is anything spoken. Typically, if you work in an
office with a lot of human traffic, you would use more oral communication. If you are
responsible for document or number processing, you probably would use written
communication more often.
The major element of a face-to-face communication is the non-verbal element. There are three
components of non-verbal communication.
1. Body language. People use body language to communicate all sorts of messages.
Body language is comprised of facial expressions, posture, and movement and
positioning of body parts.
2. Physical space. Many people communicate emotions and feelings with the amount of
physical space they leave as a buffer between themselves and others.
3. Paralanguage. Paralanguage is composed of the sounds people make that
communicate emotion and focus level, such as laughter or saying "uh-huh."
The important point to remember in communication situations that involve both elements is
that your verbal and non-verbal messages should match. If they don't, then receivers may be
confused by mixed messages.
The verbal and non-verbal messages you send in face-to-face situations need to match. They
should also match when you talk on the phone. Think about when you smile on the phone.
The person on the other end realizes it. This helps the receiver understand the message you are
conveying.
The non-verbal element is non-existent in written verbal communication. If you need to
communicate non-verbal tone and emotion in a written document, then you should use
appropriate and precise wording.
Remember, to communicate to your full potential, you must ensure that your verbal and non-
verbal elements match. Also, when you send written messages, consider how much the written
words must compensate for the lack of non-verbal cues. By being aware of the verbal and
non-verbal types of communication you use during the business day, you can more effectively
1432

and successfully deliver all your messages.




Using Formal Business Communication

Administrative support professionals may not dress in a formal uniform every day, but it is
likely they send and receive formal messages often. Formal communication, which is one of
four types of business communication you can use, involves a set of six socially known rules,
and is determined by an individual's relative position to another individual hierarchically,
relationally, or culturally.
Differences in relative position govern your decision to follow the rules of formal
communication. Use the formal communication rules whenusing yourself as the median
the person with whom you interact has a different position in one, or all, of the following
ways.
You may not have the same position hierarchically as the person with whom you are
interacting. In other words, you and this person hold different positions of authority
and responsibility within your company.
Your relative position relationally with someone dictates the type of interaction. To
discover this position, ask yourself how close you are to the receiver on a personal
level.
Your cultural position with an individual often depends on the social situations in
which you find yourselves. Your culture also can dictate that you use formal
communication with certain people no matter what situation you are in.
Communication interactions are generally formal with the following types of people: office
superiors, clients, and people you're meeting for the first time. Sometimes it is difficult to
identify formal communication situations within an office setting. The main point to
remember is this: If you doubt how comfortable your relationship with someone is, use formal
communication.
Communicating in formal business interactions is a matter of following certain rules. These
rules help guide your actions and manner of communicating. Administrative support
professionals should consider these rules and incorporate them into their work habits. The six
main rules to follow in formal business communication situations are listed below.
1. Use last names. Using last names maintains a level of formality in any interaction. It
also is a way to demonstrate your respect for someone. Include social titles with the
last name, such as Mr. or Ms.
2. Refrain from joking and using sarcasm. Some people may not have the same sense
of humor as you do. In order not to offend or exclude someone, it is important to
1433

refrain from joking or using sarcasm.
3. Show respect for the person. This is characterized by gracious consideration toward
others. You should courteously defer to those you interact with in formal situations.
4. Act your title. This means acting only in your capacity as an administrative support
professional. Maintain a professional tone during your conversation.
5. Confine communication to business matters. The parameters of your formal
conversations should be within the confines of the business realm. Stay away from
personal topics such as religion or politics. Generally, stick to business discussions.
6. Use quiet body language. Close physical space implies a close or intimate
relationship. Formality requires that a safe relational distance, and thus a safe physical
distance, be maintained. Likewise, use small non-verbal actions. Keep your arms next
to your sides and make small gestures with your hands.
Don't let formal situations intimidate you. As an administrative support professional, you will
deal with them often. Just remember to use formal communication whenever you're in doubt
about your relationship with another person, and keep the six rules for formal interactions in
mind, and you'll find that you're much more effective and comfortable when communicating
with others.


Using Informal Business Communication

Informal business communication is an important type of communication for administrative
support professionals, because it promotes openness and friendliness in your office
environment. You'll use informal business communication daily in your office in unoffical
situations and in situations that are casual, such as relaxed gatherings or conversations with
friends.
However, identifying informal business communication situations can be difficult sometimes.
Identification depends upon the closeness and equality of your relationship with an individual,
and the organizational structure within which you work. You can be fairly certain that in the
situations below, you can follow the guidelines for informal communication.
Co-workers. When you are equal relationally, hierarchically, and culturally with your
co-workers, you can use informal communication.
Informal work structures. Internal communications in companies that have informal
organizational work structures use the informal business communication guidelines.
This covers situations such as receiving instructions from your supervisor or giving
instructions to someone hierarchically lower than yourself.
Long-time customers. Often, with customers you have known for a long time, you
can use informal communication, since your relative position relationally overrides the
regular formal situations.
When communicating informally with others, you can follow five main guidelines. Keep in
mind that you do not necessarily employ one guideline at a time in informal communication.
1434

They work together, though some will be more useful at different points of an interaction than
others. The five main guidelines to follow in informal business communication situations are
listed below.
1. Use first names. This demonstrates closeness and friendship, and is a major
demonstration of informality. Friends may be slightly offended if continually called by
their last names or social titles.
2. Respect the other person. This is characterized by gracious consideration toward
others. It's important to always respect and be sensitive to individuals. It is easier to
respect someone you know because you are already familiar with any issues of
contention and can act accordingly.
3. You can talk about personal things. Your discussion does not necessarily have to be
confined to business topics. Knowing someone makes conversation "safer." You can
range farther in topic discussion.
4. You can use humor and slang. You know each other, you know your sense of humor,
and there is less chance of offending anyone. Once again, knowing someone makes
conversation "safer" and more navigable.
5. You can use "loud" or big non-verbal actions. Loud non-verbals denote a high level
of comfort, such as when you use your hands and make large gestures, or emphasize a
point. This also can include reducing the personal space between you and the person
with whom you are interacting. It is less likely that you will intimidate the other
person.
Remember, informal communication situations involve those individuals with whom you have
close relationships culturally, hierarchically, and relationally. You will have these interactions
everyday with people you know. Keep in mind that the informal communication guidelines
listed above are flexible directions, but you should be familiar with them so you can
communicate appropriately and successfully in informal situations










Using Informal Business Communication

1435

Informal business communication is an important type of communication for administrative
support professionals, because it promotes openness and friendliness in your office
environment. You'll use informal business communication daily in your office in unoffical
situations and in situations that are casual, such as relaxed gatherings or conversations with
friends.
However, identifying informal business communication situations can be difficult sometimes.
Identification depends upon the closeness and equality of your relationship with an individual,
and the organizational structure within which you work. You can be fairly certain that in the
situations below, you can follow the guidelines for informal communication.
Co-workers. When you are equal relationally, hierarchically, and culturally with your
co-workers, you can use informal communication.
Informal work structures. Internal communications in companies that have informal
organizational work structures use the informal business communication guidelines.
This covers situations such as receiving instructions from your supervisor or giving
instructions to someone hierarchically lower than yourself.
Long-time customers. Often, with customers you have known for a long time, you
can use informal communication, since your relative position relationally overrides the
regular formal situations.
When communicating informally with others, you can follow five main guidelines. Keep in
mind that you do not necessarily employ one guideline at a time in informal communication.
They work together, though some will be more useful at different points of an interaction than
others. The five main guidelines to follow in informal business communication situations are
listed below.
1. Use first names. This demonstrates closeness and friendship, and is a major
demonstration of informality. Friends may be slightly offended if continually called by
their last names or social titles.
2. Respect the other person. This is characterized by gracious consideration toward
others. It's important to always respect and be sensitive to individuals. It is easier to
respect someone you know because you are already familiar with any issues of
contention and can act accordingly.
3. You can talk about personal things. Your discussion does not necessarily have to be
confined to business topics. Knowing someone makes conversation "safer." You can
range farther in topic discussion.
4. You can use humor and slang. You know each other, you know your sense of humor,
and there is less chance of offending anyone. Once again, knowing someone makes
conversation "safer" and more navigable.
5. You can use "loud" or big non-verbal actions. Loud non-verbals denote a high level
of comfort, such as when you use your hands and make large gestures, or emphasize a
point. This also can include reducing the personal space between you and the person
with whom you are interacting. It is less likely that you will intimidate the other
person.
1436

Remember, informal communication situations involve those individuals with whom you have
close relationships culturally, hierarchically, and relationally. You will have these interactions
everyday with people you know. Keep in mind that the informal communication guidelines
listed above are flexible directions, but you should be familiar with them so you can
communicate appropriately and successfully in informal situations



Developing an Effective VOICE
Your voice is a vital communication tool. You use your voice constantly to express thoughts, feelings,
ideas and hopes, but it is easy to take it for granted.
Speech is a complex process. Your lungs, windpipe, voice box, throat, tongue, soft palate, and lips all
work together to produce your words.
The vibrating column of air coming from your vocal chords is shaped into speech sounds by your lips,
tongue, soft palate, throat, jaw, and other facial muscles. These are called your moveable articulators.
As a communicator, you must be sensitive to the influence that the quality of your voice will have on the
receiver's interpretation of your message. Your objective is to speak with the right VOICE.
V is for volume
O is for output rate
I is for inflection
C is for clarity
E is for emphasis
The strength or loudness of your voice is reliant on the amount of air or breath your lungs produce during
the respiration stage. And the rate at which your vocal chords vibrate during the phonation stage controls
the pitch of your voice.
The output rate or speed of speech is another important aspect of speech. Rapid speech is sometimes
associated with knowledge and credibility. However, if you speak too quickly, listeners can't keep up. In
contrast, speaking too slowly gives your listeners the impression that you are unsure of your message.
They are also more likely to be distracted by other things as their minds have time to wander.
Pitch, or the highness or lowness of your voice, is one of the most difficult aspects to control. A high-
pitched voice may get attention, but it is irritating and difficult to listen to for any length of time. People
prefer lower-pitched voices, just as they prefer the tones of a church organ to the shriek of a fire siren. By
varying your pitch, you can add inflection to your voice. Inflection gives variety and emphasis to the
spoken word.
1437

When you speak in a monotone, without inflection, you do not express the emotion behind your message
and are unlikely to engage or maintain the listener's full interest.
Inflection also adds meaning. The same words, said with different inflection, can mean very different
things.
The clarity of your words is determined at the articulation stage by the movement of your articulators.
People with poor articulation skills produce sounds, syllables, and words incorrectly. Sometimes this is
caused by physical deformities that can be professionally treated, but it is more often the result of
incorrect pronunciation or sloppy enunciation.
Pronunciation has to do with saying a word the way a dictionary tells you it should be said. Sometimes
words are pronounced incorrectly because you aren't familiar with the word, or you may have learned to
pronounce it incorrectly.
Enunciation has to do with saying all the sounds in a word clearly by moving your tongue and lips fully.
Truncate - One type of enunciation error stems from truncating words or dropping the ends of
words, especially "g," "ing," "ed," "d," or "t." For example, "huntin', shootin', 'n fishin'" instead of
"hunting, shooting, and fishing."
Replace - Other times, you might replace sharp "t" sounds in the middle of words, with a softer
"d" sound because it requires less effort. For example, "better" might become "bedder."
Run together - Another cause of poor enunciation is running words together. "Whadidjagit?" and
"Wuzzup?" look strange when written but are common incorrect enunciations of "What did you
get?" and "What's up?"
Poor enunciation and incorrect pronunciation can prevent listeners from understanding you. They can
also cause listeners to focus on your manner of speaking rather than your words and their meaning. Poor
enunciation and incorrect pronunciation can be interpreted as signs of laziness, or even ignorance.
Ralph Waldo Emerson said, "A man's style is his mind's voice. Wooden minds, wooden voices." Because
your manner of speaking may be undermining your image and your message, you must become aware of
your VOICE. By studying your volume, output rate, inflection, clarity, and enunciation, you can begin to
develop a better manner of speaking, one more in keeping with the kind of image and message you want
to project.

Methods for Improving Your Voice
The best communicators know they must use their voices to hold their listeners' interest and add impact
to their messages. You may have pearls of wisdom to share, but if no one is listening, they will be wasted.
An inability to engage the attention of others for any length of time may not be because of what you are
saying, but instead because of how you are saying it.
1438

A good speaking voice is clear, enjoyable, and convincing. Not everyone is born with a voice with these
qualities, but they can be developed by focusing on the volume, speed, inflection and clarity of your voice.
1. Volume Some people talk too softly, others too loudly. The volume of your voice should be
dictated by the emotional and physical circumstances in which your conversation takes place.
2. Speed Some people talk very quickly, others very slowly. Although speaking more quickly is
associated with confidence, speaking too quickly can prevent people from understanding what
you are saying.
3. Inflection People who don't use varying pitch to add inflection have monotone voices that are
much less expressive and interesting than those who do. Inflection also gives additional meaning
to your words.
4. Clarity Poor articulation, in the form of incorrect pronunciation or sloppy enunciation, may take
less effort but can have an adverse effect on your professional image.
If you have a poor speaking voice, it can be a big barrier to the success of your interpersonal
communication. Fortunately, with the right exercises, voices can be reshaped, toned, and kept in good
condition. Appropriate vocal exercises will enable you to improve and maintain correct volume, intonation,
pitch, and articulation.
The ability to control the pressure and flow of air is a large part of developing an appealing voice. Air is
crucial to voice production and volume. It is the flow of air through the vocal tract that generates sound.
Therefore, most people see immediate results when they improve their breathing.
Using your chest muscles instead of your diaphragm results in shallow breathing and a potentially weak
voice. The good news is you don't have to learn how to use your diaphragm because you can already do
it! You were born breathing that way, and you breathe that way naturally when you sleep.
Diaphragmatic breathing is the best method for producing sufficient expiratory force to speak. It supports
your voice with a column of air that extends from your diaphragm to your mouth.
As well as generating enough breath to talk at an acceptable volume, your goal is to have sufficient
breath to be capable of vocal inflection. A monotone voice is usually due to a lack of awareness of how
you sound.
You can increase awareness and improve inflection by recording yourself reading aloud from a book,
newspaper, or magazine. Play it back and evaluate your performance. Repeat the exercise, making the
necessary adjustments. Each time you do this, you should hear marked improvement.
People prefer to listen to lower-pitched voices. Opening your mouth wider when you speak will add depth
to your voice. Be careful not to push your words out through your teeth like ventriloquists do that's why
their dummies talk in high-pitched voices. Their objective is to prevent their lips from moving. Your
objective is to produce a voice that people want to listen to.
1439

Also, avoid eating, chewing, or smoking while you are speaking. These activities make it difficult for you
to open your mouth, and this will force the pitch of your voice to go up. These activities also make it hard
to keep your lips moving and articulate your words correctly.
A failure to articulate or enunciate properly causes your words to be slurred and indistinct. Sloppy
enunciation means you don't say all the sounds in a word clearly and often drop the endings and the final
consonants.
At the same time, don't overdo your articulation. Over-enunciation sounds stilted and false, and makes
the speaker appear affected. The important thing is getting your words right, even if you have to speak at
a slightly slower rate to do so.
To improve your articulation, practice repeating the following sentences or "tongue twisters."
eleven benevolent elephants
girl gargoyle, guy gargoyle
rubber baby buggy bumpers
she stood on the balcony inexplicably mimicking him hiccupping and welcoming him in
One easy yet practical method of improving inflection, vocal range, and articulation is to sing. Depending
on your confidence, you might prefer to do this in private, perhaps when you're alone in the shower or in
the car. See how well you can carry a tune. Control phrasing and enunciate lyrics while using proper
diaphragmatic breathing.
Adopting better breathing and enunciation techniques help you to slow down if you talk too quickly. The
average rate of speech for English speakers in the United States is about 150 words per minute.
When you speak very rapidly, syllables and words run together without the usual pauses, making it
difficult or impossible for the listener to understand what is being said.
Your voice can be put under strain in the workplace. Some jobs require you to talk most of the day
without a break. Other jobs are undertaken in workplaces where the environmental conditions have an
adverse effect on the vocal mechanism itself.
Your vocal chords need plenty of moisture to work efficiently. It's important to avoid becoming dehydrated
by working in very dry environments. If you have to work in this type of situation, be sure to drink plenty of
water.
Dusty environments often contain allergens that can adversely affect your throat and upper respiratory
tract. As you know, a sore throat has an immediate impact on your voice.
Cigarette smoke, whether it's your own or secondary, is another drying agent. If you smoke, it would be
beneficial to your voice if you quit. If you don't smoke, avoid spending too much time in a smoky
atmosphere.
1440

A cold or upper respiratory tract viral infection is a common cause of laryngitis or temporary voice loss.
Keep yourself warm and you should be able to avoid becoming hoarse.
Many people injure their voices by working them too hard. Don't try to compete against the sounds of loud
machinery, loud music, or crowd noise.
It is important to be aware of how physical conditions impact your voice and take the necessary steps to
avert temporary or even permanent damage. Remember, although your voice can be improved, it cannot
be replaced. A healthy voice needs plenty of moisture so avoid agents that dehydrate the body, such as
alcohol and caffeine, and drink plenty of water.
Stress can affect your voice. When you are feeling tense or nervous, your throat muscles stiffen, raising
the pitch of your voice, and making it difficult for you to sound relaxed.
Inhale deeply through your nose, and hold your breath for three to five seconds. Now, slowly exhale
through the mouth until your lungs have completely emptied. Repeat until the tenseness in your shoulders
and neck subsides.
Voice development is not restricted to actors, singers, and public speakers. Many people realize that their
voices are important to their professional success and that they don't have to live with the voices they
were born with.
With the proper practice, everyone is capable of developing a resonant and appealing voice. Once you
own these vocal skills, you will command greater respect, and people will want to listen to you.
The Benefits of a Well-placed Pause
It is not just what you say and how you say it that has an impact on the success of your interpersonal
communication. Sometimes, not saying anything can improve the delivery of your message.
Silent pauses are a very versatile and useful communication tool. Pauses can be used deliberately to
express feelings such as: anger, confusion, disapproval, or disagreement. A pause can also be used to
gain, direct, or maintain the listener's attention.
Silent pauses
build suspense
emphasize particular elements of your spoken message
indicate that you are about to change the subject
shape your vocal delivery
Pauses can be used to make your voice sound more attractive and thereby sustain the listeners' attention
and interest. Pauses shape the rhythm of your speech and can, when executed well, enhance a speaking
voice by adding an almost musical quality to it.
1441

Pausing appropriately as you speak will prevent you from talking too fast. When you talk at an agreeable
speed, the reception of your message is improved because your listener has time to take in and decode
what you have said.
A pause can be used to signal that you are about to change the subject. This prepares listeners for the
change so they have a better chance of putting what they are about to hear in the right context.
Even when people listen to what you say, they don't take in and remember every word. You can use
silence to direct their attention to the more important part of your spoken message and emphasize a
particular point.
A brief pause before a word, a point, or a phrase acts as a verbal "space" and isolates the item from what
has gone before, making it stand out.
Pauses also help the listener commit multiple items to memory by preventing the details from running into
one convoluted and complex sentence.
Pauses should always be used before the point that you want to highlight, and not after. This is because
the listener focuses more intently on the first thing that you say after a pause than on anything that has
gone before.
People speak at a rate of 100 to 175 words per minute, but they listen at a rate of between 600 and 800
words per minute. So it's easy for their minds to wander occasionally. When people aren't completely
engaged in the conversation, they hear your voice as a rhythmic background hum. A longer pause that
disrupts this rhythm can help you get their attention again. When used this way, silence can be employed
to regain attention.
There is an old saying that "silence is golden." It certainly can be when it is used effectively to enhance
your communication and improve the listener's understanding of your message.
Understanding the Seven Levels of Listening
Listening is a vital part of the interpersonal communication process, and it is critical to both personal and
business relationships.
Most people are born with the ability to hear, but listening is a skill that has to be learned. Hearing is
simply the act of perceiving sound by the ear. Listening requires concentration to enable your brain to
process the meaning of words and sentences.
Listening is a process that involves seven stages:
1. During the first stage, you receive the "raw" sound. This will include all the background sounds
around you.
2. During the second stage, your mind selects the auditory stimuli on which you will concentrate and
filters out any other sounds.
1442

3. During stage three, you focus your attention on your chosen auditory stimuli.
4. Stage four involves assigning meaning to what you are hearing.
5. Suring the fifth stage, you evaluate what you are hearing, and decide what to do with the
information.
6. Stage six involves storing what you are hearing in your memory bank.
7. During stage seven, you actively respond to what you are hearing or have heard.
Now you can understand how it is possible to "hear" a conversation, but have no recollection of what was
said no matter how hard you tried. Mentally, you didn't progress past stage one.
There are four levels of listening effectiveness: hearing, passive, attentive, and active. The least effective
is hearing. The most effective is active. Your listening level is determined by how far along the 7-stage
listening process you progress and how mentally engaged you are at the various stages.
In terms of communicating, hearing can hardly be considered as listening at all. Although you physically
receive the auditory signals, nothing registers in your conscious mind.
Listening only truly begins once your mind is engaged in the process. This happens when you make a
conscious selection of the auditory stimulus on which you intend to concentrate. At that stage of the
process, you move up to the next level of effectiveness passive listening. When you listen passively,
you register the auditory signals, but you are not fully mentally and physically engaged in the
conversation. You therefore absorb very little information and use very little energy. Passive listening is
really little more than hearing.
Although you focus on specific auditory input, your mental involvement ends there. Most of the
information you acquire is lost within a couple of hours. In fact, you can lose it within a few seconds, such
as when you forget the name of the person to whom you have just been introduced.
Attentive listening commences as you move completely into the attending stage and start to listen with
the intention of understanding. You do listen and, at a superficial level, understand the words spoken.
However, you don't assign real meaning to them.
You won't "take in" everything you are told. What you do absorb is put in your short-term memory, and 80
percent of it will be lost within five days. You may be able to repeat most of the words right after you hear
them. However, you won't think about what they meant until later, if at all.
Active listening is the most effective. When you listen actively, you do so with the objective of
understanding the full meaning of the message and responding appropriately. You are totally focused on
the speaker and his message. Active listening requires you to
maintain conscious awareness throughout the conversation
evaluate the information received
internalize the parts you regard as important
make an appropriate response
1443

To listen at the most effective level, you have to be motivated and willing to make the effort to overcome
the various barriers that prevent you from being totally focused on the speaker and her message.
When you are talking to someone, you can often tell from certain physical behaviors at what level he or
she is listening. Even when people act as if they are really listening to you, certain telltale signs can give
them away. For example, if you speak to someone who is listening at the hearing level, you will likely be
ignored. The hearing listener is not connected to you or what you say.
When people listen passively, they are not really paying attention. However, they pretend they are by
occasionally grunting or making a similar sound to make you think you are being heard. They probably
aren't even looking at you, and if they do, it is with a glazed or unfocused expression. If you were to ask
them to repeat what you had just said, they would have a very hard time. The passive listener isn't really
connected to the conversation at all.
People who are listening attentively believe they are listening and will send physical signals of attention.
Attentive listeners use supporting body language, such as leaning toward the speaker, nodding, and
making eye contact.
Despite this apparent attention, they frequently fade in and out of the conversation as they move back to
the passive level. Sometimes, they will become focused on a specific point you have made but will then
ignore other parts of what is being said.
Later, they may be able to repeat what you said, but they have not truly understood what you meant. In
some respects, the attentive listener is more connected to the speaker than to the message.
Active listeners are easy to spot by the coherent responses they make to what you say. These responses
usually convey their intention to understand the full meaning of your message. Active listening may raise
the blood pressure and the pulse rate, and may even result in an increase in perspiration. So listeners at
the active level may show signs of physical exertion or tiredness while having an extended or detailed
discussion.
Miscommunication and misunderstanding are more likely to occur when someone listens at the lower
levels. To really listen, you need to be motivated to understand what is communicated and be prepared to
focus your whole attention on the speaker's verbal and non-verbal messages. By striving to progress
through the full listening process, the quality of your interpersonal communication will improve
significantly.


The Most Common Obstacles to Listening
Listening is more than just keeping quiet while the other person talks. Better listening requires you to
make both mental and physical effort. It also requires you to concentrate on the other person rather than
on yourself. It is because of these requirements that so few people listen successfully.
1444

True understanding in interpersonal communication can only be achieved by listening at the very highest
level. This requires the motivation to be totally focused on the speaker and the message.
External conditions, such as a noisy environment, can hinder or prevent you from listening effectively.
However, most barriers to good listening are created within the listener. Daydreaming, dress rehearsal,
"When is it my turn," information overload, aim to please, and tunnel listening are examples of
psychological states which present a barrier to good listening.
Daydreaming You are not listening because you have other things not related to the current
conversation on your mind. Whatever you are concentrating on, it is not this discussion.
Dress rehearsal You don't listen because you are busy thinking about what you are going to
say next. You may even look interested, but you have heard very little, if anything, of what has
been said.
"When is it my turn?" You are not listening because you are just waiting for an opportunity to
speak. The only thing you are listening for is a break in the conversationone that is long enough
for you to jump in with your opinion.
Information overload You are not listening because you decide the information is too difficult
to comprehend or too boring. You will switch on again when you are interested in what is being
said.
Aim to please You want to create a favorable impression with the speaker, so you nod and
make "agreeing" noises. Your objective is not to listen, but to demonstrate support or agreement.
Tunnel listening You are listening, but only to what you want to hear. Emotional filters prevent
you from hearing what you do not want to hear, so you can focus your attention only on what
pleases you.
These psychological barriers influence how much attention you focus on the communication, and they
dictate how you respond.
To listen well, you must delay thinking your own thoughts until the speaker has finished communicating.
You must also strive to understand the speaker's meaning. Unfortunately, most people listen with the
intent to respond and not with the objective to understand.
A negative prejudgment about the speaker or message affects your answer. You use your response to
fulfill your agenda for the exchange. You have no need to listen because you know what you want to
happen, regardless of what he says. Your replies indicate your unwillingness to understand the true
meaning of the words.
When you reply in this way, your focus is on finding things with which to disagree. This communication
model resembles that of the courtroom. You take what the other person says and try to disprove it.
People can be irritated by your attempts to shift the conversation your way. They may see it as a lack of
respect or an indication that you think the subject is unimportant. This kind of reply will frequently cause
speakers to become indignant and stick religiously to their point of view, therefore not listening to you at
all.
1445

Listening to others can be the most fundamental and powerful communication tool of all. When you
commit to stop talking and begin to really listen to other people, your interactions become easier,
communication problems are virtually eliminated, and conflict is greatly reduced.
Overcoming Self-made Barriers to Listening
Stephen Covey, author of the best seller, "The Seven Habits of Highly Successful People," teaches that
you can listen well only when you seek first to understand, then to be understood. Poor listening is
commonly caused by not focusing on the speaker and his message and instead, focusing on:
yourself
your emotions and opinions
your own thoughts
your reply
other distractions
If you frequently find yourself concentrating on getting your opportunity to talk, interrupting, or wanting to
change the subject, then it is unlikely you are listening attentively to what you are being told.
Active listeners speak 30 percent of the time and listen 70 percent of the time. If you interrupt or dominate
a conversation, this means that you are not listening effectively. You can overcome this tendency by
listening to the whole message without interrupting, even if you don't agree with or approve of it. Wait to
express your experience or point of view, and resist the temptation to speak for the sake of saying
something. Keep in mind, the only acceptable reason to interject is to clarify or confirm what has been
said.
If you must talk when speakers are sharing something important, use short responses. Longer responses
may cause the speaker to become impatient or divert him from his original train of thought.
Sometimes you may not listen because you are busy rehearsing your reply or thinking or day dreaming
about an unrelated subject. If this is a common occurrence, then you need to listen with a purpose.
Be motivated to listen by setting a goal. It may be to gain information, obtain directions or instructions,
solve problems, or understand how another person feels. Improve your ability to focus on what is being
said by treating listening as a challenge. Mentally structure and summarize the verbal content of the
communicated message by: indexing, sequencing, and comparing.
Indexing is the process of mentally noting the key points or ideas being discussed, together with
their associated and supporting points and items.
Sequencing is listening for order or priority. Sometimes the order of what you are being told is
important or even crucial.
1446

Comparing is concentrating on the points being made, and discriminating between fact and
theory, positive and negative, advantages and disadvantages. Then, you can evaluate the ideas,
options, attitudes, facts, feelings, and beliefs.
To listen well, you must overcome any tendency to rehearse your response or allow your attention to drift.
Give speakers your undivided attention. Look them in the eye when they are speaking active listeners
maintain eye contact for five seconds or more. Focus on the speaker, and only the speaker. Ignore
internal distractions, such as your own thoughts, and external disruptions, such as telephones ringing and
people talking.
Another barrier to listening is an emotional response. When you react too emotionally, you tend to hear
what you want to hear not what is actually being said. You may focus on one comment out of context.
You may only listen to some of what the other person says, filtering out the parts that don't confirm your
own views and opinions. Another temptation is to disengage mentally because you judge what the other
person is saying or will say is irrelevant, illogical, or inconsistent. You can prevent this from happening by
remaining neutral, objective, and open-minded.
Stay in tune with your own reactions and watch out for anger, boredom, or disinterest. Be aware of your
biases and emotional triggers. For example, such things as a speaker's bad grammar, limited vocabulary,
or accent might irritate you. Your awareness helps you control, or preferably eliminate, your emotional
reactions, allowing you to concentrate on the speaker's message and not on the delivery.
As a good listener, your behavior will demonstrate your intention to understand. Acknowledge speakers
both verbally and non-verbally, and encourage them to continue by using your responses and body
language to demonstrate your interest and attention. This requires you to
adopt an open, relaxed posture
face the other party, square on
lean slightly towards the other person
ask questions to confirm and clarify what is being said
Learning to overcome the self-made barriers to listening will help you to improve your ability to
communicate. Listening more attentively to others will help you come to understand the people around
you. Effective listening enables better collaboration and cooperation by helping to eliminate
miscommunications and subsequent errors and mistakes. When both parties listen well, they are more
likely to work together successfully and make sure that everyone's needs are met.
Recognizing Non-verbal Messages
People communicate both verbally and non-verbally. Albert Mehrabian's research into communication
determined that a significant amount of meaning is transferred through the non-verbal aspects of
communication. To fully understand what people are saying, you must be skilled at decoding both verbal
and non-verbal messages.
Non-verbal communication is comprised of
1447

paralanguage the vocal part of speech and its nuances
kinesics static and dynamic use of the body in communication
proxemics spatial relationships and perception of space
Unlike verbal communication and paralanguage, most body language is automatic. Even the pupils of
your eyes communicate. When you are excited or particularly interested in something, the pupils of your
eyes increase in size.
That's why people obtain so much of the meaning of communicated messages from body language. Body
language is considered a much more reliable indicator of a person's true feelings than the words they
use.
More than half of the understanding of interpersonal communication is generated by people's body
language, so it is useful to know what behaviors you should observe in others and be aware of yourself.
Humans are highly territorial as a species, but most humans aren't aware of this until their personal space
is invaded. The distance you place between yourself and another person conveys a non-verbal message.
How you orient yourself in relation to other people when you interact with them can often indicate your
general disposition towards them. You may stand face-to-face, side-by-side, or even back-to-back.
Shaking hands, touching, holding, embracing, pushing, or patting on the back, all convey messages.
These examples of physical contact reflect the presence or absence of elements of intimacy or
attraction.
A person's posture also communicates feelings. It is not whether someone is sitting, standing, or lying
down that tells the story. The message comes from whether they are slouched or standing straight, or
have their arms folded, or have their legs crossed.
The dynamic features of body language are the ones that people are usually more aware of. As the word
suggests, these factors involve movement of a person's: face, eyes, body, hands and arms.
Facial expressions openly display the attitude of the communicator. Movement of the mouth, lips, brows,
and forehead can all convey information about how a person is feeling. Facial expressions continually
change during interaction and are monitored instinctively and constantly by the recipient.
The eyes can convey many emotions, so eye contact is a major feature of social communication. Much
valuable insight into a person's emotional state can be gained by observing the frequency and the length
of eye contact. Loss of eye contact can suggest disinterest or boredom, so it can signal when to continue
talking and when to stop. Sustained eye contact can suggest attraction or aversion, so it is a good
indicator of a person's reaction.
The direction in which people move their body can convey information about how they are feeling.
Whether the meaning is positive or negative depends on if the movement is forward or backwards, up
and down, or side to side.
1448

Because most people use hand and arm movements or gestures regularly when talking, these are
some of the most frequently observed examples of body language. But it is important not to "read" too
much into individual gestures. You should interpret these individual gestures in the same way as you deal
with words in a sentence the meaning only becomes clear when you put all of the gestures, or words,
together.
Increased awareness of your own body language and that of others can make you a more perceptive
communicator. This will have a positive influence on your approach to all your relationships, both
personal and professional.
Interpreting Four Modes of Non-verbal Expression
Body language provides important insights into the meaning behind a person's words. A person's posture
and facial expressions tell you how they think and feel. Sometimes you may even detect a discrepancy
between these non-verbal queues and what a person is saying. By learning to interpret body language,
you can read between the lines to get at the truth or essence of any conversation.
Body language is expressed in terms of facial expressions, eye contact, gestures, body orientation,
physical contact, proxemis (personal space), and posture. Of these non-verbal queues, posture is one of
the most significant. A person's posture may be open or closed, depending on their response to what is
being said and who is saying it.
People who are open and responsive generally sit with their legs outstretched, uncrossed, or with the
knees apart. Their elbows are often away from the body; their hands are open or loosely clasped. They
may lean forward toward the speaker as they listen, or display other signs of interest or agreement.
People who are closed, defensive, or even combative may sit with their legs crossed at either the knees
or the ankles. They fold their hands on their lap or fold their arms across their chest. They may lean back
in their chairs or show other signs of escape, retreat or aggression.
The open and closed, forward and backward posture groups combine to create four basic emotional
modes: reflective, responsive, defensive, and combative.
1. Reflective mode
An open and back posture may indicate a reflective state. When you are in reflective mode, you
are receptive. You may be listening to the other person, evaluating what she has said. In this
"interested" mode, your "static" (stationary) body language remains relatively constant and you
will be relatively still.

Dynamic (moving) body language will provide an indication of your specific feelings. When a
person is responding positively to what you are saying, you may observe: a relaxed brow; an
occasional nod of the head; the head tilted toward you; lots of direct eye contact.
2. Responsive mode
A forward and open position shows that a person is responsive. In this mode, he may be
demonstrating that he is comfortable and relaxed with you. Alternatively, he may have evaluated
your message and now be showing his active agreement. Once your ideas are accepted or
1449

understood, heads nod affirmatively and eyes open wider. When people are responsive, they will
probably move closer to you. If sitting, they may shift to the edge of their seats to achieve this.
When rapport is very strong, they may even begin to mirror your body language.
3. Defensive mode
If listeners are leaning back and have closed body positions, it may mean they are in defensive
mode. They may be bored, disinterested, or uncertain. They may be anxious, nervous, or
stressed. Whichever of these emotions they are experiencing, they want to escape and be
somewhere else.

These "fugitive" feelings are signaled by hunched shoulders, crossed arms or legs, and the feet
may be pointing to the door. They may fidget and demonstrate a perceptible lack of eye contact
as they look around or gaze down.

People may unconsciously touch their bodies to relieve feelings of stress. Self-touch may indicate
nervousness, confusion, or anxiety. It may also indicate deceit. Examples of self-touch include

pinching the bridge of the nose
clenching the hands
massaging the hands, arms, or legs
scratching, rubbing, or pinching the skin
holding an arm or wrist
touching the lips with the fingertips
4. Combative mode
A forward and closed position signals the person is in combative mode. In this mode, feelings can
range from disagreement to hostile aggression.

When a person has an aggressive attitude, they may stand with hands on the hips or elbows out.
This is a common method of enlarging the body's size to appear physically more powerful in
order to dominate or threaten.

It is common for people in combative mode to invade your personal space. They may stand
uncomfortably close or they may poke or prod you. They may even push their heads forward until
their faces are only inches from yours.

The hands can indicate a combative attitude. A combative person tends to clench his fists or
make short, sharp, "cutting" motions with his hands. With his palms down, a combative person
may slap or beat on a table, desk, or other surface.

Facially, you can expect to see someone in combative mode to have their eyebrows lowered into
a scowl of anger or displeasure, and their lips compressed or pursed in disagreement.
When you attempt to interpret non-verbal queues, it is important not to jump to conclusions based on a
single gesture or posture. These elements of body language are like words in a sentence they must be
taken together to extract meaning. You have to "hear" the entire "silent sentence" for it to make sense.
1450

Body language can help you to extract deeper meaning when you speak and when you listen. By
watching for non-verbal queues, you can see how your words affect others and gain insight when other
people speak. Pay attention to how people are reacting, as well as what they are saying, and your
communications skills will improve significantly.
Responding Appropriately to Body Language
There are often discrepancies between what people are thinking, as communicated by their words and
what they are feeling, as communicated by their body language. These different feelings can be
categorized as
defensive passive and rejecting
combative active and rejecting
reflective passive and accepting
responsive active and accepting
People don't often consciously notice their own body language or that of others. Mostly, it is enacted and
interpreted subconsciously. Body language can be very subtle, with each gesture and expression giving
only part of the total emotional message.
Body language becomes more apparent when it doesn't match the words it accompanies. For example,
someone's words may be reflective and receptive, but their body language may be defensive and
rejecting. Their words may convey acceptance, but if the body language says otherwise, the discrepancy
will be obvious.
When you notice that there is incongruence or a mismatch between a person's body language and his
verbal message, you should try to address unvoiced resistance and facilitate understanding.
"Probing points," such as tension observed in a friend's mouth should prompt the question, "What's
wrong?" You will need to further investigate the other person's verbal response to your message by using
questions specifically designed to target the unvoiced attitudes or hidden uncertainties indicated by the
body language.
Co-workers, friends, and family members will appreciate your acknowledgement of their feelings. They
will also be encouraged to voice their true opinions, thereby avoiding unsuspected conflict at a later time.
In addition to observing discrepancies between verbal and non-verbal queues, it is also important to
remember to put any observable behavior in context with what is being said and with other examples of
body language that is being displayed at the time.
Postures, body movements, and facial expressions do not transmit accurate information when observed
out of context. Certain "closed" movements, such as crossing the arms or the legs, may be done simply
because the position is comfortable or because the person is trying to keep warm. Other movements,
such as lowering the eyebrows can, depending on the degree, indicate either that the person is thinking
or that he or she is angry.
1451

It is indeed helpful to have the ability to pick up on people's unspoken uncertainties and concerns,
particularly when you need to know if someone's reaction to you or your idea is positive or negative. Once
you have that information, you are better positioned to give the most appropriate response and ensure
clear and mutually beneficial communication.
















Workplace Communication Skills
SkillBriefs
Three Interpersonal Communication Styles
Learn more about three interpersonal communication styles.
Four Types of Assertive Responses
Explore the four types of assertive responses.
1452

Assertive Interpersonal Negotiation Techniques
Learn to use assertive interpersonal negotiation techniques.
Using Constructive Criticism and Feedback
Learn how to use constructive criticism and feedback.
Criteria for Giving Constructive Criticism
Explore the criteria for giving constructive criticism.
Accepting Criticism in a Positive Manner
Learn how to accept criticism in a positive manner.
Using Open and Closed Questions
Explore how to use open and closed questions.
How to Use Exploratory Questions
Learn how to use exploratory questions.
Using Leading Questions to Persuade
Explore how to use questions to lead to a specific response.








Three Interpersonal Communication Styles
Unless you are extremely lucky or accommodating, it is unlikely that you will go through your career
without ever disagreeing with a colleague. During disagreements, assertive communication comes into its
own. But despite this, people often deal with difficult situations in either a passive or an aggressive
manner.
1453

Assertiveness is based on the principle that people have the right to decide what treatment they will, or
won't, accept from others. Individuals are entitled to stand up for their rights, but not at the expense of the
rights of others.
In other words, you have the right to ask for what you want, but the other person has the right to refuse
you. On this basis, assertive communication is an effective way for adults to resolve their differences
productively.
Of the three interpersonal communication styles passive, aggressive, and assertive passive and
aggressive styles are the most common, whereas people find it harder to be assertive. These styles
become more pronounced during stressful situations.
Behavior and communication can range from totally submissive (passive) at one extreme to overtly
threatening (aggressive) at the other. Assertiveness is in the middle. More information about these three
interpersonal communication styles is provided here.
The passive communication style
When people behave passively, they hope they'll get what they need without having to ask for it outright.
They're afraid that if they ask outright, people won't like them. They only hint at what they want, and then
hold others responsible for not giving it to them.
Passive people often adopt defensive postures, to make it appear that they are taking up less space.
They keep eye contact to a minimum and are often soft-spoken, hesitant, and cautious. They also can
behave passive aggressively and resort to sabotage in retaliation for not getting what they want.
People act passively because they fear conflict or confrontation. Since passive people go out of their way
to be liked, they think that they are building good relationships with co-workers. In fact, the opposite is
often true. Work relationships become unstable, because colleagues tire of "second guessing" what
passive people really want, and hearing about the "sacrifices" that passive people claim to have made.
The aggressive communication style
When someone is adopting an aggressive communication style, being liked is not a priority. Being feared
is more important. Aggressive people will say what they think, not caring about the impact on the receiver.
Aggressive people demand what they want, and the only rights and feelings that concern them are their
own.
Aggressive people adopt a threatening stance, taking up as much space as possible by standing with
legs apart and hands on hips. They act aggressively because it works those around them take the easy
route, and give in when faced with their offensive behavior. However, any gains are short term. Working
relationships can't flourish in an atmosphere of resentment, and co-workers may even retaliate with
sabotage or insubordination.
1454

The assertive communication style
If you are being assertive, you care about other people's feelings, but don't feel totally responsible for
them. You believe that you should take care of your own needs, and you trust others with theirs. You
don't want to be feared, but you're not desperate to be liked, either. You are prepared to let others decide
what they think of you.
To behave assertively, stand straight, and maintain eye contact with the other person. Ask for what you
need, and say what you think. You also should use "I" statements. Consider the following examples of
assertive statements:
"I feel very uncomfortable when you use bad language, and I'd like you to stop."
"Well, I'm moving offices now. I can't stand this language."
By acting assertively, you guide others to your desired outcome by enabling them to see the connection
between their action and your response. Acting assertively will help you to build more stable and effective
relationships, both inside and outside of the workplace although you won't necessarily be liked all of the
time.
Assertive communication is not always received well, so it takes courage to stand up for yourself. This is
particularly true for passive people, who find it difficult to be direct. At first it can be hard to maintain your
assertiveness. Initially, people may react negatively while they are getting used to the "new you."
You need to judge when to speak assertively, and to whom, but it's worth the effort. The long-term results
of assertiveness are all positive, including greater self-esteem and more successful negotiations.
Sometimes it may feel uncomfortable, but people will soon be giving you the respect that you show them,
which can only improve your work relationships.




Four Types of Assertive Responses
How often have you been lost for words when someone interferes, interrupts, or makes an insulting
remark? When others attempt to manipulate your behavior by telling you what you should do or what
they would do in your place you may think your only options are to agree or to argue.
However, there is a third option an assertive response. By using this type of response, you can maintain
both your self-esteem and your harmonious relationships with others.
1455

When you don't want to submit to unacceptable remarks or be confrontational, you can use some simple
but effective assertive responses to take a lower-key approach. Four types of assertive responses you
can use are explained here.
1. Persistent assertiveness
You can use persistent assertiveness to put your point across even when you are being interrupted, or
when someone is trying to change your mind. To use persistent assertiveness, you firmly restate your
point or request after the other person has interrupted or spoken.
When using persistent assertiveness, it's important not to get drawn into arguments or explanations.
Ignore the other person's baiting, manipulation, or irrelevant logic. Keep repeating your point, using a low,
pleasant voice. Don't get pulled into a discussion about the rights and wrongs of the situation.
2. Empathetic assertiveness
If you find another person's words or behavior unacceptable, don't assume the person's purpose was to
offend. The person may not realize the effect of what he or she has said or done.
You can use empathetic assertiveness to comment on unacceptable remarks or behavior without causing
conflict. To make your views known with empathetic assertiveness, you should describe the negative
impact of the person's remarks or behavior, avoid accusations, and let the other person decide what to
do. This type of response demonstrates empathy with the other person's position and shows that you're
not out to pick a fight.
3. Indefinite assertiveness
Use indefinite assertiveness to deflect unwelcome criticism or suggestions. This response is useful when
you want to maintain a good relationship with the other person, but don't necessarily want to follow his or
her suggestions.
To use this approach, you vaguely agree with as many of the facts as you want to, but you don't make a
commitment to changing your behavior or applying the suggested solution. Indefinite assertiveness
enables you to sidestep manipulative advice or criticism without appearing to totally disagree.
4. Negative acknowledgment
It's difficult to be assertive when you're receiving valid criticism, particularly when it's delivered in a hostile
manner. Negative acknowledgment enables you to handle hostile but valid criticism calmly and to stay
assertive even when you have to admit your mistakes.
To use this approach, you focus on the content of the criticism and not its delivery. This enables you to
prevent the discussion from escalating into an argument.
1456

These four assertive responses may not be effective every time, and they may not provide permanent
solutions for all situations. But they can take the sting out of certain situations.
Being assertive also feels better than being submissive. It enables you to maintain your self-esteem
without resorting to the sorts of aggressive confrontations that destroy relationships, and enables you to
sidestep interference, feel better about criticism, and get on with your work in your own way.

Assertive Interpersonal Negotiation Techniques
When problems arise with work colleagues, it should be easy to make them aware of your wants and
needs. Unfortunately, even as the words form in your mouth, your brain often starts thinking about the
possible consequences of what you are about to say.
You begin to have misgivings and eventually decide to stay silent. But silence won't get you results.
That's why you need to learn to think and speak assertively.
When you act aggressively, you place the responsibility for how you feel on the shoulders of others, and
demand what you want. When you act passively, you take responsibility for other people's feelings, and
hope that they will give you what you want.
When you act assertively, you accept responsibility only for yourself, your actions, your needs, and your
feelings. And you ask for what you want.
Assertive interpersonal negotiation techniques enable you to convey your wants, needs, and intentions
clearly without ignoring the rights of others. Four techniques you can use and their most common uses
are
declarative assertiveness, to state what you think or want
confrontational assertiveness, to deal with unacceptable behavior
cooperative assertiveness, to reach a satisfactory compromise
assignation of accountability, to persuade people to deal with the consequences of their actions
You can use these techniques to handle a variety of situations and to ask others to change their behavior.
But when negotiating assertively, you should always focus on what is right, not who is right.
The basis of assertiveness is that you have the right to ask for what you want, and the other person has
the right to refuse. This means that you won't always get the desired result. But it's better to try to
negotiate your preferred solutions assertively, rather than being aggressive or passive.
The success of assertive communication is affected by the balance of power. The declarative and
confrontational assertiveness approaches are easier to use and have more impact when you have
authority over the other party. When you have equal or less authority than the other party, cooperative
assertiveness or assigning accountability may be more effective.
1457

There are occasions when people don't realize, or acknowledge, the negative results of their behavior.
Either they believe that you are overreacting, or they expect you to accept the situation. You might feel
that your only options are to shrug it off, or risk an argument. But there is another route. You can assign
accountability.
It's not unusual to feel unprepared for dealing with problem situations, because they usually arise
unexpectedly. However, by practicing assertive communication approaches, you will be better equipped
to reach an acceptable outcome without getting tongue-tied or angry.
Once you accept that everyone has both entitlements and responsibilities, you can use assertive
communication techniques more effectively. They will improve your ability to stand up for yourself and
increase your chances of achieving acceptable outcomes to problem situations.

Using Constructive Criticism and Feedback
For many people, the word criticism has negative connotations. That's because some people give
"feedback" with the sole aim of delivering a personal attack and causing hurt. So it's not surprising that
criticism isn't always gratefully received, even when the intention behind it is positive.
People don't enjoy hearing that they are not perfect. And some claim to be giving constructive criticism
when, in fact, they are just voicing their disapproval or dissatisfaction. These misunderstandings arise
because people aren't aware of the differences between real criticism, feedback, and personal attacks.
Criticism is evaluative You assess another person's performance or actions. Criticism
becomes constructive when you include appropriate alternatives to boost the chance of
improvement.
Feedback is descriptive You describe the action or behavior in question and inform the
person of your reaction to it. You retain accountability for your feelings and don't insist that your
words are acted upon.
A personal attack is judgment of a person A personal attack is also evaluative, but you voice
your judgment of the person, not of the person's performance, actions, or behavior. Often, your
assessment of someone is based on your assumptions about his or her intentions, opinions, and
beliefs.
You can't give truly constructive criticism unless you are qualified to do so. To be qualified, you must be
sure of the criteria against which the performance is being judged and be able to provide the tools to
encourage the necessary improvement.
This requires suitable credentials, such as experience, authority, or proven expertise. Without these, your
criticism is unlikely to be accepted and acted upon.
If you are unsure whether you have the right credentials, it's best to limit your comments to giving
feedback. If you're not eligible to give constructive criticism, you can still offer advice, but only if it is
1458

sought. Nothing ignites conflict or resentment faster than someone giving an unsolicited or unqualified
judgment of another's work.
Don't use criticism to get your own way. There are assertive communication techniques you can use to
reach a preferred outcome, or to defend yourself against the manipulative behavior of others.
The only acceptable reason to give criticism or feedback of any kind is to try to improve a person's
performance for his or her benefit, and that of the company. At work verbal personal attacks are always
inappropriate.
When you offer constructive criticism, you must be willing to take some responsibility for the results
achieved both good and bad. After all, you are the one who has used your superior position,
knowledge, or experience to persuade someone to execute a task differently. Any other approach is
unfair and guaranteed to cause discord.
Only constructive criticism and feedback given together can positively affect interpersonal interactions.
Criticism alone and personal attacks may jeopardize relationships by making receivers feel negatively
about the givers.
Whenever you are tempted to verbalize your judgment of someone else's behavior, make sure that your
intention is to improve and not to punish. By keeping in mind the points discussed above, you'll be able to
effectively use constructive criticism and feedback.
Criteria for Giving Constructive Criticism
Giving criticism properly and constructively is not easy, particularly in the workplace. Fear of confrontation
often prevents managers and team leaders from tackling unacceptable performance. However, deferring
action can lead to an escalation of the situation, and then it becomes more difficult to handle.
The main reason people don't take criticism well is because it is often used as a disguise for personal
attack. The only acceptable reason for criticizing others at work is to gain performance improvements.
True criticism evaluates the person's behavior, not the person. Use constructive criticism to make
suggestions about how the person can improve his or her behavior.
For criticism to be effective, it must meet five criteria, which are described. If your criticism meets these
five criteria, your motive will appear to be supportive, not manipulative. This will enable the receiver to
accept your criticism more easily. However, if your criticism fails to meet these criteria, then the recipient
has every right to refuse it.
1. Criticism must be performance-related
To be accepted by the receiver, criticism must be performance-related. This means that it should be given
only when someone falls short of the company's accepted standards.
1459

You should criticize only things that have a direct impact on an individual's work. So, you can't criticize
people for looking as if they've been out all night, but you might need to criticize the fact that their
performances are below standard because they were out all night.
Think carefully about what you expect to achieve by criticizing someone before you do it. Are you
motivated by a desire to help the individual to improve his or her performance? Or are you trying to get
the person to change his or her attitude?
If the latter is true, you are criticizing someone for the wrong reason. You should focus on achievable,
performance-related outcomes.
2. Criticism must be precise
As well as being performance-related, your criticism also must be precise and based on fact. If you
criticize in a vague way, then you run a high risk of the verbal exchange becoming confrontational.
Often people become defensive when they are being criticized, and they try to protect their positions by
attacking you. Many times, these counterattacks center on the validity of what you have said. If your
information is incorrect, it will create further conflict. So make sure that you have all of the facts and that
you understand the issues thoroughly before criticizing someone.
3. Criticism must be given in private
Remember that the aim of criticism is to improve performance and not to humiliate the receiver. Only the
person concerned should hear what you have to say.
4. Criticism must be delivered politely
Just because someone's performance is below standard, doesn't give you the right to be rude. Ensure
that you use appropriate language.
5. Criticism must be "posture-sustained" or backed up by the giver's body language
You also need to make sure that your body language sends the same supportive message as your
words. Avoid combative postures or threatening gestures, such as pointing your finger, clenching your
fist, or invading the receiver's personal space. Physically demonstrate that you are prepared to listen to
the other person's point of view.
Being criticized is sometimes hard, but giving criticism is not easy either. Remember to approach your
receiver as a problem-solving partner and not as an accusing adversary.
Before giving criticism, remember that you must always be polite, and your body language should support
what you say. But most importantly you should always give precise, performance-related criticism, in
private. By keeping these five criteria in mind, you can ensure that your criticism is effective and that it is
received as it is intended.
1460

Accepting Criticism in a Positive Manner
You can't control what is said to you. But you can control the manner in which you respond to the
comments of others. One of the most difficult communications to respond to is criticism, particularly when
it does not appear to be constructive, or even justified.
Whether criticism is valid or not, most people respond negatively to it. However, you need to be able to
identify when it is in your best interest to accept criticism in a positive manner, and you should understand
how to do this effectively.
Criticism should be precise, performance-related, and "posture-sustained," which means backed up by
the giver's body language. It should be given politely and in private. Preferably, the criticism should also
be constructive, but that isn't always the case.
When criticism doesn't satisfy these five essential criteria, you can choose to refuse it, or confront it.
The most common reaction to any criticism is "fight or flight." This is a natural human reaction to a
perceived attack. It triggers a rush of adrenaline that causes you to try to defend yourself.
If you're willing to accept and act on valid criticism, you will achieve better performance and improved
results. But an inability to receive valid criticism positively can result in
repeated criticism
conflict and blame
diminished self-esteem
Criticism becomes productive when you accept that your behavior can be changed, and you are willing to
do so. It becomes unproductive when you are not open to change. Then the criticism process will simply
repeat itself.
It's not easy to accept criticism, even when you know that it's valid and that it can help you make a
change. When your abilities are being attacked, your natural reaction is to fight back verbally.
However, there's a better way to protect your self-esteem. Protection techniques enable you to accept
valid criticism assertively, without arguing. Three protection techniques you can use are to
agree with the truth of the criticism
agree with the logic of the criticism
acknowledge that improvement is possible
Agreeing with the truth or logic of criticism isn't a commitment to behavior change. Neither is
acknowledging that improvement is possible. These three approaches merely limit the potential conflict
that could arise from your instinctive need to retaliate. They help you to avoid feeling bad about yourself,
even when the criticism is justified. By agreeing with the critic verbally, you'll feel less victimized.
1461

Performance will be maximized in a work environment where criticism is given constructively and received
positively. When people are not afraid to share their knowledge and others aren't too proud to receive and
use it, criticism can work to the benefit of all.
Using Open and Closed Questions
A conversation between two people seems to be a simple enough undertaking. But you can never be
sure how it will play out. Sometimes, the other person will say little. At other times, the other person won't
stay quiet long enough to take a breath!
Fortunately, certain kinds of questions can help you in these situations. They enable you to get the quiet
people to speak up, and the others to quiet down. These questions are either open or closed.
Using open and closed questions is like using a faucet. Open questions open the "faucet," allowing the
water or words to pour from the other person. Closed questions turn the "faucet" in the opposite
direction, reducing the flow to a more controlled stream of information.
There are many situations where you might want to increase or decrease the flow of information without
being too obvious about it. Although you could say, "Tell me all about yourself" to a quiet person, he or
she probably wouldn't know where to start. You also could say, "Shut up" to a talkative person, but that
would be impolite. Open and closed questions offer a far more subtle approach.
You can use open questions when you're eager to learn all about a new acquaintance. These types of
questions also are useful when you want to obtain as much information as possible from a job applicant.
You can use closed questions to prevent another person from diverting the conversation away from the
subject you wish to discuss. These types of questions also are useful in cases of information overload, to
stop another person from talking so much.
Open questions are based on the words who, how, where, when, which, why, and what, and can't be
answered easily with just a "yes" or a "no" answer. Open questions can help you gain information. Of
course, it is still possible for people to give minimal responses to open questions, but they'll seem
ignorant or rude if they do. Here are a few examples of open questions.
Who was responsible for introducing you to your best friend?
Where do you live, and why?
When you were young, what did you want to grow up to be?
Closed questions are used to gain confirmation, clarification, or commitment. Closed questions can be
answered with simple "yes" or "no" answers and are based on words such as can, do, is, should, and will.
The skill of questioning lies in being able to use a combination of question types to direct a conversation
and gain the information you need without it sounding unnatural. If you use too many open questions,
people may feel as if they are being interrogated. But too many closed questions can make them feel that
they are not being allowed to speak.
1462

The risk in using open questions repeatedly is that you can get a lot of information and yet still not reach
the heart of the matter. That's when closed questions are most useful.
With a combination of open and closed questions, you can elicit a lot of valuable information, and then
make an informed evaluation of what you have been told. Whether you want information or confirmation,
careful questioning will help you to achieve your objectives and put you in the conversational driver's seat.
How to Use Exploratory Questions
Quite a few common work situations involve or require extended questioning. Salespeople identifying the
needs of customers, managers conducting selection interviews or staff reviews, and consultants
investigating the causes of problems all need to ask questions to achieve their objectives.
On occasions such as these, it's important to keep the conversation light and unthreatening. Open
questions are best for uncovering information. These are questions based on words such as what, where,
which, when, who, how, and why.
Unfortunately, if you use too many open questions, you can sound as if you are interrogating. In
particular, "Why?" type questions can seem threatening. Depending on your tone of voice, they can send
a variety of messages not all of them positive.
People don't enjoy being asked a succession of "Why?" type questions, because it can be unnerving.
Fortunately, exploratory questions serve the same purpose, but are more acceptable. Exploratory
questions are indirect questions and begin with the following phrases and ideas:
"Describe to me..."
"Explain to me..."
"Clarify for me..."
"Tell me..."
Exploratory questions enable you to ask for details and investigate the rationale behind a person's
statement, decision, or policy without repeatedly asking "Why?" or "What?" or "How?" They also are less
likely to trigger conflict. Consider the following examples.
Instead of asking, "Why does your company use its current supplier?" you could say, "Explain the
reasons for your company using its current supplier."
Instead of asking, "Why have you decided to look for another job?" you could say, "Tell me what's
prompted your decision to look for another job."
As you can see from these examples, exploratory questions are more sympathetic than just asking,
"Why?" Sympathy and a soft approach are essential factors when asking someone a lot of questions.
They will help you to keep the other person interested and positive, instead of making the person
defensive.
1463

People like to talk about themselves, their thoughts, and their opinions. They also like the company of
others who take an interest in them. But they don't want to feel as if they are under a microscope. This is
why exploratory questions are so useful. They enable you to get the information you need, while still
enjoying a relaxed and natural conversation.
Using Leading Questions to Persuade
Imagine this scene: You make what you believe is an acceptable suggestion to a customer or colleague,
but no matter how you try to explain it, the person does not see the logic of your proposal. In fact, the
more you talk, the more he or she seems incapable of making a decision.
The benefit is obvious to you, but the other person just can't see it. In this situation, you can use a leading
question to persuade.
The purpose of leading questions is to lead another person towards a specific decision or response.
That's why these questions often are used in court. The lawyer phrases the question so that by obtaining
a simple "yes" or "no" answer, an important point has been made. Consider the following example.
The lawyer asks, "So, would you say that there was longstanding and deep hostility between the
defendant and the deceased?"
The witness answers, "Ah...yes, I guess so," and the opposing lawyer jumps up and shouts,
"Objection! Attempting to lead the witness, Your Honor!"
In addition to guiding a person to give a preferred response, you can use leading questions to direct
people towards certain decisions. In essence, leading questions summarize the advantages to be gained
by making a choice, delivered in the form of an inquiry.
Leading questions may appear to be manipulative, but they only work if they are linked to something that
the other person wants. For your questions to succeed, the person must want what's being offered more
than what's required in return. Some other points to keep in mind when using leading questions are listed
here.
Leading questions shouldn't be too complicated. You need to keep them as simple and
straightforward as possible to guide others to the responses you want.
To direct people towards a specific response, keep your leading questions closed.
Your leading questions should offer an obvious preference. Don't make decisions difficult by
asking someone to choose between two equally attractive or unattractive options.
The skill in asking effective leading questions comes from knowing what the other person wants. The
success comes from being able to show how it can be obtained.
Leading questions enable you to present the other party with a simplified choice that effectively speeds
up the decision process. Use them correctly, and you'll be better able to "close the deal" on successful
interpersonal negotiations.
1464





















Listening Basics
SkillBriefs
The Seven Components of Communication
Discover the seven components of the communication process.
Eight Variables That Affect Communication
Discover the eight variables that affect communication.
How People Communicate Simultaneously
Explore the ways in which people communicate simultaneously.
1465

How You Receive Information
Explore the different ways in which you receive information.
Three Types of Attention Problems
Discover the three types of attention problems.
Common Causes of Misinterpreted Messages
Discover four common causes of misinterpreted messages.
Strategies for Improving Your Listening Skills
Improve your listening skills using these four strategies.
Factors That Influence Your Listening Attitudes
Discover nine factors that influence your listening.








The Seven Components of Communication
Do you have problems truly listening? Do you find your mind wandering in the middle of conversations.
Then you need to develop effective listening skills. To do this, you first have to understand how the
communication process works. This will enable you to exchange your ideas and emotions more clearly.
To begin, you should be aware of the components of the communication process. A typical conversation
involves the following seven key components.
1. The speaker The speaker starts the communication process by wanting to talk about an idea
with you or asking you a question.
1466

2. The communication channel The speaker selects the best channel to send a message. The
channel can be verbal or nonverbal, such as vision or touch. Telecommunication devices are also
channels. Each channel limits what can be expressed.
3. The message The speaker turns an idea into appropriate verbal and nonverbal language to
create a message. The message must reflect the channel chosen. For example, the telephone
requires more verbal description since there is no visual channel.
4. The listener A message is always meant for someone. The listener is often the intended target
of a message. For successful communication to occur, you must receive and decode the verbal
and nonverbal message from a speaker. However, you also can be influenced by other
components of the communication process.
5. The feedback Once you receive a message, you interpret it and respond with verbal or
nonverbal feedback. The feedback may cause the speaker to send a new message to clarify or
answer your questions.
6. The environment External components to communication can influence a message. The
environment is the situation in which communication takes place. For example, a setting may be
formal or informal. Aspects of physical environment such as light, temperature, and room size
also influence a message.
7. The noise Another component is noise. Internal noise may involve a preoccupation with a
personal problem or the development of an emotional barrier in response to a word or idea.
External noise includes background activity, talk, or static.
As you can see, each component is influenced by other components. Together, they form a simple model
of communication. By knowing the seven components of the communication process, you can better
understand how communication happens and when you understand how communication happens,
you'll be well on your way to communicating more clearly.


The Seven Components of Communication
Do you have problems truly listening? Do you find your mind wandering in the middle of conversations.
Then you need to develop effective listening skills. To do this, you first have to understand how the
communication process works. This will enable you to exchange your ideas and emotions more clearly.
To begin, you should be aware of the components of the communication process. A typical conversation
involves the following seven key components.
1. The speaker The speaker starts the communication process by wanting to talk about an idea
with you or asking you a question.
2. The communication channel The speaker selects the best channel to send a message. The
channel can be verbal or nonverbal, such as vision or touch. Telecommunication devices are also
channels. Each channel limits what can be expressed.
1467

3. The message The speaker turns an idea into appropriate verbal and nonverbal language to
create a message. The message must reflect the channel chosen. For example, the telephone
requires more verbal description since there is no visual channel.
4. The listener A message is always meant for someone. The listener is often the intended target
of a message. For successful communication to occur, you must receive and decode the verbal
and nonverbal message from a speaker. However, you also can be influenced by other
components of the communication process.
5. The feedback Once you receive a message, you interpret it and respond with verbal or
nonverbal feedback. The feedback may cause the speaker to send a new message to clarify or
answer your questions.
6. The environment External components to communication can influence a message. The
environment is the situation in which communication takes place. For example, a setting may be
formal or informal. Aspects of physical environment such as light, temperature, and room size
also influence a message.
7. The noise Another component is noise. Internal noise may involve a preoccupation with a
personal problem or the development of an emotional barrier in response to a word or idea.
External noise includes background activity, talk, or static.
As you can see, each component is influenced by other components. Together, they form a simple model
of communication. By knowing the seven components of the communication process, you can better
understand how communication happens and when you understand how communication happens,
you'll be well on your way to communicating more clearly.
How People Communicate Simultaneously
Have you ever noticed how many people can talk and listen at the same time? These components of
communication can occur simultaneously because people naturally want to respond to interesting or
confusing messages they hear.
Because listening and speaking can occur at the same time, one person's role as a listener or speaker
can change many times during communication. The other components of communication the message,
the channel, and the environment can also change.
The simultaneous model of communication illustrates how each component of communication interacts
with and creates change in the other components. The model, which is a continuous cycle or process,
demonstrates how a speaker conveys a message to a listener, who then becomes a speaker, conveying
a message back to the first person, who is now the listener.
The speaker's goal is to get the listener to recall knowledge and compare it to the new information
outlined in the speaker's message. The listener must inform the speaker if the listener doesn't
understand. The speaker creates better understanding by responding with a modified message.
Listeners gain understanding by switching speaking and listening roles throughout the cyclical process.
People may interrupt and finish each other's ideas, showing that understanding and speaking have
1468

occurred simultaneously. A confused listener will seek clarification or express misunderstanding during
the message's transmission.
The speaker and listener continuously change roles as the listener tries to understand the speaker's
message. The messages are affected by the environment and the channel used to communicate. The
cycle continues until the understanding of a message finally occurs.
During this cycle, the speaker and listener are responsible for making sure the message is understood by
remaining constantly aware of how the components of communication influence understanding. Changes
occur in the channel or method of communication, in the message content or tone, and in the
environment in which communication happens. A speaker and listener constantly adapt to changes in
these components to ensure they understand. Changes can occur in the following ways.
Channel The channel may change in mid-process if the speaker perceives the listener didn't
receive the message. For example, a visual channel may need to change to verbal or a telephone
call to face-to-face. Also, it's possible for a listener to make a visual reply such as nodding "yes"
while the speaker is talking.
Message During a conversation, the message may change to address problems with other
components, such as loud background noise or a change in channel. Also, the speaker may
perceive the need to clarify a point before continuing. The tone also can change as the listener
begins to understand.
Environment The initial background environment, including noise, may disrupt understanding,
and the location may have to change. The environment also may be too formal or relaxed for the
type of conversation. A discussion of a personal issue, for example, should occur in private.
The simultaneous communication process shows how communication occurs in the real world, where a
person can often talk and listen at the same time. The speaker's and listener's roles must be interactive to
create meaning and understanding. By being aware of the simultaneous model of communication, you'll
have a better understanding of how people communicate with each other.
How You Receive Information
Have you noticed that when you're listening to someone, you not only hear the person's message, you
also can "see" that message? This is because you receive both aural and visual messages while you're
listening to someone.
Receiving information involves the physical reception of a message by a listener. This information can be
seen visually, by the eyes, or heard aurally by the ears. Visual messages include situational background
activity, the speaker's complementary hand motions, body posture, eye contact, and head motions. Aural
messages include both background noises and verbal messages, such as the speaker's choice of words,
tone of voice, and vocal inflection.
The visual information a listener receives makes up a large portion of communication. Studies estimate
that the visual component can range from 65 percent to 93 percent of a message. Since the visual
1469

component of a message can be so important in listening, you should understand what visual information
the listener can see. Visual messages can take the following forms.
Interpersonal space Interpersonal spacing is the distance between two or more people. The
space between two friends or coworkers should be about one-and-a-half to four feet when talking.
The listener becomes uncomfortable if the speaker is too close. Likewise, too great a distance
indicates disinterest with the speaker and subject.
Graphical, object, or color reinforcement of ideas A message can be reinforced by visual
images such as pictures and presentation aids. In casual conversation, reference can be made to
objects or people nearby to provide comparison information or direction. Color plays an important
role when referring to aesthetic qualities, contrasting graphical information, regulating traffic, or
indicating significance.
Facial expressions A speaker's facial expressions send important visual messages that either
match or contradict the aural message. The face conveys a wide variety of emotions or feelings.
Some common facial expressions are happy/agree, interested/thinking, unhappy/disagree, and
bored/disinterested.
Body movement and position The last visual component a speaker uses to send a visual
message or emphasize a point is body movement and positioning. For example, an up-down
nodding of the head shows agreement, or "yes," while left-right shaking of the head shows
disagreement, or means "no." The positioning of various parts of the body also can send a
message. For example, crossed arms or yawning can signal disinterest.
Visual information is an important aspect of communication. However, hearing is still the foundation of
listening, as a message must be audible to a listener. During the course of a conversation or a
presentation, a listener hears a variety of aural information. The types of aural information include the
choice of words, contextual sounds, and noise.
Choice of words The choice of words contains the key information a speaker wishes to
convey. The message is usually composed in such a way to inform the listener or to get the
listener to react in a manner desired by the speaker. The choice of words can aid or confuse
understanding.
Contextual sounds Contextual sounds add emphasis to a message by using vocal tone,
enunciation, and other situational sounds. An example of a situational sound involves
emphasizing a word by pounding a fist. Also, the use of sarcasm, humor, or emphasis adds
meaning to a message.
Noise Noise is any external sound or internal thought process that interferes with the
successful reception of information. External noise can include office noise, construction, or
interruptions. Internal noise includes emotional responses to words or focusing on other ideas or
problems.
Remember, receiving information is both seeing and hearing messages. Your awareness of how you
receive information can help you become a better listener.

1470

Three Types of Attention Problems
To listen effectively, you must pay attention to the speaker. This may sound like an obvious point, but
paying attention is sometimes more difficult than you may think.
The process of paying attention occurs when you prioritize the many messages you hear so you can
focus in on the message that interests you. Your message prioritization can be affected by the following
attention problems.
1. Selective attention
It's natural for you to be selective about what you pay attention to. If you paid attention to all the
messages you see or hear, you would quickly overload your brain. Almost everyone has a flexible and
selective process of allocating attention to competing priorities.
To deal with the many demands for your attention, you create listening priorities about the relative
importance of each message. Unconscious and conscious decisions determine your priority list.
Unconscious decisions Unconscious decisions are those that are usually automatic. This
involves responding to a sudden noise or paying attention to a person who calls out your name.
The speaker or action catches your attention and you stop listening to competing messages.
Conscious decisions When you make conscious decisions, you use logic and rational thought
to determine which message you should focus on. Listening to your boss will take priority over
other messages, such as a ringing phone or a coworker speaking.
2. Energetic attention
This is the amount of effort you place on paying attention and remembering. You use more mental energy
when the listening task is difficult or your attention is divided between listening tasks.
For example, you may have noticed that focusing on a complex oral argument, such as a technical
discussion, causes you to ignore other messages. Likewise, if you're trying to talk to someone on a busy
street, it may be hard to focus on what the person is saying due to the noise, people, and traffic.
Similarly, when you receive too much information, you tend to scan and hear only certain highlights, or
none at all. This can occur at busy social functions when you can hear only parts of many conversations.
Do you possess the energy to always pay attention and then remember everything that is said? Most
people can't do this. Your ability to pay attention often depends upon the message you receive. People
tend to be more energetic listeners when a message is simple and easy to remember.
3. Fluctuating attention
Fluctuating attention involves the gradual fading in and out of your attention during a listening situation.
This is a natural human condition. Fluctuating attention can occur in a warm room, during long
1471

presentations, when a person is tired, or when you focus on the unstated or perceived hidden message in
a conversation and you miss part of what has been said.
The influences of selective, energetic, and fluctuating attention directly impact your ability to listen. By
being able to identify the three types of attention problems, you can become a much better listener.

Common Causes of Misinterpreted Messages
Understanding information is often a difficult task. Making sense of information relies on your ability to
interpret or assign meaning to what you hear.
To assign meaning to a message, you have to evaluate what you hear so that you develop an
understanding of the communicated idea. Understanding occurs at several levels. You must examine
what was said for content, how it was said for tone, and why it was said to determine any actions required
from you.
When assigning meaning, you're trying to match your understanding of the intent of a message to the
intended message of the speaker. However, this can be difficult, since it is almost impossible to read
another person's mind exactly.
In fact, many of the assigned-meaning problems people encounter are actually problems related to how
they think. Listed below are some common causes for incorrect assigning of meaning. Keep in mind that
not all of these common causes will always be apparent.
Frame of reference This is also known as your point of view. It can alter a listener's
interpretation of a speaker's words. Culture, experience, attitudes, knowledge, skills, feelings,
expectations, values, beliefs, biases, and other personality-shaping influences can affect your
frame of reference.
The information selection process This is based on your frame of reference. Often, many
people pay attention or seek out information only when it supports a personal viewpoint.
Information to the contrary is often disregarded or the speaker is ignored.
Control over linguistics Many people incorrectly assign meanings to words due to poor
understanding of linguistics. Often, they are unaware of the correct context in which words are
used. Incorrect choices of words on the part of the speaker also create misunderstandings or
emotional responses.
Emotional triggers You likely have certain words, ideas, topics, or phrases that trigger
emotional responses. You may have immediate and unthinking positive or negative reactions to
these triggers. This will cause you to miss or assign the wrong meaning to a message.
Your ability to recognize how the meaning of a message can be influenced will help you understand why
you may not always comprehend what you hear. Pay careful attention to the common causes of
misinterpreting messages, and you'll be better able to listen more effectively.
1472

Strategies for Improving Your Listening Skills
To become a better communicator, you have to learn how to listen more effectively. To do that, you can
use a number of successful strategies to modify and improve your listening skills. Four strategies you can
use to improve your listening skills are described below.
1. Understand yourself
Before you can improve your listening, you need to know how your thinking influences your present
listening abilities. Once you understand yourself better, you'll be able to stay more motivated while you
listen.
Understand that your personal value system has stereotypes that can negatively affect your listening.
Don't let your biases interfere with your willingness to listen to a message. Workshops and self-help
books are two of the many resources you can use to better understand yourself.
2. Be motivated
Listening is an active process that requires your constant attention. You must make a considerable effort
to listen to others' views or ideas, rather than expressing your own. Your motivation depends on your
willingness to listen to others, as well as on the personal goals you set.
Your willingness to learn depends on how well you know and respect the speaker, how important
the content is to you, and which environmental conditions influence the communication.
Setting personal goals helps motivate you to be a better listener. This type of motivation isn't a
material incentive like money or a promotion. Instead, it comes from setting a goal and then
achieving it through better listening.
3. Listen actively
Once you're motivated, you need to listen actively to what is said. Active listening requires you to
participate in the conversation, ask questions, listen carefully, and show the speaker that you are paying
attention. This will help you to better understand what a speaker is trying to say.
To listen actively, you need to pay attention and drop all other activities. Make eye contact with the
speaker, move to a comfortable speaking range, and lean toward the speaker to show you're paying
attention. You also can show the speaker you're listening by occasionally stating "uh-huh" or "I see what
you mean." Ask questions to clarify information or to get more specifics.
4. Send appropriate feedback
To indicate to the speaker your degree of understanding, you need to send appropriate feedback. When
giving feedback, keep your personal feelings or evaluations separate from the message. Give prompt
feedback that is clear and concise, and avoid using complicated words and concepts. Also, make sure
1473

the feedback is pertinent to the message or situation. Clear up any ambiguous points, and wait to be
asked before giving advice.
To succeed in today's complex business world, you have to be a good communicator, and specifically you
need to be a good listener. By using the four strategies described above understanding yourself,
motivating yourself, listening actively, and sending feedback you can improve your listening skills and
become a more effective listener.
Factors That Influence Your Listening Attitudes
There are a wide variety of factors that influence your listening attitudes. These factors range from your
own culture to your personal preferences. Many of these factors are based upon your experiences over
your lifetime. The nine factors that influence the way you listen are as follows.
1. Culture
Listening can be affected by cultural differences. Culture involves the customs, behaviors, beliefs,
traditions, perceptions, and language of a group of people. Some cultures place higher value on listening
to specific groups of people, such as men or authority figures.
2. Hemispheric specialization
Listening also can be affected when the left or right side of the brain has dominance over certain body
functions or thinking processes. This is called hemispheric specialization, and it depends on how a
person's brain has developed.
The left side of the brain has different functions than the right side of the brain. The left side can identify
names and concepts, recognize sound, and analyze and create concepts. The right side is linked to
feelings and emotions.
3. Physical and psychological state
Other factors that influence the listening process include a person's physical and psychological state.
Listening is physically affected when hearing and vision deteriorate. Your psychological state can
influence how you receive information, pay attention, and understand information. Worrying about
finances, job security, or family interferes with listening.
4. Listener apprehension
Apprehension can occur when a person is uncomfortable with a subject, speaker, or method of
communication. It also can occur when one misinterprets messages, or is incapable of understanding or
handling complex or emotional messages.
1474

5. Self-concept
Self-concept is the way you feel about yourself. People who are frequently told to "pay attention" or "listen
up" often develop a negative self-concept of being a poor listener. They may then behave as a poor
listener. People who hear encouraging phrases, such as "Good job, you were paying attention," develop a
positive self-concept and tend to be better listeners.
6. Gender
Social conditioning causes most men and women to listen differently.
7. Age
As you get older, you lose aural and visual abilities, making it harder to receive messages. Older people's
listening needs, attitudes, and behavior also change over time as a result of their life experiences.
8. Time
If you don't have time to participate in a conversation, you may be more concerned about the next activity
than the present listening situation. This may cause you to miss essential details. The time of day also
can affect your ability to listen effectively.
9. Listening preferences
Listening preferences involve a fondness for certain listening situations. You develop these preferences
over time as usual responses to recurring situations. Your personality can also affect your listening
preferences.
A wide variety of factors influence the way you listen. Awareness of these factors will help you determine
where your listening strengths and weaknesses lie. Once you have this awareness, you can work on
techniques that will help you develop better listening habits.

Vous aimerez peut-être aussi