Bluh - SQL Basics

9 important questions on Bluh - SQL Basics

What is SQL's purpose?

SQL is used for the definition and manipulation of relational databases

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?

SQL is a set-oriented and declarative language which is standardized. Despite this standardization, many different implementations (dialects) exist

- 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

- standardized since 1986
- however, many different implementations

How are the clauses executed by the computer?

In a certain order

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
Discover Study Smart

How does one use the FROM clause with multiple tables

Step 1. Calculate Cartesian product (Table1 x Table2)
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?

Is used to extract only those records that fulfill a specified criterion (selection)

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 equal to
< is smaller than
> is greater than
<= smaller than or equal
>= greater than or equal
<> or != is not equal to    

they enable you to combine multiple conditions

What is the NULL value used for?

NULL is used as a placeholder for unknown values

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?

You can use SELECT to perform calculations or simply to display a constant number


DISTINCT removed duplicates from the result-set. So it will show a list of the unique values on what it is selected

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?

Functions that calculate a (single) value based on other values. Some examples: avg(), count(), first(), last(), max(), min(), sum()

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
Remember faster, study better. Scientifically proven.
Trustpilot Logo