cst 363: week 2
SQL has the flexibility to join tables on any column(s) using any predicate (=, >, < ). Most of the time the join will use equality between a primary and foreign key. Think of example where joining on something other than keys would be needed. Write the query both as an English sentence and in SQL. If you can't think of your own example, search the textbook or internet for an example.
English example: I'd like to join a table of cat information at an adoption event, and there would be a table with medical records, joining in the adoption date and the vaccine date.
SQL example:
SELECT adoptions.cat_id, adoptions.adoption_date, vaccinations.vaccine_date
FROM adoptions
JOIN vaccinations
ON adoptions.cat_id = vaccinations.cat_id
AND adoptions.adoption_date = vaccinations.vaccine_date;
What is your opinion of SQL as a language? Do you think it is easy to learn and use? When translating from an English question to SQL, what kinds of questions do you find most challenging?
I think that SQL is a bit easier than a programming language, because it's a kind of close to writing pseudocode. I don't think it's super easy to learn, but once you get past the learning curve, it's easier to work through than a typical programming language. I think that remembering order of operations is a bit challenging for me, as well as making sure that the columns are valid.
Comments
Post a Comment