Skillstorm Intro to Coding - SQL and MySQL Flashcards
What is normalization in Databases?
Database normalization is the process of structuring a database, usually a relational database, in accordance with a series of so-called normal forms in order to reduce data redundancy and improve data integrity.
What are the requirements for a relation in a database to be in First Normal Form or 1NF?
- The domain of each attribute (column) contains only indivisible (atomic) values
- The value of each attribute (column) contains only a single value from that domain
In Other Words
- No repeating groups (multi-valued column)
==> Only one value per column
- Table must define a primary key
==> A unique identifier for a row
What are the requirements for a relation in a database to be in Second Normal Form or 2NF?
- It is in 1NF.
- It does not have any non-prime attribute that is functionally dependent on any proper subset of any candidate key of the relation.
In Other Words
- See Attached Image
What are the requirements for a relation in a database to be in Third Normal Form or 3NF?
- It is in 2NF
- 3NF states that all column references in referenced data that are not dependent on the primary key should be removed
In Other Words
- No transitive dependencies
==> A column determined by a non-key attribute
- Includes derived attributes, which should be calculated
==> Your Birthday determines your age
==> Item price times quantity determines line total
==> Sum of line totals determines the order sub-total
Who is the father of the relational database model?
Edgar F. Codd who released his landmark paper in 1970 “A Relational Model of Data for Large Shared Data Banks”
What is a good mnemonic for remembering the normal forms?
What is Functional Dependence?
- One value determines another
==> Your birthday determines your age
==> Order number determines the date the order was placed
- First name does not determine anything
What is a composite key in 2NF?
- It’s when two or more column’s come together to determine the primary key
What is a Transitive Dependency?
- A column determined by a non-key attribute
In Other Words
- A transitive dependency in a database is an indirect relationship between values in the same table that causes a functional dependency.
- By its nature, a transitive dependency requires three or more attributes (or database columns) that have a functional dependency between them, meaning that Column A in a table relies on Column B through an intermediate Column C.
Transitive Dependency: See attached image…
Description
Partial Dependence: See attached images…
Order_Date
Assign the right cardinality of each relationship: See attached images…
1) Many-to-Many
2) One-to-Many
3) One-to-One
Repeating Groups: See attached images…
Items_Ordered
The SELECT statement is used to return a result set of __________ from one or more ___________.
records
tables
A WHERE clause specifies that a SQL Data Manipulation Language statement should only affect _____ that meet specified criteria. The WHERE clause is used to extract only those results from a SQL statement, such as: _________, _________, __________, and ___________ statement.
rows
SELECT
INSERT
UPDATE
DELETE
Comparison (or relational) operators are mathematical symbols used to compare two values. They are used in conditions that compare one expression with another. The result of a comparison can be _________, ________, or _________.
TRUE
FALSE
UNKNOWN
The BETWEEN operator allows you to select values within a specified _________. These values can be ________, ________, or ________.
range
numbers
text
dates
The BETWEEN operator is inclusive: _______ and ________ values are included.
begin
end
The LIKE operator determines if a character string matches a specified ________. The pattern may include regular characters and ________ characters. Use the LIKE operator in the ________ clause of the SELECT, UPDATE, and DELETE statements to filter ________ based on pattern matching.
pattern
wildcard
WHERE
rows
Retrieve Payments: See attached image…
SELECT
FROM
WHERE
BETWEEN, AND
Retrieve Country United States: See attached images…
SELECT
FROM
WHERE
Comparison Operators
>
>=
=
!=