Database Systems

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

1/90

flashcard set

Earn XP

Description and Tags

MODULE 1 - 4

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

91 Terms

1
New cards
  • Handling Big Data

  • Real-time Data Processing

  • Enhanced Scalability

  • Support for Unstructured Data

Importance of Advanced Database Systems

2
New cards

Relational Database

  • is a type of database that stores and organizes data in tables, where relationships between the data are defined.

  • It follows a structured format, using rows and columns, making it easy to retrieve, manage, and manipulate information through SQL

  • used because of their flexibility, accuracy, and ability to handle large amounts of interconnected data.

3
New cards

Tables

  • Relations

  • Structured formats where data is stored, similar to spreadsheets

4
New cards

Rows

known as records or tuples — each row contains data entries

5
New cards

Columns

Also called fields or attributes — each column represents a particular property of the entity

6
New cards

Primary Key

  • A unique identifier for each record in a table.

  • It ensures that each row can be distinctly identified.

7
New cards

Foreign Key

  • A field in one table that refers to the Primary Key in another table.

  • It establishes a link between two tables and ensures referential integrity.

8
New cards

One-to-One (1:1)

Each record in Table A corresponds to a single record in Table B.

9
New cards

One-to-Many (1:N)

A record in Table A can be associated with many records in Table B, but a record in Table B relates to only one in Table A.

10
New cards

Many-to-Many (M:N)

Multiple records in Table A relate to multiple records in Table B, usually requiring a junction table

11
New cards

functions and operators

  • are essential tools for manipulating and analyzing data.

  • They help you perform calculations, filter results, and transform data directly within SQL queries.

12
New cards

Functions

are pre-defined operations that take inputs (arguments), process them, and return results.

13
New cards

Aggregate Functions

operate on multiple rows to produce a single result.

14
New cards

Scalar Functions

operate on individual rows and return one result per row

15
New cards

COUNT()

  • Count the number of rows in a table

  • Counts rows matching a condition

  • SELECT COUNT(*) FROM Students;

16
New cards

SUM()

  • Adds up numeric values

  • SELECT SUM (Salary) FROM Employees;

17
New cards

AVG()

  • Calculates average of values

  • SELECT AVG (Age) From Users;

18
New cards

MAX()

  • Finds maximum value

  • SELECT MAX (Price) FROM Products;

19
New cards

MIN()

  • Finds minimum value

  • SELECT MIN(Score) FROM Products;

20
New cards

WHERE

SQL clause is used to filter records

21
New cards

Operators

  • are symbols used to perform operations on data.

  • They’re crucial for filtering data and forming conditions in queries.

22
New cards

AND

True if both conditions are true

23
New cards

OR

True if at least one condition is true

24
New cards

NOT

Reverses the condition’s result

25
New cards

BETWEEN

Checks if value is within range

26
New cards

IN

Checks is value matches any in list

27
New cards

LIKE

Searches for pattern

28
New cards

IS NULL

Checks for null values

29
New cards

EXISTS

Returns true if subquery returns rows

30
New cards

join

is used to combine rows from two or more tables based on a related column.

31
New cards

CREATE PROCEDURE

to create a stored procedure

32
New cards

Aggregate Function

a function that performs a calculation on a set of values

33
New cards

Joins and Aggregate Functions

Allows you to combine data from multiple tables and perform calculations on data sets, giving you powerful ways to analyze and extract insights from relational databases.

34
New cards

INNER JOIN

Returns rows that have matching values in both tables

<p>Returns rows that have <mark data-color="yellow">matching values in both tables</mark></p>
35
New cards

LEFT JOIN

  • Returns all rows from the left table and the matched rows from the right table.

  • Unmatched rows from the right table will be NULL.

<ul><li><p>Returns all rows <mark data-color="yellow">from the left table and the matched rows from the right table</mark>.</p></li><li><p>Unmatched rows from the right table will be NULL.</p></li></ul>
36
New cards

RIGHT JOIN

Returns all rows from the right table and matched rows from the left table

<p>Returns all rows from the <mark data-color="yellow">right table and matched rows from the left table</mark></p>
37
New cards

FULL JOIN

Combines all rows from both tables, returning matched rows and NULL for unmatched rows.

<p><mark data-color="yellow">Combines all rows from both tables</mark>, returning matched rows and NULL for unmatched rows.</p>
38
New cards

CROSS JOIN

Returns the Cartesian product of two tables every combination of rows from both tables

<p><mark data-color="yellow">Returns the Cartesian product of two tables</mark> every combination of rows from both tables</p>
39
New cards

GROUP BY

clause groups rows sharing a property so you can use aggregate functions on each group

<p><mark data-color="yellow">clause groups rows sharing a property</mark> so you can use aggregate functions on each group</p>
40
New cards

DDL (Data Definition Language)

Deals with the structure of the database

  • creating (CREATE TABLE)

  • altering (ALTER TABLE)

  • deleting tables (DROP TABLE)

  • schemas/truncate (TRUNCATE TABLE)

41
New cards

DML (Data Manipulation Language)

Deals with data within tables

  • retrieving (SELECT)

  • adding (INSERT INTO)

  • updating (UPDATE)

  • deleting records (DELETE FROM)

42
New cards

DCL (Data Control Language)

Controls access and permissions to the database.

  • GRANT

  • REVOKE

43
New cards

TCL (Transaction Control Language)

Manages transactions — sequences of database operations that must be executed as a single unit.

  • COMMIT - Saves all changes made in the transaction

  • ROLLBACK - Reverts changes since the last commit.

  • SAVEPOINT - Sets a point to roll back to within a transaction

  • SET TRANSACTION - Configures transaction properties like isolation level.

44
New cards

Triggers

  • are powerful tools used to automatically execute predefined actions in response to certain events on a table or view

  • Used for enforcing business rules, auditing, logging, and validating data.

45
New cards

AFTER Triggers (FOR Triggers)

  • Executed after the triggering event (INSERT, UPDATE, DELETE) has completed.

  • Cannot be used with views.

<ul><li><p>Executed <mark data-color="yellow">after the triggering event</mark> (INSERT, UPDATE, DELETE) has completed.</p></li><li><p>Cannot be used with views.</p></li></ul>
46
New cards

INSTEAD OF Triggers

  • Executed instead of the triggering event.

  • Can be used on tables and views.

<ul><li><p>Executed <mark data-color="yellow">instead of the triggering event</mark>.</p></li><li><p>Can be used on tables and views.</p></li></ul>
47
New cards

DDL Triggers (Data Definition Language Triggers)

Fire in response to changes to database schema (CREATE, ALTER, DROP).

<p>Fire in response to <mark data-color="yellow">changes to database schema</mark> (CREATE, ALTER, DROP).</p>
48
New cards

Logon Triggers

Execute in response to a LOGON event.

<p>Execute in response to a <mark data-color="yellow">LOGON</mark> event.</p>
49
New cards

query optimization

is the process of enhancing the efficiency of a query to ensure it runs as quickly and efficiently as possible.

50
New cards

index

is a data structure that improves the speed of data retrieval.

51
New cards

Clustered Index

  • Sorts and stores rows in the table based on the indexed column.

  • There can be only one clustered index per table.

52
New cards

Non-Clustered Index

  • Contains pointers to rows in the data pages.

  • A table can have multiple non-clustered indexes

53
New cards

Unique Index

Ensures that all values in the indexed column(s) are unique.

54
New cards

view

  • is a virtual table based on a SQL query

  • It does not store data itself but shows data from one or more tables.

  • simplify complex queries by presenting results as if they were from a table

55
New cards

Transaction

  • is a sequence of operations performed as a single logical unit of work

  • must be rolled back, ensuring the database remains in a consistent state

  • sequence of one or more operations

  • executed as a single unit

56
New cards

Read(X)

is used to read the value of a particular database element X and stores it in a temporary buffer in the main memory for further actions such as displaying that value

57
New cards

Write(X)

is used to write value to the database from the buffer in the main memoryC

58
New cards

Commit

This operation in transactions is used to maintain integrity in the database

59
New cards

Rollback

undoes all the changes made by the transaction, reverting the database to its last consistent state

60
New cards

Serial Schedule

when multiple transactions are to be executed, they are executed serially

61
New cards

Non-Serial Schedule

To reduce the waiting time of transactions in the waiting queue and improve the system efficiency

62
New cards
  • Atomicity

  • Consistency

  • Isolation

  • Durability

ACID

63
New cards

Atomicity

  • This property ensures that either all operations of a transaction are executed or it is aborted

  • achieved through commit and rollback operations

64
New cards

Consistency

  • This property of a transaction keeps the database consistent before and after a transaction is completed

  • the changes made in the database are result of logical operations only which the user desired to perform and there is not any ambiguity

65
New cards

Isolation

  • This property states that two transactions must not interfere with each other

  • It ensures that the integrity of the database is maintained

66
New cards

Concurrency Control

  • is a critical mechanism in DBMS that ensures the consistency and integrity of data when multiple operations are performed at the same time

  • ensures multiple transactions can simultaneously access or modify data without causing errors or inconsistencies

67
New cards
  • Dirty Reads

  • Lost Updates

  • Inconsistent Reads

Concurrent Execution can lead to various challenges

68
New cards

Temporary Update Problem (Dirty Read)

Occurs when a transaction reads data that has been updated by another transaction but has not yet committed.

69
New cards

Incorrect Summary Problem

Happens when aggregate function produces incorrect results because concurrent transactions update some records while the calculation is in progress

70
New cards

Lost Update Problem

Occurs when two transactions update the same data simultaneously, and one update is overwritten by the other without considering the changes

71
New cards

Unrepeatable Read Problem

Occurs when a transaction reads the same data multiple times, but another transaction modifies the data in between ready leading to inconsistent results

72
New cards

Phantom Ready Problem

Happens when a transaction retrieves a set of records based on condition, but another transaction inserts or deletes records that match the condition before the first transaction completes

73
New cards

Without Concurrency Control

Transactions interfere with each other, causing issues

74
New cards

With Concurrency Control

Transactions are properly managed

75
New cards

Read Uncommitted

  • Allows dirty reads

  • When performance is the priority & data accuracy is less critical

76
New cards

Read Committed

  • Prevents dirty reads by ensuring transaction only read committed data

  • Default, suitable for most cases to avoid dirty reads

77
New cards

Repeatable Read

  • Prevents dirty reads and non-repeatable reads by locking reads rows until the transaction ends

  • When consistency is needed but phantom reads are acceptable

78
New cards

Serializable

  • Prevents dirty reads, non-repeatable reads, and phantom reads by applying reads rows

  • When strict data consistency is required

79
New cards

Snapshot

  • Provides a versioned copy of data to each transaction

  • When high concurrency is needed without blocking

80
New cards

Deadlock

  • occurs when two or more transactions are blocked indefinitely, each waiting for the other to release a resource that it needs to complete its operation, creating a circular dependency

  • is a concurrency control problem where two or more transactions are stuck in a waiting state, unable to proceed because each is holding a resource that the other needs

81
New cards

Lock Ordering

Enforce a consistency

82
New cards

Lock Escalation

Use a strategy when locks are escalated to a higher level to reduce contention

83
New cards

Short Transactions

Keep transactions as short as possible to reduce the time resources are held

84
New cards

Deadlock Prevention

Implement strategies to avoid the conditions that lead to deadlocks

85
New cards

Deadlock Detection

Implement mechanisms to detect deadlocks and take corrective actions

86
New cards

Wait-for-Graph

Use a graph to represent the wait relationships between transaction and resources

87
New cards

Timeout

Set a timeout for transactions to prevent them from waiting indefinitely

88
New cards

Rollback (Deadlock)

Roll back one or more of the deadlocked transactions to break the cycle

89
New cards

Deadlock Avoidance

is suitable for smaller databases

90
New cards

Wait-Die Scheme

If a transaction requests a resource that is locked by another transaction, then the DBMS simple checks the timestamp of both transactions and allows the older transaction to wait until the resource is available for execution

91
New cards

Wound Wait Scheme

If an older transaction requests for a resouce held by a younger transaction, then an older transaction forces a younger transaction to kill the transaction and release the resource.