Alterna · учебный материал
Links of several tables
External keys, communications one-to-one and rules on the integrity of the relational base.
Что в этом материале
- One substance — one table
- Integrity
- Three types of connections
- 1:1
- 1:M
- M:N
Содержание и основные понятия
01
One substance — one table
Data Studio has the books and the extradition tables. Extradition has a date, date, status and text field; its external key.
book_id
indicates an existing book. In a complete library chart, the reader can be placed in a separate table and add a second external key.
Table
Key
Communications
Books
book_id
One book is a great deal of time.
Readers
reader_id
One reader is a lot of extravagant.
Extraditions
loan_id
Keeps the book_id and reader_id as external keys.
02
Integrity
Don't create a "clear" link.
Extradition may not refer to a missing book.
Don't duplicate the fact.
The reader's name is stored in The Readers, not in each extradition.
Set the rule for disposal.
First check the related issuances, then delete the recording.
03
Three types of connections
1:1
One entry A corresponds to not more than one entry B: e.g. student and a separate access card.
1:M
One book has many historical gifts; the external key is kept on the "many" side.
M:N
A lot of students attend a lot of clubs. Communications are turned into two connections: 1-M through the "Participation" table.
ER
Library scheme
Books
PK book_id
name
Extraditions
PK loan_id
FK book_id
FK reader_id
Readers
PK reader_id
Group name
1
M
M
1