Table relationship
In a database, two database tables might be related in some way.
A table can link to a record of a different table, by storing the primary key of the other table’s entry. This is called a foreign key.
Types of relationship
flashcards
| Question | Answer |
|---|---|
| What is a foreign key in a database? | An identifier that stores the primary key of a record in another table to link the two tables. |
| How does one table link to a record in another table? | By storing the primary key of the other table’s record, which creates a foreign key. |
| Name the three types of table relationships. | one to one, one to many, many to many |
| What is a one-to-one table relationship? | A relationship where each record in one table corresponds to exactly one record in another table. |
| What is a one-to-many table relationship? | A relationship where a record in one table can be linked to multiple records in another table. |
| What is a many-to-many table relationship? | A relationship where records in one table can be linked to multiple records in another table, and vice versa. |