Live Lecture Materials Week 12 Flashcards
(29 cards)
The 2 different techniques used to query data from multiple tables
Join and subquery
If you want to use a query but don’t know the specific obscure values necessary to do so, what can you do?
Use a select statement + a where clause to find the obscure value(s)
ie.
SELECT SKU
FROM SKU_DATA
WHERE Department = ‘Sport’
Another term for a subquery
A nested query
T/F - Data is stored in individual tables, it’s the relationship between the tables that make the data meaningful
True
Explicit join
The JOIN operator is used as part of the SQL statement
Implicit join
The JOIN operator is not used as part of the SQL statement
Joins can be used on
Tables
Views
Materialized views
NATURAL JOIN
- Creates a join based on common attributes
- No duplicates returned
- If there’s no common column, it’s downgraded to a CROSS JOIN
CROSS JOIN
Combines each row in one table with every row in another table
The problem with CROSS JOINs or “Cartesian Products”
The nature of CROSS JOINs is illogical for database work, we want rows and tables that are related to each other, not random
An Inner join matches _______ ____ and ________ ____ of two tables
Primary and foreign keys
When you’re using an implicit join and a field name is the same in both tables, you need
To add the table name when you type a field
ie. Inventory.name
Equijoin
A join based on identical column values
The two tables are joined using an “equal to” condition
Today ________ joins are considered proper, and _______ joins are considered archaic
explicit, implicit
You can create a table alias using ________ joins
explicit
In an inner join, records that have ________ ______ are selected. ____ values are omitted
matching values, NULL
Left outer join
- Returns all records from the left table, only matching records from right
- If there are no matches in the right table, it returns NULL
Right outer join
- Returns all records from right table, only matching records from left
- If 0 matches, the join still returns a column, but it will be NULL in each row
What is a set? What is set theory?
A set is a collection of distinct data items. Set theory refers to
Mathematical operations on sets.
A relational database table meets the definition of a set, so SQL includes a group of ___ _________ to use in SQL
set operators
The standard method of visualizing sets and their relationships
Venn diagrams
In a Venn diagram a set is represented by a _______ ______, a ______ is a portion of a set that is contained entirely within the set
labelled circle, subset
The entire area of both sets in a Venn diagram is called a _____, it is the equivalent to an __ operator
Union, OR
Venn Diagram: the ____________ part of two sets is fittingly called an ____________ and is equivalent to an ___ operator
intersecting intersection, AND