Tuesday, May 7, 2024

Intro to Databases Week 2

  1.  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.
I'm thinking of a time you wouldn't need to have an equality relationship between the primary and foreign keys would be when you want to combine all the data to see all possible combinations of the data.
For example if a business wants to see all possible ways to combine several items, like a restaurant would want different ways to combine a meal and different beverage options.
The English query would be something like what are all the possible combinations of different meals and beverages.
The SQL query would be something like "select * from meals, beverages"

  1. 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?
The general concepts of the SQL language are easy to grasp, but as they say, the devil is in the details.  I felt like I had a pretty good handle of things the first week, but this second week I've definitely felt as though the trickier SQL queries took me a lot longer to process how to put them together in order to achieve the desired result output.  
Week 1 I felt as though I could read a prompt, and naturally understand the SQL query that would return the desired data, but Week 2 I've felt as though I've struggled doing that same approach.  It's been a lot more trial and error, I don't read the prompt and immediately understand the right approach to building the query.  This is especially true for queries that involve subqueries or rely on data from 3 or more tables.

0 comments:

Post a Comment