Lecture 3 - SQL SELECT Flashcards
SELECT statement in SQL?
SELECT
FROM
WHERE
(ORDER BY etc)
SELECT statement with join & select.
SELECT Fname, Lname, Address
FROM EMPLOYEE, DEPARTMENT
WHERE Dname = ‘Research’ AND Dno = Dnumber;
-> joins two tables by matching the foreign key
Can tables be treated as variables in SQL?
Yes in the FROM we can specify the name for the table by using the AS word
What is a recursive reference?
Having a foreign key that links to PK of the same relation e.g. employee and supervisor attributes
Where is using variable names expecially useful?
When dealing with recursive relations
What happens if we omit the WHERE and have FROM on two or more relations
We cross product all possible tuples (each tuple from relations is concatenated to each tuple from another relation)
-> this is computationally heavy and meaningless
What is *?
Will list all possible attributes. It is a wildcard operator.
What is a multiset?
a set that can contain duplicates
Does it matter if our queries are complex and convoluted ?
No, as all queries will go through an optimiser