Week 10 Flashcards

1
Q

What is a foreign key?

A

A Foreign key is a key borrowed from another related table (that’s why its foreign) in order to make the relationship between two tables. It is normally denoted with its first two letters, namely, FK

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

What is a primary key?

A

A Primary key is a key that uniquely identifies a row in each table. It is normally denoted with its first two letters, namely, PK

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

What is Referential Integrity?

A

means that the Foreign key must match in terms of actual values and data types with the related Primary Key.

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

What are constraints?

A

Database constraints are restrictions on the contents of the database or on database operations

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

Constraints provide a way to guarantee that (3)?

A
  • rows in table have valid primary or unique key values
  • rows in a dependent table have valid foreign key values that reference rows in a parent table
  • individual column values are valid
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Foreign Key / References constraint:

A
  • Rejects an INSERT or UPDATE of a value if a corresponding value does not currently exist in the primary key table.
  • Rejects a DELETE, if it would invalidate a REFERENCES constraint.
  • Must reference a PRIMARY KEY or UNIQUE column in primary key table.
  • Will reference the PRIMARY KEY of the primary key table if no column or group of columns is specified in the constraints.
  • Must refer a table , not a view.
  • Requires that a FOREIGN KEY column and the CONSTRAINT column have matching data types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Three primary type of relationships are:

A

one-to-one
one-to-many
Many-to-many.

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

Each row/record in a Table should be unique using a

A

Primary key

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

To create a relationship among tables you must have the ___________ on a different table

A

Foreign Key

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

Referential Integrity protects the integrity of your data by matching both your Primary key and Foreign in terms of _______ _______ and _______ _______ .

A

Data types and actual values

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

what is a Default Key Constraint –

A

At the time of cell creation a‘default value’ can be assigned to it. When the user is loading a ‘record’ with values and leaves this cell empty, the DBA will automatically load this cell with the default value specified. The data type of the default value should match the data type of the column.

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

What are check constraints?

A

•Used to enforce the validity of column values.

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

What are unique key contraints

A

purpose of a unique key is to ensure that information in the column for each record is unique

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

what is null?

A

Can mean many things:
Value does not exists
Value exists but is unknown
Value not applicable

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

truncate does the following, where as delete statement does not

A

Releases the memory used
Resets the identity value
Does not invoke delete trigger

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

Truncate Statement

A

Removes all rows in a table

Resets the table.