Lizzy McIMF

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/71

encourage image

There's no tags or description

Looks like no tags are added yet.

72 Terms

1
New cards

Relational Algebra

a formal, mathematical query language that operates on relations (tables) and produces new relations as results.

2
New cards

Closure

every operation takes one or more relations in and returns a single relation out, so the output of one operation can feed straight into the next.

3
New cards

Why Relational Algebra matters?

it’s the theoretical foundation SQL is built on; every SQL query can be expressed as a sequence of relational algebra operations. Understanding it helps you reason about what a query does and why some queries perform better than others.

4
New cards

Set Operations

Union, Intersection, Difference, Cartesian Product.

5
New cards

Relational Operations

Selection, Projection, Join.

6
New cards

Union (âˆȘ)

returns every row that appears in either set, duplicates removed.

7
New cards

Intersection (∩)

returns only the rows that appear in both sets.

8
New cards

Difference (−)

keeps rows from A that do not appear in B.

9
New cards

Cartesian Product (×)

pairs every row of A with every row of B, producing all possible combinations.

10
New cards

Selection (σ)

filters rows based on a condition, like SQL’s WHERE clause columns stay the same, only matching rows remain.

11
New cards

Projection (π)

picks specific columns and drops the rest; duplicate resulting rows are automatically removed.

12
New cards

DML (Data Manipulation Language)

the part of SQL that manages and manipulates the data stored inside tables, as opposed to DDL, which creates/modifies the structure of the database itself.

13
New cards

INSERT

adds a new data/record into the table.

14
New cards

UPDATE

modifies an existing data/record in the table.

15
New cards

DELETE

removes a data/record from the table.

16
New cards

SELECT

reads data/records from the table.

17
New cards

INT

whole numbers, no quotes needed (e.g. 100).

18
New cards

DECIMAL(10,2)

fixed-point number with set decimal places, no quotes (e.g. 1500.75).

19
New cards

FLOAT

floating-point number, no quotes (e.g. 89.5).

20
New cards

VARCHAR(50)

variable-length text, wrapped in single quotes (e.g. ‘Elmar Marquez’).

21
New cards

ENUM

only accepts values defined in its predefined list (e.g. ‘Male’).

22
New cards

DATE format

written as ‘YYYY-MM-DD’ (e.g. ‘2026-10-02’).

23
New cards

TIME format

written as ‘HH:MM:SS’ (e.g. ‘09:30:00’).

24
New cards

DATETIME format

written as ‘YYYY-MM-DD HH:MM:SS’ (e.g. ‘2026-10-02 09:30:00’).

25
New cards

Numeric values

no quotation marks needed (e.g. 100).

26
New cards

String values

wrapped in single quotation marks (e.g. ‘Elmar Marquez’).

27
New cards

Boolean values

TRUE or FALSE, equivalent to 1 or 0 in MySQL.

28
New cards

=

exact match.

29
New cards

!= or <>

not equal to.

30
New cards

>

Greater than (for numeric values).

31
New cards

<

less than (for numeric values).

32
New cards

>=

greater than or equal to.

33
New cards

<=

less than or equal to.

34
New cards

AND

both conditions must be true.

35
New cards

OR

at least one condition must be true.

36
New cards

NOT

excludes matching conditions.

37
New cards

IN

matches any value in a list.

38
New cards

NOT IN

excludes values in a list.

39
New cards

BETWEEN

matches a range of values.

40
New cards

NOT BETWEEN

excludes a range of values.

41
New cards

LIKE

matches a text pattern.

42
New cards

NOT LIKE

excludes a text pattern.

43
New cards

IS NULL

finds missing values.

44
New cards

IS NOT NULL

finds non-missing values.

45
New cards

%

Matches zero or more characters

46
New cards

_

Matches exactly one character

47
New cards

%text%

Finds text anywhere in a value

48
New cards

text%

Finds values starting with text

49
New cards

%text

Finds values ending with text

50
New cards

Aggregate Functions

combine or summarize data from multiple rows into one summary value; commonly used with SELECT and GROUP BY.

51
New cards

COUNT(*)

counts the total number of rows; works on all data types and counts non-NULL values (or all rows with COUNT()).

52
New cards

SUM(Amount)

adds up numeric values into a total; numeric only.

53
New cards

AVG(Grade)

calculates the average of numeric values; numeric only.

54
New cards

MAX(Price)

finds the highest value; works on numeric, text, or date/time — for text it uses collation rules, for dates it finds the latest.

55
New cards

MIN(Price)

finds the lowest value; works on numeric, text, or date/time — for text it uses collation rules, for dates it finds the earliest.

56
New cards

Note on NULLs

SUM() and AVG() are meant for numeric expressions; most aggregate functions skip NULL values, but COUNT(*) still counts every row.

57
New cards

GROUP BY

groups rows by a shared value so you can summarize each group separately (e.g. average grade per year level).

58
New cards

HAVING

filters grouped data based on a condition, usually applied after an aggregate function like COUNT(), SUM(), or AVG().

59
New cards

WHERE

filters individual rows, applied before GROUP BY; can’t use aggregate functions in its condition.

60
New cards

HAVING vs. WHERE

HAVING filters groups of rows instead of individual ones, is applied after grouping, and CAN use aggregate functions in its condition.

61
New cards

ORDER BY

sorts results ascending (ASC, the default) or descending (DESC).

62
New cards

LIMIT

caps the maximum number of rows returned.

63
New cards

Combining clauses

WHERE, GROUP BY, HAVING, ORDER BY, and LIMIT can all be combined in a single query, in that order.

64
New cards

JOIN

combines related data from two or more tables using a matching column, usually a primary key paired with a foreign key.

65
New cards

Why JOINs exist

normalization splits data into related tables to cut redundancy, so JOINs are what let you pull that related data back together in a single query.

66
New cards

INNER JOIN

returns only rows with matching values in both tables.

67
New cards

LEFT (OUTER) JOIN

keeps all rows from the left table, even unmatched ones; the unmatched right-table columns come back NULL.

68
New cards

RIGHT (OUTER) JOIN

keeps all rows from the right table, even unmatched ones; the unmatched left-table columns come back NULL.

69
New cards

Joining 3+ tables

SQL lets you chain three or more tables together in one query when the needed info is spread across them; each JOIN needs its own condition explaining how the tables relate.

70
New cards

Subquery

a query nested inside another query, often in parentheses, used to feed information the outer query needs; can appear in WHERE, FROM, or SELECT.

71
New cards

Correlated Subquery

a subquery that references a column from the outer query, so it re-evaluates for every row the outer query is currently checking.

72
New cards

EXISTS

returns true as soon as the subquery finds at least one matching row.