Week 6 Flashcards

1
Q

Join

A

a relational operation that connects 2+ tables with a common domain

combined into a single table/view

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

Equi-join

A

join in which the joining condition is based on equality between values in the common columns

COMMON COLUMNS WILL APPEAR REDUNDANTLY IN RESLT TABLE

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

Inner Join

A

equi-join where one of the duplicate columns is eliminated in result table

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

Inner join example, when would you use this?

A

when you need info that is in both tables

SELECT ____
FROM table 1 INNER JOIN table 2 ON t1.ID=t2.ID

NOTE THAT THE ID THAT ID BEING CONNECTED NEEDS TO BE THE SAME ID!!

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

if it is just JOIN

A

inner join is implict

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

Outer Join (Left, Right, Full)

A

A join in which rows that do not have matching values in common columns are included in the result table

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

Multi table join

A

You have to look at how the table flows and then connect the fks to each other accordingly

CONNECTED VIA INNER JOINS

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

Self Join Example

A

you oin to yourself, but basically you gotta make diff aliases

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

SELF JOIN CODE

A

SELECT s.EmployeeID [Supervisor ID], s.EmployeeName [Supervisor Name], e.EmployeeID,
e.EmployeeName, e.EmployeeSupervisor
FROM Employee_T s INNER JOIN Employee_T e on e.EmployeeSupervisor=s.EmployeeID
WHERE e.EmployeeSupervisor = s.EmployeeI

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

Sub query

A

placing an inner select statement query inside an outer query

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

where can you put the sub query?

A

a. in the condition of the WHERE CLAUSE
b. as a table of the FROM clause
c. returning a field for the SELECT clause
d. within the HAVING Clause

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

2 types of subqueries

A

non correalted: executed once for the entire outer query

correlated: execture once for each row returned by the outer query

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

what is the logic of subquery?

how do you have all the employees having the same supervisor as laura come?

A

SELECT *
FROM Employee_T
WHERE SupervisorName = (
SELECT SupervisorName
FROM Employee_T
WHERE EmployeeName LIKE ‘Laura%’)

Basically the where is the something = to something else, and then you solve for something else in the sub query

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

How to do a subquery in the from clause?

A

First off, you can alias subqueries! calling them t3 and t4

Basically you will label each sub query a diff name

SELECT t3.____, t3._______
FROM
(SELECT ____
FROM inner join the tables
WHERE _____condition) t3,
(SELECT ____
FROM inner join the tables
WHERE _____condition) t4
WHERE t3.____=t4._______

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

non corelated subqueries

A

Do not depend on data from the outer query
 Execute once for the entire outer query

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

correlated subqueries

A

 Make use of data from the outer query
 Execute once for each row of the outer query
 Can use the EXISTS and ALL operators

17
Q

correlated subquery

A

?????? textbook

18
Q

non correlated subquery

A

????????? textbook

19
Q

can you connect sub queries using union intersect except? YES

A

AND

OR

THIS BUT NOT THAT

20
Q

The outer join syntax does not apply easily to a join condition of more than ________ tables

A

two

21
Q

The ________ operator is used to combine the output from multiple queries into a single result table.

A

union

22
Q

EXISTS will take a value of ________ if the subquery returns an intermediate results table which contains one or more rows.

A

true

23
Q

In order for two queries to be UNION-compatible, they must:

A

same # of rows

24
Q

A ________ is a temporary table used in the FROM clause of an SQL query.

A

derived table

25
Q

A materialized view is/are:

A

copies or replica of data based on queries.

26
Q

The UNION clause is used to:

A

combine the output from multiple queries into a single result table.

27
Q

A join in which the joining condition is based on equality between values in the common columns is called a(n):

A

both equi-join. and natural join. .

28
Q

A join in which rows that do not have matching values in common columns are still included in the result table is called a(n):

A

outer join

29
Q

A join that is based upon equality between values in two common columns with the same name and where one duplicate column has been removed is called a(n):

A

natural join

30
Q
A