SQL Fundamentals – Lecture Review

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/58

flashcard set

Earn XP

Description and Tags

Question-and-answer flashcards covering key concepts, commands, and best practices from the SQL lecture notes.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

59 Terms

1
New cards

What does the acronym SQL stand for?

Structured Query Language

2
New cards

What is the primary purpose of SQL?

Creating, managing, and querying relational databases.

3
New cards

In a client/server architecture, where are SQL commands executed?

On the database server; only results are returned to the client.

4
New cards

Who introduced the relational model and in what year?

E. F. Codd in 1970.

5
New cards

Which IBM research project (1974-1979) proved the feasibility of the relational model?

IBM System R project.

6
New cards

What was the first commercial DBMS to support SQL and in what year?

Oracle in 1979.

7
New cards

When was the first ANSI/ISO SQL standard approved and what was it called?

1986; SQL/86.

8
New cards

Give two major purposes of the SQL standard.

(1) Define SQL syntax and semantics, (2) Enable portability of database definitions and applications.

9
New cards

List two advantages of having an SQL standard.

Lower training costs and greater application portability.

10
New cards

Name one frequently cited disadvantage of a single SQL standard.

It can stifle innovation or be slow to change.

11
New cards

As of June 2020, which three commercial DBMSs dominated the market?

Oracle, MySQL, and Microsoft SQL Server.

12
New cards

In the SQL environment, what is a catalog?

A collection of metadata describing all database objects under the control of an SQL server.

13
New cards

What are the three broad categories of SQL commands?

DDL (Data Definition Language), DML (Data Manipulation Language), and DCL (Data Control Language).

14
New cards

What does DDL do?

Creates, alters, and drops database objects such as schemas, tables, views, and indexes.

15
New cards

What does DML do?

Inserts, updates, deletes, and queries data stored in tables.

16
New cards

What does DCL do?

Grants or revokes user privileges and manages transactions.

17
New cards

Provide the basic syntax for creating a schema in ANSI SQL.

CREATE SCHEMA schemaname AUTHORIZATION owneruserid;

18
New cards

Which SQL command defines a new table?

CREATE TABLE.

19
New cards

Which command permanently deletes a table and all its data?

DROP TABLE.

20
New cards

Which command modifies the structure of an existing table?

ALTER TABLE.

21
New cards

What is the purpose of CREATE CHARACTER SET?

To define a new character set for storing text, supporting multiple languages.

22
New cards

What constraint forces a column to have unique non-NULL values?

PRIMARY KEY (or UNIQUE for candidate keys that may contain NULLs).

23
New cards

Which constraint disallows NULL values in a column?

NOT NULL.

24
New cards

Which clause is used in a child table to enforce referential integrity?

REFERENCES parent_table(column).

25
New cards

Name two ON UPDATE actions for foreign keys.

ON UPDATE RESTRICT and ON UPDATE CASCADE (also ON UPDATE SET NULL).

26
New cards

Name two ON DELETE actions for foreign keys.

ON DELETE RESTRICT and ON DELETE CASCADE (also ON DELETE SET NULL or SET DEFAULT).

27
New cards

How can you duplicate an existing table’s structure without data?

CREATE TABLE newtable LIKE existingtable; (SQL:2008).

28
New cards

What is the purpose of the DUAL table in Oracle/MySQL?

To select system variables or evaluate expressions without referencing a user table.

29
New cards

Which SQL 2008 feature automatically generates unique primary key values?

Identity columns created with GENERATED ALWAYS (or BY DEFAULT) AS IDENTITY.

30
New cards

Which command removes all rows but keeps the table definition?

TRUNCATE TABLE.

31
New cards

What is the correct clause order in a SELECT statement?

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

32
New cards

Which keyword eliminates duplicate rows from a query result?

DISTINCT.

33
New cards

Which wildcard in a LIKE pattern matches any sequence of characters?

% (percent).

34
New cards

Which wildcard in a LIKE pattern matches exactly one character?

_ (underscore).

35
New cards

Give four common SQL comparison operators.

=, <>, >, >= (others include < and <=).

36
New cards

How do you test for missing (NULL) values in SQL?

column_name IS NULL (or IS NOT NULL).

37
New cards

Which Boolean operator is evaluated first in SQL?

NOT (followed by AND, then OR).

38
New cards

Which clause sorts the final result set?

ORDER BY.

39
New cards

Which clause groups rows so aggregate functions can be applied per group?

GROUP BY.

40
New cards

Which clause filters groups after aggregation?

HAVING.

41
New cards

What is the difference between a scalar and a vector aggregate?

Scalar aggregate returns one value for the entire table; vector aggregate returns one value per group when used with GROUP BY.

42
New cards

Which aggregate function returns the average of numeric values?

AVG().

43
New cards

Which function counts all rows, including those with NULLs?

COUNT(*).

44
New cards

Name one analytical or numerical function added in SQL:2008.

LN, EXP, POWER, SQRT, FLOOR, or CEILING (any one).

45
New cards

What is the main performance benefit of creating an index?

Speeds up row retrieval, joins, and ordering by providing rapid access paths.

46
New cards

Give an example of a statement to create an index on CustomerName in Oracle.

CREATE INDEX NameIDX ON CustomerT (CustomerName);

47
New cards

In an identity column definition, which option sets the first generated value?

START WITH n (e.g., START WITH 1).

48
New cards

Name two common ANSI numeric data types.

INTEGER (or INT) and NUMERIC(p,s) / DECIMAL(p,s).

49
New cards

How does NUMERIC(p,s) differ from INTEGER?

NUMERIC stores exact numbers with specified precision and scale; INTEGER stores whole numbers with zero scale.

50
New cards

Why assign meaningful names to constraints instead of letting the system generate them?

To make them easier to identify, manage, and reference during maintenance.

51
New cards

Define referential integrity in relational databases.

A rule ensuring that every foreign-key value in a child table matches a primary-key value in the parent table or is NULL.

52
New cards

In a 1:M relationship, a foreign-key value must match what in the parent table?

A valid primary-key value (or be NULL if allowed).

53
New cards

Why are parentheses important when combining AND and OR conditions?

They control evaluation order, ensuring the intended logical grouping of predicates.

54
New cards

Which operator selects values within an inclusive range?

BETWEEN (e.g., value BETWEEN 10 AND 20).

55
New cards

When DISTINCT is applied to multiple columns, how are duplicates determined?

Rows are removed only if all selected columns have identical values.

56
New cards

What advantage does the IN operator provide when used with subqueries?

Allows comparison against a set of values returned by another SELECT, supporting powerful set-based logic.

57
New cards

What is the purpose of the LIMIT clause (or OFFSET … FETCH)?

To restrict the number of rows returned, often for paging results.

58
New cards

List the internal execution order of major SQL clauses.

1 FROM 2 WHERE 3 GROUP BY 4 HAVING 5 SELECT 6 ORDER BY

59
New cards

Explain how removing optional clauses helps debug a complex SQL query.

By viewing intermediate results after each clause is added back, you can isolate and correct logic or syntax errors.