Module 4: SQL Flashcards
What does a unique constraint do?
Ensures the column contains only unique values
What does a foreign key constraint do?
Ensures the record referenced from table A exists in table B
(T/F) The following scenario is the correct way to update the structure of a table assuming the table already exists:
+ Edit the CREATE TABLE query/file
+ Rerun the CREATE TABLE query
False
(T/F) MySQL allows multiple NULL values in a column constrained by a unique constraint.
Example: email column is unique on the Users table, will it allow more than one record to have a NULL value in this column?
id email
1 NULL
2 NULL
3 test@test.com
4 NULL
True
(T/F) A foreign key must refer to a primary key
True
What does a JOIN do?
Combines rows from two or more tables, based on a related column between them
(T/F) A database and a table are the same thing.
False
What does the following query do?
SELECT id, email, password from Users WHERE email = :email OR username = :email
- Returns records whose email or username columns equal the passed in value
- Returns records whose email and username columns contain the passed in value
- Verifies a password
- Returns records where email or username columns include/contain the passed in value (partial match)
1
Select
Retrieves data from a table
Insert
Adds data to a table
Update
Changes existing data in a table
Delete
Removes data from a table
Where
Filters results from a table
Create table
Makes a table if it already does not exist
Alter table
Changes the structure of the table