Week 19: CST363 Week 2: SQL’s Flexibility

SQL’s Flexibility: 

The structure of SQL closely resembles how we think about data, which makes it relatively easy to understand once you grasp the key concepts. A case where a join uses a range condition: we have two tables: vegetables and harvest_seasons. The vegetables table contains information about various vegetables and their harvest dates, while the harvest_seasons table defines the typical harvest seasons for different vegetables. We need to find which vegetables were harvested during their normal harvest season. 

English: List all vegetables that were harvested within their harvest season, showing the vegetable name and the harvest season.

SQL:

SELECT v.name, hs.season 

FROM vegetables v 

JOIN harvest_seasons hs 

ON v.harvest_date BETWEEN hs.start_date AND hs.end_date;


Opinion on SQL:

SQL is a powerful and intuitive language when working with relational databases. The way SQL mirrors human logic, especially in cases like this, makes it easy to express complex relationships and data manipulations. The most challenging part for me has been translating real-world scenarios into SQL queries when they involve complex logic or aggregate functions.

 

Comments