Questions and CORRECT Answers
Primary Key - CORRECT ANSWER - Uniquely identifies a row. Must be non-null and
can only appear once.
Unique Key - CORRECT ANSWER - Uniquely identifies a row. Values can be null and
can have multiple unique statements.
SELECT Clause - CORRECT ANSWER - Where you format outputs & assign attributes.
Can also have expressions
DISTINCT - CORRECT ANSWER - Removes duplicates. Only use if truly necessary
FROM Clause - CORRECT ANSWER - The clause that indicates the table from which to
retrieve the specified columns
WHERE Clause - CORRECT ANSWER - Contains the bulk of the conditions, deciding
tuples the query will return. Can contain multiple subqueries, but cannot have aggregate values.
DESC - CORRECT ANSWER - Used by ORDER BY to sort from High to Low.
ASC - CORRECT ANSWER - Used by ORDER BY to sort from Low to High
ORDER BY - CORRECT ANSWER - Sorts output by first attribute listed. If two tuples
have the same value, then it is by the second. Defaults to ASC.
Matches Zero or more - CORRECT ANSWER - LIKE '%'
,Matches exactly one - CORRECT ANSWER - LIKE '_'
Three value Logic - CORRECT ANSWER - TRUE, FALSE, UNKNOWN
ACID - CORRECT ANSWER - Atomicity, Consistency, Isolation, Durability
Isolation - CORRECT ANSWER - Different transactions shouldn't step over each other.
Ex: Protect against multiple transactions at the same time from the same bank account.
Relation Schema - CORRECT ANSWER - Set of attributes addressing a single value
Consistency - CORRECT ANSWER - Transaction must change affected data in only the
allowed ways. Ex: Student & course exist if the student is enrolled in a course.
First Normal Form (1NF) - CORRECT ANSWER - Every type of attribute is atomic.
(Every other Normal Form assumes 1NF). It only has one value defined for each attribute (no
nested attributes)
Relations: - CORRECT ANSWER - Structures with rows and columns subset of cartesian
products
Count(A) - CORRECT ANSWER - The number of tuples with non-NULL values
Count(*) - CORRECT ANSWER - The number of rows, including NULL
Alternate Key - CORRECT ANSWER - A non-primary key that can be used to identify
only one row in a table
, Declarative programs - CORRECT ANSWER - Specifies what's the expected outcome,
not how it's obtained. Ex: Scheme, Ocaml . SQL is declarative but it is not fully declarative.
Procedural Program - CORRECT ANSWER - Program specified as a sequence of
operations to get the desired outcome. (How the outcome is obtained) Ex. Java, C.
Hierarchical Data Model - CORRECT ANSWER - Organizes data into a tree-based
structure. Ex: XML, JSON
Durability - CORRECT ANSWER - If transaction occurs, it should exist.
Key - CORRECT ANSWER - Can't be in two different tuples in an instance of R for all
K, but the same uniquely identifies current relations
Super Key - CORRECT ANSWER - Any key that uniquely identifies each row (always a
key, but not vice versa)
HAVING - CORRECT ANSWER - Choose groups based on some aggregate property of
the group itself (WHERE applies conditions to each group. Removing any that don't satisfy.
MIN, MAX - CORRECT ANSWER - Non-Aggregate columns in the select clause must
come from attributes in GROUP BY. Also cannot be in WHERE.
INSERT INTO - CORRECT ANSWER - Tuple is inserted into Relation R, where
attribute a_i = V_i and default values are NULL for any not entered/missing.
GROUP BY - CORRECT ANSWER - A SQL clause used to create frequency
distributions when combined with any of the aggregate functions in a SELECT statement. Does
not ignore NULL
Atomicity - CORRECT ANSWER - All or nothing.