2.09 Primary Keys and Foreign Keys

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/6

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

7 Terms

1
New cards

rimary key

a column, or group of columns, used to identify a row.

is usually the table's first column and appears on the left of table diagrams, but the position is not significant to the database.

  • Primary keys (simple or composite) must be:

    • UNIQUE. This rule ensures that each value identifies at most one row.

    • NOT NULL. This rule ensures that each value identifies at least one row.

2
New cards

simple primary key

key consists of a single column.

3
New cards

composite primary key

consists of multiple columns

4
New cards

auto-increment

is a numeric column that is assigned an automatically incrementing value when a new row is inserted.

5
New cards

AUTO_INCREMENT

keyword defines an auto-increment column. AUTO_INCREMENT follows the column's data type in a CREATE TABLE statement.

database users occasionally make the following errors when inserting primary keys:

  • Inserting values for auto-increment primary keys.

  • Omitting values for primary keys that are not auto-increment columns.

  • MySQL allows insertion of a specific value to an auto-increment column. However, overriding auto-increment for a primary key is usually a mistake.

6
New cards

foreign key

is a column, or group of columns, that refer to a primary key.

7
New cards

FOREIGN KEY/REFERENCES

constraint is added to a CREATE TABLE statement with the FOREIGN KEY and REFERENCES keywords.

When a foreign key constraint is specified, the database rejects insert, update, and delete statements that violate referential integrity.