Question
Which of the following accurately describes the role of
a "foreign key" in a relational database system?Solution
A foreign key is a column (or a set of columns) in one table that refers to the primary key in another table. This relationship enforces referential integrity , ensuring that the value in the foreign key column matches an existing value in the referenced table's primary key column. This mechanism is crucial for relational databases as it defines how data in one table is related to data in another. For example, consider a database with two tables: Orders and Customers .
- The Orders table has a column CustomerID which acts as a foreign key referencing the primary key CustomerID in the Customers table.
- This relationship ensures that each order is associated with a valid customer.
'рдЬреНрдЮрд╛рдирдореБрджреНрд░рд╛' рдХрд╛ рд╕рдВрдзрд┐ рд╡рд┐рдЪреНрдЫреЗрдж рд╣реЛрдЧрд╛┬а
рдЬрд┐рд╕рдХреА рд╡рд┐рд╢реЗрд╖рддрд╛ рдмрддрд╛рдпреА рдЬрд╛рдпреЗ, рдЙрд╕реЗ рдХрд╣рддреЗ рд╣реИрдВ-
рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рд╡рд╛рдХреНрдп рдореЗрдВ рдкреНрд░рдпреБрдХреНрдд рдЕрд╡реНрдпрдп рдХрд╛ рднреЗрдж рдмрддрд╛рдЗрдПтАФ
рдпрджрд┐...
" рдХреБрдЯреБрдВрдм ┬ардореЗрдВ рд╡реНрдпрдХреНрддрд┐ рд╣реЛрддреЗ рд╣реИрдВ, рд╕рдорд╛рдЬ рдореЗрдВ рд░рд╛рд╖реНрдЯреНрд░реА рдЗрд╕реА рдкя┐╜...
рдХрд╛рдХ рдХрд╛ рддрджреНрднрд╡ рд╢рдмреНрдж _________ рд╣реИред
'рдИрдкреНрд╕рд┐рдд' рдХрд╛ рд╡рд┐рд▓реЛрдо рд╢рдмреНрдж рд╣реИ
тАЬ рдмрдирд╛рд░рд╕реА рд╕рд╛рдбрд╝реА рдкреНрд░рд╕рд┐рджреНрдз рд╣реИтАЭ рдЗрд╕ рд╡рд╛рдХреНрдп рдореЗрдВ тАШрдмрдирд╛рд░рд╕реА рдХреМрди рд╕рд╛┬а рд╡я┐╜...
рдкрдХреНрд╖реА рдореЗрдВ рдХрд┐рддрдиреЗ рд╡реНрдпрдВрдЬрди┬ард╡рд░реНрдг рд╣реИ ?
рдЫреБрд░реА рдХрд╛ рддрддреНрд╕рдо рд╢рдмреНрдж рд╣реИ-
рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдореЗрдВ рд╕реЗ рдХреМрди-рд╕рд╛ рд╡рд╛рдХреНрдп рд╢реБрджреНрдз рд╣реИ?