Databases / Data Flashcards

1
Q

Schema

A

Blueprint / structure of DB.

Key Components
- Tables
- Columns/fields
- Views
- Indexes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Benefits of having multiple DB Schemas

A
  • Allows for better organization
  • Separation of DB objects into logical groupings
  • Easier to manage
  • Security and access control allowing for fine-grained control of who can access the data
  • Modularity: Schemas can represent diff modules / components of an application allowing for modular design and development
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Flyway

A

Open source DB migration tool that helps manage changes to a DB. (Similar to GIT)

Helps keep DB in sync, organized and consistent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Flyway Versioned Migrations

A

Uses versioning mechanism to apply migrations in a specific order. Each is given a unique version number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Benefits of Flyway

A
  • Automates the process of applying DB migrations
  • Ensures same migrations are applied in same order across all env
  • Version control making it easy to track changes over time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

DB Object

A

Any defined obj in a DB that can store or reference data.

Created using Data Definition Language (DDL) like CREATE, ALTER, DROP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

DB Object Examples

A
  • Tables: rows and columns
  • Views: virtual tables representing the result of a stored query
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Views

A

Virtual tables defined by a query

  • simplify complex’s queries
  • encapsulate complex logic
  • present data in a specific format without altering underlying tables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

View Details

A

Views do not store data but dynamically generate results based on the query when accessed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What 4 properties a transaction must exhibit

A

ACID

  • Atomicity: ensures all operations are completed successfully. If any operations fail the transaction is rolled back and DB is left unchanged
  • Consistency: guarantees a transaction will bring the DB from one valid state to another
  • Isolation: ensures that all operations of a transaction are isolated from others. Intermediate states within a transaction are not visible to other transactions
  • Durability: ensures changes by a committed transaction are permanent even in the case of system failure
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

DB Transactions

A

A sequence of operations performed as a single logical unit of work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Example Transaction Scenario

A
  1. Begin Transaction

BEGIN;

  1. Debit amount from account A

UPDATE accounts SET balance = 200;

  1. Update amount from account B

UPDATE accounts SET balance = 1;

  1. Commit Transaction

COMMIT;

** If the debit operation fails the transaction is rolled back

ROLLBACK

How well did you know this?
1
Not at all
2
3
4
5
Perfectly