Super key: An attribute set that uniquely identifies a tuple in a relationship is called a hyper-key of a relational pattern
Candidate key (candidate Key): A super-key that does not contain extra attributes is called a candidate key
Primary key (primary key): A candidate key that the user selected as a tuple ID becomes the primary key
Foreign key (foreign key) if the set of properties in the relational schema R1 is not the primary key of the R1, but the primary key of the other relationship R2, the property set is the foreign key of the relational schema R1.
Specific explanations of the examples:
Suppose you have the following two tables:
Student (school number, name, gender, social Security number, teacher number)
Teacher (teacher number, name, salary)
The definition of a super-key indicates that any combination of the student's number or a social Security number is a super-key for the table. such as: (School Number), (school number, name), (Social Security number, gender) and so on.
A candidate key is a super-key, which is the smallest super-key, meaning that if you remove any of the candidate keys, it is no longer a super-key. The candidate keys in the student table are: (Student number), (Social Security number).
The primary key is one of the candidate keys, is a man-made rule, for example, in the student table, we usually let the "learning number" key, teachers table let "teacher number" key.
Foreign keys are relatively simple, and the foreign keys in the student table are "teacher numbers". A foreign key is primarily used to describe the relationship of two tables.
Database-Super Key, candidate key, primary key, foreign key