Constraints Flashcards

(12 cards)

1
Q

What is a constraint?

A

A relationship among data elements that the DBMS is required to enforce

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

When are triggers executed?

A

When a specified condition occurs
Ex. Insertion of a tuple

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

What is another name for a foreign key?

A

referential integrity

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

For a foreign key, what must referenced attributes be declared?

A

PRIMARY KEY
or
UNIQUE

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

If there is a foreign key constraint from relation T1 to relation T2, what two violations are possible?

A

An insert or update to T1 introduces values not found in T2

A deletion or update to T2 causes some tuples of T1 to dangle

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

What are the three ways we can handle a deletion or update of T2 (the table that is referenced in a foreign key)?

A
  1. Default
  2. Cascade
  3. Set NULL
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the default case?

A

Reject the modification

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

What does cascade do?

A

Make the same changes in T1 that were made it T2

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

What does Set NULL do?

A

Change the affected tuples to NULL, but only the attribute that is a foreign key of the table that was changed

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

To choose policies for a foreign key what do you follow the foreign key declaration with?

A

ON [UPDATE, DELETE] [SET NULL CASCADE] then choose what you want from the brackets

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

What happens if you do not choose policies for a foreign key?

A

The default (reject the statement) is used

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

When are attribute based checks performed?

A

ONLY when a value for that attribute is inserted or updated

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