0% found this document useful (0 votes)
160 views

Section 12 Lesson 1

This document contains 36 multiple choice questions from lessons in Sections 12-17 about SQL and relational databases. The questions cover topics such as data modeling, integrity constraints, joins, aggregation, expressions and functions in SELECT statements, comparison operators, and filtering results.

Uploaded by

id
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
160 views

Section 12 Lesson 1

This document contains 36 multiple choice questions from lessons in Sections 12-17 about SQL and relational databases. The questions cover topics such as data modeling, integrity constraints, joins, aggregation, expressions and functions in SELECT statements, comparison operators, and filtering results.

Uploaded by

id
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 11

Section 12 Lesson 1

1. A table must have at least one candidate key, as well as its primary key. True or False?

True
False (*)

Section 12 Lesson 1

2. The explanation below is a column integrity constraint: A column must contain only values consistent with the
defined data format of the column. True or False?

True (*)
False

Section 12 Lesson 1

3. The explanation below is a userdefined integrity rule: A primary key must be unique, and no part of the primary
key can be null. True or False?

True
False (*)

Section 12 Lesson 1

4. A table must have a primary key. True or False?

True
False (*)

Section 12 Lesson 2

5. In a physical data model, a relationship is represented as a combination of:

(Choose all correct answers)

Column
Primary Key or Unique Key (*)
Check Constraint or Unique Key
Foreign Key (*)

Section 12 Lesson 2

6. The transformation from an ER diagram to a physical design involves changing terminology. Secondary Unique
Identifiers becomes

Columns
Tables
Unique Constraints (*)
Primary Key Constraints

Section 12 Lesson 2

7. In a physical data model, an attribute becomes a _____________.

Table
Foreign Key
Constraint
Column (*)

Section 12 Lesson 3

8. Many to many relationships are implemented via a structure called a: ________________

Supertype
Intersection Table (*)
Intersection Entity
Subtype

Section 12 Lesson 3

9. What do you create when you transform a one to one relationship from your ER diagram into a physical design?

Unique key constraints


Intersection entity
Intersection table (*)
Two tables with a Foreign key constraints between them

Section 12 Lesson 4

10. When mapping supertypes, relationships at the supertype level transform as usual. Relationships at subtype level
are implemented as foreign keys, but the foreign key columns all become mandatory. True or False?

True
False (*)

Section 12 Lesson 4

11. Which of the following are reasons why you should consider using a Subtype Implementation?

The resulting table will reside in a single database and be used by just ONE user.
When the common access paths for the supertypes are different.
Business functionality and business rules, access paths and frequency of access are all very different between
subtypes. (*)
Most of the relationships are at the supertype level

Section 13 Lesson 1

12. What command will return data from the database to you?

FETCH
GET
SELECT (*)
RETURN

Section 13 Lesson 1

13. The DESCRIBE command returns all rows from a table. True or False?

True
False (*)
Section 16 Lesson 1

14. Evaluate this SELECT statement:


SELECT (salary * raise_percent) raise
FROM employees;

If the RAISE_PERCENT column only contains null values, what will the statement return?

Only zeroes
Only null values (*)
A null value or a zero depending on the value of the SALARY column
A null value or a numeric value depending on the value of the SALARY column

Section 16 Lesson 1

15. When you use the SELECT clause to list one or two columns only from a table and no WHERE clause, which
SQL capability is used?

Joining only
Selection only
Projection only (*)
Projection and Selection

Section 16 Lesson 1

16. Which statement best describes how arithmetic expressions are handled?

Addition operations are handled before any other operations.


Multiplication and substraction operations are handled before any other operations.
Multiplication and addition operations are handled before subtraction and division operations.
Division and multiplication operations are handled before subtraction and addition operations. (*)

Section 16 Lesson 1

17. The SELECT statement retrieves information from the database. In a SELECT statement, you can do all of the
following EXCEPT:

Projection
Manipulation (*)
Joining
Selection

Section 16 Lesson 1

18. You query the database with this SQL statement:


SELECT * FROM students;
Why would you use this statement?

To insert data
To view data (*)
To display the table structure
To delete data

Section 16 Lesson 1

19. Which SQL statement will return an error?


SEL * FR sky; (*)
select star from sky;
SELECT star FROM sky;
SELECT * FROM sky;

Section 16 Lesson 1

20. In a SELECT clause, what is the result of 2 + 3 * 2?

6
8 (*)
10
13

Section 16 Lesson 3

21. All computers in the world speaks the same languages, so you only need to learn one programming language -
Oracle SQL. True or False?

True
False (*)

Section 16 Lesson 3

22. In a SELECT statement ADDITIONS are evaluated before Multiplications. True or False?

True
False (*)

Section 17 Lesson 1

23. You need to display employees whose salary is in the range of 10000 through 25000 for employees in department
50 . What does the WHERE clause look like?

WHERE department_id < 50


AND salary BETWEEN 10000 AND 25000

WHERE department_id > 50


AND salary BETWEEN 10000 AND 25000

WHERE department_id = 50
AND salary BETWEEN 25001 AND 10001

WHERE department_id = 50
AND salary BETWEEN 25000 AND 10000 (*)

Section 17 Lesson 1

24. When using the LIKE condition, which symbol represents any sequence of none, one or more characters?

_
% (*)
#
&
Section 17 Lesson 1

25. Which operator is used to combine columns of character strings to other columns?

*
/
+
|| (*)

Section 17 Lesson 1

26. The Concatenation Operator does which of the following?

Links rows of data together inside the database.


Links two or more columns or literals to form a single output column (*)
Is represented by the asterisk (*) symbol
Separates columns.

Section 17 Lesson 1

27. When using the LIKE condition to search for _ symbols, which character can you use as the ESCAPE option?

%
^
&
\ (*)

Section 17 Lesson 1

28. You need to display employees whose salary is in the range of 30000 and 50000. Which comparison operator
should you use?

IN
LIKE
BETWEEN...AND... (*)
IS NULL

Section 17 Lesson 2

29. What will the result of the following SELECT statement be:
SELECT last_name, salary, salary + 300
FROM employees;

Display the last name, salary and the results of adding 300 to each salary for all the employees (*)
Modify the salary column by adding 300 and displaying the last name, salary and the new salary.
Modify the salary column by adding 300 and only display the last name and the new salary.
Display the last name, salary and the results of adding 300 to the salary of the first employee row

Section 17 Lesson 2

30. The PLAYERS table contains these columns:


PLAYER_ID NUMBER (9) Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER (4)
MANAGER_ID NUMBER (9)
POSITION_ID NUMBER (4)

Which SELECT statement should you use if you want to display unique combinations of the TEAM_ID and
MANAGER_ID columns?

SELECT * FROM players;


SELECT team_id, manager_id FROM players;
SELECT DISTINCT team_id, manager_id FROM players; (*)
SELECT team_id, DISTINCT manager_id FROM players;
SELECT team_id, manager_id DISTINCT FROM players;

Section 17 Lesson 2

31. Which of the following commands will display the last name concatenated with the job ID from the employees
table, separated by a comma and space, and label the resulting column "Employee and Title"?

SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM employees;
SELECT last_name||', '|| job_id "Employee and Title" FROM employees; (*)
SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM emp;
SELECT last_name||","|| job_id "Employee and Title" FROM employees;

Section 17 Lesson 2

32. You need write a SELECT statement that should only return rows that contain 34, 46, or 48 for the
DEPARTMENT_ID column. Which operator should you use in the WHERE clause to compare the
DEPARTMENT_ID column to this specific list of values?

=
!=
IN (*)
BETWEEN..AND..

Section 17 Lesson 2

33. You need to display all the values in the EMAIL column that contains the underscore (_) character. The WHERE
clause in your SELECT statement contains the LIKE operator. What must you include in the LIKE operator?

The ESCAPE option (\) and one or more percent signs (%)
The (+) operator
A percent sign (%)
The ESCAPE option (\) (*)

Section 17 Lesson 3

34. The STUDENT table contains these columns:


STUDENT_ID NUMBER(10) Primary Key
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
MAJOR_ID NUMBER(3)
ADVISOR_ID NUMBER(5)

Evaluate this statement:


SELECT DISTINCT advisor_id, major_id
FROM student;
Which statement is true?

Each ADVISOR_ID can be displayed only once.


Each MAJOR_ID can be displayed more than once per ADVISOR_ID. (*)
Each combination of ADVISOR_ID and MAJOR_ID can be displayed more than once.
Each MAJOR_ID can be displayed only once.

Section 17 Lesson 3

35. The The PRODUCT table contains these columns:


PRODUCT_ID NUMBER(9)
DESCRIPTION VARCHAR2(20)
COST NUMBER(5,2)
LOCATION_ID VARCHAR2(10)

You want to display product costs with these desired results:


1. The cost displayed for each product is increased by 10 percent.
2. The product location id must be 4859, 9789, or 9898.
3. Ten percent of the original cost is less than $10.

Which statement should you issue?

SELECT product_id, cost * 1.10


FROM product
WHERE cost * .10 < 10.00
AND location_id IN (4859, 9789, 9898); (*)

SELECT product_id, cost * .10


FROM product
WHERE cost * 1.10 > 10.00
AND location_id IN (4859, 9789, 9898);

SELECT product_id, cost * 1.10


FROM product
WHERE cost * 1.10 < 10.00
AND location_id = (4859, 9789, 9898);

SELECT product_id, cost * 1.10


FROM product
WHERE cost * .10 > 10.00
AND location_id = (4859, 9789, 9898);

Section 17 Lesson 3

36. The EMPLOYEES table contains these columns:


LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
EMAIL VARCHAR2(50)

You are writing a SELECT statement to retrieve the names of employees that have an email address.

SELECT last_name||', '||first_name "Employee Name"


FROM employees;

Which WHERE clause should you use to complete this statement?


WHERE email = NULL;
WHERE email != NULL;
WHERE email IS NULL;
WHERE email IS NOT NULL; (*)

Section 18 Lesson 1

37. The ORDER BY clause always comes last. True or False?

True (*)
False

Section 18 Lesson 1

38. Which statement about the default sort order is true?

The lowest numeric values are displayed last.


The earliest date values are displayed first. (*)
Null values are displayed first.
Character values are displayed in reverse alphabetical order.

Section 18 Lesson 1

39. You need to override the default sort order of the ORDER BY clause so that the data is displayed in reverse
alphabetical order. Which keyword should you include in the ORDER BY clause?

DESC (*)
ASC
SORT
CHANGE

Section 18 Lesson 1

40. Which of the following are TRUE regarding the logical AND operator?

TRUE AND TRUE return FALSE


TRUE AND FALSE return TRUE
FALSE AND TRUE return NULL
TRUE AND FALSE return FALSE (*)

Section 18 Lesson 1

41. From left to right, what is the correct order of Precedence?

Arithmetic, Concatenation, Comparison, OR (*)


NOT, AND, OR, Arithmetic
Arithmetic, NOT, Logical, Comparison
Arithmetic, NOT, Concatenation, Logical

Section 18 Lesson 1

42. Which of the following best describes the meaning of the LIKE operator?

Display rows based on a range of values.


To test for values in a list.
Match a character pattern. (*)
To find Null values.

Section 18 Lesson 2

43. Evaluate this SELECT statement:


SELECT emp_id, last_name, first_name, salary 'Yearly Salary'
FROM employees
WHERE salary IS NOT NULL
ORDER BY last_name, 3;

Which clause contains an error?

SELECT emp_id, last_name, first_name, salary 'Yearly Salary' (*)


FROM employees
WHERE salary IS NOT NULL
ORDER BY last_name, 3;

Section 18 Lesson 2

44. What value will the following SQL statement return?


SELECT employee_id
FROM employees
WHERE employee_id BETWEEN 100 AND 150
OR (employee_id IN(119, 175, 205)
AND (employee_id BETWEEN 150 AND 200);

19
No rows will be returned.
100, 101, 102, 103, 104, 107, 124, 141, 142, 143, 144, 149 (*)
200, 201, 202, 203, 204, 205, 206

Section 18 Lesson 2

45. Which SELECT statement should you use to limit the display of product information to those products with a
price of less than 50?

SELECT product_id, product_name FROM products WHERE price < 50; (*)
SELECT product_id, product_name FROM products HAVING price < 50;
SELECT product_id, product_name FROM products WHERE price <= 50;
SELECT product_id, product_name FROM products GROUP BY price < 50;
SELECT product_id, product_name FROM products WHERE price < 50.00 GROUP BY price;

Section 18 Lesson 2

46. You attempt to query the database with this SQL statement:
SELECT product_id "Product Number", category_id "Category", price "Price"
FROM products
WHERE "Category" = 5570 ORDER BY "Product Number";

This statement fails when executed. Which clause contains a syntax error?

SELECT product_id "Product Number", category_id "Category", price "price"


ORDER BY "Product Number";
FROM products
WHERE "Category" = 5570 (*)
Section 18 Lesson 2

47. You need to create a report to display all employees that were hired on or after January 1, 1996. The data should
display in this format:
Employee Start Date and Salary
14837 - Smith 10-MAY-92 / 5000

Which SELECT statement could you use?

SELECT employee_id || - || last_name "Employee",


hire_date || / || salary "Start Date and Salary"
FROM employees
WHERE hire_date <= '01-JAN-96';

SELECT employee_id ||' '|| last_name "Employee",


hire_date ||' '|| salary "Start Date and Salary"
FROM employees
WHERE hire_date <= '01-JAN-96';

SELECT employee_id ||'"- "|| last_name "Employee",


hire_date ||" / "|| salary "Start Date and Salary"
FROM employees
WHERE hire_date <= '01-JAN-96';

SELECT employee_id ||' - '|| last_name 'Employee',


hire_date ||' / '|| salary 'Start Date and Salary'
FROM employees
WHERE hire_date <= '01-JAN-96';

SELECT employee_id ||' - '|| last_name "Employee",


hire_date ||' / '|| salary "Start Date and Salary"
FROM employees
WHERE hire_date <= '01-JAN-96'; (*)

Section 18 Lesson 2

48. Evaluate this SELECT statement:


SELECT last_name, first_name, salary
FROM employees;

How will the results of this query be sorted?

The database will display the rows in whatever order it finds it in the database, so no particular order. (*)
The results will be sorted ascending by the LAST_NAME column only.
The results will be sorted ascending by LAST_NAME and FIRST_NAME only.
The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY.

Section 18 Lesson 3

49. The PLAYERS table contains these columns:


PLAYERS TABLE:
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(8,2)
TEAM_ID NUMBER(4)
MANAGER_ID NUMBER(9)
POSITION_ID NUMBER(4)

You must display the player name, team id, and salary for players whose salary is in the range from 25000 through
100000 and whose team id is in the range of 1200 through 1500. The results must be sorted by team id from lowest to
highest and then further sorted by salary from highest to lowest. Which statement should you use to display the desired
result?

SELECT last_name, first_name, team_id, salary


FROM players
WHERE (salary > 25000 OR salary < 100000)
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id, salary;

SELECT last_name, first_name, team_id, salary


FROM players
WHERE salary BETWEEN 25000 AND 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id, salary DESC; (*)

SELECT last_name, first_name, team_id, salary


FROM players
WHERE salary > 24999.99 AND salary < 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id ASC, salary DESC;

SELECT last_name, first_name, team_id, salary


FROM players
WHERE salary BETWEEN 24999.99 AND 100000.01
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id DESC, salary DESC;

Section 18 Lesson 3

50. Evaluate this SQL statement:


SELECT e.employee_id, e.last_name, e.first_name, m.manager_id
FROM employees e, employees m
ORDER BY e.last_name, e.first_name
WHERE e.employee_id = m.manager_id;

This statement fails when executed. Which change will correct the problem?

Reorder the clauses in the query. (*)


Remove the tables aliases in the WHERE clause.
Remove the table aliases in the ORDER BY clause.
Include a HAVING clause.

You might also like