Database Concepts and SQL

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

1/70

flashcard set

Earn XP

Description and Tags

These flashcards cover key concepts about databases, SQL commands, and data manipulation techniques.

Last updated 7:49 AM on 4/27/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

71 Terms

1
New cards

What is a database?

An organized collection of data arranged in a structured way so it can be stored, searched, and updated efficiently.

2
New cards

What is a DBMS?

A Database Management System is software that controls how data is stored, accessed, secured, and managed.

3
New cards

What is a query?

A request to retrieve, insert, update, or delete data from a database.

4
New cards

What does SQL stand for?

Structured Query Language.

5
New cards

What are the 3 parts of the relational model?

Data structures, operations, and rules.

6
New cards

What is a tuple?

An ordered collection of elements written in parentheses ().

7
New cards

What is a set?

An unordered collection of elements written in braces {}.

8
New cards

What is a primary key?

A column (or columns) that uniquely identifies each row and cannot be NULL.

9
New cards

What is a foreign key?

A column that references the primary key of another table.

10
New cards

What is referential integrity?

A rule requiring foreign key values to either match an existing primary key value or be NULL.

11
New cards

What does DDL include?

CREATE, ALTER, DROP.

12
New cards

What does DML include?

INSERT, UPDATE, DELETE.

13
New cards

What does DQL include?

SELECT.

14
New cards

What does DCL include?

GRANT, REVOKE.

15
New cards

What does TCL include?

COMMIT, ROLLBACK, SAVEPOINT.

16
New cards

What does SELECT do?

Retrieves data from a table.

17
New cards

What does WHERE do?

Filters individual rows before grouping.

18
New cards

What does ORDER BY do?

Sorts results.

19
New cards

What does DISTINCT do?

Removes duplicate rows.

20
New cards

What is the correct way to check for NULL?

IS NULL or IS NOT NULL.

21
New cards

What is the wrong way to check for NULL?

' = NULL.'

22
New cards

What does COUNT(*) do?

Counts all rows including rows with NULL values.

23
New cards

What does COUNT(column) do?

Counts only non-NULL values in that column.

24
New cards

What does SUM() do?

Adds values.

25
New cards

What does AVG() do?

Finds the average.

26
New cards

What does MIN() do?

Finds the smallest value.

27
New cards

What does MAX() do?

Finds the largest value.

28
New cards

Do SUM, AVG, MIN, and MAX ignore NULL values?

Yes.

29
New cards

Does COUNT(*) ignore NULL values?

No.

30
New cards

What does GROUP BY do?

Groups rows together for aggregate calculations.

31
New cards

What does HAVING do?

Filters grouped results after GROUP BY.

32
New cards

What is the difference between WHERE and HAVING?

WHERE filters rows before grouping, while HAVING filters groups after grouping.

33
New cards

What is the GROUP BY rule?

Every non-aggregate column in SELECT must appear in GROUP BY.

34
New cards

What is the SQL execution order?

FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY.

35
New cards

What is a JOIN?

A JOIN combines data from two tables using related columns.

36
New cards

What does INNER JOIN do?

Returns only matching rows from both tables.

37
New cards

What does LEFT JOIN do?

Keeps all rows from the left table and matching rows from the right table.

38
New cards

What does RIGHT JOIN do?

Keeps all rows from the right table and matching rows from the left table.

39
New cards

What does CROSS JOIN do?

Returns every possible combination of rows.

40
New cards

What does SELF JOIN do?

A table joins to itself.

41
New cards

What does the ON clause do?

Specifies how tables are matched.

42
New cards

What is a view?

A virtual table created from a saved SQL query.

43
New cards

Does a view store copied physical data?

No.

44
New cards

Why are views useful?

Simplicity, security, reusability, and cleaner reporting.

45
New cards

What is the syntax to create a view?

CREATE VIEW ViewName AS SELECT …

46
New cards

What is a subquery?

A query inside another query.

47
New cards

What is a common use of a subquery?

Comparing values to AVG(), MAX(), or MIN.

48
New cards

Example of a subquery for students taller than average?

SELECT Fullname FROM Students WHERE HeightM > (SELECT AVG(HeightM) FROM Students);

49
New cards

What does ROUND(16.25,1) return?

16.3

50
New cards

What does ABS(-42) return?

42

51
New cards

What does UPPER(‘mysql’) return?

MYSQL

52
New cards

What does LOWER(‘MYSQL’) return?

mysql

53
New cards

What does CONCAT(‘North’,‘Carolina’) return?

NorthCarolina

54
New cards

What does CURDATE() return?

The current date.

55
New cards

What does YEAR(Birthday) do?

Extracts the year from a date.

56
New cards

What does MONTH(Birthday) do?

Extracts the month from a date.

57
New cards

Which is correct: WHERE COUNT() > 2 or HAVING COUNT() > 2?

HAVING COUNT(*) > 2.

58
New cards

Which is correct: WHERE Age = NULL or WHERE Age IS NULL?

WHERE Age IS NULL.

59
New cards

Which is safer: SUM(Salary + Bonus) or SUM(Salary) + SUM(Bonus)?

SUM(Salary) + SUM(Bonus).

60
New cards

Does INNER JOIN show all students?

No, only matching students.

61
New cards

Does LEFT JOIN show all students?

Yes, all students from the left table.

62
New cards

Show Fullname and Age for students older than 20.

SELECT Fullname, Age FROM Students WHERE Age > 20;

63
New cards

Count students in each GradeLevel.

SELECT GradeLevel, COUNT(*) AS NumStudents FROM Students GROUP BY GradeLevel;

64
New cards

Show only grade levels with more than 2 students.

SELECT GradeLevel, COUNT() AS NumStudents FROM Students GROUP BY GradeLevel HAVING COUNT() > 2;

65
New cards

Show student names and ActivityName using INNER JOIN.

SELECT S.Fullname, L.ActivityName FROM Students S INNER JOIN LeisureActivity L ON S.StudentID = L.StudentID;

66
New cards

Show all students even if they have no activities.

SELECT S.Fullname, L.ActivityName FROM Students S LEFT JOIN LeisureActivity L ON S.StudentID = L.StudentID;

67
New cards

Find students taller than average height.

SELECT Fullname, HeightM FROM Students WHERE HeightM > (SELECT AVG(HeightM) FROM Students);

68
New cards

Create a view called StudentSummary.

CREATE VIEW StudentSummary AS SELECT Fullname, Age, GradeLevel FROM Students;

69
New cards

Find the average CreditScore by GradeLevel.

SELECT GradeLevel, AVG(CreditScore) FROM Students GROUP BY GradeLevel;

70
New cards

Find grade levels where average CreditScore is above 700.

SELECT GradeLevel, AVG(CreditScore) FROM Students GROUP BY GradeLevel HAVING AVG(CreditScore) > 700;

71
New cards

Find all female students with CreditScore above 700.

SELECT Fullname, GradeLevel FROM Students WHERE Sex = ‘Female’ AND CreditScore > 700.