SQL Flashcards

1
Q

relational database

A

represents a collection of related (two-dimensional) tables. Each of the tables are similar to an Excel spreadsheet, with a fixed number of named columns (the attributes or properties of the table) and any number of rows of data.

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

SQL

A

structured query language

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

in SQL columns represent x?

A

properties

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

in SQL rows represent x?

A

instances

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

how to select all columns of data in a table?

“dumping all the data at once”

A

SELECT *

FROM table_name;

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

how to select several columns in a database?

A

by separating them with a comma:

SELECT title, director FROM movies;

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

conditional word for operations with constraints

A
WHERE
e.g.:
SELECT column, another_column, …
FROM mytable
WHERE condition
    AND/OR another_condition
    AND/OR …;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

operator for: Number is within range of two values (inclusive)

A

BETWEEN … AND …
e.g.:
col_name BETWEEN 1.5 AND 10.5

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

operator for: Number is not within range of two values (inclusive)

A

NOT BETWEEN … AND …
e.g.:
col_name NOT BETWEEN 1 AND 10

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

operator for: number exists in a list

A

IN (…)
e.g.:
col_name IN (2, 4, 6)

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

operator for: number does not exist in a list

A

NOT IN (…)
e.g.:
col_name NOT IN (1, 3, 5)

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

query capitalization mandatory?

A

NO. Just a convention to help distinguish from column and table names

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

operator: Case sensitive exact string comparison

A

=

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

operator: Case sensitive exact string inequality comparison

A

!= or <>

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

operator: Case insensitive exact string comparison

A

LIKE

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

operator: Case insensitive exact string inequality comparison

A

NOT LIKE

17
Q

operator: Used anywhere in a string to match a sequence of zero or more characters (only with LIKE or NOT LIKE)

A

%
e.g. col_name LIKE “%AT%”
(matches “AT”, “ATTIC”, “CAT” or even “BATS”)

18
Q

operator: Used anywhere in a string to match a single character (only with LIKE or NOT LIKE)

A

_ (underscore)
e.g.: col_name LIKE “AN_”
(matches “AND”, but not “AN”)

19
Q

string quoting mandatory?

A

yes. Allows to distinguish strings from SQL keywords

20
Q

how do we add an additional condition?

A
By introducing AND/OR after WHERE.
e.g.:
SELECT column, another_column, …
FROM mytable
WHERE condition
    AND/OR another_condition
    AND/OR …;
21
Q

keyword: a convenient way to discard rows that have a duplicate column value

A

DISTINCT
SELECT DISTINCT column, another_column, …
FROM mytable
WHERE condition(s);

22
Q

clause: SQL provides a way to sort your results by a given column in ascending or descending order (alphanumerically)

A
ORDER BY
e.g.:
SELECT column, another_column, …
FROM mytable
WHERE condition(s)
ORDER BY column ASC/DESC;
23
Q

clause: will specify where to begin counting the number rows from

A

OFFSET

24
Q

clause: will reduce the number of rows to return

A
LIMIT
e.g.:
SELECT column, another_column, …
FROM mytable
WHERE condition(s)
ORDER BY column ASC/DESC
LIMIT num_limit OFFSET num_offset;
25
Q

SQL is used by …?

A
  • database administrators
  • developers writing data integration scripts
  • data analysts looking to set up and run analytical queries
26
Q

SQL is used for…?

A
  • modifying database table and index structures;
  • adding, updating and deleting rows of data;
  • retrieving subsets of information from within relational database management systems (RDBMSes)
27
Q

database object: VIEW

A

logical representations of data assembled from one or more database tables

28
Q

database object: INDEX

A

lookup tables that help speed up database lookup functions

29
Q

database object: REPORT

A

consist of data retrieved from one or more tables, usually a subset of that data that is selected based on search criteria

30
Q

SQL status?

A

de facto standard programming language for relational databases

31
Q

database normalization

A

splitting data into separate tables

helps minimize duplicate data in any single table, and allows for data in the database to grow independently of each other. BUT, queries get slightly more complex since they have to be able to find data from different parts of the database, and performance issues can arise when working with many large tables