2. Introduction to SQL Flashcards

1
Q

Features

A

Data Manipulation Language:

-Query data
-Insert/modify / remove data

Data Definition Language :

-Create/ Modify tables
-Define triggers
-Create constraints

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the main data manipulation tasks?

A

Requesting data
Inserting data
Deleting data
Changing data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the main data definition tasks?

A

Create tables
Deleting tables
Changing tables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does it mean for SQL to be strongly types?

A

Error if you use the wrong data types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does it mean for SQL to be statically typed?

A

You cannot modify the type mid program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the main data types in SQL?

A

Boolean - T/F
Integer - integers
Decimal - exact fixed point number
Double - 64 bit floating point numbers
Date - date
DATETIME - a date plus time
CHAR(n) - fixed length character string
VARCHAR(n) - variable length character string
TEXT - string of text
BLOB - binary storage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What database design feature does strong typing help solve?

A

Data integrity –> overall accuracy and consistency of data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Restriction

A

Condition: boolean expression for which rows to include

Made of :
- Column names from referenced tables
- Literals : numbers, strings….
- Operators: =, <> , >, >=, <, <=
- Combining terms: AND, OR
- Missing values: IS NULL, IS NOT NULL
- Within a subquery: IN, NOT IN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Ordering Output

A

ORDER BY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Cross Join (Cartesian product)

A

Produces all possible combinations of the rows of 2 tables (does not care if there are crossovers that are false)

DO NOT USE THS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Inner Join (Natural Join)

A

Keeps only rows with matching common columns

Eliminates rows from both tables that do not satisfy the join condition –> gives us the INTERSECTION of two tables ( think stats)

Most common join

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Outer Join

A

Returns matched values and unmatched values from either or both tables

3 Types:

1) LEFT JOIN: returns only unmatched rows from the left table, as well as matched rows in both tables

2) RIGHT JOIN: returns only unmatched rows from the right table, as well as matched rows in both tables

3) FULL OUTER JOIN: returns unmatched rows from both tables, as well as matched rows in both tables

THINK OF THE JOINS IN TERMS OF PROBABILITY CONCEPTS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Aliasing tables

A

Tool for abbreviating reference to table name –> useful for referring to commonly used tables

Syntax:

<table> AS <alias>

EX:
Select d.dname, e.salary
FROM Department AS d, EMPLOYEE as e
WHERE d.id = e.id
</alias></table>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly