Document directory
- What is a primary key and a foreign key?
What is a primary key? What is a foreign key? [Tag: foreign key, key, foreign key] What is a primary key in a database? What is a foreign key? What are their functions. Please give me the answer as much as you can !! ☆Snow silent ☆answer: 3 popularity: 6 solution time:
Satisfactory answer
Favorable rating:100%
To put it bluntly
Let's talk about the primary key: one or more columns of a table (Link) can be used as the primary key, provided that this column is used as the primary key, this column ensures that the values of individual rows (tuples) in this column cannot be the same. For example, if you use the name attribute as the primary key, this primary key is not necessarily acceptable, if two people have the same name, the values of the data in the tuples under this attribute cannot be different. It is a good choice to use Arabic numbers as the primary key.
Foreign key: A table (relational) Column (attribute) exists in both table 1 and table 2. It is not the primary key of table 1, it is the primary key of table 2. It can be said that it is the foreign key of table 1.
So what is the candidate key? A column (attribute) that uniquely identifies a row (tuples) in a table (Link) is called a candidate key, it is also called a candidate keyword or candidate code. From this point of view, there can be more than one candidate key. We can also see that the primary key is also a candidate key.