SQL Flashcards

1
Q

What is a static type system?

A

You declare a column with a specific data type

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

What is a dynamic type system?

A

Value stored in column determines its data type

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

Give examples of static type systems:

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

Give examples of dynamic type systems:

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

What are data types in SQLite?

A

5 primitive data types:
NULL
INTEGER
REAL
TEXT
BLOB

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

What is the syntax for a creating a table?

A

CREATE TABLE tableName(
name type constraint
)

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

What is the syntax for linking foreign keys in tables?

A

Foreign key(foreignKey) REFERENCES tableName(candidateKey)
ON UPDATE action
ON DELETE action

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

What are some actions we can have for foreign key instances?

A

SET NULL
CASCADE
RESTRICT
SET DEFAULT

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

What are aggregate functions?

A

Act on a single column and returns a single value (used in select)

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

Give examples of aggregate functions

A

COUNT
SUM
AVG
MIN
MAX

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

What are the different types of joining?

A

Cross join
Inner join
Left join

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

What is cross join?

A

Computes the cartesian product of relations

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

What is inner join?

A

Matches each from from 1st relation with every row from 2nd relation over a common attribute

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

What is left join?

A

Matches each row from the first row with every row from the 2nd over a common attribute. If no common attribute, then NULL

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