Section 1

Preview this deck

self vs. inner vs. outer vs. cross

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (65)

Section 1

(50 cards)

self vs. inner vs. outer vs. cross

Front

"outer" will return nulls and "inner" won't "self" is useful when everyone has an employee id and supervisor id in the same table--> can join so we can identify the supervisor's name in each case for CROSS see http://www.mysqltutorial.org/mysql-cross-join/

Back

SELECT DISTINCT

Front

used to return unique values in the result set. It filters out all duplicate values. Here, the result set lists each genre in the movies table exactly once. 1. SELECT DISTINCT specifies that the statement is going to be a query that returns unique values in the specified column(s)

Back

intersect

Front

Back

limit

Front

Back

replace into table(column) values()

Front

insert a new row or delete old row first then insert new row

Back

alter table/view

Front

adding/removing columns changing column attributes add primary key change column datatype rename table/view

Back

minus

Front

can only use with select and froms

Back

like

Front

create similar tables, DBs, wildcards (% and __)

Back

delete join

Front

more than one delete at the same time

Back

MERGE

Front

does not have its own indexes; it uses indexes of the component tables instead speed up performance when joining multiple tables MySQL only allows you to perform SELECT, DELETE, UPDATE and INSERT operations on the MERGE tables.

Back

set

Front

change values in table, often followed by WHERE for conditions

Back

recursive stored procedure

Front

stored procedure that calls itself

Back

update

Front

Back

cursor

Front

iterate through a result set returned by a SELECT statement and process each row accordingly -> like a for loop with stuff inside read-only, non-scrollable and asensitive 1. declare cursor 2.declare NOT FOUND handler 3. build whatever 4. test outside of script

Back

insert

Front

putting VALUES into table

Back

update join

Front

Back

MyISAM

Front

optimized for compression and speed. MyISAM tables are also portable between platforms and operating systems. default storage engine

Back

Group By operator

Front

operator that divides the selected records into groups based on the values in the specified field.

Back

Memory

Front

stored in memory and use hash indexes so that they are faster than MyISAM tables. lifetime of the data of the memory tables depends on the uptime of the database server i.e. HEAP

Back

delete

Front

delete from ... where ...

Back

in

Front

Back

insert ignore

Front

Back

LOOP statements

Front

while; repeat; (loop, leave, iterate)

Back

CASE

Front

sub for IF CASE - WHEN - THEN - ELSE*

Back

insert on duplicate key update

Front

Back

order by

Front

comes at end of statement, can ASC or DESC

Back

CSV

Front

storage engine

Back

SIGNAL statement

Front

return an error or warning condition to the caller from a stored program provides you with control over which information for returning such as value and messageSQLSTATE. SIGNAL SQLSTATE | condition_name; SET condition_information_item_name_1 = value_1, condition_information_item_name_1 = value_2, etc;

Back

exists

Front

Back

rollup

Front

add-on to GroupBy, will add up and total

Back

error handling

Front

action either EXIT or CONTINUE DECLARE action HANDLER FOR condition_value statement; SELECT 'Error, duplicate key occurred'; -> what user sees

Back

where

Front

filtering, good place to nest statements with "in" or "="

Back

ON DELETE CASCADE

Front

To ensure all child tables are deleted inf the parent is deleted. This can be your FOREIGN KEY constraint.

Back

Views

Front

can only subquery from WHERE, not FROM can create views from three types of algorithms (merged, temptable, undefined) helps with security and complexity of queries updateable

Back

stored functions

Front

...

Back

having

Front

similar to WHERE, same placement

Back

Archive

Front

compresses a record when it is inserted and decompress it using the zlib library as it is read. only allow INSERT and SELECT statements does not support indexes

Back

select

Front

choosing columns to hold in table

Back

IF procedure

Front

Back

IS NULL

Front

a comparison operator used to check whether an attribute has a value.

Back

and

Front

Back

InnoDB

Front

fully support ACID-compliant and transactions. supports foreign keys, commit, rollback, roll-forward operations. The size of an InnoDB table can be up to 64TB -> 1/4th size of MyISAM

Back

between

Front

in same place we would find "and"/"or"

Back

stored procedure

Front

program stored in the database that is used to enforce business rules can be invoked by triggers, other stored procedures, and applications such as Java, Python, PHP. MySQL puts it into a cache and maintains its own stored procedure cache for every single connection. reduce the traffic between application and database server only run in command line with delimiters?

Back

union

Front

Back

view resolution

Front

combination of input query and the query in the view definition into one query

Back

or

Front

Back

joins

Front

connect two DBs at the hip, the hip being wherever you define the two to have overlap already (foreign keys)

Back

RESIGNAL

Front

must use the RESIGNAL statement within an error or warning handler, otherwise, you will get an error message saying that "RESIGNAL when handler is not active". Notice that you can use SIGNAL statement anywhere inside a stored procedure. You can omit all attributes of the RESIGNAL statement, even the SQLSTATE value

Back

insert into... select

Front

insert data into a table from the result of a SELECT statement.

Back

Section 2

(15 cards)

CTE vs. derived table

Front

CTE can be self-referencing (a recursive CTE) or can be referenced multiple times in the same query. CTE provides better readability and performance in comparison with a derived table use like a view WITH

Back

Aggregate functions list

Front

avg() count(*) sum() max() min()

Back

"with check option" clause with views

Front

prevents you from updating or inserting rows that are not visible through the view, which would lead to inconsistencies place at bottom of statement

Back

CREATE INDEX

Front

instead of using Select, From, Where to locate something, stores key values for faster lookups primary-clustered indexes vs. secondary-nonclustered CREATE INDEX index_name ON table_name (column_list) BTREE index

Back

control flow functions

Front

if case ifnull nullif

Back

use index

Front

instruct the query optimizer to use only a list of named indexes for a query. One of the most important parameters for choosing which index to use is stored key distribution which is also known as cardinality. but cardinality might not accurate after table edits can see details of query with EXPLAIN Select ...

Back

math functions

Front

http://www.mysqltutorial.org/mysql-math-functions/

Back

date functions

Front

http://www.mysqltutorial.org/mysql-date-functions/

Back

"with local/cascade check option"

Front

cascade - checks the rules of the point of reference views local - exclusively abides to that views' rules

Back

fund unmatched records across 2 tables

Front

SELECT id,title FROM ( SELECT id, title FROM t1 UNION ALL SELECT id,title FROM t2 ) tbl GROUP BY id, title HAVING count(*) = 1 ORDER BY id;

Back

ANALYZE TABLE

Front

see indexes and accompanying cardinality

Back

row count of all tables in DB with 1 query

Front

SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = 'classicmodels' ORDER BY table_name

Back

Updating Views

Front

o create an updatable view, the SELECT statement that defines the view must not contain any of the following elements: Aggregate functions such as MIN, MAX, SUM, AVG, and COUNT. DISTINCT GROUP BY clause. HAVING clause. UNION or UNION ALL clause. Left join or outer join. Subquery in the SELECT clause or in the WHERE clause that refers to the table appeared in the FROM clause. Reference to non-updatable view in the FROM clause. Reference only to literal values. Multiple references to any column of the base table or be made with TEMPTABLE

Back

map NULL values to meaningful values

Front

SELECT customername, IFNULL(state,"N/A") state, country FROM customers ORDER BY country;

Back

string functions

Front

http://www.mysqltutorial.org/mysql-string-functions/ concat trim lower, upper

Back