Concept Review
- What does (relational) DB bring?
- It’s actually a collection of info organized to afford efficient retrieval.
- DBMS: software packages designed to store, access, manage DBs.
- In relational DB:
Join
Be used to apply Non-Equi-Joins
1234select e.emp_id, e.fnamefrom employee e Inner Join product pOn e.s_date>= p.date_offerAnd e.s_date< p.date_retireSelf-Joins and use subqueries as tables
Aggregation
Be careful about implicit/explicit groups.
Example 1: group ~ product_cd = ‘CHK’
Example 2: group ~ product_cd
Example 3: Multicolumn Grouping, understanding: what being grouped on will perform as “P Key” on the resulting table.
Example 4: Expressions
|
|
String manipulation (RE)
Keyword: Like
| Search Expression | Interpretation |
| — | — |
| F% | Strings beginning with F |
| %t | Strings ending with t |
| %bas% | Strings containing the substring ‘bas’ |
| __t_ | Four-character strings with a t in the third position |
Keyword: REGEXP
E.g. Find all employees whose last name starts with F or G.
Mistakes collection when Writing queries
- If you want to generate a column/set, must select the data from table in the first place.
Demo.