sql-ecology-lesson
sql-ecology-lesson copied to clipboard
Adding a discussion about primary and foreign keys
Hi! I wanted to make a suggestion for the https://datacarpentry.org/sql-ecology-lesson/03-sql-joins/index.html Combining Data with Joins episode. In the first part of this lesson https://datacarpentry.org/sql-ecology-lesson/00-sql-introduction/index.html , there is some mention of primary and foreign keys as necessary in relational databases. However, in the episode that is actually doing JOINs on tables, the word "key" doesn't appear even once. I think it'd be a good addition to bring back that concept that was introduced in the beginning of the lesson, and then stress the importance of joining on keys. It could further explain the importance of a relational database to the learner as well. Thanks to all who contribute and maintain this lesson :)
Hi and thanks for the suggestion. You make a good point, and reading through it again I see that the concept requiring unique keys for doing a JOIN is made implicitly by using "ID" columns (species_id, plot_id).
A paragraph of non-implicit explanation would be welcome.
Hi,
I also agree that we need to discuss about Key, Primary Key, and Foreign Key. In addition, we can also give them a short explanation from the existing example we already have in the lesson, like
surveys.species_id = species.species_id;