Module 4: SQL Flashcards

1
Q

What does a unique constraint do?

A

Ensures the column contains only unique values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a foreign key constraint do?

A

Ensures the record referenced from table A exists in table B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

(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

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

(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

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

(T/F) A foreign key must refer to a primary key

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does a JOIN do?

A

Combines rows from two or more tables, based on a related column between them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

(T/F) A database and a table are the same thing.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the following query do?

SELECT id, email, password from Users WHERE email = :email OR username = :email

  1. Returns records whose email or username columns equal the passed in value
  2. Returns records whose email and username columns contain the passed in value
  3. Verifies a password
  4. Returns records where email or username columns include/contain the passed in value (partial match)
A

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Select

A

Retrieves data from a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Insert

A

Adds data to a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Update

A

Changes existing data in a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Delete

A

Removes data from a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Where

A

Filters results from a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Create table

A

Makes a table if it already does not exist

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Alter table

A

Changes the structure of the table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Truncate

A

Deletes data from a table but keeps the structure

17
Q

Drop table

A

Deletes the entire table