sql-join Flashcards

1
Q

What is a foreign key?

A

Notice how each row in the “products” table has a “supplierId” column. That column specifically refers to values in the “supplierId” column of the “suppliers” table. This is known as a foreign key. Instead of putting all of the supplier information for a product into the product row itself, there is instead just one column that links the “products” table to the “suppliers” table.

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

How do you join two SQL tables?

A

select *
from “products”
join “suppliers” using (“supplierId”);

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

How do you temporarily rename columns or tables in a SQL statement?

A

select “products”.”name” as “product”,
“suppliers”.”name” as “supplier”
from “products”
join “suppliers” using (“supplierId”);

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