Joins, foreign keys, and primary keys are all closely-related concepts in a relational database.
The Primary Key uniquely identifies rows in a given table.
A Foreign Key denotes a primary key in a different table.
A Join is a way to retrieve data from multiple tables.
I haven't used SQL Workbench much, but my guess is that a link table is referring to a table containing multiple foreign keys to create a "many to many" relationship between two tables.
For example:
Table User
CREATE TABLE User(
userId INT PRIMARY KEY,
username VARCHAR(40)
);
Table Post
CREATE TABLE Post(
postId INT PRIMARY KEY,
postContents VARCHAR(max)
);
Table UserPost
CREATE TABLE UserPost(
userId INT FOREIGN KEY REFERENCES User(userId),
postId INT FOREIGN KEY REFERENCES Post(postId)
);
The table UserPost
would be a "link table" that links together the User
and Post
tables to indicate the many posts that any one user could have.
You could then find all posts of a given user with a SQL query like below, using UserPost
to link together User
and Post
SELECT u.username, p.postContents FROM User u
JOIN UserPost up ON up.userId = u.userId
JOIN Post p ON up.postId = p.postId
So in summary, a link table allows us to use joins to "join" together information from multiple tables. Because of this, link tables are more often referred to as "join tables". See this post for more details about join tables.