Join Tables Flashcards
List the 6 steps that are involved in writing a query that requires joining tables:
- Identify the entities and relationships
- Define the cardinality of the relationships
- Identify the logical expressions for those relationships
- Determine whether to include entities for which the logical expressions are never satisfied
- Write the FROM clause
- Write the SELECT clause
(6.5)
Where are table aliases defined?
In the FROM clause.
6.5
Are table aliases required to be unique?
Yes. Each table alias in the FROM clause is unique.
6.5
Why is it important to identify which entity relationship will be used by the query?
Because multiple relationships between the entities are possible.
(6.6)
What does the cardinality of a relationship describe?
The numeric relationship between two entities.
6.6
The cardinality of a relationship can be summarized with a phrase of the form “M to N” where M and N are each one of four phrases. What are those phrases?
- Zero or One
- Zero or More
- One (One exactly)
- One or More
(6.6 - 6.7)
Should you avoid many-to-many relationships?
Yes
6.8
“One to Zero or More” can be read as…
1-to-many
6.8
“Zero or More to One exactly” can be read as…
many-to-1
6.8
“Zero or more to Zero or More” can be read as…
many-to-many
6.8
What is each type of entity represented in a relational database known as?
A table.
6.9
What does the join type of a join dictate?
Whether or not rows in one table that have no valid matches in the other table will be in the query result.
(6.10)
What type of join only includes rows that represent a match between the two tables?
The INNER JOIN (or just JOIN)
6.10
What type of join should you use if you want your query result to only include valid matches?
INNER JOIN
6.10
Why is an INNER JOIN an appropriate choice for relationship cardinalities that don’t include “Zero or…” on either side?
If there aren’t “Zero or…” on either side than the INNER JOIN would return everything.
(6.10)