Lesson 3- Relational Model Key Constraints Flashcards

1
Q

What are keys used for?

A
  • Used to uniquely identify an individual record of data
  • Used to ensure the integrity, efficiency and proper structure of the data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Keys help?

A
  • Help uniquely identify records (rows) in a table
  • Enforce relationships between tables
  • Optimize database operations like searching, sorting and filtering
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a super key?

A

A combination of one or more attributes that uniquely identifies a row in a database table

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

What are two attributes of super key?

A
  1. Beyond the minimum need for uniqueness (non-minimal)
  2. It must always guarantee uniqueness for the entire table (uniqueness)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a candidate key?

A

A candidate key is a minimal superkey that can uniquely identify each row in a table

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

A table can have multiple candidate keys but one of them is chosen as _______

A

The primary key

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

Describe three features of candidate keys

A
  1. Unique for every row, with no redundant columns
  2. Minimal
  3. Can have more than one candidate key in a table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Every candidate key and primary key is a superkey but not every superkey is a _______

A

Candidate key

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

What is a primary key?

A

A column or a set of columns in a table that uniquely identifies each row in that table

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

Describe some characteristics of primary keys

A
  • No two rows can have the same values in the primary key column
  • It cannot contain NULL values
  • Must be unique for each record
  • Can be a single attribute (simple key)
  • A combination of attributes (composite key)
  • There is only one primary key per table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an alternate/secondary key?

A

An alternate key is any candidate key that is not chosen as the primary key (its an alternate option for uniquely identifying rows

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

What is a characteristic of an alternate key?

A

Exists when a table has multiple candidate keys

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

What is a composite key?

A

A type of candidate key that consists of two or more columns

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

What is a unique key?

A

A unique key is a column or set of columns that ensures all values in a column (or set of columns) are unique across rows, but is can contain NULL values (unlike a primary key) = can be a single column or a combination of columns

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

A unique key allows _______

A

Allows for NULL vaalues, but all non-NULL values must be unique

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

Superkey vs composite key

A
  • Superkey= Any set of one or more attributes that uniquely identifies a row, can be a single attribute or a combination of attributes, may contain unecessary attributes (not minimal)
  • Composite key= A candidate key that consists of two or more attributes, always a combination of two or more attributes, must be minimal with no extra attributes
17
Q

What is a foreign key?

A

A column or a set of columns in one table that references the primary key of another table

18
Q

What does a foreign key do?

A
  • It establishes and enforces a relationship between the two tables
  • It creates a link between two tables by ensuring that the value in the foreign key column corresponds to an existing value in the primary key column of the referenced table
  • Used to enforce referential integrity
19
Q

What is the primary key and foreign key for this example?

A
20
Q

What are referential integrity constraints used for?

A

Used to establish rules for referential keys

21
Q

Two types of reference table are dealt with?

A
  • Referencing table that holds the primary key
  • Referenced table that holds the foreign key