Test 1 - Module 2 Flashcards

1
Q

Ad-hoc queries

A

A non-standard inquiry, created to obtain information as the need arises. Contrast with a query that is predefined and routinely processed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Components of a data warehouse

A
  • Operational databases, other internal data, external data
  • ETL System (extraction/cleaning/preparation)
  • DW DBMS
  • BI tools
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

SQL

A
  • to work with relational databases
  • Starts since 1970
  • Not a full programming language
  • Data sublanguage
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

SQL categories

A

DDL: Data Definition Language
DML: Data Manipulation Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

SELECT statement

A

SELECT [Column]
FROM [Table]
WHERE [condition];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to eliminate duplicates

A

SELECT DISTINCT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

WHERE

A

WHERE … AND…
WHERE … IN …
WHERE … NOT IN …
WHERE … BETWEEN …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to sort results

A

With the clause ‘ORDER BY’
ORDER BY [Column] DESC, [Column] ASC
//optional operators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which options WHERE clause has?

A

AND to add more than one condition
OR to admit one condition OR another
IN to look for a condition of a sub-conjunct
NOT IN to negate a condition of sub-conjunct
BETWEEN to establish ranges
Math symbols
LIKE that admits wildcards _ or % (SQL 92)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which built-in Functions SQL has

A

COUNT - counts the amount of rows
SUM - sums the values of a column
AVG - returns the average value of a column
MIN - returns the minimum value of a column
MAX - returns the maximum value of a column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to group results from a report?

A

Using the SQL keyword ‘GROUP BY’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to state GROUP BY keyword?

A

WHERE is placed before GROUP BY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How restrict grouped results

A

Using HAVING operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to eliminate a ambiguity when using HAVING operator

A

By always applying WHERE clause before HAVING operator, just for sure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the syntax of a subquery in a DDL statement

A
SELECT SUM (ExtendedPrice) AS Revenue
FROM ORDER_ITEM
WHERE SKU IN
	(SELECT SKU
	FROM SKU_DATA
	WHERE Department = 'Water Sports');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What’s the syntax to perform a junction between tables

A

SELECT Column1, Column2
FROM TABLE1, TABLE2
WHERE TABLE1.ColumnX = TABLE2.ColumnY
//admits AND or OR operators on WHERE clause

17
Q

What’s is the syntax of JOIN ON

A
SELECT Column1, Column2
FROM TABLE1 JOIN TABLE2
     ON TABLE1.ColumnX =
            TABLE2.ColumnY
WHERE ColumnWhatever > 1000000
18
Q

How INNER JOIN works?

A

Returns all rows when there is at least one match in BOTH tables

19
Q

How LEFT JOIN works?

A

Return all rows from the left table, and the matched rows from the right table

20
Q

How RIGHT JOIN works?

A

Return all rows from the right table, and the matched rows from the left table

21
Q

How FULL JOIN works?

A

Return all rows when there is a match in ONE of the tables

22
Q

What’s the difference between JOIN and subqueries?

A

In most cases JOINs are faster than sub-queries and it is very rare for a sub-query to be faster.
Subqueries works in a top-down approach, while JOIN derives “new” tables