You are on page 1of 83

These are quiz answers for CIMW 105

Introduction to SQL based on the book


A Guide to SQL by Chris Pratt
Each quiz had multiple attempts so this is helpful but only a study aid
even if you are enrolled in the same class. MANY of the answers are
wrong but you can see the correct answers which I found very
helpful.

Quizzes
Quiz 1
What best defines the term PHP/MySQL?

  
Server-Side Scripting Language
 

  
Oracle
 
Correct Answer
  
PHP language and a set of libraries for PHP that allow access to a MySQL RDBMS
 
You Answered
  
a Server supporting PHP and MySQL
 
 
Question 2
0 / 1 pts
Give this table:inventory

fruitID quantity
1 100
2 10
2 20
3 25
3 15
3 10

What is the data output (ignore column header names) for this:
select sum( quantity ) from inventory where fruitID < 3;

query?

  
180
 

  
30
 
Correct Answer
  
130
 
You Answered
  
empty set
 

  
100
 

  
sql error
 
for fruitID < 3
you have 100+10+20 = 130
 
Question 3
0 / 1 pts
What is the name of a popular tool for interfacing to a MySQL, using only a Web
Browser?
Correct Answer
  
PHPMyAdmin
 
You Answered
  
none of the above
 

  
MySQL Query Interface
 

  
SQL Query Window
 

  
navicat
 

  
MySQL Query Browser
 
RDBMS - Relational Database Management System are the most popular database
system. Almost all web hosting companies provide you with a PHPMyAdmin interface.
PHPMyAdmin is one of the most popular open source applications. This class will be
using PHPMyAdmin as the interface to your MariaDB/MySQL database.
 
Question 4
0 / 1 pts
Given This Table:fruit

fruitID name price


1 apple 2.50
2 pear 3.00
3 banana 1.00
4 grpe 0.75
8 pluot 4.50
6 plum 1.25
Ignoring column header names
How many fruit names (aka column name) would this query
select fruitID, price from fruit where price >= 1.25;
output?
You Answered
  
2
 

  
4
 
Correct Answer
  
0
 

  
empty set
 

  
3
 

  
5
 

  
1
 
the display expression is
 
select fruitID, price from fruit;
 
so it will display no fruit names,
 
Question 5
0 / 1 pts
In Databases a synonym for fields  is _____?
You Answered
table

Correct Answers
column
 
Columns
 
columns
 
Column
 
 
Question 6
0 / 1 pts
Give this table:inventory

fruitID quantity
1 100
2 10
2 20
3 25
3 15
3 10

What is the data output (ignore column header names) for this:
select sum( quantity ) from fruit;

query?

  
10
 
Correct Answer
  
SQL error
 

  
100
 
You Answered
  
180
 

  
empty set
 
using table fruit would result in error, exception thrown,
table fruit doesn't have the column quantity.
 
Question 7
0 / 1 pts
In the fruit RDB (Relational Database) which field in inventory forms a relationship with
the table:fruit ?
You Answered
name

Correct Answers
fruitID
 
 
Question 8
1 / 1 pts
Read all possible answers, select the best answer.
What would this SQL command do?

select * from fruit where fruitID=2;

  
Generate an Error
 
Correct!
  
Would output the row that has fruitID equal to 2 or an empty set if fruitID = 2 doesn't
exist in table
 

  
Output the fruitID=2 row
 

  
would output all rows with fruitID of 2
 

  
Output the contents of fruit table
 

  
none of the above
 

  
Output the three Apple fields
 
fruitID is a primary key,
each record of the table must have a unique primary key.
Therefore, it will only output one row matching the fruitID=2;
If the table:fruit doesn't have a row with fruitID=2, it will output the empty set.
 
Question 9
1 / 1 pts
RDBMS  stands for ______ Database Management System (1 word only).
Correct!
relational

Correct Answers
Relational
 
relational
 
 
Question 10
0.33 / 1 pts
Clicking a table:fruit  in the left navbar of PHPMyAdmin is equivalent to which SQL
query.

  
select * from fruit where fruitID=1
 
Correct Answer
  
select * from fruit;
 

  
select * from fruit where fruitID<8
 

  
select * from Fruit;
 
Correct Answer
  
Select * from fruit;
 
Correct!
  
SELECT * From fruit;
 
When you select a table name in the left navBar,
it automatically excecutes the query
select * from tableReferenceName;
note keywords select and from are case insensitive
the table name and usernames are case sensitive.
So
select * from Fruit;

will not occur Fruit is not fruit. PHPMyAdmin does add the accents `fruit`, which are
used to delimit table names. At this stage they are optional, when we add views and
variables, they become required.
Quiz Score: 2.33 out of 10
Quiz Submissions
 Attempt 1: 2.33
 Attempt 2: 7

has no attempts left


 Back to Quiz

Question 1
1 / 1 pts
In fruit database, the table fruit has ____ columns.
Correct!
3

Correct Answers
Three
 
three
 
3
 
 
Question 2
1 / 1 pts
In Databases a synonym for rows is _____?
Correct!
record

Correct Answers
Record
 
Records
 
record
 
records
 
In C.S. a tuple is a sorted list with possible duplicates
The two statements below are true:

 synonym for rows is record or tuple


 database synonym for a row is a record
(especially from a historic perspective, tuple would not fit)

Notice three different questions:

1. In  CS data structures a synonym for rows is tuple or record


2. For databases synonym for  rows  is record

 
Question 3
0 / 1 pts
The top Open source RDBMS is ______?
You Answered
SQL

Correct Answers
Mysql
 
MySQL
 
mySQL
 
mysql
 
 
Question 4
1 / 1 pts
A table is organized into rows and ___.
Correct!
columns

Correct Answers
field
 
column
 
fields
 
Column
 
Columns
 
columns
 
 
Question 5
1 / 1 pts
What would this SQL command do?

select * from fruit where price = .75;

  
Output the contents of fruit table
 

  
first row with price equal to 0.75
 

  
Output the most expensive fruit
 

  
Output only the first record
 
Correct!
  
Would output all rows with price equal to .75
 

  
Generate an Error
 
 
Question 6
1 / 1 pts
What is the SQL keyword used to generate output ______ (1 word only).
Correct!
select

Correct Answers
select
 
Select
 
SELECT
 
 
Question 7
1 / 1 pts
Which company has the largest share of the RDBMS market place?

  
none of the above
 

  
Microsoft
 
Correct!
  
Oracle
 

  
Sybase
 

  
SAP
 

  
IBM
 
RDBMS - Relational Database Management System are dominating
 
Question 8
0 / 1 pts
Cloud is just an _____________ based service.
(fill in best answer)
You Answered
enterpris

Correct Answers
network
 
Internet
 
internet
 
cloud is just an internet based service.
notice an (so both network and web are wrong)
Web is too specific. Web is an internet connection with Web server software.
 
Question 9
0 / 1 pts
What is the most popular noSQL database?
You Answered
lamp

Correct Answers
mongoDB
 
MongoDB
 
mongodb
 
Correct answer is MongoDB.
Consult viewgraphs 16-20.
 
Question 10
1 / 1 pts
A RDBMS implies that you have relationship among and between tables?
Correct!
  
True
 

  
False
 

Quiz Score: 7 out of 10
Quiz Submissions
 Attempt 1: 2.33
 Attempt 2: 7

has no attempts left


 Back to Quiz

Quiz o orentation

Question 1
1 / 1 pts
Class Website is at....

  
ebay.com
 
Correct!
  
www.saddleback.edu/faculty/tdedonno/cimw105
 

  
on myspace
 

  
gamespot.com
 
Remember CIM is your master index page, everything has cim shortcut keys
class site:    http://cim.saddleback.edu/cimw105
Canvas:
http://cim.saddleback.edu/canvas
help: http://cim.saddleback.edu/help
 
Question 2
1 / 1 pts
You must stay up to date with the course, by providing a home email forwarding address
for your Saddleback email account that you check often.
Correct!
  
True
 

  
False
 
 
Question 3
1 / 1 pts
One of the ways to do well in this course is to...

  
Read the text book and do weekly homework assignments.
 

  
Play your favorite computer game in class.
 
Correct!
  
Pay attention to the schedule, and complete quizzes and homework either before or in
time with the schedule recommendations.
 

  
Skip class frequently, put off taking all the tests to the very last day.
 
 
Question 4
1 / 1 pts
Canvas is used to maintain all online quizzes and has links to class website and other
important data.
Correct!
  
True
 

  
False
 
 
Question 5
1 / 1 pts
On all emails sent to instructor your subject header should begin with CIMW 105  or
MySQL?
Correct!
  
True
 

  
False
 
I get a lot of e-mails and a proper subject is the best way to sent them.
 
Question 6
1 / 1 pts
Your MariaDB (MySQL 5.5 Fork) database is located at which server?
(Recently OpenSuse has moved from MySQL to MariaDB)
MariaDB is an open source replacement for MySQL, it is identical to MySQL 5.5;
Correct!
  
cim.saddleback.edu
 
  
www.saddleback.edu
 

  
ebay
 

  
oracle
 
cim.saddleback.edu is the testing server for My classes,
you have two databases on cim;   DBsbusername and DB1sbusername
where sbusername is your Saddleback username firstInitialLastNameUniqueNumber
we will be using phpMyAdmin to interface to your Database
 
Question 7
1 / 1 pts
Both Class websiteLinks to an external site. and Saddleback homepageLinks to an
external site. have links to Canvas which holds the private information for the course the
on-line quizzes, Web-cast archives and videos?
Correct!
  
True
 

  
False
 
 
Question 8
1 / 1 pts
Class Grades consists of...

  
In class Tests, and homework assignments.
 
Correct!
  
Online Canvas quizzes and homework assignments
 

  
Tests and a Computer Programming projects.
 

  
Final, midterm, and weekly homework assignments.
 
 
Question 9
1 / 1 pts
It is the students responsibility to officially withdraw from the course?
Correct!
  
True
 

  
False
 
Good Job, if you are unable to finish the class pay attention to withdrawal dates, and
withdraw before the deadlines.
 
Question 10
1 / 1 pts
You should first Watch online Canvas videos before starting the book?
Correct!
  
True
 

  
False
 
We have a set of initial assignments (tutorial, fruit.sql) and a set of intro Videos to
MySQL database that will make reading the book easier. On low to medium resolution
monitors, download Opera and/or use view  zoom to see bottom VCR controls on some
videos.
Quiz Score: 10 out of 10
Previous Next
Last Attempt Details:
Time: 9 minutes

Current Score: 10 out of 10

Kept Score: 10 out of 10


1 More Attempt available

Quiz 2

Question 1
1 / 1 pts
SQL keyword used to sort columns?
Hint ____ by.
Correct!
order

Correct Answers
(?i)order\s*(by)?
 
order by
 
order
 
to sort by price we use

select * from fruit


order by price; 
 
Question 2
1 / 1 pts
Single-word table names for fruit database are all in ________ letters.
Correct!
low ercas

Correct Answers
lower
 
[lL][oO][wW][eE][rR][- ]?[cC][aA][sS][eE]
 
lowercase
 
Consistency Notes...
fruit tables are all lowercase
premiere tables are all uppercase
note the correct word is lowercase,  when a new word is introduced such as email it is
typical to use a hypen e-mail, we also sometimes initially capitalize it,
(i.e., Web E-Mail) but over time it becomes accepted and the word is just web or email.
When we introduction tables with multiple words, we will be using lower camel case,
in lower camel case the first word is lowercase letters, first letter or 2nd word is
uppercase.
e.g.,  orderLine, or iPhone
 
Question 3
1 / 1 pts
When a Query output doesn't match the solution,
submit uses the  ____  command to generate side by side comparison of the solution
versus the assignment output.
Correct!
sdiff

Correct Answers
sdiff
 
[sS][dD][iI][fF][fF]
 
the command is allow lower case 

called sdiff
 
Question 4
1 / 1 pts
The default sorting order for SQL is?

  
descending
 
Correct!
  
ascending
 

  
doesn't have a default

  
set by operating system variable
 
 
Question 5
1 / 1 pts
SQL keyword to used to display the string Hello.
Correct!
select

Correct Answers
(?i)select.*
 
select "Hello";
 
select "Hello"
 
select
 
select "Hello";
its just the select keyword
 
Question 6
1 / 1 pts
In SQL in-line comments begin with a double dash (aka - -) or __.
Correct!
#

Correct Answers
#
 
(?i)hash(tag| character)
 
(?i)pound\s+sign
 
before you enter a query, for submission.
You should always have
# comment in the line above each  query
The comment should identify the query number and also what the query is suppose to
do, you can lose points by not properly documenting your code.
You can use both # and -- on the same line as a query. For Example,
select * from fruit # display all fields for table fruit where price < 1.0; #for price less that
1.0
however in SQL is best not to intermingle comments and code.
 
Question 7
0 / 1 pts
To display only the first 3 rows of a query one would use the SQL keyword.
(1 word keyword only all lowercase letters)
You Answered
select

Correct Answers
limit
 
[lL][iI][mM][iI][tT]\s+3?;?\s*
 
select * from fruit limit 3;
but all I'm asking for is the keyword so correct answer is limit
 
Question 8
1 / 1 pts
In the videos for  class we created tabbed browsing for how many key sites.
Correct!
4

Correct Answers
5
 
(?i)five
 
five
 
4
 
four
 
Five 5 key sites

1. Canvas private info videos/quizzes


2. class site public assignment page
3. phpMyAdmin testing database system
4. submit for submitting assignments
5. premiere web site where you can display database scripts used in class

Tabs are set once and forgot the exact location, but a modern student should be able to
quickly comprehend what each tab is used for.
Note intermediate level browsing skills are important not only for this class, but it is a
skill you should develop in the 21st century.
 
Question 9
1 / 1 pts
After selecting a table in PHPMyAdmin,
you can enter select  queries using the ____ tab.
Correct!
SQL

Correct Answers
SQL
 
(?i)sql
 
(?i)Browse
 
Browse
 
The query tab is not available once a table is selected,
only the SQL and Browse tab. 

Browse tab is the active tab, need to click edit to edit default query
SQL allows you to enter any query w templates on Select, Delete, Insert and Update.
 
Question 10
1 / 1 pts
All popular browsing can be configured to automatically open up a set of default pages. 
Correct!
  
True
 

  
False
 
We did this in the video with chrome,

but IE, FireFox, Safari and Opera can also so this.

Quiz Score: 9 out of 10
Quiz Submissions
Question 1
1 / 1 pts
To delimit numbers to be used as literal constants  one uses?

Correct!

  

single quote

  

accent

  

double quote

  

literal quote

The single quote is used to quote literal values.


 

Question 2
1 / 1 pts
phpmyadm submit
For cimw 105, we will be using   for testing all queries and   for grading
assignments.

Answer 1:

Correct!phpMyAdmin

Correct Answer

(https://)?cim.saddleback.edu/(pma|phpMyAdmin)

Correct Answer
PHPMyAdmin

Correct Answer

pma

Answer 2:

Correct!submit

Correct Answer

(http://)cim.saddleback.edu/(~tdedonno/)?/submit

We will be using phpMyAdmin to test all queries.


Submit is for grading not debugging, always pay attention to what is being asked.
 

Question 3
1 / 1 pts
Single-word table names for fruit database are all in ________ letters.

Correct!
low ercase

Correct Answers

lower

[lL][oO][wW][eE][rR][- ]?[cC][aA][sS][eE]

lowercase

Consistency Notes...
fruit tables are all lowercase
premiere tables are all uppercase
note the correct word is lowercase,  when a new word is introduced such as email it is
typical to use a hypen e-mail, we also sometimes initially capitalize it,
(i.e., Web E-Mail) but over time it becomes accepted and the word is just web or email.
When we introduction tables with multiple words, we will be using lower camel case,
in lower camel case the first word is lowercase letters, first letter or 2nd word is
uppercase.
e.g.,  orderLine, or iPhone
 

Question 4
0 / 1 pts
What is the universal hotkey for pasting in content from phpMyAdmin into submit's editing
pane?
(Use a capital letter for the first letter of words)

You Answered
Ctrl^C

Correct Answers

Ctrl^V

(?i)c(on)?tr[o]?l\s*(\-|\+|\^)?\s*v\s*

Control+V

Control-V

CTRL+V

Control V

Control^V is the universal paste


 
if you missed this question, you need to rewatch the tutorial video on intermediate
browsing.
Developing skills is more important than learning how to wing it or google it.
 

Question 5
1 / 1 pts
SQL keyword used to sort columns?
Hint ____ by.
Correct!
order

Correct Answers

(?i)order\s*(by)?

order by

order

to sort by price we use

select * from fruit


order by price; 
 

Question 6
0 / 1 pts
When using submit, to detemine exact location of white space errors, 
submit will output?
Correct Answer

  
octal dump

You Answered

  

sdiff comparison

  

blank lines

  

line numbers

The od, octal dump display the octal/hexadecimal value of each character.

It will compare it to the solution.

Question 7
1 / 1 pts
Default sort order for MySQL is? 

Correct!
ascending

Correct Answers

ascending

[aA][sS][cC][eE]?[nN]?[dD]?[iI]?[nN]?[gG]?

asc

 
ASC

ascending order

Question 8
0 / 1 pts
In surfing the Web you should always try to decipher URL addresses.

You Answered

  

True

Correct Answer

  

False

Let the Web guide,


the only time you should check a URL is  with an HTTPS access, if  server is not have a
validated certificate your  system should warn you.
For this class, let the Web guide you. Just follow the current module due every Monday.
Key links are everywhere, and a prerequisite is to set up the correct multi-tab work
space browser environment.
Short-cutting curriculum helps keep enrollments up at CCC. But if your goal is to learn
and develop skills, then don't skip videos.
 

Question 9
0 / 1 pts
For this class we are using the Web application  _______ as our database testing srever
You Answered
phpadmin

Correct Answers

phpMyAdmin

pma

(?i)phpmyadmin

Question 10
1 / 1 pts
Learning how to create an effective tabbed web-based browsing SQL development environment
has been covered in this class.

Correct!

  

True

  

False

Do not cut corners in the class, by skipping videos.


The videos are designed to gradually teach skills, one of the key building blocks skills for
success in this class, is learning how to configure an IDE (Integrated Developers
Environment) using a browser with preset tabs.

Quiz Score: 6 out of 10

Quiz Submissions
Quiz 3

Question 1
0 / 1 pts

Table A has the columns: price, aID (where aID is primary key of table A)
Table B has three columns:  aID (Foreign Key), bID (pirmary key) and quantity.
Which query will display the price, and quantity for all items whose quantity is greater
than 0.
During table creation,  all columns are set to not null. A price of null on output is okay.

  

select price, quantity from A, B where A.aID = b.aID and quantity > 0;

You Answered

  
select price, quantity from A, B where A.aID = b.aID or quantity > 0;

  
select price, quantity from A left join B on A.aID = b.aID

where quantity > 0;


Correct Answer

  
select price, quantity from A right join  B on A.aID = b.aID

where quantity > 0;

  
select price, quantity from A, B where quantity > 0;

Since you are interested in quantity greater than 0 and price,

A left join B will not work, you will not get items in B but not in A

You need to use table 2, and look for quantity > 0


 

Question 2
0 / 1 pts
table:
table: fruit
inventory

fruitI pric
name fruitID quantity
D e

1 apple 2.50 1 100

2 pear 3.00 3 500


    
4 grpe 0.75 2 100

5 peach 1.25 5 10

8 pluot 4.50 1 250

6 plum 1.25 2 200

3 banana 1.00    

what will the first data row (ignoring header/field/column names) output,
for the query

select count( fruitID ) from inventory group by fruitID order by fruitID DESC limit 1;

  

Correct Answer

  

  
2

  

  

You Answered

  

the group by groups all elements by fruitID


the order by fruitID asc puts the highest fruitID first which is 5,
since we have only one 5, it kicks out 1 first
 

Question 3
0 / 1 pts
     table:
table: fruit
inventory

fruitI pric
name fruitID quantity
D e

1 apple 2.50 1 100

2 pear 3.00 3 500

4 grpe 0.75 2 100

5 peach 1.25 5 10

8 pluot 4.50 1 250


6 plum 1.25 2 200

3 banana 1.00    

what will the first data row (ignoring header/field/column names) output,
for the query

select sum( quantity ) from inventory group by fruitID order by fruitID DESC;


Correct Answer

  

10

  

350

  

500

You Answered

  

1160

  

700

  

100

 
the group by clause will group them by fruitID,
which will then cause sum, to only sum the same fruitIDs
however, the order by clause will put the highest fruitID first.
 

Question 4
1 / 1 pts
With two table intersection, ____ items are not matched.

Correct!
null

Correct Answers

null

[nN][uU][lL][lL]\s*

NULL

on Inner joins,
intersecton NULL items are not matched.
e.g.,
select * from fruit, inventory where fruit.fruitID = inventory.fruitID;
 

Question 5
0 / 1 pts
     table:
table: fruit
inventory

fruitI pric
name fruitID quantity
D e

1 apple 2.50 1 100


2 pear 3.00 3 500

4 grpe 0.75 2 100

5 peach 1.25 5 10

8 pluot 4.50 1 250

6 plum 1.25 2 200

3 banana 1.00    

What would the data of the query


select name, price from fruit order by price asc limit 1;
 
Output (ignoring the header row)?

  

apple  2.50

  

plout 4.50

  

pear 3.0

You Answered

  

banana 1.00

Correct Answer

  

grp 0.75
 

  

apple 0.75

Note select name, price


outputs name and price
order by price will sort by price with the lowest price first (aka ASC ending)
limit 1; will print out only 1 row of data; it still prints out the header row
 

Question 6
0.33 / 1 pts
table:
table: fruit
inventory

fruitI pric
name fruitID quantity
D e

1 apple 2.50 1 100

2 pear 3.00 3 500


 
4 grpe 0.75 2 100

5 peach 1.25 5 10

8 pluot 4.50 1 250

6 plum 1.25 2 200

3 banana 1.00    

Which items below are correct about the following query?

select name, price, quantity from fruit, inventory where fruit.fruitID = inventory.fruitID
and quantity <= 100;

Correct!
  

will display three rows of data

Correct Answer

  

you have a customer that is interested in name, price and quantity for all rows in inventory table
that have a quantity of not more than 100 items.

Correct Answer

  

you are joining two tables by fruitID

  

select * from Inventory where fruitID = 1;

  

will only display 1 row of data

  

will display fruit with no inventory

Question 7
0 / 1 pts
A String is an _____  of characters.

You Answered
length
Correct Answers

array

Question 8
0 / 1 pts

In the illustration above which query corresponds to table One.


The primary key for A is aID;
The primary key for B is bID, it has the foreign key aID;
Correct Answer

  

select * from A left join B on a.aID = b.aID;

You Answered

  

select * from A right join B on a.aID = b.aID;

  

select * from A, B where a.aID = b.aID;

Correct Answer

  

select * from B right join A on a.aID = b.aID;

 
  

select * from B left join A on a.aID = b.aID;

  

select * from A, B where a.aID = b.bID;

Question 9
1 / 1 pts
Both indeed.com and dice.com has a lot of SQL job openings?

Correct!

  

True

  

False

SQL is one of the most popular technology keywords for technical jobs.
 

Question 10
0 / 1 pts
In Modern day, the most popular database is?

  

IBM

  

Microsoft
 

Correct Answer

  

RDBMS

You Answered

  

PHP/MySQL

  

Hierarchical

  

Flat

RDBMS - Relational Database Management System are dominating


 

Question 11
0 / 1 pts
What is the name of the SQL keyword used to only print out a specific number of  rows? ______
(1 word only).

You Answered
select

Correct Answers

LIMIT

Limit

 
limit

Quiz Score: 2.33 out of 11

Quiz Submissions

Question 1
0.5 / 1 pts

In the illustration above which query corresponds to table Two


The primary key for A is aID;
The primary key for B is bID,  B also has the foreign key aID;

  

select * from A left join B on a.aID = b.aID;

Correct!

  

select * from A right join B on a.aID = b.aID;

  

select * from A, B where a.aID = b.aID;

  

select * from B right join A on a.aID = b.aID;

 
Correct Answer

  

select * from B left join A on a.aID = b.aID;

  

select * from A, B where a.aID = b.bID;

Question 2
1 / 1 pts

In the illustration above which table illustrates only an intersection?

  

one

  

two

Correct!

  

three

  
four

  

one and two

  
one and four

  
two and three

  

none of them

An intersection is items common in both tables.


 

Question 3
1 / 1 pts
A String is an _____  of characters.

Correct!
array

Correct Answers

array

Question 4
0 / 1 pts
Can all major programming languages interface to a RDMBS using basic SQL strings.

Correct Answer
  

True

You Answered

  

False

Question 5
0 / 1 pts
Since time stamps are used so often in databases, SQL has specific Date and Time types.

Correct Answer

  

True

You Answered

  

False

Question 6
0 / 1 pts
Given two columns:    mickey, disney.com.
which function would use use to create    mickey@disney.com, we are adding the
separator @
just give the function name, no arguments or parathensis 
You Answered
concat mic

Correct Answers

concat_ws

[cC][oO][nN][cC][aA][tT][_][wW][sS]\(?.*

concat

concat_ws( "@", "mickey", "disney.com" );


could use
concat( "mickey", "@", "disney.com" )
but questions used with separator, so that is not a good answer.
 

Question 7
1 / 1 pts
table:
table: fruit
inventory

fruitI pric
name fruitID quantity
D e

1 apple 2.50 1 100

2 pear 3.00 3 500


 
4 grpe 0.75 2 100

5 peach 1.25 5 10

8 pluot 4.50 1 250

6 plum 1.25 2 200

3 banana 1.00    

Given the tables above which Data Manipulation commands will delete peach?
Correct!

  

delete from fruit where fruitID= '5'

  

delete from Fruit where name = "peach";

  

delete from fruit where price = 1.25 order by fruitID desc limit 1;

  

delete from fruit where name like "p%" order by fruitID limit 1;
delete from fruit where name like "p%" order by fruitID limit 1;

delete from Fruit where name = "peach"; 

table name is fruit not Fruit


note this will also work....
delete from fruit where price = 1.25 order by fruitID desc limit 1;

delete from fruit where name like "p%" order by fruitID limit 1;

pear will come first

Question 8
0 / 1 pts
In MySQL internal functions are often called:

You Answered
string func

Correct Answers

intrinsics
 

([iI]ntrinsics?)|([iI]ntrinsic\s+[fF]unctions)

intrinsic

title of video 3 is Internal functions aka intrinsics


 

Question 9
0 / 1 pts

table:
table: fruit
inventory

fruitI pric
name fruitID quantity
D e

1 apple 2.50 1 100

2 pear 3.00 3 500


    
4 grpe 0.75 2 100

5 peach 1.25 5 10

8 pluot 4.50 1 250

6 plum 1.25 2 200

3 banana 1.00    

Given the two tables above what will the query...


Select name from fruit where price >= 2.50;
Output?
Correct!

  

apple
 

Correct Answer

  

pear

You Answered

  

grpe

You Answered

  

peach

Correct Answer

  

pluot

You Answered

  

plum

You Answered

  

banana

We output the three fruits with a price greater than or equal to  2.50
that is apple, pear and pluot
 

Question 10
1 / 1 pts
Which company has the largest share of the RDBMS market place?

  

IBM

  

Microsoft

Correct!

  

Oracle

  

SAP

  

none of the above

  

Sybase

RDBMS - Relational Database Management System are dominating


 

Question 11
0 / 1 pts
table:
table: fruit
inventory

fruitI pric
name fruitID quantity
D e

1 apple 2.50 1 100

2 pear 3.00 3 500


    
4 grpe 0.75 2 100

5 peach 1.25 5 10

8 pluot 4.50 1 250

6 plum 1.25 2 200

3 banana 1.00    

Given the two tables above what will the query...


Select name from fruit where price >= 2.50;
Output?
Correct!

  

apple

Correct Answer

  

pear

You Answered

  

grpe

 
You Answered

  

peach

Correct Answer

  

pluot

You Answered

  

plum

You Answered

  

banana

We output the three fruits with a price greater than or equal to  2.50
that is apple, pear and pluot

Quiz Score: 4.5 out of 11

Quiz Submissions

Quiz 4

Question 1
0.5 / 1 pts
Which query will output all contents of the table:inventory, sorted first by fruitID, and on ties
sorted with smallest quantity first.
Correct Answer

  

select fruitID,quantity from inventory order by fruitID, quantity;

  

select * from inventory order  by fruitID,  quantity DESC;

Correct!

  

select * from inventory order by fruitID, quantity ASC;

  

select * from inventory order by fruitID, quantity DESC;

Question 2
1 / 1 pts
The left navBar of PHPMyAdmin allows the user to?

  

Directly enter SQL queries

Correct!

  

Navigate their Databases/Tables

  
Import Data

  

Enter Data

Question 3
1 / 1 pts
In all modern day programming languages we use /* to begin a multi line comments, this multi
line comment ends with a _ _ ?

Correct!
*/

Correct Answers

*/

/*

comment

 */
 

Question 4
0 / 1 pts
What data  does this query output,

select concat( "$", "200*2.5" );


You Answered
$,quantity,

Correct Answers

$200*2.5

Nota Bene, "200*2.5" is a string not two numbers


 

Question 5
1 / 1 pts
Defacto standard for communicating to RDBMS is?

Correct!

  

SQL

  

MySQL

  

Java

  

HTML

Question 6
1 / 1 pts
Given this create table...
--
-- Table structure for table `fruit`
--

CREATE TABLE IF NOT EXISTS `fruit` (


`fruitID` smallint(6) NOT NULL,
  `name` varchar(8) DEFAULT NULL,
  `price` double(5,2) DEFAULT NULL,
   PRIMARY KEY( `fruitID` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;

Which PHPMyAdmin tab would display this information?

  

Browse

Correct!

  

Structure

  

SQL

  

Operations

Question 7
1 / 1 pts
Given Two Tables A & B

Table A:          Table: B


I
Data AID Data
D

1 Mickey 1 Mouse

2 Donald 3 Duck

3 Goofy 4 Mouse

Ignoring column name/header, what does this query output?


select AID from B where B.AID not in (select ID from A);
Correct!
4

Correct Answers

Question 8
0 / 1 pts
select name, sum( quantity ) as "Total Quantity"
from fruit as f , inventory as i where i.fruitID = f.fruitiD;

What  critical clause is missing from the above query?


Hint sum( quantity ) requires this for correct output.

  

order by i.fruitID

You Answered

  

order by sum( quantity ) DESC

 
Correct Answer

  

group by i.fruitID

  

okay as is

For sum( quantity ) to work on the aggregate quantity in inventory


we need group by,
remember we can have the same fruitID repeated more than once in table inventory
 

Question 9
0.33 / 1 pts
Given this create table script, which prices are legal?

create table if not exists `fruit` {


 fruitID int(11) NOT NULL auto_increment,
 name varchar( 8 ) default NULL,

 price double( 5, 2 ) default NULL,

 PRIMARY KEY( fruitID ) 

} ENGINE = MyISAM DEFAULT CHARSET= latin1 AUTO_INCREMENT = 9;


Correct Answer

  

-5.25

Correct Answer
  

199.99

Correct!

  

NULL

  

4555.5

Question 10
0 / 1 pts
The big three Database providers are Adobe, Oracle and MicroSoft

You Answered

  

True

Correct Answer

  

False

Oracle first w 50%


IBM second w 25%
Microsoft third w 18%

Quiz Score: 5.83 out of 10
Quiz Submissions
Question 1
0 / 1 pts
what does this output?
select concat( "$", 200*2.5 ) as "Value";
Correct Answer
  
field (aka column) name Value
 
Correct Answer
  
Only one data row
 
Correct Answer
  
$500.0
 
You Answered
  
$200*2.5
 
 
Question 2
0 / 1 pts
To change the database schema (i.e., database structure - which includes tables and table
formats) one can use the SQL keywords alter, create or ______. (lowercase one word)
You Answered
import

Correct Answers
drop
 
Data manipulation language comprises the SQL data change statements, which modify
stored data but not the schema or database objects.
Select is included in this group.
Data Definition languages deal with altering the structure of the schema (i.e., data
definition).
You can drop a table from the schema with drop table;
You can alter its keys, datatypes or fields with alter.
You can create a new table with create table.
 
Question 3
1 / 1 pts
Microsoft is the largest database provider?

  
True
 
Correct!
  
False
 
third
Oracle first w 50%
IBM second w 25%
 
Question 4
1 / 1 pts
Need to add a new record/row into a table, how would you do this using PHPMyAdmin?
Correct!
  
Insert tab
 
Correct!
  
SQL Tab w then click the  Insert Button, then edit the insert DML code. 
 

  
Structure
 

  
Browse Tab - then click insert button listed under the table contents
 
Insert tab on phpMyAdmin allows you to input data directly into each field
the SQL tab has select, update, insert and delete buttons at the bottom of the dialog
panel, which insert the SQL code template.

browse has an edit, delete and export button under table but no insert button
 
Question 5
0 / 1 pts
What best describes would this query do?

select * from fruit where price < 1.0 order by price DESC;

  
list all fruit with price less than 1.0
 

  
list all fruit
 
Correct Answer
  
list all fruit with prices less than 1.0 sorted with price closest to one first.
 
You Answered
  
list all fruit with prices less than 1.0; list least expensive fruits first.
 
 
Question 6
1 / 1 pts
In the fruit relation database, the table inventory forms a relationship with the fruit table
using the quantity value.

  
True
 
Correct!
  
False
 
 
Question 7
1 / 1 pts
In all modern day programming languages we use /* to begin a multi line comments, this
multi line comment ends with a _ _ ?
Correct!
*/

Correct Answers
*/
 
/*

comment

 */
 
Question 8
1 / 1 pts
Defacto standard for communicating to RDBMS is?
Correct!
  
SQL
 

  
MySQL
 

  
Java
 

  
HTML
 
 
Question 9
1 / 1 pts
The primary key is normally used to index each row of a table?
Correct!
  
True
 

  
False
 
 
Question 10
0.67 / 1 pts
Given this fruit table:
Table: fruit
fruitID name price
1 apple 2.50
2 pear 3.00
3 bnana 1.0

How would one fix the name of banana from bnana to banana.
Correct Answer
  
In phpMyAdmin select table, click browse, click Edit icon (pencil) on row with fruitID=3
 
Correct!
  
update fruit set name="banana" where fruitID=3;

  
In phpMyAdmin single-click the name bnana
 
Correct!
  
In phpMyAdmin, select table, click SQL tab,
then click  update button, then manually edit placeholder contents.

Quiz Score: 6.67 out of 10
Quiz Submissions
 Attempt 1: 5.83
 Attempt 2: 6.67

Quiz 5

Question 1
1 / 1 pts
The three basic cateogories for SQL data types are Date & time, String and ______ ,.
Correct!
number

Correct Answers
[nN]umber.*
 
numeric
 
number
 
Number
 
The SQL language techinically has three data types
Number, Date & time and String

The textbook uses numeric for number


 
Question 2
1 / 1 pts
A user wants to delete all fruit in the database that has a price greater than $1.0;
Which query (DML) will do this?
Correct!
  
delete from `fruit` where price > 1.0;

  
delete from fruit where "price" > 1.0;

  
delete from fruit where price >= 1.0

  
delete from fruit where price > $1.0;
 
Question 3
1 / 1 pts
Which character is the wild card used to select all fields (aka columns)?
Correct!
*

Correct Answers
star
 
asterisk
 
*
 
Correct answer is *
* is an astrerisk
it is not a star, but star is acceptable.
we use
select * from inventory;
 
Question 4
1 / 1 pts
SQL pronounced (ES Que L or Sequel) stands for?
 
Sequel was the original name for SQL
Correct!
structured Qu

Correct Answers
[sS]tructured.*[qQ]uery.*[lL]anguage.*
 
Structured Query Language
 
Structured Query Language,
We always capitalize first letter of each acronoymn word.
 
Question 5
1 / 1 pts
Once a table is selected,
you can click the ____ tab that gives you a set of input fields that can add rows/records to a table.
Correct!
insert

Correct Answers
insert
 
 
Question 6
1 / 1 pts
Complete the DML command below which will delete both tables.

_______  table fruit, inventory;


Correct!
drop

Correct Answers
drop
 
In PHPMyAdmin we just selected the tables from the database view,
and then selected delete;
but phpMyAdmin displayed and executed the correct DML command
drop table fruit, inventory;
DML (Data Manipulation Language) term used when we are manipulating data.
 
Question 7
1 / 1 pts
PHPMyAdmin has a create table, tab across its top navigator?

  
True
 
Correct!
  
False
 
We create tables, but selecting a Database,
on the table name view in the main window, you can enter the name of a new table at the bottom.
If not tables are currently present you can set database comment and also create a new table.
 
Question 8
1 / 1 pts
The first steps in creating a table in PHPMyAdmin requires the user to?
Correct!
  
Select (aka use) the Database, the  table will belong to
 
Correct!
  
Specify the number of columns
 

  
Specify the number of rows
 
Correct!
  
Enter a Table Name
 
In order to create a table you must always select the database that the table will belong to.
In PHPMyAdmin we then enter the table name and number of columns
 
Question 9
0.67 / 1 pts
The left navBar or PHPMyAdmin allows the user to?

(The left navBar is an abbreviation for left navigation bar, it is is the panel at the left side
of the browser,
both blackboard and phpMyAdmin have a left navBar, you use the left navBar in blackboard
to select the quizzes)

  
Enter Queries
 
Correct!
  
Select their Database
 
Correct Answer
  
Logout
 
Correct!
  
Select tables
 
 
Question 10
1 / 1 pts
Starting with OpenSuSE 13.1, SuSE has replaced MySQL with this MySQL fork?
Correct!
MariaDB

Correct Answers
MariaDB
 
cim server is currently running MariaDB, it is a fork, (i.e., based on the MySQL 5.5 code).

Quiz Score: 9.67 out of 10
Previous Next

Quiz 6

Question 1
1 / 1 pts
When dealing with a table that has one to many relationship, with a primary key in
another table, when one wants to use an aggregate in a query, you must use the SQL
clause.

  
where
 

  
on
 
Correct!
  
group by
 

  
order by
 
 
Question 2
1 / 1 pts
A view increases the calculation overhead, but reduces the time it takes to write
complex or frequently used multi-table queries.?
Correct!
  
True
 

  
False
 
 
Question 3
0 / 1 pts
Given these two tables:

table: inventory table: fruit


fruitI
name price
D
fruitID quantity
1 apple 2.50
3 500  
2 pear 3.00
1 100
3 banana 1.00
1 250
4 Grpe 0.75
8 pluot 4.50

How may data rows (ignoring header rows) does query below ouptut?

select fruit.fruitID, name, price, sum( quantity )  from fruit left join inventory on fruit.fruitID =
inventory.fruitID group by fruit.fruitID;

  
3
 

  
2
 
You Answered
  
4
 

  
0
 
Correct Answer
  
5
 

  
6
 
on left join, you join all members with  the left set/table fruit
select fruit.fruitID, name, price, sum( quantity )  from fruit left join  inventory on fruit.fruitID =
inventory.fruitID group by fruit.fruitID;

 
Question 4
1 / 1 pts

Since DATETIME support current_timestamp defaults,

in the altered updated version of fruit we maintained all date datatypes as


DATETIME (true is yes; false is no)

  
True
 
Correct!
  
False
 
we had to go to TIMESTAMP in fruitAlter.sql.html
 
Question 5
1 / 1 pts
To create a view from this query:

SELECT name, concat( "$", price ) as "price" from fruit 


where fruit.fruitID in (select fruitID from inventory );

one must use as "price" so that column 2 is not listed as concat( "$", price )?
Correct!
  
True
 

  
False
 
without as "price" ,  you will get the column concat( "$", price ) which is not a standard
column name
 
Question 6
0 / 1 pts
To create a new order record/row, which files must you set?

  
startDate
 

  
shipDate
 
You Answered
  
orderID
 
Correct Answer
  
customerID
 
 
Question 7
1 / 1 pts
In order for a View to be able to update the physical tables it was created from, it must
have?

  
Transaction supported storage engine
 

  
Created from a single table
 
Correct!
  
1 to 1 Relationship
 

  
1 to Many relationship
 
 
Question 8
0 / 1 pts
Given these two tables...

table: inventory table: fruit


fruitI
name price
D
fruitID quantity 1 apple 2.50
3 500   2 pear 3.00
1 100 3 banana 1.00
1 250 4 Grpe 0.75
 
8 pluot 4.50
 

 
How may data rows (ignoring header rows) does query below ouptut?
 
select * from fruit, inventory where fruit.fruitID = inventory.fruitID or inventory.fruitID is
null;
 

 
 
 

  
6
 

  
0
 

  
2
 
You Answered
  
5
 
Correct Answer
  
3
 

  
4
 
3 You will be matching all three rows/lines in inventory
 
select * from fruit, inventory where fruit.fruitID = inventory.fruitID or inventory.fruitID is null;

 
note we use left join to get null values, so since inventory.fruit has no null is adds nothing to the query

 
Question 9
0.33 / 1 pts
Given these tables:
 
table: inventory table: fruit
fruitID name price
fruitID quantity 1 apple 2.50
3 500 2 pear 3.00
1 100 3 banana 1.00
1 250 4 grape 0.75
  8 pluot 4.50
 

 
What is wrong with this query:
select fruitID, price, name, quantity from fruit left join inventory on fruit.fruitID =
inventory.fruitID group by inventory.fruitID;

  
missing where clause
 
Correct Answer
  
no aggregate present
 

  
missing order by clause
 
Correct!
  
ambiguous field in select
 
You Answered
  
missing where clause
 
Correct!
  
wrong group by field
 
select fruitID, price, name, quantity from fruit left join inventory on fruit.fruitID = inventory.fruitID group by
inventory.fruitID;

 
select fruitID is ambiguous needs to be fruit.fruitID, note inventory.fruitID will come out
as null for three values
you have group by but no aggregate function like sum( quantity )
you need to group by fruit.fruitID not inventory.fruitID, inventory.fruitID will group by 1,
3 and null only.
 
with left join we use on to signify the joining where clause
whole idea of a join, is to line up missing items, so its understood that inventory may not
have all fruitIDs or table:fruit
where, limit and order by clause are always optional
 
Question 10
0 / 1 pts
select fruit.fruitID, name, price, sum( quantity ) 
from fruit left join inventory
on fruit.fruitID = inventory.fruitID
group by fruit.fruitID order by fruit.fruitID ASC;

If inventory has 6 rows; and fruit has 7 rows;


fruitID is the primary key for table:fruit.
How many rows is in the select output?

  
42
 
Correct Answer
  
7
 

  
13
 
You Answered
  
6
 
from fruit left join inventory
on fruit.fruitID = inventory.fruitID
a left join, inventory will join up to each item in fruit (left side)
so if fruit has 7 rows we have 7 rows in the output
 
Question 11
1 / 1 pts
In fruit Database all primary keys end with which two letters? (Type them exact)
Correct!
ID

Correct Answers
ID
 
the primary key is always tableNameID

so for table: fruit

its fruitID
 
Question 12
1 / 1 pts
given this query:

select * from `order` where shipDate is not null order by orderID ASC;
 
which statements below are true;

For quiz question, we are using the keyword `order` as a table name,
but we will always put table name inside of a pair of ` accent, back ticks,
For Best practices, one  should always enclose field and table names inside backtick.
Using keywords as table and field names can be argued either way.
 

  
of orders displayed, it will display the order with the smallest orderID first
 

  
will display all orders that have shipped
 

  
dealing with table `order`
 
Correct!
  
all of the above
 
 
Question 13
0 / 1 pts
Given these two tables:

table: inventory table: fruit


fruitI
name price
D
fruitID quantity 1 apple 2.50
3 500   2 pear 3.00
1 100 3 banana 1.00
1 250 4 Grpe 0.75
 
8 pluot 4.50
 
 
How may data rows (ignoring header rows) does query below ouptut?

 
select fruit.fruitID, name, price, sum( quantity )  from fruit left join inventory on fruit.fruitID =
inventory.fruitID group by fruit.fruitID;

 
 
 
Correct Answer
  
5
 

  
6
 

  
3
 
You Answered
  
2
 

  
4
 

  
0
 
 
 

on left join, you join all members with  the left set/table fruit
 
select fruit.fruitID, name, price, sum( quantity )  from fruit left join  inventory on fruit.fruitID =
inventory.fruitID group by fruit.fruitID;

 
Question 14
0 / 1 pts
What is the reserved keyword that restricts the number of rows/records to output?
You Answered
limit by

Correct Answers
limit
 
select * from fruit limit 5;

Will display only the first 5 records/rows of the table:fruit;


 
Question 15
1 / 1 pts
PHPMyAdmin supports import of SQL files that may be compressed with either bzip2 or
zip? (Yes is true; No is False)
Correct!
  
True
 

  
False
 
PHPMyAdmin import tab, supports importing of a uncompressed, zip or bzip2 file,
just make sure it has the proper extension fruit.sql, fruit.sql.zip or fruit.sql.bz2
bz2 works only with single files

Quiz Score: 8.33 out of 15
Previous Next
Last Attempt Details:
Time: 43 minutes

Current Score: 8.33 out of 15

You might also like