Bluh - SQL Basics
9 important questions on Bluh - SQL Basics
What is SQL's purpose?
1. Define (DDL)
- SQL can be used as a Data Definition Language (DDL)
- used to refine a RDBMS
2. Manupulate (DML)
- SQL can be used as Data Manipulation Language (DML)
- Used to consult (retrieve) and manipulate data (insert, update, delete)
What are the SQL specific characteristics?
Set-oriented
- SQL is based on the relational model
- model is based on set theory and predicate logic (relational algebra and calculus)
- Thus: SQL statements operate on sets and return their results in sets
Declarative: which, not how
- specifiy which data (sets) you want to retrieve or manipulate
- do not specify how this data should be retrieved or manipulaed
- thus: no procedural programming
Dialects
- standardized since 1986
- however, many different implementations
How are the clauses executed by the computer?
1. From - determine the necessary tables for the dataset
2. Where - put a first condition on dataset
3. Group By - group dataset by one or more columns
4. Having - put a condition on grouped dataset
5. Select - determine which columbs should be projected
6. Distinct - remove all duplicate rows from projection
7. Order by - sort the projection
SQL is declarative, yet this aids understanding
- Higher grades + faster learning
- Never study anything twice
- 100% sure, 100% understanding
How does one use the FROM clause with multiple tables
Step 2. Apply JOIN or WHERE (if necessary) to filter matching records
The cartesian product matches all the contents together. The INNER JOIN or WHERE conditions can filter the non-meaningfull record
What is the purpose of the where clause?
Thus: specifies a condition on the data. The where clause makes a selection of these data by applying a filter that achieves a horizontal partitioning of the data
What are comparison operators?
And the Boolean?
< is smaller than
> is greater than
<= smaller than or equal
>= greater than or equal
<> or != is not equal to
BOOLEAN = AND, OR, NOT
they enable you to combine multiple conditions
What is the NULL value used for?
NULL values are treated differently from other valyes
- use IS NULL to retrieve records with NULL values
- use IS NOT NULL to retrieve records without NULL values
Who do expressions do?
And Distinct?
SEE EXAMPLES
DISTINCT removed duplicates from the result-set. So it will show a list of the unique values on what it is selected
NOTE.
SELECT DISTINCT is not the same as GROUP BY. It solely removes duplicate records from the query result-set. The GROUP BY class shall aggregate some columns bases on the values in these columns
What do aggregated functions do?
You can insert a column for instance
The question on the page originate from the summary of the following study material:
- A unique study and practice tool
- Never study anything twice again
- Get the grades you hope for
- 100% sure, 100% understanding