Insert, Update, Delete, RI, and Constraints Flashcards

1
Q

INSERT

A

Adds a new row of data to a table
Can be shortened to insert every column:
INSERT INTO table_name VALUES (value1, value2, … value_n);

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

UPDATE

A

Updates the value of columns on an existing row of data for the specific rows.
UPDATE table_name
SET column = value
WHERE column = value;

Can update multiple columns in a since update statement.
UPDATE table_name
SET column1 = value1, column2 = value2
WHERE column = value;

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

DELETE

A
Deletes row(s) of data from a table.
DELETE FROM table_name
WHERE column=value;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Referential Integrity

A

Referential Integrity is a property of the data stating whether or not references within it are valid. For example, to use a foreign key on a table, the value must exist on the primary table.

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

Constraints

A

defines properties that the column data must comply with. It sets a rule that must be obeyed to maintain the integrity of the data

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

Constraints examples

A
NOT NULL
UNIQUE
PRIMARY KEY
FOREIGN KEY
CHECK
DEFAULT
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

NOT NULL constraint

A

The column cannot contain a null value

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

UNIQUE constraint

A

The column can only contain unique values

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

PRIMARY KEY constraint

A

Enforces NOT NULL and UNIQUE. Allows Foreign Key relationships to be established.

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

FOREIGN KEY constraint

A

Only allows values where the value exists on the related table. Does not allow the related value to be removed from the related table as long as the foreign key value is in use.

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

CHECK constraint

A

Specifies a list of acceptable values that can be added into a column

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

DEFAULT constraint

A

Provides a default value for a column, if no value is provided.

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

Transactions

A

a single unit of work made up of multiple SQL statements that must all succeed or fail as one

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

When a transaction is successful it is

A

committed and the data is saved in the new state

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

When a transaction fails it is

A

rolled back and all the data is left in the original state.

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

The ACID Test

A
is used to determine whether a series of actions should be a transaction:  Must the actions occur as all or none
Atomicity
Consistency
Isolation
Durability
17
Q

Atomicity

A

Must the actions occur as all or none

18
Q

Consistency

A

Once the series of actions is complete is the data left in a consistent state, meaning any rules that pass before the transaction still pass after the transaction

19
Q

Isolation

A

Does the final result of the transaction leave the data in the same state as they would have if executed serially

20
Q

Durability

A

Once the transaction has been committed, will it remain so even after an error, system crash, or power loss