SQL Pocket Guide (PostgreSQL) Flashcards

This deck is Built for PostgreSQL. It is based of the SQL Pocket Guide written by Alice Zhao and Published by O'Reilly (26 cards)

1
Q

What does SQL stand for

A

Structured Query Language

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

What is an SQL Database?

A

It is a data base with tables or relations. It is also known as a Relational Database or RDB.

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

What is a NOSQL Database

A

It stands for Not Only SQL.This is a database which is not relational. It is just a suppository of unstructured information. It may have some tables in it though.

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

What is a DBMS

A

This is a Database Management System. It is software which is designed to manage Databases. examples of this are Microsoft SQL Server, SQL Light, PostgreSQL, and Orical.

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

what is an SQL query

A

This is similar to an SQL statement. The only difference is that a query only has read access and can only do the read function.

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

What is an SQL statement

A

An SQL statement is SQL code which can do any of the four operations from CRUD.

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

What is CRUD

A

A common acronym for SQL queries is CRUD. it stands for Create, Read, Update and Delete. These are the four main purposes to write an SQL query.

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

What is the order of a written SQL query

A

SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
LIMIT

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

What is the order of execution of an SQL statement.

A

FROM
WHERE
GROUP BY
HAVING
SELECT
ORDER BY

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

What is an RDBMS

A

it stands for Relational Database Management System. this is the software which executes you commands. You could also use a command line to use the data bases as well as embed the code into other languages such as Python or R. An RDBMS is the most common way though.

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

What is an SQL Function

A

an SQL function is a Keyword which takes in zero input or more input, does something to the input and returns an output. examples of this are COUNT(), and YEAR().

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

What is an identifier

A

An identifier is the name of a database object such as a table or a column.

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

What is an Alias

A

An Alias renames a column or a table temporarily, only for the duration of the query.
The standard is to use the keyword AS and no additional text when renaming tables and subqueries when required.

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

What is an expression

A

an expression can be thought of as a formula that results in a value. An example of an expression is COUNT(column_name).

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

What is a predicate

A

A predicate is a logical comparison which results in one of three values, TRUE/FALSE/UNKNOWN. These are found mostly in a WHERE or HAVING clause.

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

What is a CLAUSE

A

this is a line of code in SQL which begins with a Key word such as, SELECT, FROM, WHERE, HAVING, GROUP BY, etc.

17
Q

What is a comment

A

a comment can be created by using – for a comment on a single line or
/*
comment
here
*/
for a comment on multiple lines.
a comment is used to pass on information to other users who may be using your code or your future self so that they can get a better understanding of what you are doing and why.

18
Q

What is the SELECT clause

A

The SELECT clause returns the specific columns you want the statement to return.

19
Q

SELECT expressions

A

In addition to listing columns, you can list more complex expressions within the select clause to be returned as columns in the results.

SELECT name, ROUND(population * 0.9, 0)
FROM county;

this would return a name column and a column which was 90% or the population which was rounded to a whole number.

20
Q

SELECT function

A

expression in the SELECT list typically refer to columns in the table that you are pulling from, but there are expressions. For example a common expression that does not refer to any table is the one to return the current date

SELECT CURRENT_DATE:

21
Q

What is Qualifying Columns

A

When you have two tables merged they may have a column each with the same name. To tell the database which column you mean you will have to Qualify the Column.

Select table_name.column_name, second_table_name.column_name

22
Q

How do you Qualify a table

A

If you qualify a column by the table name you qualify a table by the database or schema name in the same way.

SELECT sqlbook.owner.id, sqlbook.owner.name
FROM sqlbook.owner;

23
Q

Selecting Subqueries

A

A subquery is a query that is nested inside another query.
- subqueries must be surrounded by parenthesis.
- when you write a subquery in a SELECT clause it is highly recommended that you give it an ALIAS this way the column has a simple name.

24
Q

Corelated and non corelated subquery

A

A Corelated subquery is a query which refers to the values in the outer query. A Non Corelated subquery is a query which does not refer to any of the values in the outer query.

25
Distinct
The DISTINCT keyword will return only one of each item in the column. There will be no duplicates.
26