Sunteți pe pagina 1din 3

2/14/13

Topic Transcript

Querying and Manipulating Relational


Databases
Learning Objectives

After completing this topic, you should be able to


recognize the different relational algebra operations
recognize how to use SQL statements for queries and manipulation
Exercise overview
In this exercise, you are required to recognize different relational algebra operations and to determine how to use
SQL statements.
This involves the following tasks:
using relational algebra operations and
using SQL statements

Using relational algebra operations

Question
Each region in an organization has a separate sales table that stores the details of each sale,
including the employee ID of the employee who made the sale. You want a list of the employee IDs
of all employees who have made a sale in both regions.
Which traditional set operation in relational algebra would you use?
Options:
1. Union
2. Intersection
3. Difference
4. Cartesian product

Answer
Option 1: This option is incorrect. Represented b y the union symb ol, a union operation merges the
content of two or more union compatib le tab les. The tab le resulting from this union contains unique
values from all tab les involved in the operation. If used, this operation would result in a list of all
employees who made a sale in either region.
Option 2: This option is correct. An intersection, represented b y the intersect symb ol, compares the
information in two or more tab les. This operation results in a tab le that contains only the values
common to b oth tab les.
https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t8/misc/transcript.html

1/3

2/14/13

Topic Transcript

Option 3: This option is incorrect. The difference operator is represented b y the minus symb ol and
compares two or more union compatib le tab les. This operation returns the data that is unique to a
particular tab le. Using this operation in the current scenario would result in the list of all employees
who have only made a sale in the first region.
Option 4: This option is incorrect. A Cartesian product is represented b y the cross symb ol and
helps create a tab le that contains the product of two tab les. The tab le that results from this
operation contains the rows and columns that are a product of the numb er of rows and columns of
the b ase tab les. This operation would result in all the ways each employee could have made a sale
in b oth regions.
Correct answer(s):
2. Intersection

Question
Your organization is hosting a lucky draw for people who purchased products above a certain
amount. So you want to retrieve the IDs of all customers who meet this condition.
Which special operation in relational algebra will you use to retrieve this information?
Options:
1. Relational selection
2. Relational projection
3. Relational joins
4. Relational division

Answer
Option 1: This option is correct. The relational selection operation enab les you to select rows that
meet the condition you define. This condition can use any of the six comparison operators equals,
is not equal to, is less than, is greater than, is less than or equal to, and is greater than or equal to.
This operation is performed on a single tab le.
Option 2: This option is incorrect. The relational projection operation helps you retrieve unique
values from specific columns from a tab le. These columns need to b e specified in the expression
itself. This operation is performed on a single tab le. When used in this scenario, this operation
would result in a list of all customers who have purchased an item.
Option 3: This option is incorrect. Relational joins help comb ine records of two tab les that include a
column that contains the same type of data. In this instance you do not need to join two tab les to
retrieve the appropriate data.
Option 4: This option is incorrect. Using the relational division operation, you can divide one tab le
from another. This operation is represented b y the division sign and enab les you to compare the
values in the column common to two tab les. Then, the noncommon columns are retrieved from the
matching records in the dividend tab le. This operation cannot b e used in this scenario b ecause it
requires two tab les.
Correct answer(s):
1. Relational selection
https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t8/misc/transcript.html

2/3

2/14/13

Topic Transcript

Using SQL statements

Question
The name of a product offered by your organization has changed and the change needs to be
reflected in the Products table.
Which SQL statement would you use to make the change?
Options:
1. INSERT
2. GRANT
3. ALTER
4. UPDATE

Answer
Option 1: This option is incorrect. The INSERTstatement allows you to add records to a tab le. To do
this, you use the INSERTINTOclause followed b y the name of the tab le to which the record is to b e
added. This statement doesn't help you update the records of a tab le.
Option 2: This option is incorrect. The GRANTstatement defines the DML statements that a user is
allowed to perform. For example, you can define that a user can retrieve and modify records and is
therefore, allowed to perform b oth the SELECTand UPDATEstatements. This statement doesn't help
you update the records of a tab le.
Option 3: This option is incorrect. You use the ALTERstatement to modify the structure of an
existing tab le. You can use this statement to add and delete columns from a tab le. You can also
use it to modify the field type of an existing statement. This statement doesn't help you update the
records of a tab le.
Option 4: This option is correct. The UPDATEstatement allows you to edit the values present in a
tab le. To use this statement, you specify the name of the tab le b y using the UPDATEstatement and
then specify the change b y using the SETclause.
Correct answer(s):
4. UPDATE

2013 SkillSoft Ireland Limited

https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t8/misc/transcript.html

3/3

S-ar putea să vă placă și