sql Flashcards
how do i create a table
CREATE TABLE tableName (attributes);
how do i show foreign keys
FOREIGN KEY (fk) REFERENCES fkTable (fk)
how do you insert into a table
INSERT INTO relation (attributes)
VALUES (all values to be inserted)
how do you delete from a table
DELETE name
FROM relation
WHERE condition
how do you select from a table
SELECT name
FROM relation
WHERE condition
*
all
DISTINCT
when selecting distinct indicates that it should not return any duplicates
what is the cross product of a relation list
when you combine each row in one table with each row in the other
basically the cartesian product
what are the steps in the conceptual evaluation strategy
compute the cross product
discard the tuples that dont satisfy the condition
display the attributes in the attribute list
if DISTINCT eliminate the duplicate rows
when do you HAVE create a variable/copy of the table (e.g. s.id instead of student.id)
when you are joining the table with itself as there each id will be duplicated and you need to know which one youre talking about
in which two ways can you name fields in result
AS and =
LIKE
used for string matching
_
any one character
%
o or more characters
UNION
used for the union of any two union-compatible sets
basically used instead of AND but have to have 2 queries instead of 1