SQL for non-programmers Flashcards

You may prefer our related Brainscape-certified flashcards:
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 SQL used for?

A

Programming language used to communicate with and manage relational databased

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

SQL is based on _______-_______ commands

A

English-language
It avoids having to learn complex programming syntax

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

What are the 3 things you need to utilize SQL?

A
  1. Database management system
  2. Tool to interact with Database
  3. Data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is SQLite.org?

A

A free, open-source, and user-friendly system

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

What is SQLiteStudio?

A

Free graphical user interface
Designed to make these databases more friendly and accessible

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

What are 4 things that SQL allows you to do with data?

A

Define
Manipulate
Control
Query

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

What are relational databases?

A

They are a type of database that organized data into tables, with each table consisting of rows and columns
Each row represing a unique record of data and each column represents an attribute or characteristics of that data

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

How can tables be linked or related?

A

They can with common keys. Common keys are data that is common to each table and alow you to create bridges that connect one table to another.

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

What are some of the relational database solutions on the market today?

A

MySQL
Microsoft SQL Server
PostgreSQL
SPLite

Relational databases are flexible, scalable solution for complex data

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

How are relational databases designed/structured?

A

Attempt to minimize redundancies and maximize efficiency

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

Relational databases are built using a process called normalization, explain

A

To organize data in a database so that each piece of data is only stored in one place. Makes it more efficient and accurate

To prevent data duplication and inconsistencies

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

Define

DQL or Data Query Language

A

An SQL command family, allows you to retrieve data from a database for both broad population and data professionals alike

Most common command family and maybe only one you’ll need

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

What are the four main command families?

A

DDL: Data Definition Language
DCL: Data Control Language
DML: Data Manipulate Language
DQL: Data Query Language

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

What is the process of normalization used for?

A

To organize data more optimally and efficiently in a database

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

What is the only statement in the DQL command family?

A

The SELECT statement

This makes the program very accessible

Need at least 2 pieces of info

17
Q

What requires a SELECT statement?

A

What data you want to select
From where do you want to select it

18
Q

How do you close a statement with the FROM command?

A

Use semicolon
Ex: FROM oliveoil.sales;

19
Q

What does the
SELECT *
command do?

A

It pulls everything from the table, we are usually not interested in pulling everything from the data, only a subset.

20
Q

Use LIMIT for?

A

LIMIT will limit the output to the amount of rows you tell it to. Ex:
LIMIT 10;

10 is the number of rows you are limiting it to

21
Q

When you are hit with many repeats of the same information, use
SELECT DISTINCT

A

This will only show you things that are unique from that column. Ex:
SELECT DISTINCT prod_category
FROM oliveoil.sales;

22
Q

What is the videos best practice #1?

A
  • SQL keywords are uppercase (SELECT)
  • Column and table names are lowecase (employee-name)
23
Q

Videos best practice #2?

A
  • Column and table names with 2 or more words are separated by an underscore (employee_name)

Make sure you use the same naming convention on all tables and codes

24
Q

Videos best practice #3?

A
  • Use whitespace intentionally, it improves readability and maintainability
  • Use spaces to separate keywords, operators and punctuations

Use line brakes to separate clauses or column names in your query

25
Q

Video best practice #4?

A
  • Use comments to explain sections of statements
  • Use comments to clock areas of statements from being executed

These are ignored at execution

26
Q

What is the ORDER BY clause?

A

This is used to sort data in ascending or descencing order based on a column

Helpful to draw insights or conclusions

Helps find patterns by ordering data
Default order is ascending

27
Q

How do you specify if you want your ORDER BY clause to be descending or ascending?

A

Ascending is by default, but can specify with adding in caps ASC (from smallest to largest)
Descending you have to specify by adding DESC (from largest to smallest)
Ex:
ORDER BY order_total DESC;

Always select your query and press the play button

To open up a file, select the folder icon and change your extension to all files so they are all visible

28
Q

What is considered bad programming practice?

A

Ordering a query by it’s ordinal position. Ex:
ORDER BY 4 DESC;

It doesn’t really change the resulting data
Reference by name and not ordinal position

29
Q

What ORDER BY is also default?

A

Alphabetical and ascending

30
Q

5 Basic clauses we discuss

A

SELECT
FROM
WHERE
ORDER BY
LIMIT

Use this order to maintain good coding convention practice

31
Q

What is the WHERE clause used for?

A

To filter data based certain conditions
When using the WHERE clause, be careful because it is case sensitive, must use single quotes (‘ ‘) and must be written exactly as it is listed in database

Ex:
WHERE prod_category = ‘Bath Products’
use equal sign to address one conditon and encapsulate it with single quotes

32
Q

How to include multiple conditions using the WHERE clause?

A

Use IN and parentheses and commas but get rid of the equal sign when using multiple conditions
WHERE order_total IN (‘Bath Products’, ‘Gift Basket’)

Can also use AND to filter more conditions between diff columns. Ex:
WHERE prod_category = ‘Bath Products’
AND emp_name = ‘Clement Carry’

33
Q

How to exclude 1 category using WHERE clause

A

Use != which means not equal to

33
Q

How to exclude more than 1 category using WHERE clause

A

Use NOT IN, encapsulate the conditons in parenthesis, single quotes and commas
Ex: WHERE prod_category NOT IN (‘Olive Oil’, ‘Gift Basket’)

34
Q

When using the OR clause

Why should you carefully understand what is being asked?

A

You can exclude or include data you didn’t mean to
Use parentheses to separate individual conditions
If management wants all orders of bath products, all orders of employee Clement Carry and in both only bulk orders of greater than 5 items

WHERE prod_category = (‘Bath Products’
OR emp_name = ‘Clement Carry’)
AND quantity > 5
by putting the 2 conditions in parentheses, we have grouped them together

34
Q

How to filter with WHERE using a numerical value?

A

You do not need quotation signs, you can use IN, AND, equal, or other comprison operators like less than or more than. Then use the number you are looking for.
If looking for a range, use BETWEEN

BETWEEN will include the numbers you are stating. EX: if you say BETWEEN 2 AND 4, then it will also include the numbers 2 and 4 in the results