Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Structure. Primary Key and Foreign Key | Section
Relational Database Fundamentals

bookStructure. Primary Key and Foreign Key

Свайпніть щоб показати меню

Primary and Foreign Keys

In relational databases, the foundation lies in tables and their relationships, which are often established using Primary Keys and Foreign Keys.

  • A Primary Key (PK) serves as a unique identifier for a record within a table;

  • A Foreign Key (FK) references the Primary Key of a different table, connecting records between them.

Take, for instance, two tables: "student" and "group." In the "student" table, each record might have details such as id (representing the student's ID), name, surname, age, and group_id (which is a foreign key pointing to the primary key of the "group" table). The "group" table, on the other hand, might contain id (indicating the group's ID), name, and grade.

carousel-imgcarousel-img

From this, it's evident that both John and Kesha are members of the BG1 group, as indicated by their foreign key referencing the group id. The BG4 group has one student, Emma, while the MG2 group currently has no students associated with it.

Such a structure facilitates the use of JOIN operations in database queries.

Take a closer look at the "group-student" entity-relationship (ER) diagram:

1. What is a primary key?

2. What is a foreign key?

question mark

What is a primary key?

Виберіть правильну відповідь

question mark

What is a foreign key?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 1. Розділ 5
some-alt