Professional Documents
Culture Documents
Cognizant E Learning Modules PDF
Cognizant E Learning Modules PDF
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
HTML
Introduction to HTML
Learning Objectives
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.
10
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
11
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
12
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.
13
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.
14
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
15
<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 XHTMLcompliant, 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>
16
<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.
17
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
18
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.
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
19
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>
20
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
21
</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
22
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>
23
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
24
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>
25
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
26
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:
<img>
A.
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.
27
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>.
28
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
29
</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):
30
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>
31
</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>
32
<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>
33
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>
34
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.
Graphic
This code is highlighted: <a href="produce_list.htm">here</a>
35
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"> </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
36
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>
37
</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
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
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
38
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>
<a href="#OrganicVegetables">Organic
Vegetables</a>
<a href="#OrganicFruit">Organic Fruit</a>
<a href="#OrganicMeat">Organic Meat</a>
<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
39
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
40
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>
41
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.
42
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">
43
<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
44
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"> </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.
45
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.
46
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">
47
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".
48
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>
49
<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.
50
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">
51
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
52
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.
53
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
54
55
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"
56
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):
57
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
58
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
59
Code
table { font-family: "Times New Roman", Times, serif; fontsize: small; font-style: normal; color: black; textdecoration: none}
Code
<title>Welcome to EarthFarm</title>
<link rel="stylesheet" type="text/css"
href="earthfarmstyle.css">
60
Code
<title>Welcome to EarthFarm</title>
<link rel="stylesheet" type="text/css"
href="earthfarmstyle.css">
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>
Code
<head>
<style type="text/css">P{
text-indent: 10px;
}
</style>
</head>
61
Code
<span style="color: red; background:white; font-family: sans-serif; fontsize: 24 px;">Welcome to Earthfarm</span>
Question
Match each type of style sheet implementation to its description.
Options:
A.
B.
Inline style
C.
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
62
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.
63
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.
64
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>
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>
65
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"
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>
66
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">
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.
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">
67
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>
68
<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"
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>
69
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.
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
70
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
71
You type </map> to add the closing tag to the image map.
Correct answer(s):
1. </map>
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.
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>
72
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.
73
Animation
74
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 crossbrowser 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
75
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
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">
76
</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
77
<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>
78
Question
Match each scripting language to its description.
Options:
A.
B.
JavaScript
VBScript
79
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.
80
Question
Identify the features of the DOM.
81
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
82
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
83
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>
84
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.
85
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.
86
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
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):
87
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.
88
89
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):
90
91
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):
92
2. 3-tier
93
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.
94
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.
95
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.
96
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 clientside 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
97
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
Question
In your report, you explain the multitiered computing models.
Match the 3-tier components with their descriptions.
Options:
98
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.
99
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
100
EXCEL
Opening an Excel 2010 Workbook
Learning Objectives
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.
101
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
102
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.
103
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.
104
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.
105
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.
106
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
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.
107
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.
108
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.
109
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
110
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
111
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.
112
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
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.
113
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-
114
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.
115
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
Question
What commands are available by default on the Quick Access Toolbar?
Options:
1. Save
2. Undo
3. Redo
4. Print
5. Open
116
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
117
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.
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.
118
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
119
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
120
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.
121
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.
122
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.
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
123
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
Graphic
124
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
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
125
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.
126
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
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.
127
Graphic
Diallonics has been filled into the [Your Company Name] field.
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.
128
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
129
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.
130
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
131
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.
132
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
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.
133
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
134
Steps list
Instructions
5. Select the Sales Predictions worksheet, then click Create New
Steps list
Instructions
1. Click File
2. Click Open
3. Double-click Timesheets
4. Select the workbook Week45 Timesheet TChavis, then click Open
Steps list
Instructions
1. Click cell F7
2. Type Monday, then drag the fill handle across cells G7, H7, I7, and J7
135
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.
136
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.
137
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.
138
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.
139
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
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.
140
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.
Graphic
141
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.
142
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
143
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.
144
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 twocolor 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.
Graphic
145
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
146
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.
147
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.
148
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.
149
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
150
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.
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 dropdown 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.
151
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.
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
152
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.
153
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.
154
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):
155
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.
156
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.
B.
C.
D.
Targets:
1. Number format
2. Currency format
3. Accounting format
4. General format
Answer
157
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.
158
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.
B.
C.
D.
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.
159
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.
160
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
161
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.
B.
C.
D.
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
162
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.
163
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
164
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 J9
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
165
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.
166
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
167
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
Steps list
Instructions
1. Click Merge & Center
2. Select cell D3 and click the Top Align button in the Alignment group
Steps list
Instructions
1. Click the Number launcher
2. Select Date from the Category list
168
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.
169
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.
170
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.
171
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
172
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.
Graphic
The formula is =A3*4+24/A7+5.
Excel also evaluates multiple sets of parentheses from left to right.
173
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
174
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
175
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.
176
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
177
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.
178
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
179
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
180
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.
181
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
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.
182
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
183
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
184
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
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
185
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
186
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.
187
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.
188
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
189
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.
190
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.
191
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
192
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.
193
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
194
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
195
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.
196
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.
197
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
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
198
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.
199
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.
200
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
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.
201
create a formula
entering a formula
Steps list
Instructions
1. Select cell K9 in the June worksheet
2. Type =H9*I9 in the Formula Bar and click the Enter button
202
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
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
203
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.
204
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.
205
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.
206
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.
207
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
208
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.
209
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
210
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
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
211
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 dropdown 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
212
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.
213
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.
214
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.
215
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.
216
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
217
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
218
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 dropdown 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.
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
219
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
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.
220
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.
221
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.
222
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.
223
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
224
may want to compare and color-code your data to see the lowest, average, and highest values
using the Color Scale feature.
225
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
226
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, May19, 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.
227
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.
228
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:
229
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
230
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.
231
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.
232
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.
233
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.
234
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.
235
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.
236
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.
237
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.
238
formatting the data as a table, and sorting and filtering the data
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
239
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
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
240
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.
241
Operating Systems
UNIX Philosophy and History
Learning Objectives
242
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
243
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 backwardcompatible 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
244
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
245
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 countersued 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:
246
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.
247
248
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
249
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.
250
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 SVIDcompliant 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.
251
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
252
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 highperformance 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.
253
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.
254
UNIX Distributions
Learning Objectives
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
255
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
256
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.
257
Options:
A.
B.
C.
Is free of charge
D.
E.
F.
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 HewlettPackard'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.
258
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 preinstalled.
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
259
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 HewlettPackard's HP-UX. Well-known open source UNIX variants include BSD and Linux.
260
Question
Match each feature of a UNIX distribution to its distribution type.
Options:
A.
C.
D.
E.
F.
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.
261
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
262
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.
263
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?
264
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.
265
UNIX Implementations
Learning Objectives
266
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.
267
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.
Question
Match each UNIX implementation example to its associated computer type.
Options:
A.
B.
This computer boots from a local disk, and runs applications from the server
C.
D.
Targets:
1. Server
268
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
269
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
#
270
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.
271
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.
272
273
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
274
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
275
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.
276
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.
277
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.
278
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
279
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
280
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.
281
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
282
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.
283
logging on
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.
284
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
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>
285
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
286
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.
287
recognize examples of how the UNIX shell processes using expansion and substitution
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
288
#$
>
>
>
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
289
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.
290
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.
291
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?
292
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
293
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
Code
#$ ls userlist && sort userlist
userlist
BAKER, Daniel
CARUSO, Maria
GARZA, Teresa
294
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
$
295
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 ( && )
296
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
297
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
298
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
299
#!/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.
300
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.
301
302
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.
B.
csh
C.
ksh
D.
bash
sh
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
303
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
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
304
# 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
305
# 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?
306
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.
307
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
308
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-#
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
309
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.
310
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--#
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.
311
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
312
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.
313
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
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
314
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.
315
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
316
# 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.
B.
batch
C.
cron
at
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
317
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.
C.
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.
318
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.
319
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
320
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):
321
1. passwd -s /bin/bash
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):
322
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
323
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
324
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.
325
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
#
326
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.
Targets:
1. Separates the two statements
327
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
328
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 email 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
/backup/mylog \
...
cp /var/log/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.
329
Answer
Correct answer(s):
1. ||
Question
You want to group a number of commands into a command block. Which operators do you use to
do this?
Options:
330
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
331
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
332
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.
333
Redirection in UNIX
Learning Objectives
Code
$ set -o noclobber
$
334
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:
335
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. <
336
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
337
A.
B.
C.
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
338
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.
B.
>&2
C.
1>
D.
2>|
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):
339
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
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>
340
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
341
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
$
>
>
>
>
Code
$
>
>
>
>
>
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
342
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.
343
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.
344
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.
345
[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
346
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.
347
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.
348
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.
349
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
-rw-r--r-- 1 vincep vincep
-rw-r--r-- 1 vincep vincep
-rw-r--r-- 1 vincep vincep
-rw-r--r-- 1 vincep vincep
9880
9372
73234
247416
451008
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
350
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:
351
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.
352
use redirection
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.
353
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):
354
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/)
355
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.
356
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)
357
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.
358
the ampersand
the at symbol
the asterisk
the backslash
359
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.
360
.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
361
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:
362
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
363
Question
Match each file type to its description.
Options:
A.
Regular file
B.
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
364
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.
365
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
#
366
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.
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
367
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
368
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
369
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.
370
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
#
371
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.
B.
cd
C.
cd ..
D.
cd ~
pwd
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
372
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
373
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.
374
Code
# ls -a
.
..
.cshrc
.profile
altroot
bin
boot
bsd
bsd-rd
dev
emul
etc
home
mnt
root
sbin
stand
sys
tmp
usr
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
.profile
altroot/
bin/
boot
bsd
bsd-rd
dev/
emul/
etc/
home
mnt/
root/
sbin/
stand/
sys@
tmp/
usr/
var/
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
.profile
altroot
bin
boot
bsd
bsd-rd
dev
emul
etc
home
mnt
root
sbin
stand
sys
tmp
usr
var
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--rw-r--r-drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
1
1
2
2
1
1
root
root
root
root
root
root
wheel
578
wheel
292
wheel
512
wheel
1024
wheel 43348
wheel 686156
Aug
Aug
Aug
Aug
Mar
Mar
12
12
12
12
27
27
375
2008
2008
2008
2008
2009
2009
.cshrc
.profile
altroot
bib=n
boot
bsd
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
usr
tmp
sys
stand
sbin
root
mnt
home
etc
emul
dev
bsd.rd
bsd
boot
bin
altroot
.profile
.cshrc
Code
# ls -t
etc
tmp
dev
root
emul
boot
sys
bsd.rd
bsd
sbin
bin
.cshrc
.profile
usr
var
altroot
home
mnt
stand
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
drwxr-xr-x 21 root wheel
-rw-w--r-- 2 root wheel
#
Question
Match the switches you can use with the ls command to their functions.
Options:
A.
B.
-F
C.
-r
D.
-l
-a
376
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
Code
# cat filename.txt
line a
line b
line c
line d
line e
377
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.
378
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
379
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:
cat -n names.txt
A.
B.
cat -b names.txt
C.
cat names.txt
D.
380
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.
381
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.
382
delete files
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
383
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
384
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.
385
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
386
# 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*
387
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]
388
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:
write to, or modify, a file or create and delete files in a directory, and
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 readonly 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.
389
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
390
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
391
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.
392
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.
393
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
.profile boot
altroot
bsd
#INSERT THE MISSING
bsd-rd
dev
emul
CODE
etc
home
mnt
root
sbin
stand
sys
tmp
usr
var
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
394
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
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.
395
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.
396
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.
397
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
app49.exe
app1.exe
App1.exe
app5.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
398
app.exe
app49.exe
#
app1.exe
app5.exe
app5.exe
Question
399
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
400
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
401
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.
402
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
403
You want to look for files on your computer using the find command.
Match each search scenario to the relevant find command.
Options:
A.
C.
D.
E.
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 512byte 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
404
Target 5 = Option E
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
405
-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
406
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."
407
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
#
408
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
409
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
410
411
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.
412
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.
C.
D.
Targets:
413
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.
C.
D.
414
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,
415
you can use regular expression metacharacters such as the caret, asterisk, and question mark
to perform similar functions to shell wildcards.
416
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--rwxrw-rwdrwxr xr x
-rwx------rw-r--r--rwxrw--------w--w-rw-r--r--rw-r--r-#
1
1
2
1
1
1
1
1
1
samo
samo
samo
samo
samo
samo
samo
samo
samo
wheel
wheel
wheel
wheel
wheel
wheel
wheel
wheel
wheel
0
173
512
0
559
2
0
0
512
Dec
Dec
Dec
Nov
Nov
Jul
Dec
Dec
Dec
12
4
10
29
29
14
4
4
4
08:44
13:56
07:20
12:29
09:38
2000
11:05
14:06
14:09
data#3
en_figures
myfiles
nfsreport
nomad
prcfile
psbook.ps
sales
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
417
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:
418
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-onnon-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.
419
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.
420
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
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.
421
-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
422
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
423
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
424
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.
425
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.
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
426
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.
427
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
428
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
429
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 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
430
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
431
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.
432
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
433
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.
C.
D.
434
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.
C.
435
D.
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"
436
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
437
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.
C.
D.
E.
F.
Targets:
1. #find /home -name meeting
2. #find / -atime 3
3. #find / -ctime 3
4. #find / -size 3
438
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 512byte 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
Question
You want to create a new directory using the mkdir command.
Match each scenario with the relevant command.
Options:
439
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.
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.
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.
440
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.
441
Correct answer(s):
1. -czf
Files have been searched for in Unix, and directories have been created and archived .
442
Introduction to Windows 7
Learning Objectives
443
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
444
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.
445
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
446
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
447
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.
448
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.
C.
449
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.
450
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.
451
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
452
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
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.
453
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
454
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.
455
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.
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
456
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.
457
access programs and files via the Start menu and the taskbar
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
458
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
459
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
460
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 rightclick 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
461
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.
462
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
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.
463
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.
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):
464
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
Graphic
465
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.
466
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
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
467
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.
468
access a program
using Snap
accessing a program
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
469
Steps list
Instructions
1. Click Start and select All Programs
2. Select Accessories - Command Prompt
Steps list
Instructions
1. Click Start and click the arrow next to Internet Explorer
2. Select Open new tab
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.
470
471
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
472
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.
473
Correct answer(s):
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
navigation pane
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
474
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.
475
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
476
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.
477
Everyday computing tasks often involve working with files and folders. Some common tasks you
perform with folders include
moving folders
renaming folders
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.
478
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
479
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
480
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.
481
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.
482
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
483
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.
484
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
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.
485
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.
486
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
487
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.
488
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.
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.
489
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.
490
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
491
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
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
492
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.
493
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
494
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
495
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.
496
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
497
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.
498
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
499
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.
500
501
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
502
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.
503
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.
504
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.
C.
D.
E.
F.
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.
505
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
506
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.
507
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
508
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):
509
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.
510
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.
511
You can adjust various print settings. You can also view documents that are printing or cancel,
pause, or restart print jobs.
512
install a program
remove a program
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
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
513
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
Steps list
Instructions
1. Click Add a printer
2. Click Add a local printer
3. Click Next
514
Steps list
Instructions
4. Select HP, select HP PSC 1500 series, and click Next
5. Click Next
6. Click Finish
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.
515
System Maintenance
Learning Objectives
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.
516
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
Network firewall
Virus protection
Maintenance messages are grouped into three categories:
Windows Backup
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
517
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.
518
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.
519
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):
520
1. Windows Troubleshooting
2. Windows Backup
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
521
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.
522
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,
523
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
524
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.
525
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.
526
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
527
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
528
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.
529
Windows 7 Security
Learning Objectives
recognize the words and phrases that follow the guidelines for strong passwords
530
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
531
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.
532
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):
533
1. T0dd!Gr3y\ID4
2. $w33T_t00th
534
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.
B.
A task, setting, or program that's not part of Windows, but has a digital signature
C.
D.
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.
535
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.
536
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.
537
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.
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.
538
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.
539
540
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.
541
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
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.
542
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
543
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.
544
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.
545
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.
546
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.
547
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
548
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
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.
549
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
550
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.
551
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
552
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.
553
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
554
Steps list
Instructions
6. Click OK
Steps list
Instructions
1. Click Set up backup
2. Click Next
3. Click Next
4. Click Save settings and run backup
Steps list
Instructions
1. Click Restore my files
2. Click Browse for files
555
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
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
556
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.
557
558
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.
559
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
desktop background
window color
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.
560
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.
561
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 dropdown 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
562
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.
563
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.
564
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.
565
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.
566
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.
567
568
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.
569
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.
570
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
571
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
572
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.
573
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.
574
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.
575
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.
576
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.
577
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
enable auto-hide
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.
578
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.
579
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
580
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.
581
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.
582
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.
583
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
584
Steps list
Instructions
6. Click Display
7. Select Medium - 125% and click Apply
Steps list
Instructions
1. Select Desktop Gadgets
2. Double-click Weather
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
585
Steps list
Instructions
5. Click OK
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.
586
DBMS
Overview of Databases and DBMSs
Learning Objectives
587
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-today 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
588
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 TransactSQL. 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
589
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:
590
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.
D.
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
database designers
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
591
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
592
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
593
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
schedule the downtime of the database outside of regular business hours, and
594
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
595
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.
596
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.
597
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 can share the network load among multiple clients and help reduce server side processing
598
599
600
increased reliability
local autonomy
better performance
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
601
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.
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 sharedmemory 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.
602
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.
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.
603
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.
604
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.
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.
605
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.
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.
making small changes in the middle of the file in a large database easily
606
multiple users want to access and update the database at the same time
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.
607
608
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.
Question
Match each database model to the corresponding description.
Options:
A.
Flat-file database
B.
Relational database
C.
Object-oriented database
D.
Network database
609
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.
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
610
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.
611
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.
B.
C.
D.
E.
Targets:
1. Database
2. DBMS
Answer
612
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.
613
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.
614
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
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
615
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.
616
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.
617
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.
618
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
619
Supplement
Selecting the link title opens the resource in a new browser window.
Job Aid
620
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
621
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
622
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
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.
623
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
624
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:
625
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
626
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.
627
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
628
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.
629
630
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.
631
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
632
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
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
633
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
634
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
635
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.
636
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):
637
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.
638
Database Normalization
Learning Objective
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:
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.
639
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
each nonkey column must be fully dependent on the key column or columns
640
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.
641
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
642
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
643
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:
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
644
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.
645
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.
646
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.
647
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.
648
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
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-tomany 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.
649
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.
650
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
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
651
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.
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,
652
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.
2.
3.
4.
5.
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-
653
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.
654
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.
655
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.
656
Question
See if you can model the real-world relationship between students and courses.
Options:
1.
2.
3.
4.
5.
6.
Student
Course
Skill
One-to-many relationship
Many-to-many relationship
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 welldefined 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
657
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.
658
After completing this topic, you should be able to describe the three-schema database
architecture and the database design life cycle.
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
659
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.
660
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 lifecycle 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:
661
A.
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.
662
663
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.
664
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.
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
665
Data categories
Category
Definition
entity
666
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.
Summary
667
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.
668
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.
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
669
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:
670
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.
2.
3.
4.
You can gather information about users' current and future requirements for a system
You can gather information about the types of tasks users perform and the processes involved
You can prove a hypothesis using statistics
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
671
Question
What do you think is the advantage of using a standardized question template for an interview?
Options:
1.
2.
3.
4.
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
672
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.
673
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.
674
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.
2.
3.
4.
5.
6.
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.
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.
675
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
676
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.
677
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.
678
After completing this topic, you should be able to describe how to generate a conceptual EntityRelationship diagram (ERD) to support the functional specification for a database system.
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."
679
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.
2.
3.
4.
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.
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.
680
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.
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.
681
"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.
2.
3.
4.
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.
682
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:
683
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.
684
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.
685
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:
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.
686
Supplement
Selecting the link title opens the resource in a new browser window.
Step 1 of 1
Select the entities that should be included in the initial ERD.
Options:
1.
2.
3.
4.
5.
6.
Access
Instructor
Module
Student
System
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.
687
Supplement
Selecting the link title opens the resource in a new browser window.
Address
Duration
Name
Objective
Password
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.
688
Supplement
Selecting the link title opens the resource in a new browser window.
Step 1 of 1
Match the notations with the relationships they express.
Options:
1.
2.
3.
4.
5.
1:1
1:N
N:1
N:M
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.
689
Supplement
Selecting the link title opens the resource in a new browser window.
690
After completing this topic, you should be able to use Entity-Relationship (ER) modeling to
design a relational database.
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
Conceptual design
Logical design
Physical design
Requirements analysis
Answer
Correct ranking
Option
Description
Requirements analysis
Conceptual design
Logical design
691
Correct ranking
Option
Description
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.
2.
3.
4.
Attribute
Constraint
Entity
Relationships
Targets:
A.
Table
B. Column
C. Primary key
D. Foreign key
692
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.
2.
3.
4.
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.
693
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
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
694
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 singlevalued 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.
2.
3.
4.
Age
Birth_Date
Colors
Product_Description
Targets:
A.
Composite attribute
B. Derived attribute
C. Multivalued attribute
D. Stored attribute
695
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
696
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
697
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
698
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
699
Summary
In database design, you can use Entity-Relationship (ER) modeling to create an EntityRelationship 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.
700
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:
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.
Supplement
Selecting the link title opens the resource in a new browser window.
701
Supplement
Selecting the link title opens the resource in a new browser window.
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.
702
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 oneto-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.
703
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.
Supplement
Selecting the link title opens the resource in a new browser window.
Step 1 of 1
In the Brocadero ER model, match each key to the appropriate entity.
Options:
1.
2.
3.
4.
PK Co_ID
FK2 Instructor_ID
PK Mo_ID
PK Student_ID
Targets:
A.
704
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.
Supplement
Selecting the link title opens the resource in a new browser window.
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
705
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.
706
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.
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
707
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:
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.
708
attributes that are not dependent on an entire composite UID to another table and establish a
relationship between the two tables.
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:
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.
709
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.
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.
710
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
711
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
712
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.
713
After completing this topic, you should be able to describe how to use advanced EntityRelationship (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
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.
714
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.
715
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).
716
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.
717
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.
718
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.
719
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.
720
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.
721
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.
722
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:
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.
Supplement
Selecting the link title opens the resource in a new browser window.
723
Supplement
Selecting the link title opens the resource in a new browser window.
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.
2.
3.
4.
Student entity
Course entity
Module entity
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.
724
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.
2.
3.
4.
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.
725
Supplement
Selecting the link title opens the resource in a new browser window.
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.
726
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.
2.
3.
4.
Optional/mandatory N:M
Mandatory/optional 1:N
Mandatory 1:N
Optional 1:N
Result
The two relationships between the Course and Prerequisite entities are mandatory/optional one-tomany (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.
727
Supplement
Selecting the link title opens the resource in a new browser window.
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.
2.
3.
4.
Optional/mandatory N:M
Mandatory/optional 1:N
Optional 1:N
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.
728
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.
2.
3.
4.
Mandatory 1:N
Optional 1:N
Mandatory/optional 1:N
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.
729
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.
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.
730
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.
731
After completing this topic, you should be able to describe how to create the physical database
design based on the logical database model.
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.
732
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.
733
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
734
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.
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:
735
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.
736
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.
Question
The following outlines a database design for a system that manages projects for a consultancy:
PROJECT
(#Proj_ID, Name)
737
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)
738
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)
Question
Why do you think views are useful in databases?
Options:
1.
2.
3.
4.
5.
739
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.
740
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:
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.
Supplement
Selecting the link title opens the resource in a new browser window.
741
Supplement
Selecting the link title opens the resource in a new browser window.
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.
742
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
743
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.
Supplement
Selecting the link title opens the resource in a new browser window.
Step 1 of 1
See if you can identify the tables that you could denormalize to improve database performance.
Options:
1.
2.
3.
4.
Access
Enrollments
Instructors
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.
744
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.
Supplement
Selecting the link title opens the resource in a new browser window.
Step 1 of 2
See if you can identify the tables that would make up the Enrollments_View.
Options:
1.
2.
3.
4.
Enrollments
Modules
Prerequisites
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.
745
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.
746
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
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.
747
Question
What do you think are some of the benefits of using a database?
Options:
1.
2.
3.
4.
5.
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.
748
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.
749
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.
750
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.
2.
3.
4.
To control redundancy
To provide backup and recovery
To restrict user access
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.
751
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:
752
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
753
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.
754
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.
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
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.
755
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.
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.
756
This case study describes a sample database system comprising tables with rows and columns
that users manipulate by using the Database Management System (DBMS).
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
757
No
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
Package B
Pension
Medical aid
Car allowance
Package C
16
Package D
Medical aid
15
17
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
758
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.
759
Database models
Learning objective
After completing this topic, you should be able to describe the evolution of database models.
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.
760
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 objectoriented 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
Network database
Relational database
Flat-file
Hierarchical database
Answer
Correct ranking
Option
Description
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.
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.
Network database
In a network database, tables are related to one another like those in the hierarchical database,
761
Correct ranking
Option
Description
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.
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:
762
763
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.
764
765
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.
2.
3.
4.
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.
766
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.
2.
3.
4.
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, objectoriented, and object-relational databases.
767
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.
768
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.
2.
3.
4.
Flat-file
Network
Object-relational
Relational
Answer
On early mainframes, data was usually stored in flat files.
769
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
770
a server
one or more client machines, such as PCs or workstations
771
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.
2.
3.
4.
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.
772
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.
2.
3.
4.
An Internet connection
A supported web browser installed on a PC
A web server
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.
773
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.
774
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
775
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
776
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.
2.
3.
4.
Data tracking
Distributed transaction management
Replicated data management
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.
777
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.
778
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:
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.
779
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.
780
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.
Read/write system
Read-only system
Runs day-to-day operations of a business Contains data for analyzing the business
Highly volatile data
781
Secure data
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), datamining, and Online Analytical-Processing (OLAP) applications can be used to analyze the
historic data in a data warehouse.
782
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.
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.
783
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.
This Oracle Internet technology and Oracle's built-in application development tools allow for
784
785
After completing this topic, you should be able to describe the main components of an Oracle9i
database server.
786
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.
2.
3.
4.
Answer
The Oracle9i database server supports compatibility and connectivity, data security, and high
performance and availability.
787
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.
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
788
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.
789
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:
790
1.
2.
3.
4.
Database availability
Defining object types
Logical database structures
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.
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
791
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.
792
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.
793
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
794
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.
795
After completing this topic, you should be able to describe relational database concepts.
Question
What do you think are the advantages of using the relational database model?
Options:
1.
2.
3.
4.
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:
796
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.
2.
3.
4.
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?
797
Options:
1.
2.
3.
4.
Data independence
Flat-file structure
Set-oriented processing
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.
attribute
domain
tuple
798
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.
799
Question
Match the different parts of a table to their definition.
Options:
1. Attribute
2. Domain
3. Tuple
Targets:
A.
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.
800
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.
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 setoriented 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)
801
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.
802
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.
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
803
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.
804
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.
805
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.
2.
3.
4.
5.
6.
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
806
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,
807
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.
808
3. Relationships
A relationship is an association between tables that share data.
In relational databases, you
Question
Which process do you think you use to reduce data redundancy in a relational database table?
809
Options:
1.
2.
3.
4.
Indexing
Normalization
Schematization
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.
Index
Procedure
Trigger
810
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.
811
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.
812
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
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
813
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.
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.
814
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:
815
1.
2.
3.
4.
5.
CARTESIAN PRODUCT
DIVISION
INTERSECTION
SET DIFFERENCE
UNION
Answer
CARTESIAN PRODUCT, INTERSECTION, SET DIFFERENCE, and UNION are mathematical set
theory 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:
816
817
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])
818
819
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
820
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.
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.
821
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.
822
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.
823
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:
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.
Supplement
Selecting the link title opens the resource in a new browser window.
Table details
824
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.
2.
3.
4.
INTERSECT (Employees)
PROJECT (Employees:[Salary < 20000])
SELECT (Employees:[Salary < 20000])
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.
Supplement
Selecting the link title opens the resource in a new browser window.
825
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.
2.
3.
4.
JOIN (Employees,Employee_ID)
PROJECT (Employees: [Last_Name, Employee_ID])
PROJECT (Last_Name, Employee_ID)
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.
Supplement
Selecting the link title opens the resource in a new browser window.
Table details
826
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.
2.
3.
4.
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.
Supplement
Selecting the link title opens the resource in a new browser window.
Table details
827
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.
828
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
829
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];
830
[WHERE condition];
AND
To modify data in a database, you can use the following SQL statements:
DELETE
INSERT
UPDATE
831
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?
Answer
To delete the four employees from the finance department, you use the command
DELETE FROM employees_finance
WHERE employees_id IN
832
(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]);
833
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.
834
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]);
835
836
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;
837
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)];
838
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.
839
After completing this topic, you should be able to discuss and write basic SELECT SQL
statements.
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?
840
Options:
1.
2.
3.
4.
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.
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:
841
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
842
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.
843
After completing this topic, you should be able to describe how to insert, update, and delete data
in an Oracle9i database.
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)
844
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.
2.
3.
4.
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.
845
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 =
846
'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.
847
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
848
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.
employees;
849
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;
850
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);
851
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:
852
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.
853
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.
854
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
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.
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.
855
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.
WHERE
SET
VALUES
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.
856
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.
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.
857
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.
858
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
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.
859
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.
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
860
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
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
861
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
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.
2.
3.
4.
A buffer failure
A system failure
A transaction failure
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.
2.
3.
4.
862
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.
2.
3.
4.
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.
863
864
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.
865
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.
866
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.
2.
3.
4.
Targets:
A.
Exclusive (X) lock
B. Share (S) lock
867
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.
2.
3.
4.
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.
868
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.
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.
869
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.
870
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:
871
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:
872
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.
873
Database security
Learning objective
After completing this topic, you should be able to describe database security and access issues.
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.
2.
3.
4.
The database
The database and hardware
The database and operating system
The database and applications
874
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
875
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.
2.
3.
4.
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,
876
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.
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.
2.
3.
4.
An entity
A tuple
A value
A view or virtual table
877
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.
2.
3.
4.
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.
878
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.
879
After completing this topic, you should be able to describe Oracle9i database users, how to
authenticate them, and their relationship to schemas.
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.
880
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.
2.
3.
4.
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.
881
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:
882
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.
Question
Which of the following do you think are examples of schema objects?
Options:
1.
2.
3.
4.
Constraints
Indexes
Tables
Views
883
Answer
Examples of schema objects include constraints, indexes, tables, and views.
Question
Which of these statements are true?
Options:
1.
2.
3.
4.
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.
884
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
2. System privileges
System privileges include privileges that enable users to
You assign a system privilege to a role or user using the GRANT command.
To specify that the role or user should have the privilege in any schema, you add the ANY
keyword.
A user requires the DROP ANY TABLE privilege to truncate a table in another schema
A CREATE command for a specific object does not include the DROP command for that object
The CREATE TABLE command includes the ANALYZE and CREATE INDEX commands
You cannot grant the UNLIMITED TABLESPACE privilege to a role
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:
886
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
887
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.
888
Programming languages
The Evolution of Computers and Software Programming
Learning Objectives
889
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.
Code
.model small
.stack 100h
.data
msg
db
'Hello, world!$'
mov
lea
int
mov
int
ah, 09h
; Display the message
dx, msg
21h
ax, 4C00h ; Terminate the executable
21h
.code
start:
end start
890
Code
.model small
.stack 100h
.data
msg
db
'Hello, world!$'
mov
lea
int
mov
int
ah, 09h
; Display the message
dx, msg
21h
ax, 4C00h ; Terminate the executable
21h
.code
start:
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.
Code
.model small
.stack 100h
.data
msg
db
'Hello, world!$'
.code
891
start:
mov
lea
int
mov
int
ah, 09h
; Display the message
dx, msg
21h
ax, 4C00h ; Terminate the executable
21h
end start
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
Code
IF age < 12 THEN
Classification := "child";
ENDIF
892
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");
}
893
has evolved over time, and has laid the groundwork for derivative languages such as C++ and
C#.
Code
main( ) {
printf("hello, world");
}
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'
894
Select *
From Employees
Where Full_Time = 'Yes'
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.
895
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.
896
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:
897
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. Fourthgeneration 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
898
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.
899
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:
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
900
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
901
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
902
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
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.
903
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.
904
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
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.
905
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.
906
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.
907
Programming Basics
Learning Objectives
908
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 realworld 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.
909
it's complete
it's efficient
it's usable
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.
910
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.
911
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.
912
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.
913
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
a debugger
914
an installation program
a profiler, and
915
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 reinterpreted. 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.
916
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
917
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
918
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.
E.
Profiler
919
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.
920
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.
921
Question
Match each type of programming language to its description.
Options:
A.
B.
C.
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
922
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
923
Question
Match commonly used development tools with their functions.
Options:
A.
Editor
B.
Compiler or interpreter
C.
Debugger
D.
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):
924
Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D
Target 5 = Option E
Target 6 = Option F
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.
925
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
926
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):
927
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
928
Algorithms Explained
Learning Objectives
recognize factors to consider when writing an algorithm using the top-down approach
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.
929
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:
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.
930
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
931
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
use indentation
provide one entry and one exit point for the algorithm, and
932
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
933
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
934
int a
int b
if (b
c
}
= 15;
= 10;
== 10) {
= 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.
935
getting input
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:
+
936
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
937
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:
GET
A.
B.
READ
C.
D.
WRITE
E.
LET
F.
VAR
938
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
939
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
940
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%
941
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
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%
942
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
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
943
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,
944
and group instructions into modules. You can apply conventions that most programming
languages use to make pseudocode easier to convert into executable code.
945
Creating an Algorithm
Learning Objectives
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
946
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:
947
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?
948
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
Question
949
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:
GET invoice total
A.
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:
950
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.
951
Structuring an Algorithm
Learning Objectives
952
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:
22:
23:
24:
25:
26:
27:
28:
PRINT name
IF address IS empty GOTO 25
PRINT address
GOTO 26
PRINT postbox
PRINT city
PRINT state
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
953
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:
22:
23:
24:
25:
PRINT
PRINT
PRINT
PRINT
PRINT
name
address
postbox
city
state
The most commonly used commands for capturing information for selection control are IF,
THEN, and ELSE.
Code
954
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.
955
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
956
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
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.
957
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.
B.
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.
958
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
959
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
960
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.
961
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.
962
IF Statements
Learning Objectives
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.
963
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 !=.
964
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
965
[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
966
{
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.
967
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
968
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.
969
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')
970
{
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");
971
}
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
972
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
973
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
974
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.
975
CASE Statements
Learning Objective
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.
976
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
THEN
PRINT
END IF
IF result
THEN
PRINT
END IF
IF result
THEN
PRINT
= "F"
"You got an F"
= "D"
"You got a D"
= "C"
"You got a C"
977
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
978
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
979
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
980
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.
981
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
Code
case comparator of
'<' : writeln ("less than");
'>' : writeln ("greater than");
'=' : writeln ("equal");
else
writeln ("invalid");
end
982
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");
}
983
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
984
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.
985
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.
986
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
987
B.
C.
D.
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.
the center section, which has 100 seats costing $20 each, and
988
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.
989
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
990
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
991
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
992
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");
993
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;
994
995
996
997
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.
998
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.
999
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.
1000
completing IF statements
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.
1001
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
1002
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
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.
1003
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
1004
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.
B.
P:
C.
F:
D.
Other:
X:
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.
1005
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:
1006
FOR Loops
Learning Objectives
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
1007
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
1008
Question
Identify the order of the steps a program takes when it executes a FOR loop.
Options:
A.
B.
If the counter hasn't reached its limit, execute the instructions included in the FOR loop
C.
D.
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.
Code
Name$ = "Joe Bloggs"
Address$ = "12 Basic Language Avenue"
FOR count = 1 to 5
PRINT "Name: "; Name$; " Address: "; Address$
NEXT count
1009
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.
1010
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.
1011
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
1012
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
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.
1013
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
Grade #1 for
Grade #2 for
Grade #3 for
Grade #4 for
Grade #5 for
Sands grades
student John
student John
student John
student John
student John
Sands
Sands
Sands
Sands
Sands
Smith
Smith
Smith
Smith
Smith
is
is
is
is
is
is
is
is
is
is
86
62
90
75
78
91
88
91
82
78
1014
Grade
Grade
Grade
Grade
Grade
#1
#2
#3
#4
#5
for
for
for
for
for
student
student
student
student
student
Elaine
Elaine
Elaine
Elaine
Elaine
Evans
Evans
Evans
Evans
Evans
is
is
is
is
is
77
79
83
70
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.
1015
WHILE Loops
Learning Objective
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.
1016
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
1017
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"
1018
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.
1019
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.
1020
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");
1021
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.
1022
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
1023
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
1024
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:
1025
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"
1026
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.
1027
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.
1028
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
1029
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?'
1030
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
1031
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.
1032
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
1033
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
1034
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.
C.
D.
ENDWHILE
1035
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.
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);
1036
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);
1037
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);
The entry condition of the WHILE loop is decided by the value of the other_donations
variable.
1038
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
1039
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);
1040
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);
1041
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
1042
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.
1043
Using Loops
Learning Objectives
Question
Match each defining table heading with the element contained in its column.
Options:
A.
B.
Process
C.
Output
Input
Targets:
1. Amount of each donation
2. Calculate the total donations
3. Total donations
Answer
1044
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
1045
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
1046
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.
1047
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
1048
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
1049
After completing this topic, you should be able to discuss the history of computers and describe
the different types of computers
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 8digits 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.
1050
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
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.
1051
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.
2.
3.
4.
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 customdesigned 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.
1052
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.
1053
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.
2.
3.
4.
Keyboard
Hard drive
Operating system
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
1054
word processors
spreadsheets
database managers
word processors
Word-processing programs, such as Microsoft Word, have replaced typewriters in producing textbased 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 customdesigned programs for their clients. Computer programmers are also required to produce offthe-shelf applications.
1055
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.
1056
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.
1057
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.
1058
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.
1059
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.
1060
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
Where
*
Employees
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.
2.
3.
4.
A := 3
1000100011100110
Set A equal to 3
MOV A,3
Targets:
A.
Machine language
B. Assembly language
C. High-level language
D. Fourth-generation language
1061
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
1062
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 structuredprogramming 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.
1063
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.
1064
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++.
Robust
Efficient
Usable
Maintainable
Robust
1065
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?
1066
Options:
1.
2.
3.
4.
Answer
Programmers can use well-structured code and documentation including manuals, wellcommented 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.
IF statement*/
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:
1068
1.
2.
3.
4.
Efficiency
Maintainability
Robustness
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.
1069
<p> 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.<br />&
lt;/p>
| Print | Contents | Close |
After completing this topic, you should be able to describe the phases of the software life cycle.
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
1070
Answer
Correct ranking
Option
Description
There are typically five steps involved in the software life cycle.
1071
1072
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.
1073
Question
Match the programming development roles with the relevant responsibilities.
Options:
1. Programmer
2. Programmer analyst
3. Systems analyst
Targets:
A.
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.
1074
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
Answer
Correct ranking
Option
Description
1075
Correct ranking
Option
Description
When writing a program, the programmer must complete each of these steps.
1076
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
1077
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.
1078
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.
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
1079
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.
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
1080
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.
2.
3.
4.
The programmer
The systems analyst
The vendor of the program
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.
1081
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.
1082
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
1083
Options
Option
Description
If the kettle contains less than 1 quart of water, fill it with water
Answer
Correct ranking
Option
Description
If the kettle contains less than 1 quart of water, fill it with water
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.
1084
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.
1085
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:
1086
Answer
There is no absolute standard for pseudocode.
There is no absolute standard for pseudocode, but you can follow these guidelines:
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.
1087
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.
2.
3.
4.
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.
2.
3.
4.
GET
SEND
READ
FORMAT
1088
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'
1089
=
+
*
/
()
=
= (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.
1090
*
* (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.
1091
Specific language conventions are used for basic computer operations. Algorithms can express
the arithmetic operations that you require a computer to perform.
1092
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.
21:
22:
23:
24:
25:
26:
27:
28:
PRINT name
IF street IS empty GOTO 25
PRINT street
GOTO 26
PRINT postbox
PRINT city
PRINT state
GOTO 17
The following code is used to print address labels uses the IFTHENELSE statement. This
code is simpler and easier to follow.
1093
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.
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
1094
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.
2.
3.
4.
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.
1095
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.
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.
1096
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.
2.
3.
4.
Input
Output
Process
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.
1097
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"
1098
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
1099
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.
1100
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.
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.
1101
Creating an algorithm
Learning objective
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:
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.
2.
3.
4.
5.
word_length1
total
word_length2
word1
word2
Targets:
A.
B.
C.
D.
E.
Input 1
Output 1
Input 2
Output 2
Output 3
1102
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
ADD word_length1+word_length2=total
GET word1
GET word2
PRINT total
CALCULATE word_length1
CALCULATE word_length2
1103
Answer
Correct ranking
Option
Description
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.
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.
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.
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.
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
1104
Option
Description
tax / final_amount
GET invoice
ADD tax+invoice=final_amount
CALCULATE tax
invoice
Answer
Correct ranking
Option
Description
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.
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.
CALCULATE tax
Each invoice generates a different amount of tax, depending on how large the invoice is and its
geographical location.
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.
tax / final_amount
The last step that this algorithm performs is to return the results it calculates to the calling
1105
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.
1106
After completing this topic, you should be able to discuss the roles of variables, constants and
data types in a program
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.
2.
3.
4.
Variable
Constant
Operator
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.
1107
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.
2.
3.
4.
5.
Names may not be the same as those reserved as keywords in a programming language
Names may not begin with a digit
Names may not begin with a letter
Certain characters may not be used in variable names
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.
1108
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
1109
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
1110
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.
1111
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.
2.
3.
4.
Boolean
Char
Integers
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.
1112
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.
1113
After completing this topic, you should be able to describe the functions of expressions and
statements in programming.
Question
Operators work with operands.
Which of the following do you think is the best definition of an operand?
Options:
1.
2.
3.
4.
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:
1114
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
1115
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
Parentheses
Answer
Correct ranking
Option
Description
Parentheses
1116
Correct ranking
Option
Description
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?
1117
Options:
1.
2.
3.
4.
As a division operator
To group expressions
As an addition operator
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.
2.
3.
4.
7
13
15
18
Answer
The value of the variable t is 15.
In the statement
y = 3 * (1+ 9 / 3)
1118
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.
2.
3.
4.
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.
1119
Question
Select the rule that you think is applicable to building assignment statements.
Options:
1.
2.
3.
4.
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.
1120
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.
1121
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
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.
2.
3.
4.
Operators
Constants
Variables
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
1122
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.
2.
3.
4.
item=9
float rate;
int car;
var car: integer;
1123
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.
1124
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.
Question
In an expression, certain operators have precedence over others.
Match each expression with the result it will produce.
Options:
1.
2.
3.
4.
5.
7+3*5
7*(3+5)
4*6-4
4*(6-4)
8/4-3+20-4
Targets:
A.
B.
C.
D.
E.
=8
= 22
= 20
= 56
= 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
1125
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.
B. m_5
C. 12_5
D. 5_7
m_m
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
1126
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.
Question
Integers are a specific subset of positive and negative numbers.
Which of the following are integers?
Options:
1.
2.
3.
4.
1
-1.5
-1348
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.
1127
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.
2.
3.
4.
0.25
4
4.0
-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.
1128
String
Operand
Operator
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:
1129
A.
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.
1130
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
1131
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 contain special characters that are disallowed by the programming language
1132
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
1133
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
1134
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.
1135
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 typechecking 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.
1136
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
1137
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;
1138
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.
1139
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.
1140
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
1141
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
1142
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
1143
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
1144
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.
1145
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.
1146
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
1147
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
1148
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
1149
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
1150
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.
1151
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.
1152
Building Expressions
Learning Objectives
recognize how variables, operators, and values are used to construct 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):
1153
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
1154
B.
254
C.
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
1155
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
1156
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.
D.
Answer
Correct answer(s):
1157
1158
Arrays
Learning Objectives
1159
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
1160
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
Code
DIM
You specify a name for the array, without using spaces or special characters.
Code
1161
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.
1162
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"]
1163
Creating two-dimensional arrays in LibertyBASIC and REALbasic is similar to creating onedimensional 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 twodimensional 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]
1164
Using Revolution, you can enter data as you create two-dimensional arrays, just as you can
when creating one-dimensional arrays.
Code
put
put
put
put
put
put
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.
1165
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.
1166
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
1167
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.
1168
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.
1169
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.
1170
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
1171
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
1172
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.
1173
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.
1174
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
1175
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
1176
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,
1177
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
1178
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
1179
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()
1180
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.
1181
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
1182
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
1183
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.
B.
Local
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
1184
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.
1185
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.
1186
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]
1187
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
1188
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
1189
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
1190
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?
1191
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.
1192
1193
SkillBrief
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.
1194
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.
1195
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.
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.
1196
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.
1197
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.
1198
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 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.
prototypes
user profiles
1199
user stories
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 end-user input about whether or not the software solution meets their 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.
1200
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
gain understanding of how the system can be designed to better help users achieve their goals
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.
1201
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
reach stakeholder agreement on the key features and functions that must be included in the
system and their priority
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.
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
1202
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), preconditions, flow of events, and post-conditions.
build an understanding of the problem domain and the components within the scope of the
domain
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.
1203
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.
prototypes
user profiles
user stories
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 end-user input about whether or not the software solution meets their requirements
1204
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.
gain understanding of how the system can be designed to better help users achieve their goals
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.
1205
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
reach stakeholder agreement on the key features and functions that must be included in the
system and their priority
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.
1206
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
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), preconditions, flow of events, and post-conditions.
build an understanding of the problem domain and the components within the scope of the
domain
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.
1207
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
1208
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
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.
1209
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.
1210
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.
1211
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.
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.
1212
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.
accurately understand the proposed future state of business within the enterprise
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.
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
1213
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 objectoriented 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 processcentric and pays particular attention to the data that flows into and out of processes. Unlike objectoriented 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.
1214
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.
1215
"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.
terms
facts
mandatory constraints
guidelines
action enablers
computations
inferences
1216
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
1217
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.
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
data flows that move data from external entities to processes, between processes and data
stores, and from processes to external entities
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.
1218
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.
process involved
1219
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.
1220
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
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:
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.
1221
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
data flows that move data from external entities to processes, between processes and data
stores, and from processes to external entities
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.
1222
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.
process involved
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.
1223
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
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:
1224
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
it is important to know about the decisions that can affect the order in which activities occur
business workflows
complex algorithms
Key elements
Activity diagrams use specific components to help describe a sequence of activities or workflow.
1225
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.
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.
1226
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
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.
1227
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.
1228
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 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.
1229
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
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
When documenting functional requirements, it's important to do so in such a way that stakeholders are
able to
1230
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.
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.
1231
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.
1232
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.
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.
1233
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.
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.
1234
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.
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
1235
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.
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.
1236
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.
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
1237
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 highestpriority 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.
1238
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 nonmandatory 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.
1239
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
1240
description, a business requirements document, a software requirements specification, and a request for
proposal or quotation.
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.
1241
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.
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.
1242
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.
1243
Software testing
The Necessity of Software Testing
Learning Objectives
1244
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.
1245
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
1246
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.
C.
Targets:
1. Failure
2. Defect
3. Error
Answer
1247
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
1248
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.
1249
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.
1250
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.
1251
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
1252
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
1253
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.
1254
1255
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.
1256
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.
1257
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
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.
1258
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.
1259
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.
1260
1261
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):
1262
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?
1263
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.
1264
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.
1265
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
1266
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
1267
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
1268
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.
1269
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
1270
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.
1271
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
1272
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
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.
1273
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.
B.
Static
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.
1274
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
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.
1275
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
1276
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
1277
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,
1278
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.
1279
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 conditions and architecture and then create test cases
C.
D.
E.
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.
1280
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.
1281
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.
1282
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.
Specify as a test condition that only users with authorized user names and passwords can log on
1283
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.
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
1284
assessed against the objectives. Test closure activities include creating a test summary report
and archiving testware.
1285
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
evaluate current activities in the testing process and decide steps for further action
1286
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
1287
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
1288
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 costeffective. 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 userdefined 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.
1289
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.
1290
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.
1291
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.
1292
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 selfreviews.
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.
1293
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.
1294
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 GUIbased 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.
1295
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.
1296
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.
1297
1298
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
1299
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
1300
fair and objective feedback. This helps bring testers and developers together and creates a
unified team.
1301
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
1302
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.
1303
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.
1304
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
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.
1305
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 costeffective.
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
1306
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.
1307
1308
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.
1309
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.
1310
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 thirdparty application, you perform acceptance testing on the third-party application first. Then you
carry out system testing for the web portal.
1311
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
1312
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.
1313
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
1314
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:
1315
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.
1316
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.
1317
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.
1318
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.
1319
1320
application efficient if it retrieves information within a few seconds. So the ability of an orderprocessing 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
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.
B.
1321
C.
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.
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.
1322
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
is ready to be deployed
1323
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.
1324
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
1325
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
1326
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).
1327
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
1328
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.
1329
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
1330
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
1331
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
1332
non-functional testing tests the behavioral, or the quantified characteristics, of the systems and software
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.
1333
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.
1334
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:
1335
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
1336
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 nonfunctional 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
1337
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-
1338
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
1339
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.
1340
1341
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.
1342
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.
1343
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
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
1344
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
1345
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
1346
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
1347
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
1348
testing is performed to ensure that previously working parts of the system have not had faults
introduced as a result of these fixes.
1349
1350
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
1351
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
1352
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.
1353
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
1354
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.
1355
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.
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
1356
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.
1357
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
1358
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
1359
ENGLISH
1360
SkillBrief
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
in single-word abbreviations
to indicate an ellipsis, which is the omission of a word, phrase, line, paragraph, or more from a
quoted passage
are not used after indirect questions, which report what someone has asked but not in the form of
the original question
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
1361
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 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.
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.
1362
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:
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.
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.
You also use a comma to separate main clauses connected by a coordinating conjunction.
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.
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.
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
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.
1363
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.
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 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
1364
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."
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.
1365
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.
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:
1366
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 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.
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.
1367
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.
1368
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.
1369
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.
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.
1370
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.
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.
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.
1371
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.
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.
1372
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.
1373
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.
1374
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.
You should generally avoid sentence fragments. However, it's acceptable to use them in some cases:
as exclamations,
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.
make one clause subordinate, especially if one idea is more important than the other, or
1375
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 semicolon
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.
1376
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.
1377
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.
you You are is contracted to you're, and the possessive form is your or yours.
who Who is or who has is contracted to who's and the possessive is whose.
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.
1378
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.
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.
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:
Continuous and continual are very similar in meaning both describe duration:
1379
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:
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:
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.
1380
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.
1381
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
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.
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
1382
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.
Literally means exactly as described. But people often misuse literally to emphasize something.
The word shouldn't be used in a figurative sense.
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.
1383
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:
1384
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:
1385
Coordinating conjunctions join words or groups of words that are of equal importance that is,
independent elements.
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
Being able to identify the eight parts of speech and use them correctly will help ensure your business
writing is clear, professional, and effective.
In the passive voice, the subject comes after the verb or may even be left out of a sentence.
1386
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.
1387
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 :
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.
1388
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.
1389
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.
capitalization becomes easier when you know how to spot proper nouns
being able to spot abstract nouns and replacing them with concrete nouns can often help you
write more clearly and vividly
1390
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:
1391
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.
1392
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
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.
1393
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:
"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.
1394
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 onesyllable 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.
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.
1395
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.
1396
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
1397
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 editorsin-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.
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.
1398
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.
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:
1399
use memory aids for example, visualize a word that you struggle with
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.
1400
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.
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.
1401
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."
1402
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.
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:
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:
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.
1403
1404
formal organizations, including companies and groups like non-profit organizations, movements,
and athletic groups
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
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,
1405
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.
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.
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.
1406
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 threehundredths 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.
1407
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.
1408
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
1409
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.
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.
1410
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.
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
1411
gestures to add meaning to your message, and ensure your facial expressions match the content of your
message.
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
1412
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.
1413
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.
1414
1415
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.
1416
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 logical relationship, in which one idea leads to another or relates logically to another
place or direction
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.
1417
unnecessary repetition, where more than one word or phrase means the same thing
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.
1418
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:
1419
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.
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.
1420
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:
according to level of importance for example if you need to outline recommended actions
1421
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.
1422
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.
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.
1425
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.
1427
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
1428
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.
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.
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 nonverbal 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
1431
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
1432
3.
4.
5.
6.
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.
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.
1433
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
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.
1435
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
V is for volume
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 highpitched 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.
1436
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.
1437
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.
1438
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."
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.
1439
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.
build suspense
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.
1440
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.
1441
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
1442
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.
1443
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.
1444
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.
yourself
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.
1445
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
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.
1446
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.
1447
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.
1448
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.
1449
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.
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.
1450
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.
1451
1452
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.
1453
"I feel very uncomfortable when you use bad language, and I'd like you to stop."
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.
1454
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.
1455
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.
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.
1456
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.
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
1457
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.
1458
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.
1459
repeated criticism
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
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.
1460
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.
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.
1461
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.
"Describe to me..."
"Explain to 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.
1462
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.
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.
1463
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.
1464
1465
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.
1466
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.
1467
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.
1468
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.
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.
1469
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
1470
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.
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.
1471
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.
1472
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.
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.
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.
1473
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.
1474