Lecture 3 - SQL SELECT Flashcards

1
Q

SELECT statement in SQL?

A

SELECT
FROM
WHERE
(ORDER BY etc)

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

SELECT statement with join & select.

A

SELECT Fname, Lname, Address
FROM EMPLOYEE, DEPARTMENT
WHERE Dname = ‘Research’ AND Dno = Dnumber;

-> joins two tables by matching the foreign key

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

Can tables be treated as variables in SQL?

A

Yes in the FROM we can specify the name for the table by using the AS word

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

What is a recursive reference?

A

Having a foreign key that links to PK of the same relation e.g. employee and supervisor attributes

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

Where is using variable names expecially useful?

A

When dealing with recursive relations

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

What happens if we omit the WHERE and have FROM on two or more relations

A

We cross product all possible tuples (each tuple from relations is concatenated to each tuple from another relation)

-> this is computationally heavy and meaningless

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

What is *?

A

Will list all possible attributes. It is a wildcard operator.

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

What is a multiset?

A

a set that can contain duplicates

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

Does it matter if our queries are complex and convoluted ?

A

No, as all queries will go through an optimiser

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