CIS407

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

1/129

encourage image

There's no tags or description

Looks like no tags are added yet.

130 Terms

1
New cards

First paper detailing SEQUEL happened when?

1974

2
New cards

The first paper detailing SEQUEL was published by who?

IBM

3
New cards

Who were IBM Researchers?

Donald J Chamberlin + Raymond F Boyce

4
New cards

SEQUEL stands for

Structure English Query language

5
New cards

The American National Standards institue (ANSI) prescribes a standard SQL (offcially accepted)

1986

6
New cards

RDBMS

Relational Database Management Systems

7
New cards

Different RDBMS (MySQL, PostgreSQL, Oracle, and SQL Server) follow the SAME _____ with ______ differences

ANSI standards, minor syntax

8
New cards

Relational Databases + Sql = built on strong mathematical principles, such as

set theory, relational algebra, and relational calculus.

9
New cards

Set theory

Relational databases treat tables as sets of tuples, which ensures data consistency.

10
New cards

Tuples

Rows

11
New cards

SQL is a _______ language - it allows developes to SPECIFY their ______ _______ without DETAILING EACH ______ ______ execution process

Declarative, desired results, step-by-step

12
New cards

DCL

Data Control Language

13
New cards

What does DCL do?

a subset of SQL commands used to manage security by controlling user access to database objects like tables, views, and procedures

14
New cards

DCL allows administrators to

GRANT, REVOKE user access permission

15
New cards

GRANT

Assigns specific privileges to users, allowing them to perform actions such as SELECT, INSERT, UPDATE, or DELETE on database objects.

16
New cards

REVOKE

Removes previously granted or denied privileges from users, taking away their access rights.

  • Example: REVOKE UPDATE ON Employees FROM 'HR_user';


17
New cards

Main Purpose of DCL?

  • access management - Controlling which users can access data and to what extent.

  • security - Protecting sensitive information from unauthorized access

  • role-based access - Often used in conjunction with user roles to assign permissions to groups of users efficiently


18
New cards

DBA

Database Administrators

19
New cards

DCL is _______ for database security and is generally managed by ______ to ensure data integrity and confidentiality.

crucial, DBA’s.

20
New cards

DDL

Data Definition Language

21
New cards

DDL is a subset of SQL that

is used to define, modify, and manage the structure of database objects such as tables, indexes, views, and schemas

22
New cards

DDL commands deal with the _________ of the database, not the _______ ______ within it.

blueprint/schema, data stored

23
New cards

Primary DDL commands

CREATE, DROP, ALTER

24
New cards

CREATE

Used to build a new database, table, index, view, or other object.

  • Example: _______ TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), salary DECIMAL(10,2));


25
New cards

DROP

  • Deletes an existing object and all the data and structure associated with it permanently.

    • Example: _____ TABLE employees;


26
New cards

ALTER

This command modifies the structure of an existing database object. It can be used to add, modify, or drop columns; add or delete constraints; or rename a column or table.

  • Example (Add a column): ______ TABLE Customers ADD Email varchar(255);


27
New cards

DML

Data Manipulation Language

28
New cards

Data Manipulation Language (DML) is a subset of SQL commands used to

manage, modify, and retrieve data within database objects (tables/views)

29
New cards

What does DML focus on?

on the data itself—rather than database structure (DDL)

30
New cards

DML commands

INSERT, DELETE, UPDATE records

31
New cards

INSERT

  • Adds new rows of data to a table.


32
New cards

DELETE

  • Removes rows or records from a table.


33
New cards

UPDATE:

  • Modifies existing data within a table.


34
New cards

DML works on the _______, interacting directly with _______information rather than creating tables or schemas.

data plane, stored

35
New cards

DML real life

  • inventory updates

  • data analysis

  • user data management


36
New cards

DML vs DDL

  • DML works INSIDE the EXISTING data

  • DDL works on the STRUCTURE of the data


37
New cards

DQL

Data Query Language

38
New cards

Data Query Language commands

SELECT data records

39
New cards

Data Query Language (DQL) is a subset of SQL used to

retrieve data from a database.

40
New cards

SELECT

fetches data records based on the query criteria.

41
New cards

TCL

Transaction Control Language

42
New cards

TCL commands

COMMIT, ROLLBACK (Undo)

43
New cards

Transaction Control Language (TCL) in SQL is used to

manage database transactions, ensuring data integrity and consistency by either permanently saving changes or undoing them.

44
New cards

COMMIT

used to permanently save all changes made during the current transaction to the database.the changes are irreversible and become visible to all other database users and sessions

45
New cards

ROLLBACK

used to undo all changes made during the current transaction that have not yet been committed. This restores the database to its state before the transaction began or to the last savepoint.


46
New cards

TCL commands enforce the ___ properties

ACID

47
New cards

ACID STANDS FOR?

  • Atomicity - Ensures that all operations within a transaction are treated as a single, indivisible unit

  • Consistency - Guarantees that a transaction transforms the database from one valid state to another

  • Isolation - Ensures that concurrent execution of transactions leaves the database in the same state as if they were executed sequentially, preventing intermediate, uncommitted data from being visible to other transactions.

  • Duration - Guarantees that once a transaction is committed, its changes are permanently stored in the system, even in the event of a power loss, crash, or error.


48
New cards

Using a small data type for rapidly growing data can lead to severe data integrity issues such as :

truncation, rounding

49
New cards

truncation

loss of precision/data

50
New cards

rounding

the small difference between an exact number and its rounded approximation

51
New cards

Though small data types help with space, they can also cause _________ issues

memory + performance

52
New cards

storing variable length data in ______ instead of ______ actually WASTES storage space since _______ uses FULL FIXED LENGHT

CHAR, VARCHAR, CHAR

53
New cards

CHAR

Fixed length, column always reserves and uses a fixed amount of storage space equal to the defined length n for every entry, regardless of the actual length of the data inserted. Shorter strings are padded with trailing spaces to meet the fixed length, which consumes unnecessary disk space if the data length varies significantly.

54
New cards

VAR CHAR

  • What it is: Variable-length string (non-Unicode)

  • Max size: Up to 8,000 characters

  • Storage: 1 byte per character

  • Use when: You only need standard English/ASCII text


55
New cards

VARCHAR is significantly more effective since

it takes up space EFFICENTLY, doesnt waste, doesnt take up unnecessary amount

56
New cards

Storing numeric values/dates in VARCHAT can cause issues with

  • data integrity

  • formatting

  • sorting efficiency



57
New cards

Database systems handle VARCHAR data as

texts, not numeric or temporal types

58
New cards

NVARCHAR

  • What it is: Variable-length string with Unicode support

  • Max size: Up to 4,000 characters

  • Storage: 2 bytes per character

  • Use when: You need to support multiple languages, emojis, or special characters


59
New cards

NVARCHAR vs VARCHAR

  • one stores non-Unicode (ASCII) data, using 1 byte per character, making it ideal for saving space. for efficency

  • the other stores Unicode data, using 2 bytes per character, supporting multilingual text. for internationalization,


60
New cards

VARCHAR(max)

  • What it is: Variable-length string for very large text

  • Max size: Up to 2 GB (~2 billion characters)

  • Storage: 1 byte per character

  • Use when: Storing long text like:

    • Articles

    • Logs

    • Descriptions


61
New cards

using NVARCHAR or VARCHAR(MAX) for all columns wastes storage space and can ______ impact query performance

negatively

62
New cards

Good design =

  • tight

  • efficient

  • scalable


63
New cards

Delete and update statements only apply to ______ table at a time

1

64
New cards
  • Need multiple languages or emojis →

  • Small/medium English-only text →

  • Huge text blobs →


NVARCHAR, VARCHAR(n), VARCHAR(MAX)

65
New cards

A single _______ command cannot modify multiple tables simultaneously.

UPDATE

66
New cards

referential integrity

If one table depends on another, you can’t delete the “parent” record while the “child” still exists.

67
New cards

Think of a table like a

folder

68
New cards

Drop Table =

deleting the whole folder

69
New cards

Dropping a table deletes:

  • Table Structure

  • All Data

  • Indexes


70
New cards

Truncate Table

Empties the folder (wipe it clean but keep the table)

71
New cards

Trunucate Table deletes _________ but keeps _______ and also_____

all rows, table structure, resets auto increments (ID start back at 1)

72
New cards

DELETE TABLE

remove specific files in a table (choose what to remove)

73
New cards

DELETE table delects _______ keeps ________ but doesn’t _______

selected rows, table structure, resets auto-increments

74
New cards
  • _____ (inner) → smallest impact (one/some rows)

  • _______ (middle) → bigger (all rows)

  • ______ (outer) → biggest (table + everything)


DELETE, TRUNCATE, DROP

75
New cards
  • You can’t ________ or _______ if other tables depend on it


  • TRUNCATE

  • DROP


76
New cards

SQL Query follows this order:

SELECT —— FROM —- WHERE ——- GROUP BY ——- HAVING ——- ORDER BY. (instruction to get data)

77
New cards

SELECT =

What do you want? (______ name, age)

78
New cards

FROM =

Which table are you getting it from?

79
New cards

WHERE=?

choose a specific row ( _______ age>18)

80
New cards

GROUP BY =

used when you want summaries (like counts, average) (______ by major)

81
New cards

HAVING =

filter groups (after grouping)

82
New cards

ORDER BY =

sorting the results

83
New cards

SELECT major, COUNT(*)
FROM Students
WHERE age > 18
GROUP BY major
HAVING COUNT(*) > 5
ORDER BY COUNT(*) DESC;

ranslation:

  • Get majors and how many students are in each

  • Only students older than 18

  • Group by major

  • Only keep majors with more than 5 students

  • Sort from biggest to smallest


84
New cards

SELECT *

“Give me ALL columns” Select all columns

85
New cards

SELECT * should be avoided and only used for small data since

  • It pulls unnecessary data → slower

  • Uses more memory

  • Bad practice for big tables


86
New cards
  • WHERE = _____ grouping

  • HAVING = _____ grouping


before, after

87
New cards

SQL is written like this:

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

👉 BUT it actually runs like this:


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


88
New cards

“Which runs first?”

FROM

89
New cards

2. “Why can’t you use alias in WHERE?”


Because SELECT hasn’t happened yet

90
New cards

Which comes last?


ORDER BY

91
New cards

FWGHSO

FROM → WHERE → GROUP → HAVING → SELECT → ORDER

92
New cards

COUNT =

how many things are there

93
New cards

So what is COUNT actually counting?

It counts rows (records)

94
New cards

COUNT(*) →

  • counts everything (all rows)



95
New cards

COUNT(column) →

counts only NON-null values, count only filled cells

96
New cards
COUNT(*) = COUNT(column)


if there are NO NULL

97
New cards

DISTINC

= remove duplicates

98
New cards

DISTINCT applies to the

whole row combination

99
New cards

DISTINCT often appears _______ BUT you should always use ORDER BY if you care about order

sorted

100
New cards

DISTINCT can be slow because:

  • It has to compare rows

  • It has to remove duplicates