Week 2 Learning Journal Prompt:
- 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.
- 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?
One example that I can think of where something other than primary keys would be needed is if you were doing an analysis on a specific aspect of the data. I think it would be useful if you were to compare something like a budget where there was a budget amount and actual cost. The primary key would be the transaction ID, but the budget would be a separate entity. Something like the following:
SELECT *
FROM cost
JOIN budget USING(category)
ORDER BY category
My opinion of SQL as a language is that it is very approachable and has clear syntax that attempts to make working with database information as efficient as possible. I do think that this language is somewhat easy to use. I am still learning the syntax details, but with practice I will start to recognize the patterns and identify the proper syntax needed to achieve the right results. SQL is different from other programming languages in its structure, but it works because it is developed in a way to focus on working with database data. For myself, the most challenging thing when translating from English to SQL is understanding how the different key words work together and the proper order to piece them together to get the desired output.
Comments
Post a Comment