SQL (Structured Query Language) II
Hello! Today, we will be diving further into SQL and the world of data in software applications.
We will be using the Repl.it assignment here to
start this lab with some practice using queries with JOIN
s and INDEX
.
If you are finished with the lab code, here are some questions to think about:
- If we have some database, how do we know the relationships among the entities stored inside of it?
- Once we know that a relationship exists between certain entities, how do we implement that in our database?
- (regarding the
books
and authors
tables) Can the IDs of the author and the book be the same? For example, if author_id
is 1 and book_id
is also 1 in the authored table, will there be a mix-up?
- If we have a lot of joint tables like this, wouldn’t that take up too much space?
- In the sea lions database, how are the IDs created? Do they come from the
sea_lions
table or the migrations
table?
- If we are trying to join three tables, how can we know which the left or right tables are?
- When we join tables, does the resulting joined table get saved? Can we reference it later without joining again?
- There’s many different kinds of
JOIN
. Is there a default one we should use?